82 lines
2.8 KiB
TypeScript
82 lines
2.8 KiB
TypeScript
|
import { _decorator, Component, Node } from 'cc';
|
||
|
import { ItemDataConfig } from './ItemDataConfig';
|
||
|
import { GameGlobalData } from '../global/GameGlobalData';
|
||
|
import { Button } from 'cc';
|
||
|
import { EGAME_STATE } from '../config/GameDefine';
|
||
|
import { director } from 'cc';
|
||
|
import { UmStorageManager } from '../../../cc-common/cc-util/UmStorageManager';
|
||
|
import { Label } from 'cc';
|
||
|
const { ccclass, property } = _decorator;
|
||
|
|
||
|
@ccclass('LayoutDataConfig')
|
||
|
export class LayoutDataConfig extends Component {
|
||
|
@property(Button) btnOk: Button = null!;
|
||
|
@property(Button) btnCancel: Button = null!;
|
||
|
@property(Button) btnClearDataSaver: Button = null!;
|
||
|
@property(Label) txtNotice: Label = null!;
|
||
|
|
||
|
@property(ItemDataConfig) listItems: ItemDataConfig[] = [];
|
||
|
|
||
|
beforeState = EGAME_STATE.WAIT;
|
||
|
|
||
|
protected onLoad(): void {
|
||
|
this.btnCancel.node.on(Button.EventType.CLICK, this.onCancel, this);
|
||
|
this.btnOk.node.on(Button.EventType.CLICK, this.onOk, this);
|
||
|
this.btnClearDataSaver.node.on(Button.EventType.CLICK, this.onClearDataSaver, this);
|
||
|
}
|
||
|
|
||
|
onEnable()
|
||
|
{
|
||
|
this.beforeState = GameGlobalData.Instance.gameState;
|
||
|
GameGlobalData.Instance.changeState(EGAME_STATE.WAIT);
|
||
|
this.txtNotice.string = "";
|
||
|
|
||
|
// var currentHeroData = GameGlobalData.Instance.heroData.getHeroData();
|
||
|
|
||
|
// this.listItems[0].setData(currentHeroData.shooting.AtkRange);
|
||
|
// this.listItems[1].setData(currentHeroData.shooting.AtkCoolDown);
|
||
|
// this.listItems[2].setData(currentHeroData.shooting.AtkSpeed);
|
||
|
// this.listItems[3].setData(currentHeroData.shooting.Damage);
|
||
|
// this.listItems[4].setData(currentHeroData.hp);
|
||
|
// this.listItems[5].setData(currentHeroData.manaRecoveryTime);
|
||
|
}
|
||
|
|
||
|
protected onDisable(): void {
|
||
|
GameGlobalData.Instance.changeState(this.beforeState);
|
||
|
}
|
||
|
|
||
|
onCancel()
|
||
|
{
|
||
|
this.node.setNodeActive(false);
|
||
|
}
|
||
|
|
||
|
onOk()
|
||
|
{
|
||
|
// var heroData = GameGlobalData.Instance.heroData.getHeroData();
|
||
|
// heroData.shooting.AtkRange = this.listItems[0].getData();
|
||
|
|
||
|
// heroData.shooting.AtkRange = this.listItems[0].getData();
|
||
|
// heroData.shooting.AtkCoolDown = this.listItems[1].getData();
|
||
|
// heroData.shooting.AtkSpeed = this.listItems[2].getData();
|
||
|
// heroData.shooting.Damage = this.listItems[3].getData();
|
||
|
// heroData.hp = this.listItems[4].getData();
|
||
|
// heroData.manaRecoveryTime = this.listItems[5].getData();
|
||
|
|
||
|
// GameGlobalData.Instance.heroData.setHeroDara(heroData);
|
||
|
|
||
|
|
||
|
this.node.setNodeActive(false);
|
||
|
|
||
|
GameGlobalData.Instance.newGame();
|
||
|
}
|
||
|
|
||
|
onClearDataSaver()
|
||
|
{
|
||
|
UmStorageManager.instance.removeAllKey();
|
||
|
this.txtNotice.string = "Motice: " + "Clear Data Saver => Done";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|