CharactorAI.ts 715 B

1234567891011121314151617181920212223242526
  1. import { _decorator, Component } from 'cc';
  2. import { Charactor } from './Charactor';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('CharactorAI')
  5. export class CharactorAI extends Component {
  6. charactor: Charactor;
  7. clickCountDown = 0;
  8. protected start(): void {
  9. this.charactor = this.getComponent(Charactor);
  10. }
  11. protected update(dt: number): void {
  12. let ps = window.gm.state.gameSystemState.playerStates.find(v => v.index === this.charactor.playerIndex);
  13. if (ps) {
  14. this.clickCountDown -= dt;
  15. if (this.clickCountDown <= 0) {
  16. this.clickCountDown = 0.3;
  17. this.charactor.inputAcc();
  18. }
  19. }
  20. }
  21. }