Exemplo n.º 1
0
        // 当前场景加载后触发
        private void OnSceneWasLoaded(Scene arg0, LoadSceneMode arg1)
        {
            FBSceneArgs e = new FBSceneArgs
            {
                Index = arg0.buildIndex
            };

            SendEvent(FBConsts.E_SceneEnter, e);
        }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 加载场景
        /// </summary>
        /// <param name="index">场景索引</param>
        public void LoadScene(int index)
        {
            //退出旧场景
            //事件参数
            FBSceneArgs e = new FBSceneArgs
            {
                Index = SceneManager.GetActiveScene().buildIndex
            };

            //发布事件
            SendEvent(FBConsts.E_SceneExit, e);

            //加载新场景
            SceneManager.LoadScene(index, LoadSceneMode.Single);
        }
Exemplo n.º 4
0
        public override void HandleEvent(string eventName, object data = null)
        {
            switch (eventName)
            {
            case FBConsts.E_SceneEnter:
                FBSceneArgs e = (FBSceneArgs)data;
                if (e.Index == 3)
                {
                    StartCountDown();
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public override void Execute(object data = null)
        {
            FBSceneArgs e = data as FBSceneArgs;

            //注册视图(View)
            switch (e.Index)
            {
            case 0:
                break;

            case 1:
                RegisterView(GameObject.Find("UIStart").GetComponent <FBUIStart>());
                break;

            case 2:
                RegisterView(GameObject.Find("UISelect").GetComponent <FBUISelect>());
                break;

            case 3:
                RegisterView(GameObject.Find("Map").transform.GetComponent <FBUISpawner>());
                RegisterView(GameObject.Find("TowerPopup").transform.GetComponent <FBUITowerPopup>());
                RegisterView(GameObject.Find("Canvas").transform.Find("UIBoard").GetComponent <FBUIBoard>());
                RegisterView(GameObject.Find("Canvas").transform.Find("UICountDown").GetComponent <FBUICountDown>());
                RegisterView(GameObject.Find("Canvas").transform.Find("UIWin").GetComponent <FBUIWin>());
                RegisterView(GameObject.Find("Canvas").transform.Find("UILost").GetComponent <FBUILost>());
                RegisterView(GameObject.Find("Canvas").transform.Find("UISystem").GetComponent <FBUISystem>());
                break;

            case 4:
                RegisterView(GameObject.Find("UIComplete").GetComponent <FBUIComplete>());
                break;

            default:
                break;
            }
        }