Exemplo n.º 1
0
        public override void update(float dt)
        {
            ActiveDungeon     activeDungeon          = GameLogic.Binder.GameState.ActiveDungeon;
            CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter;

            if (!base.Character.isExecutingSkill())
            {
                if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f))
                {
                    this.m_movementBehaviour.update(dt);
                }
                else if ((!primaryPlayerCharacter.IsDead && (primaryPlayerCharacter.CurrentHpNormalized <= 0.5f)) && (Time.fixedTime >= this.m_nextPossibleSkillExecutionTime))
                {
                    if (base.Character.TargetCharacter != primaryPlayerCharacter)
                    {
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter, Vector3.zero);
                    }
                    if (base.Character.PhysicsBody.rotatedEnoughForMovement())
                    {
                        GameLogic.Binder.SkillSystem.activateSkill(base.Character, SkillType.Heal, -1f, null);
                        this.m_nextPossibleSkillExecutionTime = Time.fixedTime + ConfigSkills.SHARED_DATA[SkillType.Heal].Cooldown;
                    }
                }
                else if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero))
                {
                    if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos))
                    {
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos);
                    }
                    this.m_movementBehaviour.update(dt);
                    this.m_seekTacticalPosition = true;
                }
                else if (this.m_seekTacticalPosition)
                {
                    this.m_targetingAiBehaviour.update(dt);
                    if (base.Character.TargetCharacter != null)
                    {
                        Vector3 worldPt = base.Character.TargetCharacter.PhysicsBody.Transform.position - ((Vector3)(base.Character.TargetCharacter.PhysicsBody.Transform.forward * 1.5f));
                        worldPt = activeDungeon.ActiveRoom.calculateNearestEmptySpot(worldPt, worldPt - base.Character.TargetCharacter.PhysicsBody.Transform.position, 1f, 1f, 6f, null);
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, null, worldPt);
                        this.m_seekTacticalPosition = false;
                    }
                }
                else
                {
                    this.m_targetingAiBehaviour.update(dt);
                    this.m_movementBehaviour.update(dt);
                    if (((base.Character.TargetCharacter != null) && this.m_movementBehaviour.WithinAttackDistance) && base.Character.PhysicsBody.rotatedEnoughForMovement())
                    {
                        base.Character.AttackRoutine = GameLogic.Binder.CommandProcessor.executeCharacterSpecific(base.Character, new CmdAttackMelee(base.Character, base.Character.TargetCharacter), 0f);
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void onCharacterSpawned(CharacterInstance character)
 {
     this.addAiBehaviour(character);
     if (character.IsSupport)
     {
         for (int i = 0; i < GameLogic.Binder.GameState.ActiveDungeon.ActiveRoom.ActiveCharacters.Count; i++)
         {
             CharacterInstance instance = GameLogic.Binder.GameState.ActiveDungeon.ActiveRoom.ActiveCharacters[i];
             if (!instance.IsPlayerCharacter)
             {
                 CmdSetCharacterTarget.ExecuteStatic(instance, null, Vector3.zero);
             }
         }
     }
 }
        public override void update(float dt)
        {
            CharacterInstance instance;

            if (base.Character.Confused)
            {
                instance = GameLogic.Binder.GameState.ActiveDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
            }
            else
            {
                instance = GameLogic.Binder.GameState.ActiveDungeon.ActiveRoom.getEnemyCharacterWithHighestThreat(base.Character, false);
            }
            if ((instance != null) && instance.IsDead)
            {
                CmdSetCharacterTarget.ExecuteStatic(base.Character, null, Vector3.zero);
            }
            else
            {
                CmdSetCharacterTarget.ExecuteStatic(base.Character, instance, Vector3.zero);
            }
        }
Exemplo n.º 4
0
        public override void update(float dt)
        {
            ActiveDungeon     activeDungeon          = GameLogic.Binder.GameState.ActiveDungeon;
            CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter;

            if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f))
            {
                this.m_movementBehaviour.update(dt);
            }
            else if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero))
            {
                if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos))
                {
                    CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos);
                }
                this.m_movementBehaviour.update(dt);
                this.m_seekTacticalPosition = true;
            }
            else if (this.m_seekTacticalPosition)
            {
                this.m_targetingAiBehaviour.update(dt);
                if (base.Character.TargetCharacter != null)
                {
                    Vector3 worldPt = base.Character.TargetCharacter.PhysicsBody.Transform.position - ((Vector3)(base.Character.TargetCharacter.PhysicsBody.Transform.forward * 1.5f));
                    worldPt = activeDungeon.ActiveRoom.calculateNearestEmptySpot(worldPt, worldPt - base.Character.TargetCharacter.PhysicsBody.Transform.position, 1f, 1f, 6f, null);
                    CmdSetCharacterTarget.ExecuteStatic(base.Character, null, worldPt);
                    this.m_seekTacticalPosition = false;
                }
            }
            else
            {
                this.m_targetingAiBehaviour.update(dt);
                this.m_movementBehaviour.update(dt);
                if (((base.Character.TargetCharacter != null) && this.m_movementBehaviour.WithinAttackDistance) && base.Character.PhysicsBody.rotatedEnoughForMovement())
                {
                    base.Character.AttackRoutine = GameLogic.Binder.CommandProcessor.executeCharacterSpecific(base.Character, new CmdAttackMelee(base.Character, base.Character.TargetCharacter), 0f);
                }
            }
        }
Exemplo n.º 5
0
        public override void update(float dt)
        {
            Room activeRoom = GameLogic.Binder.GameState.ActiveDungeon.ActiveRoom;
            CharacterInstance targetCharacter = activeRoom.getClosestEnemyCharacter(base.Character, true);

            if (targetCharacter == null)
            {
                targetCharacter = activeRoom.getClosestEnemyCharacter(base.Character, false);
            }
            if (targetCharacter == null)
            {
                CmdSetCharacterTarget.ExecuteStatic(base.Character, null, Vector3.zero);
            }
            else if ((base.Character.TargetCharacter != null) && base.Character.TargetCharacter.IsPlayerCharacter)
            {
                CmdSetCharacterTarget.ExecuteStatic(base.Character, targetCharacter, Vector3.zero);
            }
            else if ((targetCharacter != base.Character.TargetCharacter) && (((base.Character.TargetCharacter == null) || base.Character.TargetCharacter.IsDead) || (Mathf.Abs((float)(PhysicsUtil.DistBetween(base.Character, base.Character.TargetCharacter) - PhysicsUtil.DistBetween(base.Character, targetCharacter))) > 2f)))
            {
                CmdSetCharacterTarget.ExecuteStatic(base.Character, targetCharacter, Vector3.zero);
            }
        }
        public override void update(float dt)
        {
            ActiveDungeon     activeDungeon          = GameLogic.Binder.GameState.ActiveDungeon;
            CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter;

            if (!base.Character.isExecutingSkill())
            {
                if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f))
                {
                    this.m_movementBehaviour.update(dt);
                    this.m_seekTacticalPositionTime = Time.fixedTime + UnityEngine.Random.Range((float)2f, (float)2.5f);
                }
                else if ((!primaryPlayerCharacter.IsDead && (primaryPlayerCharacter.CurrentHpNormalized <= 0.5f)) && (Time.fixedTime >= this.m_nextPossibleSkillExecutionTime))
                {
                    if (base.Character.TargetCharacter != primaryPlayerCharacter)
                    {
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter, Vector3.zero);
                    }
                    if (base.Character.PhysicsBody.rotatedEnoughForMovement())
                    {
                        GameLogic.Binder.SkillSystem.activateSkill(base.Character, SkillType.Heal, -1f, null);
                        this.m_nextPossibleSkillExecutionTime = Time.fixedTime + ConfigSkills.SHARED_DATA[SkillType.Heal].Cooldown;
                    }
                }
                else if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero))
                {
                    if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos))
                    {
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos);
                    }
                    this.m_movementBehaviour.update(dt);
                    this.m_seekTacticalPositionTime = Time.fixedTime;
                }
                else if ((this.m_seekTacticalPositionTime <= 0f) || (Time.fixedTime < this.m_seekTacticalPositionTime))
                {
                    CharacterInstance b = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
                    if ((b != null) && (PhysicsUtil.DistBetween(base.Character, b) < (base.Character.AttackRange(true) * 0.5f)))
                    {
                        this.m_seekTacticalPositionTime = Time.fixedTime;
                    }
                    else
                    {
                        this.m_targetingAiBehaviour.update(dt);
                        this.m_movementBehaviour.update(dt);
                        if (((base.Character.TargetCharacter != null) && this.m_movementBehaviour.WithinAttackDistance) && (this.m_movementBehaviour.LineOfSightToTargetCharacter && base.Character.PhysicsBody.rotatedEnoughForMovement()))
                        {
                            Vector3 position = base.Character.TargetCharacter.PhysicsBody.Transform.position;
                            base.Character.AttackRoutine = GameLogic.Binder.CommandProcessor.executeCharacterSpecific(base.Character, new CmdAttackRanged(base.Character, position), 0f);
                        }
                    }
                }
                else
                {
                    CharacterInstance toCharacter = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
                    if (toCharacter != null)
                    {
                        Vector3 vector;
                        int     num2 = 0;
                        do
                        {
                            float   num3    = base.Character.AttackRange(true) * 0.75f;
                            Vector3 vector2 = (Vector3)(new Vector3(UnityEngine.Random.insideUnitCircle.x, 0f, UnityEngine.Random.insideUnitCircle.y) * 0.5f);
                            switch (UnityEngine.Random.Range(0, 3))
                            {
                            case 0:
                                vector = (toCharacter.PhysicsBody.Transform.position - ((Vector3)(toCharacter.PhysicsBody.Transform.right * num3))) + vector2;
                                break;

                            case 1:
                                vector = (toCharacter.PhysicsBody.Transform.position + ((Vector3)(toCharacter.PhysicsBody.Transform.right * num3))) + vector2;
                                break;

                            default:
                                vector = (toCharacter.PhysicsBody.Transform.position - ((Vector3)(toCharacter.PhysicsBody.Transform.forward * num3))) + vector2;
                                break;
                            }
                            int?mask = null;
                            vector = activeDungeon.ActiveRoom.calculateNearestEmptySpot(vector, Vector3.zero, 1f, 1f, 6f, mask);
                            num2++;
                        }while ((num2 < 20) && (!activeDungeon.ActiveRoom.lineOfSightCharacterToCharacter(base.Character, toCharacter) || (activeDungeon.ActiveRoom.getEnemyCharactersWithinRadius(vector, base.Character.AttackRange(true) * 0.5f, base.Character).Count > 0)));
                        CmdSetCharacterTarget.ExecuteStatic(base.Character, null, vector);
                    }
                    this.m_seekTacticalPositionTime = 0f;
                }
            }
        }
Exemplo n.º 7
0
        public override void update(float dt)
        {
            ActiveDungeon     activeDungeon          = GameLogic.Binder.GameState.ActiveDungeon;
            CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter;

            if (((base.Character.getPerkInstanceCount(PerkType.AllyHeal) > 0) && !primaryPlayerCharacter.IsDead) && ((primaryPlayerCharacter.CurrentHpNormalized <= base.Character.getGenericModifierForPerkType(PerkType.AllyHeal)) && (Time.fixedTime >= this.m_nextPossibleHealSkillExecutionTime)))
            {
                GameLogic.Binder.SkillSystem.activateSkill(base.Character, SkillType.Heal, -1f, primaryPlayerCharacter);
                this.m_nextPossibleHealSkillExecutionTime = Time.fixedTime + ConfigSkills.SHARED_DATA[SkillType.Heal].Cooldown;
            }
            if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > 6f)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero))
            {
                if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos))
                {
                    CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos);
                }
                this.m_movementBehaviour.update(dt);
                this.m_seekTacticalPositionTime = Time.fixedTime;
            }
            else if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f))
            {
                this.m_movementBehaviour.update(dt);
                this.m_seekTacticalPositionTime = Time.fixedTime + UnityEngine.Random.Range((float)2f, (float)2.5f);
            }
            else
            {
                Vector3 targetWorldPt = primaryPlayerCharacter.PhysicsBody.Transform.position + ((Vector3)(primaryPlayerCharacter.PhysicsBody.Transform.forward * 2f));
                if (base.Character.canBlink(targetWorldPt))
                {
                    GameLogic.Binder.BlinkSystem.blinkCharacter(base.Character, targetWorldPt, 0.6f);
                }
                else if ((this.m_seekTacticalPositionTime > 0f) && (Time.fixedTime >= this.m_seekTacticalPositionTime))
                {
                    CharacterInstance instance2 = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
                    if (instance2 != null)
                    {
                        bool    flag = false;
                        Vector3 zero = Vector3.zero;
                        for (int i = 0; (i < 20) && !flag; i++)
                        {
                            Vector3 vector4    = new Vector3(UnityEngine.Random.insideUnitCircle.x, 0f, UnityEngine.Random.insideUnitCircle.y);
                            Vector3 normalized = vector4.normalized;
                            zero = instance2.PhysicsBody.Transform.position + ((Vector3)(normalized * base.Character.AttackRange(true)));
                            int?mask = null;
                            zero = activeDungeon.ActiveRoom.calculateNearestEmptySpot(zero, normalized, 1f, 0.25f, 2f, mask);
                            CharacterInstance instance3 = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, true);
                            CharacterInstance instance4 = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
                            flag = (instance3 != null) && (Vector3.Distance(instance4.PhysicsBody.Transform.position, zero) >= (base.Character.AttackRange(true) * 0.5f));
                        }
                        if (flag)
                        {
                            CmdSetCharacterTarget.ExecuteStatic(base.Character, null, zero);
                        }
                    }
                    this.m_seekTacticalPositionTime = 0f;
                }
                else
                {
                    CharacterInstance b = activeDungeon.ActiveRoom.getClosestEnemyCharacter(base.Character, false);
                    if ((b != null) && (PhysicsUtil.DistBetween(base.Character, b) < (base.Character.AttackRange(true) * 0.5f)))
                    {
                        this.m_seekTacticalPositionTime = Time.fixedTime;
                    }
                    else
                    {
                        this.m_targetingAiBehaviour.update(dt);
                        this.m_movementBehaviour.update(dt);
                    }
                }
            }
        }