Ejemplo n.º 1
0
        public void Leave()
        {
            BattleManager.Dispose();

            SceneManager.LoadScene(1, LoadSceneMode.Single);

            if (Env.useNetwork)
            {
                NetModule.instance.RemoveQCMDListener(Module.BATTLE, Command.QCMD_LEAVE_BATTLE, this.HandleLeaveBattle);
            }

            EventCenter.RemoveListener(UIEventType.COUNT_DOWN, this.HandleCountDown);
            EventCenter.RemoveListener(UIEventType.WIN, this.HandleWin);
            EventCenter.RemoveListener(UIEventType.ENTITY_CREATED, this.HandleEntityCreated);
            EventCenter.RemoveListener(UIEventType.ENTITY_DESTROIED, this.HandleEntityDestroied);
            EventCenter.RemoveListener(UIEventType.ENTITY_ATTR_CHANGED, this.HandleEntityAttrChanged);
            EventCenter.RemoveListener(UIEventType.PICK_ITEM, this.HandlePickItem);
            EventCenter.RemoveListener(UIEventType.ITEM_USED, this.HandleItemUsed);

            this._useItemBtn.onClick.Remove(this.OnUseItemBtnClick);
            this._useItemBtn = null;

            this._winCom["n4"].onClick.Remove(this.OnQuitBtnClick);
            this._winCom = null;

            this._hudManager.Dispose();
            this._hudManager = null;

            this._gestureStateOne.Dispose();
            this._gestureStateOne = null;

            this._root.Dispose();
            this._root = null;
        }
Ejemplo n.º 2
0
        public void Enter(object param)
        {
            BattleManager.Init(( BattleParams )param);

            this._hudManager = new HUDManager();

            this._root = UIPackage.CreateObject("battle", "Main").asCom;
            this._root.displayObject.name = "Battle";
            this._root.enableDrag         = true;
            this._root.onDrag.Add(this.OnDrag);
            this._root.onTouchBegin.Add(this.OnTouchBegin);
            this._root.onTouchEnd.Add(this.OnTouchEnd);
            GRoot.inst.AddChild(this._root);
            this._root.size = GRoot.inst.size;
            this._root.AddRelation(GRoot.inst, RelationType.Size);

            this._gestureStateOne          = new GestureStateOne(this);
            this._gestureStateOne.joystick = ( Joystick )this._root["joystick"];

            this._winCom = this._root["win_com"].asCom;
            this._winCom["n4"].onClick.Add(this.OnQuitBtnClick);

            this._useItemBtn = this._root["n11"].asCom;
            GComponent icon   = this._useItemBtn["icon"].asCom;
            GLoader    loader = icon["loader"].asLoader;

            loader.maskSprite = ( NSprite )UIPackage.GetItemAsset("battle", "item_btn_mask");

            EventCenter.AddListener(UIEventType.COUNT_DOWN, this.HandleCountDown);
            EventCenter.AddListener(UIEventType.WIN, this.HandleWin);
            EventCenter.AddListener(UIEventType.ENTITY_CREATED, this.HandleEntityCreated);
            EventCenter.AddListener(UIEventType.ENTITY_DESTROIED, this.HandleEntityDestroied);
            EventCenter.AddListener(UIEventType.ENTITY_ATTR_CHANGED, this.HandleEntityAttrChanged);
            EventCenter.AddListener(UIEventType.PICK_ITEM, this.HandlePickItem);
            EventCenter.AddListener(UIEventType.ITEM_USED, this.HandleItemUsed);

            if (Env.useNetwork)
            {
                NetModule.instance.AddQCMDListener(Module.BATTLE, Command.QCMD_LEAVE_BATTLE, this.HandleLeaveBattle);
            }
        }