PlayerController.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { _decorator, Component, Node, v3, Vec3, Vec2, v2, Prefab, instantiate, tween, KeyCode } from 'cc';
  2. import { GameMgr, Skill } from '../../module_basic/scripts/GameMgr';
  3. import { Cell } from './Cell';
  4. import { PlayerMovement2D } from './PlayerMovement2D';
  5. const { ccclass, property } = _decorator;
  6. const tempV2 = v2();
  7. @ccclass('PlayerController')
  8. export class PlayerController extends Component {
  9. @property(Node)
  10. firePoint: Node;
  11. @property(Node)
  12. barrel: Node;
  13. private _movement2d: PlayerMovement2D;
  14. start() {
  15. tgx.EasyController.on(tgx.EasyControllerEvent.BUTTON, this.onButtonHit, this);
  16. this._movement2d = this.node.getComponent(PlayerMovement2D);
  17. }
  18. onButtonHit(btnSlot: string) {
  19. if (btnSlot == 'btn_skill_1') {
  20. if (GameMgr.inst.castSkill(Skill.SKILL_1)) {
  21. //this._cell.shoot();
  22. }
  23. }
  24. if (btnSlot == 'btn_skill_2') {
  25. if (GameMgr.inst.castSkill(Skill.SKILL_2)) {
  26. this._movement2d.tempSpeedUp(2.0, 3000);
  27. }
  28. }
  29. }
  30. onDestroy() {
  31. tgx.EasyController.off(tgx.EasyControllerEvent.BUTTON, this.onButtonHit, this);
  32. }
  33. }