import Hive from "../Objects/Hive";

const { ccclass, property } = cc._decorator;

@ccclass
export default class StageController extends cc.Component {
  @property(Array(cc.Node)) dogList: Array<cc.Node> = new Array<cc.Node>();
  @property(Array(cc.Node)) hiveList: Array<cc.Node> = new Array<cc.Node>();
  @property(Array(cc.Node)) blockedObjects: Array<cc.Node> = new Array<cc.Node>()

  static instance: StageController;

  protected onLoad(): void {
    StageController.instance = this;
  }

  onHunting() {
    for (let i = 0; i < this.hiveList.length; i++) {
      let hive = this.hiveList[i];
      hive.getComponent(Hive).isSpawnable = true;
    }
    for (let i = 0; i < this.dogList.length; i++) {
      let dog = this.dogList[i];
      dog.getComponent(cc.RigidBody).type = cc.RigidBodyType.Dynamic;
      dog.getComponent(cc.Animation).play("DogScare");
    }
  }

  onCompleted() {
    for (let i = 0; i < this.dogList.length; i++) {
      let dog = this.dogList[i];
      dog.getComponent(cc.Animation).play("DogIdle");
    }
  }
}
