TowerData.ts 825 B

12345678910111213141516171819202122232425262728293031323334
  1. import gameUI from "../UIFace/gameUI";
  2. const {ccclass, property} = cc._decorator;
  3. @ccclass
  4. export default class TowerData {
  5. static _instance: TowerData = null!;
  6. public static instance()
  7. {
  8. if (!this._instance)
  9. {
  10. this._instance = new TowerData();
  11. }
  12. return this._instance;
  13. }
  14. public getTowerPos(level:number):cc.Vec2[]
  15. {
  16. let levelpos1 = [];
  17. let leth = gameUI.instance.myDataObj.LevelData.coordinate_x.length;
  18. for (let i = 0; i < leth; i++) {
  19. const xxx = gameUI.instance.myDataObj.LevelData.coordinate_x[i];
  20. const yyy = gameUI.instance.myDataObj.LevelData.coordinate_y[i];
  21. let onepos = cc.v2(xxx,yyy);
  22. levelpos1.push(onepos);
  23. }
  24. return levelpos1;
  25. }
  26. }