Пример #1
0
    public override State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
    {
        float distanceFromTarget = Vector3.Distance(enemyManager.currentTarget.transform.position, enemyManager.transform.position);

        HandleRotationTowardsTarget(enemyManager);

        if (enemyManager.isPerformingAction)
        {
            enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime);
        }

        if (enemyManager.currentRecoveryTime <= 0 && distanceFromTarget <= enemyManager.maximumAttackRange)
        {
            return(attackState);
        }
        else if (distanceFromTarget > enemyManager.maximumAttackRange)
        {
            return(pursueTargetState);
        }
        else
        {
            return(this);
        }
        //potentially circle the player or walk around them
    }
Пример #2
0
 void Start()
 {
     EStats                      = GetComponent <Enemy_Stats>();
     EStats.MaxHealth            = 1000f;
     EStats.CurrentHealth        = EStats.MaxHealth;
     EStats.MeleeDamage          = 40f;
     EStats.RangeDamage          = 25f;
     EStats.MeleeAttackSpeed     = 1f;
     EStats.MeleeAttackCooldown  = 0f;
     EStats.RangeAttackSpeed     = 0.5f;
     EStats.RangeAttackCooldown  = 0f;
     EStats.GroundPoundDamage    = 15f;
     EStats.GroundPoundSpeed     = 10f;
     EStats.GroundPoundCooldown  = 0f;
     EStats.EarthShatterDamage   = 30f;
     EStats.EarthShatterSpeed    = 7f;
     EStats.EarthShatterCooldown = 0f;
     EStats.SightRadius          = 60f;
     EStats.SightSize            = 40f;
     EStats.Range                = 30f;
     target                      = CharacterCombat.instance.transform;
     agent = GetComponent <NavMeshAgent>();
     agent.stoppingDistance = 2;
     Player = GameObject.Find("Player");
     PStats = CharacterCombat.instance;
 }
Пример #3
0
 void Start()
 {
     Player = GameObject.FindGameObjectWithTag("Player");
     PStats = Player.GetComponent <PlayerStats>();
     Enemy  = GameObject.FindGameObjectWithTag("Boss");
     EStats = Enemy.GetComponent <Enemy_Stats>();
 }
Пример #4
0
    public override State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
    {
        if (enemyManager.isPerformingAction)
        {
            enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime);
            return(this);
        }


        Vector3 targetDirection    = enemyManager.currentTarget.transform.position - enemyManager.transform.position;
        float   distanceFromTarget = Vector3.Distance(enemyManager.currentTarget.transform.position, enemyManager.transform.position);
        float   viewableAngle      = Vector3.Angle(targetDirection, enemyManager.transform.forward);

        //if we are performing an action, stop our movement
        if (distanceFromTarget > enemyManager.maximumAttackRange)
        {
            enemyAnimatorManager.anim.SetFloat("Vertical", 1, 0.1f, Time.deltaTime);
        }

        HandleRotationTowardsTarget(enemyManager);


        if (distanceFromTarget <= enemyManager.maximumAttackRange)
        {
            return(combatStanceState);
        }
        else
        {
            return(this);
        }
    }
Пример #5
0
 private void Awake()
 {
     enemyLocomotionManager = GetComponent <EnemyLocomotionManager>();
     enemyAnimationManager  = GetComponentInChildren <EnemyAnimatorManager>();
     enemyStats             = GetComponent <Enemy_Stats>();
     navMeshAgent           = GetComponentInChildren <NavMeshAgent>();
     enemyRigidBody         = GetComponent <Rigidbody>();
     navMeshAgent.enabled   = false;
 }
Пример #6
0
 void Start()
 {
     stats          = GetComponent <Enemy_Stats>();
     animator       = GetComponent <Animator>();
     enemyRigidBody = GetComponent <Rigidbody2D>();
     if (!goingLeft)
     {
         Flip();
     }
 }
Пример #7
0
    public override State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
    {
        Vector3 targetDirection    = enemyManager.currentTarget.transform.position - transform.position;
        float   viewableAngle      = Vector3.Angle(targetDirection, transform.forward);
        float   distanceFromTarget = Vector3.Distance(enemyManager.currentTarget.transform.position, enemyManager.transform.position);

        HandleRotationTowardsTarget(enemyManager);
        //select one of our many attacks
        //if the selected attack is not able to be used because of bad angle or distance, select a new attack
        //if the attack is viable, stop our movement and attack the target
        //set our recovery timer to the attacks recovery time
        //return to the combat stance state

        #region Attacks

        if (enemyManager.isPerformingAction)
        {
            return(combatStanceState);
        }

        if (currentAttack != null)
        {
            //if too close, get new attack

            if (distanceFromTarget < currentAttack.minimumDistanceNeededToAttack)
            {
                return(this);
            }
            //if we are close enough to atack, then let us proceed
            else if (distanceFromTarget < currentAttack.maximumDistanceNeededToAttack)
            {
                //if our enemy is within our attacks viewable angle, we attack
                if (viewableAngle <= currentAttack.maximumAttackAngle &&
                    viewableAngle >= currentAttack.minimumAttackAngle)
                {
                    if (enemyManager.currentRecoveryTime <= 0 && enemyManager.isPerformingAction == false)
                    {
                        enemyAnimatorManager.anim.SetFloat("Vertical", 0, 0.1f, Time.deltaTime);
                        enemyAnimatorManager.anim.SetFloat("Horizontal", 0, 0.1f, Time.deltaTime);
                        enemyAnimatorManager.PlayTargetAnimation(currentAttack.actionAnimation, true);
                        enemyManager.isPerformingAction  = true;
                        enemyManager.currentRecoveryTime = currentAttack.recoveryTime;
                        currentAttack = null;
                        return(combatStanceState);
                    }
                }
            }
        }
        else
        {
            GetNewAttack(enemyManager);
        }

        return(combatStanceState);
    }
Пример #8
0
    public override State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
    {
        if (isSleeping && enemyManager.isInteracting == false)
        {
            //play sleep anim
            Debug.Log("Is sleeping");
            enemyAnimatorManager.PlayTargetAnimation(sleepAnimation, true);
        }

        #region Handle Target Detection

        Collider[] colliders = Physics.OverlapSphere(enemyManager.transform.position, detectionRadius, detectionLayer);

        for (int i = 0; i < colliders.Length; i++)
        {
            CharacterStats characterStats = colliders[i].transform.GetComponent <CharacterStats>();

            if (characterStats != null)
            {
                Vector3 targetsDirection = characterStats.transform.position - enemyManager.transform.position;
                float   viewableAngle    = Vector3.Angle(targetsDirection, enemyManager.transform.forward);

                if (viewableAngle > enemyManager.minimumDetectionAngle &&
                    viewableAngle < enemyManager.maximumDetectionAngle)
                {
                    enemyManager.currentTarget = characterStats;
                    isSleeping = false;

                    //play wake animation
                    Debug.Log("Is awake!");
                    enemyAnimatorManager.PlayTargetAnimation(wakeAnimation, true);
                }
            }
        }

        #endregion

        #region Handle State Change

        if (enemyManager.currentTarget != null)
        {
            return(pursueTargetState);
        }
        else
        {
            return(this);
        }
        #endregion
    }
Пример #9
0
 void Start()
 {
     EStats                     = GetComponent <Enemy_Stats>();
     EStats.MaxHealth           = 50f;
     EStats.CurrentHealth       = EStats.MaxHealth;
     EStats.MeleeDamage         = 10f;
     EStats.MeleeAttackSpeed    = 1f;
     EStats.MeleeAttackCooldown = 0f;
     EStats.SightRadius         = 60f;
     EStats.SightSize           = 30f;
     target                     = CharacterCombat.instance.transform;
     agent = GetComponent <NavMeshAgent>();
     agent.stoppingDistance = 3;
     Player = CharacterCombat.instance.gameObject;
     PStats = CharacterCombat.instance;
 }
Пример #10
0
 void Start()
 {
     EStats                     = GetComponent <Enemy_Stats>();
     EStats.MaxHealth           = 70f;
     EStats.CurrentHealth       = EStats.MaxHealth;
     EStats.RangeDamage         = 15f;
     EStats.RangeAttackSpeed    = 1f;
     EStats.RangeAttackCooldown = 0f;
     EStats.SightRadius         = 60f;
     EStats.SightSize           = 60f;
     EStats.Range               = 50f;
     Player                     = CharacterCombat.instance.gameObject;
     target                     = Player.transform;
     agent = GetComponent <NavMeshAgent>();
     agent.stoppingDistance = 2;
     PStats         = Player.GetComponent <PlayerStats>();
     recentSighting = false;
 }
Пример #11
0
 void Start()
 {
     EStats                     = GetComponent <Enemy_Stats>();
     EStats.MaxHealth           = 200f;
     EStats.CurrentHealth       = EStats.MaxHealth;
     EStats.MeleeDamage         = 20f;
     EStats.MeleeAttackSpeed    = 1f;
     EStats.MeleeAttackCooldown = 0.5f;
     EStats.GroundPoundDamage   = 15f;
     EStats.GroundPoundSpeed    = 10f;
     EStats.GroundPoundCooldown = 2f;
     EStats.SightRadius         = 60f;
     EStats.SightSize           = 30f;
     EStats.DamageResistant     = false;
     target                     = CharacterCombat.instance.transform;
     agent = GetComponent <NavMeshAgent>();
     agent.stoppingDistance = 2;
     Player = GameObject.Find("Player");
     PStats = Player.GetComponent <PlayerStats>();
 }
Пример #12
0
    public override State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager)
    {
        #region Handle Enemy Target Detection
        Collider[] colliders = Physics.OverlapSphere(transform.position, enemyManager.detectionRadius, detectionLayer);

        for (int i = 0; i < colliders.Length; i++)
        {
            CharacterStats characterStats = colliders[i].transform.GetComponent <CharacterStats>();

            if (characterStats != null)
            {
                //check for team id

                Vector3 targetDirection = characterStats.transform.position - transform.position;
                float   viewableAngle   = Vector3.Angle(targetDirection, transform.forward);

                if (viewableAngle > enemyManager.minimumDetectionAngle && viewableAngle < enemyManager.maximumDetectionAngle)
                {
                    enemyManager.currentTarget = characterStats;
                }
            }
        }
        #endregion

        #region Handle Switching To Next State
        if (enemyManager.currentTarget != null)
        {
            return(pursueTargetState);
        }
        else
        {
            return(this);
        }

        #endregion
    }
Пример #13
0
    private void OnTriggerEnter(Collider collision)
    {
        Debug.Log("collided");

        if (collision.tag == "Player")
        {
            PlayerStats playerStats = collision.GetComponent <PlayerStats>();
            Debug.Log("Hit Player");
            if (playerStats != null)
            {
                playerStats.TakeDamage(currentWeaponDamage);
            }
        }

        if (collision.tag == "Boss")
        {
            Enemy_Stats enemyStats = collision.GetComponent <Enemy_Stats>();
            Debug.Log("Hit enemy");
            if (enemyStats != null)
            {
                enemyStats.TakeDamage(currentWeaponDamage);
            }
        }
    }
Пример #14
0
    private void IceAttack(Enemy_Stats enemy)
    {
        StartCoroutine(PlayerIceAttack(enemy));

        if (enemy.Health <= 0)
        {
            enemy.Die();
            if (enemies.Count <= 0)
            {
                CommandoMenu.SetActive(false);
            }
            AttackBox.SetActive(false);
            GetComponent <Player_Controller>().enabled = true;
            Player.transform.position = new Vector2(-5, -3);
            state = BattleState.NONE;
        }

        else
        {
            state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyNeutralAttack());
            state = BattleState.PLAYERTURN;
        }
    }
Пример #15
0
 void Start()
 {
     enemy = GetComponentInParent <Enemy_Stats>();
     print("Enemy Attack Value: " + enemy.BaseAttack);
 }
Пример #16
0
 public abstract State Tick(Enemy_Manager enemyManager, Enemy_Stats enemyStats, EnemyAnimatorManager enemyAnimatorManager);
Пример #17
0
        void Update_Info_thread(object obj)
        {
            byte g = (byte)obj;

            if (Player_HP.InvokeRequired)
            {
                Player_HP.Invoke(new MethodInvoker(delegate { Player_HP.Text = string.Format("HP: {0}/{1}", hero.HP, hero.FULLHP); }));
            }
            if (Enemy_HP.InvokeRequired)
            {
                Enemy_HP.Invoke(new MethodInvoker(delegate { Enemy_HP.Text = string.Format("HP: {0}/{1}", enemy.HP, enemy.FULLHP); }));
            }
            string Hero_text  = string.Format(@"Full HP: {0}
Damage: {1}
Evade Chance: {2}
Block Chance: {3}
CriticalDMG %: {4}
CriticalDMG: {5}%", hero.HP, hero.DMG, hero.EvadeChance, hero.BlockChance, hero.CriticalDMGChance, hero.CriticalDMG);
            string Enemy_text = string.Format(@"Full HP: {0}
Damage: {1}
Evade Chance: {2}
Block Chance: {3}
CriticalDMG %: {4}
CriticalDMG: {5}%", enemy.HP, enemy.DMG, enemy.EvadeChance, enemy.BlockChance, enemy.CriticalDMGChance, enemy.CriticalDMG);

            if (Hero_Stats.InvokeRequired)
            {
                Hero_Stats.Invoke(new MethodInvoker(delegate { Hero_Stats.Text = Hero_text; }));
            }
            if (Enemy_Stats.InvokeRequired)
            {
                Enemy_Stats.Invoke(new MethodInvoker(delegate { Enemy_Stats.Text = Enemy_text; }));
            }
            if (hero.HP <= 0)
            {
                Thread t = Thread.CurrentThread;
                fight = false;
                enemyRectanglepos.RemoveAt(g);
                enemys.RemoveAt(g);
                foreach (Thread thr in thList)
                {
                    thr.Resume();
                }
                LoadEnemySightAndWay();
                if (pictureBox2.InvokeRequired)
                {
                    pictureBox2.Invoke(new MethodInvoker(delegate { pictureBox2.Image = Image.FromFile(Environment.CurrentDirectory + "\\ImagesH\\Battle_tendence.png"); }));
                }
                if (Attack_Button.InvokeRequired)
                {
                    Attack_Button.Invoke(new MethodInvoker(delegate
                    {
                        Attack_Button.Enabled = false;
                        Attack_Button.Visible = false;
                    }));
                }
                if (STOIKA_BUTTON.InvokeRequired)
                {
                    STOIKA_BUTTON.Invoke(new MethodInvoker(delegate
                    {
                        STOIKA_BUTTON.Enabled = false;
                        STOIKA_BUTTON.Visible = false;
                    }));
                }
                if (Player_HP.InvokeRequired)
                {
                    Player_HP.Invoke(new MethodInvoker(delegate
                    {
                        Player_HP.Visible = false;
                    }));
                }
                if (Enemy_HP.InvokeRequired)
                {
                    Enemy_HP.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_HP.Visible = false;
                    }));
                }
                if (Hero_Stats.InvokeRequired)
                {
                    Hero_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Hero_Stats.Visible = false;
                    }));
                }
                if (Enemy_Stats.InvokeRequired)
                {
                    Enemy_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_Stats.Visible = false;
                    }));
                }
                if (hodiki.InvokeRequired)
                {
                    hodiki.Invoke(new MethodInvoker(delegate
                    {
                        hodiki.Visible   = false;
                        hodiki.Text      = "<--Ваш ход";
                        hodiki.ForeColor = Color.Green;
                    }));
                }
                t.Abort();
            }
            else if (enemy.HP <= 0)
            {
                if (pictureBox2.InvokeRequired)
                {
                    pictureBox2.Invoke(new MethodInvoker(delegate { pictureBox2.Image = Image.FromFile(Environment.CurrentDirectory + "\\ImagesH\\Battle_tendence.png"); }));
                }
                Thread t = Thread.CurrentThread;
                fight = false;
                enemyRectanglepos.RemoveAt(g);
                enemys.RemoveAt(g);
                foreach (Thread thr in thList)
                {
                    thr.Resume();
                }
                LoadEnemySightAndWay();
                if (hodiki.InvokeRequired)
                {
                    hodiki.Invoke(new MethodInvoker(delegate
                    {
                        hodiki.Visible   = false;
                        hodiki.Text      = "<--Ваш ход";
                        hodiki.ForeColor = Color.Green;
                    }));
                }
                if (Attack_Button.InvokeRequired)
                {
                    Attack_Button.Invoke(new MethodInvoker(delegate
                    {
                        Attack_Button.Enabled = false;
                        Attack_Button.Visible = false;
                    }));
                }
                if (STOIKA_BUTTON.InvokeRequired)
                {
                    STOIKA_BUTTON.Invoke(new MethodInvoker(delegate
                    {
                        STOIKA_BUTTON.Enabled = false;
                        STOIKA_BUTTON.Visible = false;
                    }));
                }
                if (Player_HP.InvokeRequired)
                {
                    Player_HP.Invoke(new MethodInvoker(delegate
                    {
                        Player_HP.Visible = false;
                    }));
                }
                if (Enemy_HP.InvokeRequired)
                {
                    Enemy_HP.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_HP.Visible = false;
                    }));
                }
                if (Hero_Stats.InvokeRequired)
                {
                    Hero_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Hero_Stats.Visible = false;
                    }));
                }
                if (Enemy_Stats.InvokeRequired)
                {
                    Enemy_Stats.Invoke(new MethodInvoker(delegate
                    {
                        Enemy_Stats.Visible = false;
                    }));
                }
                t.Abort();
            }
            else
            {
                if (Hero_Attacked)
                {
                    Turn_Enemy.Invoke(this, new NumOfEnemy {
                        i = g
                    });
                }
                else
                {
                    Turn_Hero.Invoke(this, new NumOfEnemy {
                        i = g
                    });
                }
            }
        }
Пример #18
0
 void Start()
 {
     Enemy  = GameObject.FindGameObjectWithTag("Range_M");
     EStats = Enemy.GetComponent <Enemy_Stats>();
 }
Пример #19
0
 public void Init(Enemy_Stats stats)
 {
     EStats = stats;
 }
Пример #20
0
 IEnumerator PlayerNeutralAttack(Enemy_Stats enemy)
 {
     enemy.TakeTurnBasedNeutralDamage(playerStats.BaseAttack);
     Debug.Log("Enemy Hit");
     yield return(new WaitForSeconds(2f));
 }
Пример #21
0
 IEnumerator PlayerIceAttack(Enemy_Stats enemy)
 {
     enemy.TakeTurnBasedIceDamage(playerStats.BaseIceAttack);
     Debug.Log("Enemy Hit by IceAttack");
     yield return(new WaitForSeconds(2f));
 }