Exemplo n.º 1
0
        private bool GetTargetCorner(BaseMonoEntity entity, Vector3 sourcePosition, Vector3 targetPosition, ref Vector3 targetCorner)
        {
            DetourElement element;

            this._detours.TryGetValue(entity.GetRuntimeID(), out element);
            if (element == null)
            {
                return(false);
            }
            if (Miscs.DistancForVec3IgnoreY(targetPosition, element.targetPosition) > this._getPathDisThreshold)
            {
                this._detours.Remove(entity.GetRuntimeID());
                return(false);
            }
            if (Miscs.DistancForVec3IgnoreY(element.corners[element.targetCornerIndex], sourcePosition) <= element.disReachCornerThreshold)
            {
                if (element.targetCornerIndex == (element.corners.Length - 1))
                {
                    this._detours.Remove(entity.GetRuntimeID());
                    targetCorner = targetPosition;
                    return(true);
                }
                element.targetCornerIndex++;
                targetCorner = element.corners[element.targetCornerIndex];
                return(true);
            }
            targetCorner = element.corners[element.targetCornerIndex];
            return(true);
        }
Exemplo n.º 2
0
 public override void Core()
 {
     if (this._blackHoleTimer.isActive)
     {
         this._blackHoleTimer.Core(1f);
         if (this._blackHoleTimer.isTimeUp)
         {
             this.KillBlackHole(true);
         }
         else
         {
             for (int i = 0; i < this._insideActors.Count; i++)
             {
                 BaseAbilityActor targetActor = this._insideActors[i];
                 if ((targetActor != null) && targetActor.IsActive())
                 {
                     if ((this._pullVelocity > 0f) && (Miscs.DistancForVec3IgnoreY(targetActor.entity.XZPosition, this._fieldActor.triggerField.transform.position) < 0.3f))
                     {
                         this.RemoveAdditiveVelocity(targetActor);
                     }
                     else
                     {
                         Vector3 additiveVelocity = this._fieldActor.triggerField.transform.position - targetActor.entity.XZPosition;
                         additiveVelocity.y = 0f;
                         additiveVelocity.Normalize();
                         this.SetAdditiveVelocity(targetActor, additiveVelocity);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        protected void SelectNearestEntity()
        {
            List <BaseMonoEntity> list = new List <BaseMonoEntity>();

            foreach (BaseMonoAvatar avatar in Singleton <AvatarManager> .Instance.GetAllAvatars())
            {
                if (avatar.IsActive())
                {
                    list.Add(avatar);
                }
            }
            foreach (BaseMonoMonster monster in Singleton <MonsterManager> .Instance.GetAllMonsters())
            {
                if (monster.IsActive() && (monster != this._monster))
                {
                    list.Add(monster);
                }
            }
            if (list.Count != 0)
            {
                BaseMonoEntity newTarget = null;
                bool           flag      = false;
                if ((this._monster.AttackTarget != null) && this._monster.AttackTarget.IsActive())
                {
                    if ((this._monster.AttackTarget as BaseMonoAnimatorEntity).denySelect)
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                float positiveInfinity = float.PositiveInfinity;
                if (flag)
                {
                    positiveInfinity = Miscs.DistancForVec3IgnoreY(this._monster.AttackTarget.XZPosition, this._monster.XZPosition) * this.ChangeAvatarDistanceRatioBias;
                }
                float num2 = float.PositiveInfinity;
                foreach (BaseMonoEntity entity2 in list)
                {
                    if (((entity2 != null) && entity2.IsActive()) && ((!(entity2 is BaseMonoAvatar) || !(entity2 as BaseMonoAvatar).denySelect) && (!(entity2 is BaseMonoMonster) || !(entity2 as BaseMonoMonster).denySelect)))
                    {
                        if (flag && (Miscs.DistancForVec3IgnoreY(entity2.XZPosition, this._monster.XZPosition) < positiveInfinity))
                        {
                            newTarget = entity2;
                        }
                        else if (!flag && (Miscs.DistancForVec3IgnoreY(entity2.XZPosition, this._monster.XZPosition) < num2))
                        {
                            newTarget = entity2;
                            num2      = Miscs.DistancForVec3IgnoreY(entity2.XZPosition, this._monster.XZPosition);
                        }
                    }
                }
                this._monster.SetAttackTarget(newTarget);
            }
        }
        public override TaskStatus OnUpdate()
        {
            if (!Singleton <LevelManager> .Instance.levelActor.witchTimeLevelBuff.isActive)
            {
                List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

                for (int i = 0; i < allMonsters.Count; i++)
                {
                    BaseMonoMonster monster = allMonsters[i];
                    if (monster.isGoingToAttack(this.TimeBeforeAttack) && (Miscs.DistancForVec3IgnoreY(base._avatar.XZPosition, monster.XZPosition) < monster.config.AIArguments.AttackRange))
                    {
                        return(TaskStatus.Success);
                    }
                }
            }
            return(TaskStatus.Failure);
        }
        protected BaseMonoEntity SelectTarget()
        {
            List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters();

            BaseMonoEntity entity   = null;
            float          maxValue = float.MaxValue;

            for (int i = 0; i < allMonsters.Count; i++)
            {
                BaseMonoMonster monster = allMonsters[i];
                if (monster.IsActive() && !monster.denySelect)
                {
                    List <BaseMonoAbilityEntity> allHitboxEnabledBodyParts = monster.GetAllHitboxEnabledBodyParts();
                    if (allHitboxEnabledBodyParts.Count > 0)
                    {
                        foreach (BaseMonoAbilityEntity entity2 in allHitboxEnabledBodyParts)
                        {
                            float num3 = Miscs.DistancForVec3IgnoreY(entity2.XZPosition, this._avatar.XZPosition);
                            if ((!this.hasDistanceLimit || ((num3 >= this.minDistance) && (num3 <= this.maxDistance))) && (num3 < maxValue))
                            {
                                maxValue = num3;
                                entity   = entity2;
                            }
                        }
                    }
                    else
                    {
                        float num4 = Miscs.DistancForVec3IgnoreY(monster.XZPosition, this._avatar.XZPosition);
                        if ((!this.hasDistanceLimit || ((num4 >= this.minDistance) && (num4 <= this.maxDistance))) && (num4 < maxValue))
                        {
                            maxValue = num4;
                            entity   = monster;
                        }
                    }
                }
            }
            if ((entity != null) && entity.IsActive())
            {
                return(entity);
            }
            return(null);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 private float GetCurrentSpawnDistance()
 {
     return(Miscs.DistancForVec3IgnoreY(base._aiEntity.transform.position, this.TargetPosition.Value));
 }
Exemplo n.º 8
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);
        }