TouchMgr.ts 891 B

123456789101112131415161718192021222324252627
  1. import { _decorator, Component, Node, Vec2, Vec3 } from 'cc';
  2. import { ModulerBase } from './ModulerBase';
  3. import { MapMgr } from './MapMgr';
  4. import { CardMgr } from './CardMgr';
  5. import { TowerMgr } from './TowerMgr';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('TouchMgr')
  8. export class TouchMgr extends ModulerBase {
  9. private _towerPos: Vec3 = null;
  10. init(): void{
  11. this.node.on(Node.EventType.TOUCH_START,(e)=>{
  12. const touchPos: Vec2 = e.getUILocation();
  13. const pos: Vec3 = this.getModuler(MapMgr).getCenterByPos(touchPos);
  14. if(this.getModuler(CardMgr).touchCard(touchPos)){
  15. this.getModuler(TowerMgr).creatTower(this._towerPos,1);
  16. return;
  17. }
  18. if(!this.getModuler(CardMgr).show(pos)){
  19. this._towerPos = pos;
  20. return;
  21. }
  22. })
  23. }
  24. }