BattleSceneLeft.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { _decorator, director, EditBox, } from 'cc';
  2. import { GameInfo } from '../../GameInfo';
  3. import { resMgr } from '../../Frames/ResourcesMgr';
  4. import { ModulerBase } from '../GameFrameWork/ModulerBase';
  5. import { GameMgr } from '../GameFrameWork/GameMgr';
  6. import { SelectTroops } from './SelectTroops';
  7. import { BattleSceneTop } from './BattleSceneTop';
  8. import { localDt } from '../../Frames/LocalDt';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('BattleSceneLeft')
  11. export class BattleSceneLeft extends ModulerBase {
  12. editBox: EditBox | null = null;
  13. protected onStart() {
  14. this.editBox = this.getComponentInChildren(EditBox);
  15. this._setEdit();
  16. this._curLv(GameInfo.Instance.getCurlv());
  17. this.onBtnClick("_btnLevel", this._btnLevel);
  18. if(GameInfo.Instance.getOverWin() && GameInfo.Instance.getGameOverReward().size != 0){
  19. this._curLv(GameInfo.Instance.getGameOverReward().get("CurLv"));
  20. }
  21. this.editBox.node.on("editing-did-ended", this._onEdit, this)
  22. }
  23. //当前关卡
  24. private _curLv(lv: number) {
  25. this.getLabel("_curLv").string = String(lv);
  26. }
  27. private _btnLevel() {
  28. GameMgr.Instance.getModuler(SelectTroops).show();
  29. GameMgr.Instance.getModuler(BattleSceneTop).battleMode("选择部队")
  30. }
  31. //保存名字
  32. private _onEdit(editbox: EditBox){
  33. localDt.savePlayerName(editbox.string);
  34. }
  35. private _setEdit(){
  36. if(localDt.getPlayerName()){
  37. this.editBox.string = localDt.getPlayerName();
  38. }
  39. }
  40. }