Esempio n. 1
0
        public uint RetargetByThreat(uint curTargetID)
        {
            int  num  = 0;
            uint num2 = 0;

            for (int i = 0; i < this._threatTable.Count; i++)
            {
                int num4 = this._threatTable.Values[i];
                if (num4 > num)
                {
                    uint runtimeID = this._threatTable.Keys[i];
                    if (Singleton <EventManager> .Instance.GetActor <AvatarActor>(runtimeID) != null)
                    {
                        BaseMonoAvatar avatarByRuntimeID = Singleton <AvatarManager> .Instance.GetAvatarByRuntimeID(runtimeID);

                        if ((avatarByRuntimeID != null) && avatarByRuntimeID.IsActive())
                        {
                            num  = num4;
                            num2 = this._threatTable.Keys[i];
                        }
                    }
                }
            }
            if (num2 != curTargetID)
            {
                float threat = this.GetThreat(curTargetID);
                if (num > (threat + 10f))
                {
                    return(num2);
                }
            }
            return(curTargetID);
        }
Esempio n. 2
0
 private int Compare(BaseMonoAvatar a, BaseMonoAvatar b)
 {
     if ((a.GetRuntimeID() == this._localAvatarRuntimeID) && (b.GetRuntimeID() != this._localAvatarRuntimeID))
     {
         return(-1);
     }
     if ((a.GetRuntimeID() != this._localAvatarRuntimeID) && (b.GetRuntimeID() == this._localAvatarRuntimeID))
     {
         return(1);
     }
     if (a.IsActive() && !b.IsActive())
     {
         return(-1);
     }
     if (!a.IsActive() && b.IsActive())
     {
         return(1);
     }
     return(0);
 }
Esempio n. 3
0
        private void Update()
        {
            if (this._lightForwardTransform == null)
            {
                this._lightForwardTransform = Singleton <StageManager> .Instance.GetStageEnv().lightForwardTransform;

                this._lightDir = this._lightForwardTransform.forward;
            }
            List <BaseMonoAvatar> allAvatars = Singleton <AvatarManager> .Instance.GetAllAvatars();

            for (int i = 0; i < allAvatars.Count; i++)
            {
                BaseMonoAvatar key = allAvatars[i];
                if (key.IsActive() && ((this.zone == null) || this.zone.Contain(key.XZPosition)))
                {
                    State state;
                    if (this._avatarStateDict.ContainsKey(key))
                    {
                        state = this._avatarStateDict[key];
                    }
                    else
                    {
                        state = new State();
                        string avatarTypeName = key.AvatarTypeName;
                        state.setting         = !this._avatarTypeNameSettingDict.ContainsKey(avatarTypeName) ? this._defaultSetting : this._avatarTypeNameSettingDict[avatarTypeName];
                        state.particleSystem  = this._settingParticleSystemDict[state.setting];
                        state.controller      = key.GetComponent <BaseStepController>();
                        state.lastLeftPatten  = BaseStepController.Pattern.Void;
                        state.rightLeftPatten = BaseStepController.Pattern.Void;
                        if (state.controller == null)
                        {
                        }
                        this._avatarStateDict.Add(key, state);
                    }
                    BaseStepController controller = state.controller;
                    if (controller != null)
                    {
                        this.HandleStep(controller.currentLeftStepParam, ref state.lastLeftPatten, state);
                        this.HandleStep(controller.currentRightStepParam, ref state.rightLeftPatten, state);
                    }
                }
            }
        }
Esempio n. 4
0
        private BaseMonoAvatar SelectNearestAvatar()
        {
            BaseMonoAvatar        avatar     = null;
            float                 maxValue   = float.MaxValue;
            List <BaseMonoAvatar> allAvatars = Singleton <AvatarManager> .Instance.GetAllAvatars();

            for (int i = 0; i < allAvatars.Count; i++)
            {
                BaseMonoAvatar avatar2 = allAvatars[i];
                if (((avatar2 != null) && avatar2.IsActive()) && !avatar2.denySelect)
                {
                    float num3 = Miscs.DistancForVec3IgnoreY(this._monster.XZPosition, avatar2.XZPosition);
                    if (num3 < maxValue)
                    {
                        maxValue = num3;
                        avatar   = avatar2;
                    }
                }
            }
            return(avatar);
        }
Esempio n. 5
0
        public override TaskStatus OnUpdate()
        {
            List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

            List <BaseMonoAvatar> allAvatars = Singleton <AvatarManager> .Instance.GetAllAvatars();

            List <BaseMonoMonster> list3 = new List <BaseMonoMonster>();

            for (int i = 0; i < allAvatars.Count; i++)
            {
                BaseMonoAvatar avatar = allAvatars[i];
                if ((avatar != null) && avatar.IsActive())
                {
                    BaseMonoMonster item = avatar.AttackTarget as BaseMonoMonster;
                    if (item != null)
                    {
                        list3.Add(item);
                    }
                }
            }
            if (allMonsters.Count <= 0)
            {
                return(TaskStatus.Failure);
            }
            BaseMonoMonster monster2 = null;
            float           maxValue = float.MaxValue;

            for (int j = 0; j < allMonsters.Count; j++)
            {
                BaseMonoMonster monster3 = allMonsters[j];
                if (monster3.IsActive())
                {
                    float num4 = Miscs.DistancForVec3IgnoreY(monster3.XZPosition, this._avatar.XZPosition);
                    if (!this.hasDistanceLimit || ((num4 >= this.minDistance) && (num4 <= this.maxDistance)))
                    {
                        if (list3.Contains(monster3))
                        {
                            num4 *= 2f;
                        }
                        if (num4 < maxValue)
                        {
                            maxValue = num4;
                            monster2 = monster3;
                        }
                    }
                }
            }
            if (monster2 == null)
            {
                return(TaskStatus.Failure);
            }
            BaseMonoEntity  attackTarget = this._avatar.AttackTarget;
            BaseMonoMonster newTarget    = monster2;

            this.isNewTarget.SetValue(attackTarget != newTarget);
            if (this.muteAnimRetarget)
            {
                this._avatar.SetMuteAnimRetarget(true);
                this._avatar.SetAttackTarget(newTarget);
            }
            else
            {
                this._avatar.GetActiveAIController().TrySetAttackTarget(newTarget);
            }
            return(TaskStatus.Success);
        }