Exemple #1
0
        void ShowUpgradePanel(FBShowTowerUpgradeArgs args)
        {
            HideAllPanels();
            FBGameModel gm = GetModel <FBGameModel>();

            f_upgadePanel.Show(gm, args.Tower);
        }
Exemple #2
0
        void ShowCreatePanel(FBShowTowerCreatArgs args)
        {
            HideAllPanels();
            FBGameModel gm = GetModel <FBGameModel>();

            f_spawnPanel.Show(gm, args.Position, args.UpSide);
        }
Exemple #3
0
        public void Show(FBGameModel gm, FBTower tower)
        {
            transform.position = tower.transform.position;

            f_upgradeIcon.Load(gm, tower);
            f_sellIcon.Load(tower);
            gameObject.SetActive(true);
        }
Exemple #4
0
        public void Load(FBGameModel game, FBTower tower)
        {
            f_tower = tower;

            FBTowerInfo info = FBGame.Instance.StaticData.GetTower(tower.ID);
            string      path = "Res/Roles/" + (tower.IsTopLevel ? info.NormalIcon : info.DisabledIcon);

            f_render.sprite = Resources.Load <Sprite>(path);
        }
Exemple #5
0
        private void OnRestartClick()
        {
            FBGameModel gameModel = GetModel <FBGameModel>();

            SendEvent(FBConsts.E_LevelStart, new FBStartLevelArgs()
            {
                ID = gameModel.PlayLevelIndex
            });
        }
 public void Show(FBGameModel gm, Vector3 createPosition, bool upSide)
 {
     transform.position = createPosition;
     for (int i = 0; i < f_icons.Length; i++)
     {
         FBTowerInfo info = FBGame.Instance.StaticData.GetTower(i);
         f_icons[i].Load(gm, info, createPosition, upSide);
     }
     gameObject.SetActive(true);
 }
Exemple #7
0
        private void CarrotDead(FBRole carrot)
        {
            FBGame.Instance.ObjectPool.Unspawn(carrot.gameObject);

            FBGameModel gameModel = GetModel <FBGameModel>();

            SendEvent(FBConsts.E_LevelEnd, new FBEndLevelArgs()
            {
                ID = gameModel.PlayLevelIndex, IsWin = false
            });
        }
Exemple #8
0
        public override void Execute(object data = null)
        {
            //游戏开始
            FBGameModel gameModel = GetModel <FBGameModel>();

            gameModel.IsPlaying = true;

            //出怪
            FBRoundModel roundModel = GetModel <FBRoundModel>();

            roundModel.StartRound();
        }
 public override void HandleEvent(string eventName, object data = null)
 {
     switch (eventName)
     {
     case FBConsts.E_SceneEnter:
         FBSceneArgs e = data as FBSceneArgs;
         if (e.Index == 2)
         {
             f_gameModel = GetModel <FBGameModel>();
             LoadCards();
         }
         break;
     }
 }
Exemple #10
0
        public void Load(FBGameModel game, FBTowerInfo info, Vector3 creatPos, bool upSide)
        {
            f_towerInfo = info;
            f_creatPos  = creatPos;
            //f_enough = game.Gold > info.BasePrice;
            f_enough = true;
            string path = "Res/Roles/" + (f_enough ? info.NormalIcon : info.DisabledIcon);

            f_render.sprite = Resources.Load <Sprite>(path);

            Vector3 pos = transform.localPosition;

            pos.y = upSide ? Mathf.Abs(pos.y) : -Mathf.Abs(pos.y);
            transform.localPosition = pos;
        }
        public override void Execute(object data = null)
        {
            //注册模型(Model)
            RegisterModel(new FBGameModel());
            RegisterModel(new FBRoundModel());
            //注册命令(Command)
            RegistControllers();

            //初始化
            FBGameModel gameModel = GetModel <FBGameModel>();

            gameModel.OnInitialized();

            //进入开始界面
            FBGame.Instance.LoadScene(1);
        }
Exemple #12
0
        private void OnSpawnCarrot(FBSceneArgs args)
        {
            if (args.Index == 3)
            {
                f_map = GetComponent <FBMap>();
                f_map.OnFBGridClick += OnMapGridClick;
                //获取数据
                FBGameModel gameModel = GetModel <FBGameModel>();
                f_map.LoadLevel(gameModel.PlayLevel);

                GameObject go = FBGame.Instance.ObjectPool.Spawn("Carrot");
                f_carrot = go.GetComponent <FBCarrot>();
                f_carrot.transform.position = f_map.Path[f_map.Path.Length - 1];
                f_carrot.DeadAction        += CarrotDead;
            }
        }
        public override void Execute(object data = null)
        {
            FBStartLevelArgs e = data as FBStartLevelArgs;
            //第一步
            FBGameModel gameModel = GetModel <FBGameModel>();

            gameModel.StartLevel(e.ID);

            //第二步
            FBRoundModel roundModel = GetModel <FBRoundModel>();

            roundModel.LoadLevel(gameModel.PlayLevel);

            // 进入游戏
            FBGame.Instance.LoadScene(3);
        }
Exemple #14
0
        public override void Execute(object data = null)
        {
            FBSellTowerArgs e     = data as FBSellTowerArgs;
            FBTower         tower = e.Tower;

            //清除Tile存储的信息
            tower.Tile.Data = null;

            //半价出售
            FBGameModel gm = GetModel <FBGameModel>();

            gm.Gold += e.Tower.Price / 2;

            //回收
            FBGame.Instance.ObjectPool.Unspawn(e.Tower.gameObject);
        }
Exemple #15
0
        private void OnContinuteClick()
        {
            FBGameModel gameModel = GetModel <FBGameModel>();

            if (gameModel.PlayLevelIndex >= gameModel.LevelCount - 1)
            {
                //游戏通关
                FBGame.Instance.LoadScene(4);
            }
            else
            {
                SendEvent(FBConsts.E_LevelStart, new FBStartLevelArgs()
                {
                    ID = gameModel.PlayLevelIndex + 1
                });                                                                                              //开始下一关卡
            }
        }
Exemple #16
0
        private void OnMapGridClick(object sender, FBGridClickEventArgs e)
        {
            FBGameModel game = GetModel <FBGameModel>();

            //游戏还未开始,那么不操作菜单
            if (!game.IsPlaying)
            {
                return;
            }

            //如果有菜单显示,那么隐藏菜单
            if (FBUITowerPopup.Instance.IsPopShow)
            {
                SendEvent(FBConsts.E_TowerHide);
                return;
            }

            FBGrid grid = e.Grid;

            if (!grid.CanHold)
            {
                SendEvent(FBConsts.E_TowerHide);
                return;
            }

            if (grid.Data == null)
            {
                FBShowTowerCreatArgs args = new FBShowTowerCreatArgs()
                {
                    Position = f_map.GetPosition(grid),
                    UpSide   = grid.Index_Y < FBMap.RowCount / 2
                };
                SendEvent(FBConsts.E_ShowTowerCreat, args);
            }
            else
            {
                FBShowTowerUpgradeArgs args = new FBShowTowerUpgradeArgs()
                {
                    Tower = grid.Data as FBTower
                };
                SendEvent(FBConsts.E_ShowTowerUpgrade, args);
            }
        }
Exemple #17
0
        private void MonsterDead(FBRole monster)
        {
            //回收
            FBGame.Instance.ObjectPool.Unspawn(monster.gameObject);

            GameObject[] monsters   = GameObject.FindGameObjectsWithTag("Monster");
            FBRoundModel roundModel = GetModel <FBRoundModel>();

            //  萝卜没死             场景上已没有怪物           所有怪物已出完
            if (!f_carrot.IsDead && monsters.Length <= 0 && roundModel.AllRoundComplete)
            {
                FBGameModel gameModel = GetModel <FBGameModel>();
                //游戏胜利
                SendEvent(FBConsts.E_LevelEnd, new FBEndLevelArgs()
                {
                    ID = gameModel.PlayLevelIndex, IsWin = true
                });
            }
        }
        public override void Execute(object data = null)
        {
            FBEndLevelArgs e = data as FBEndLevelArgs;

            //保存游戏状态
            FBGameModel  gameModel  = GetModel <FBGameModel>();
            FBRoundModel roundModel = GetModel <FBRoundModel>();

            roundModel.StopRound();
            gameModel.StoptLevel(e.IsWin);

            //弹出UI
            if (e.IsWin)
            {
                GetView <FBUIWin>().Show();
            }
            else
            {
                GetView <FBUILost>().Show();
            }
        }
        private void OnClearClick()
        {
            FBGameModel gameModel = GetModel <FBGameModel>();

            gameModel.ClearProgress();
        }