1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { _decorator, Component, Node } from 'cc';
- import { CatAction } from './CatAction';
- import { PinAction } from './PinAction';
- import { ColorDate } from './ColorDate';
- const { ccclass, property } = _decorator;
- @ccclass('LayerCatAction')
- export class LayerCatAction extends Component {
- onLoad(): void {
- }
- start() {
- }
- update(deltaTime: number) {
-
- }
- //put a pin to slot by pin_color
- public put_pin(pin:PinAction):boolean{
- let can_move_arr:CatAction[] = [];
- this.node.children.forEach(slot => {
- if(slot.getComponent(CatAction).check_able_put(pin)){
- can_move_arr.push(slot.getComponent(CatAction));
- }
- });
- let target:CatAction = null;
- can_move_arr.forEach(element => {
- if(!target){
- target = element;
- }else{
- if(element.get_temp_hole_num()<target.get_temp_hole_num()){
- target = element;
- }
- }
-
- });
- if(target){
- return target.put_pin(pin,"LayerSolot");
- }
- return false;
- }
- public init_cat(){
- this.node.children.forEach(slot => {
- slot.getComponent(CatAction)?.init_cat();
- // slot.getComponent(CatAction)?.into_scence();
- });
- }
- public get_cat_color_arr(){
- let arr:ColorDate[] = [];
- this.node.children.forEach(slot => {
- if(slot.getComponent(CatAction)){
- let color = slot.getComponent(CatAction).get_cat_color();
- if(color){
- arr.push(color);
- }
- }
- });
- return arr;
- }
-
- }
|