Exemplo n.º 1
0
        public AbilityDefendModeMonsterMixin(ActorAbility instancedAbility, ActorModifier instancedModifier, ConfigAbilityMixin config) : base(instancedAbility, instancedModifier, config)
        {
            this._hatredAIAreaSections = new List <float>();
            this._hatredAIValues       = new List <int>();
            this.config            = (DefendModeMonsterMixin)config;
            this._monsterActor     = base.actor as MonsterActor;
            this._monster          = base.entity as BaseMonoMonster;
            this._monsterHatredDic = new Dictionary <uint, float>();
            this._monsterHatredDic.Clear();
            this._hatredDecreaseTimer = new EntityTimer(instancedAbility.Evaluate(this.config.HatredDecreaseInterval));
            this._hatredDecreaseTimer.Reset(false);
            this._minAISwitchTimer = new EntityTimer(instancedAbility.Evaluate(this.config.MinAISwitchDuration));
            this._minAISwitchTimer.Reset(false);
            for (int i = 0; i < this.config.hatredAIAreaSections.Length; i++)
            {
                this._hatredAIAreaSections.Add(this.config.hatredAIAreaSections[i]);
            }
            this._hatredAIAreaSections.Add(1f);
            for (int j = 0; j < this.config.hatredAIValues.Length; j++)
            {
                this._hatredAIValues.Add(this.config.hatredAIValues[j]);
            }
            this._defaultHatredAIValue = this.config.DefaultAIValue;
            this._currentHatredAIValue = this._defaultHatredAIValue;
            BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)this._monster.GetActiveAIController();

            if (activeAIController != null)
            {
                activeAIController.OnAIActive = (Action <bool>)Delegate.Combine(activeAIController.OnAIActive, new Action <bool>(this.OnMonsterAIActive));
            }
        }
Exemplo n.º 2
0
 private bool IsMonsterAIRunning()
 {
     if (this._monster.IsAIControllerActive())
     {
         BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)this._monster.GetActiveAIController();
         return((activeAIController != null) && activeAIController.IsBehaviorRunning());
     }
     return(false);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 private void OnMonsterAIActive(bool active)
 {
     if (active)
     {
         BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)this._monster.GetActiveAIController();
         activeAIController.SetBehaviorVariable <int>("_CommonAIType", this._defaultHatredAIValue);
         if (activeAIController != null)
         {
             activeAIController.OnAIActive = (Action <bool>)Delegate.Remove(activeAIController.OnAIActive, new Action <bool>(this.OnMonsterAIActive));
         }
     }
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 private void SwitchAI(int aiTypeValue)
 {
     if (!this._minAISwitchTimer.isActive)
     {
         this._minAISwitchTimer.Reset(true);
     }
     if (this._minAISwitchTimer.isTimeUp && this._monster.IsAIControllerActive())
     {
         BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)this._monster.GetActiveAIController();
         if (activeAIController != null)
         {
             if (!activeAIController.IsBehaviorRunning())
             {
                 activeAIController.EnableBehavior();
             }
             activeAIController.SetBehaviorVariable <int>("_CommonAIType", aiTypeValue);
             this._currentHatredAIValue = aiTypeValue;
         }
     }
 }