Exemple #1
0
        public override TaskStatus OnUpdate()
        {
            if (this._minionConfigLs != null)
            {
                List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

                for (int i = 0; i < this._minionConfigLs.length; i++)
                {
                    ConfigGroupAIMinion config = this._minionConfigLs.GetConfig <ConfigGroupAIMinion>(i);
                    if (this._minions.ContainsKey(i))
                    {
                        if (this._minions[i] != null)
                        {
                            continue;
                        }
                        this._minions.Remove(i);
                    }
                    for (int j = 0; j < allMonsters.Count; j++)
                    {
                        if ((allMonsters[j].MonsterName == config.MonsterName) && (allMonsters[j] != this.monster))
                        {
                            BehaviorDesigner.Runtime.BehaviorTree component = allMonsters[j].GetComponent <BehaviorDesigner.Runtime.BehaviorTree>();
                            bool       flag     = true;
                            SharedBool variable = component.GetVariable("Group_IsMinion") as SharedBool;
                            if (!variable.Value)
                            {
                                flag = false;
                            }
                            SharedEntity entity = component.GetVariable("Group_LeaderEntity") as SharedEntity;
                            if ((entity != null) && (entity.Value != null))
                            {
                                flag = false;
                            }
                            SharedString str = component.GetVariable("GroupAIGrid") as SharedString;
                            if ((str != null) && !string.IsNullOrEmpty(str.Value))
                            {
                                flag = false;
                            }
                            if (flag && allMonsters[j].IsAIControllerActive())
                            {
                                BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)allMonsters[j].GetActiveAIController();
                                if (activeAIController.IsBehaviorRunning())
                                {
                                    activeAIController.SetActive(false);
                                    activeAIController.SetActive(true);
                                    component.SetVariableValue("Group_LeaderEntity", this.monster);
                                    AIData.SetSharedVariableCompat(component, config.AIParams);
                                    this._minions.Add(i, allMonsters[j]);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            return(TaskStatus.Success);
        }
Exemple #2
0
 public override TaskStatus OnUpdate()
 {
     if (this._gridEntry != null)
     {
         string name = null;
         if (this._gridEntry.LeaderActions.ContainsKey(this.LeaderAction.Value))
         {
             List <ConfigLeaderToMinionAction> list = this._gridEntry.LeaderActions[this.LeaderAction.Value];
             for (int i = 0; i < list.Count; i++)
             {
                 if (UnityEngine.Random.value < list[i].Probability)
                 {
                     name = list[i].Name;
                     break;
                 }
             }
             if (name != null)
             {
                 foreach (KeyValuePair <int, BaseMonoEntity> pair in this.MinionDict.Value)
                 {
                     if (pair.Value.IsActive() && (pair.Value is BaseMonoMonster))
                     {
                         BTreeMonsterAIController activeAIController = ((BaseMonoMonster)pair.Value).GetActiveAIController() as BTreeMonsterAIController;
                         if (activeAIController != null)
                         {
                             ConfigGroupAIMinionParam[] paramArray = this._gridEntry.Minions.GetConfig <ConfigGroupAIMinion>(pair.Key).TriggerActions[name];
                             foreach (ConfigGroupAIMinionParam param in paramArray)
                             {
                                 if (param.Interuption)
                                 {
                                     activeAIController.btree.SendEvent <object>("Interruption", true);
                                     activeAIController.btree.SendEvent <object>("Interruption", false);
                                     activeAIController.btree.SetVariableValue("Group_TriggerAttack", false);
                                 }
                                 if (param.Delay.fixedValue == 0f)
                                 {
                                     AIData.SetSharedVariableCompat(activeAIController.btree, param.AIParams);
                                 }
                                 else
                                 {
                                     activeAIController.DelayedSetParameter(param.Delay.fixedValue, param.AIParams);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(TaskStatus.Success);
 }
Exemple #3
0
 public override void OnAwake()
 {
     if (!string.IsNullOrEmpty(this.GruopAIGridType.Value))
     {
         this.monster  = base.GetComponent <BaseMonoMonster>();
         this._minions = this.MinionDict.Value;
         if (this._minions == null)
         {
             this._minions         = new Dictionary <int, BaseMonoEntity>();
             this.MinionDict.Value = this._minions;
         }
         this._minionConfigLs = AIData.GetGroupAIGridEntry(this.GruopAIGridType.Value).Minions;
     }
 }
Exemple #4
0
 public override void Core()
 {
     if (this._delayedParameters != null)
     {
         for (int i = 0; i < this._delayedParameters.Count; i++)
         {
             if (this._delayedParameters[i] != null)
             {
                 this._delayedParameters[i].Item1.Core(1f);
                 if (this._delayedParameters[i].Item1.isTimeUp)
                 {
                     AIData.SetSharedVariableCompat(this._btree, this._delayedParameters[i].Item2);
                     this._delayedParameters[i] = null;
                 }
             }
         }
     }
 }