예제 #1
0
 /// <summary>
 /// 游戏状态发生变化
 /// </summary>
 /// <param name="iGameState"></param>
 /// <param name="fieldName"></param>
 private void IGameStateChanged_In_IMonsterCollection(IGameState iGameState, string fieldName)
 {
     if (string.Equals(fieldName, GameState.Instance.GetFieldName <IGameState, string>(temp => temp.SceneName)))//场景名发生变化说明切换了场景
     {
         if (allMonsterObjDic != null)
         {
             foreach (KeyValuePair <MonsterDataInfo, List <GameObject> > item in allMonsterObjDic)
             {
                 if (item.Value != null)
                 {
                     foreach (GameObject obj in item.Value)
                     {
                         try
                         {
                             GameObject.Destroy(obj);
                         }
                         catch { }
                     }
                 }
             }
         }
         allMonsterObjDic = new Dictionary <MonsterDataInfo, List <GameObject> >();
         thisSceneCanCheckMonsterObjDic  = new Dictionary <MonsterDataInfo, List <GameObject> >();
         thisSceneCanCheckMonsterObjList = new List <GameObject>();
         //加载该场景的怪物配置
         MonsterData monsterData = DataCenter.Instance.GetMetaData <MonsterData>();
         monsterDataInfos = monsterData.GetMonsterDataInfos(iGameState.SceneName);
         //创建检测
         if (monsterDataInfos != null)
         {
             runTaskStruct_CheckMonster.InitTask();
             runTaskStruct_CheckMonster.SetSpeed(1);
             runTaskStruct_CheckMonster.StartTask(UpdateTime, CheckMonsterDataInfoState, 0, true);
         }
     }
 }