Exemplo n.º 1
0
        public IEnumerator Execute()
        {
            while (owner.StateMachine.CurrentState is PatrolState)
            {
                var isPatrol = Random.Range(1, 3) == 1;
                if (isPatrol)
                {
                    var startPos      = owner.transform.position;
                    var numberOfMoves = Random.Range(1, 10);
                    while (numberOfMoves > 0)
                    {
                        EnemyAnimations.ResetAllAnimParameters(owner);
                        EnemyAnimations.SetAnimation(owner, "Walk");
                        var dest = startPos + new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f));
                        agent.SetDestination(dest);
                        var time = (dest - owner.transform.position).magnitude / agent.speed;
                        yield return(new WaitForSeconds(time));

                        numberOfMoves--;
                    }
                }
                else
                {
                    agent.ResetPath();
                    EnemyAnimations.ResetAllAnimParameters(owner);
                    EnemyAnimations.SetAnimation(owner, "Idle");
                    yield return(new WaitForSeconds(ownerChillTime));
                }
            }
        }
Exemplo n.º 2
0
 public IEnumerator Execute()
 {
     EnemyAnimations.ResetAllAnimParameters(owner);
     EnemyAnimations.SetAnimation(owner, "Walk");
     while (owner.StateMachine.CurrentState is ChasingState)
     {
         LookAt(player);
         agent.SetDestination(player.position);
         yield return(null);
     }
 }
Exemplo n.º 3
0
 // Update is called once per frame
 void Update()
 {
     if (m_EnemyAnimations.m_IsDead == false || m_EnemyAnimations == null)
     {
         m_Direction = (m_PlayerTransform.position - m_Origin.position).normalized;
         m_FireRate -= Time.deltaTime;
         if (Physics.Raycast(m_Origin.position, m_Direction, out hit, m_ShotRange))
         {
             if (hit.transform.CompareTag("Player") && m_FireRate <= 0)
             {
                 Debug.Log("aoowfjaklsdjflk");
                 m_EnemyAnimations.SetAnimation(AnimationState.ShootTwoHanded);
                 Rigidbody enemyProjectile = Instantiate(m_Projectile, m_Origin.position, m_Origin.rotation);
                 enemyProjectile.AddForce(m_Origin.forward * m_InitialForce, ForceMode.Impulse);
                 enemyProjectile.GetComponent <Bullets>().m_Owner = m_EnemyName;
                 m_FireRate = m_OriginalFireRate;
             }
             else
             {
                 m_EnemyAnimations.SetAnimation(AnimationState.MoveTwoHanded);
             }
         }
     }
 }
Exemplo n.º 4
0
 public void TakeDamage(float Damage)
 {
     Damage  *= StatManager.m_Data.m_DamageModifier;
     m_Health = m_Health - Damage;
     if (m_Health <= 0)
     {
         int cashDrop = Random.Range(m_MinCashDrop, m_MaxCashDrop);
         StatManager.m_Data.m_CurrentMoney    += cashDrop;
         StatManager.m_Data.m_TotalCashEarned += cashDrop;
         m_EnemyAnimations.SetAnimation(AnimationState.Death);
         StatManager.SaveStats();
         GameObject BotDeath = Instantiate(m_BotDeath, transform.position, new Quaternion(0, 0, 0, 0));
         Destroy(gameObject);
     }
 }
Exemplo n.º 5
0
        public IEnumerator Execute()
        {
            agent.ResetPath();

            if (owner.EnemySo.TypeEnemy == EnemySO.EnemyType.Ranged)
            {
                Coroutine lookAtCoroutine = null;
                while (owner.StateMachine.CurrentState is AttackState)
                {
                    EnemyAnimations.ResetAllAnimParameters(owner);
                    EnemyAnimations.SetAnimation(owner, "Attack");
                    if (!(lookAtCoroutine is null))
                    {
                        owner.StopCoroutine(lookAtCoroutine);
                    }
                    lookAtCoroutine = owner.StartCoroutine(LookAtPlayer(player));

                    if (Physics.Raycast(owner.transform.position, owner.transform.TransformDirection(Vector3.forward), out var hit,
                                        layerMask))
                    {
                        owner.Line.SetPosition(0, owner.transform.position);
                        owner.Line.SetPosition(1, hit.point);

                        if (hit.transform.TryGetComponent <PlayerHealth>(out var plHealth))
                        {
                            plHealth.playerHealthDecrease.Invoke(owner.EnemyRaw.Damage);
                        }
                    }
                    else
                    {
                        owner.Line.SetPosition(0, owner.transform.position);
                        owner.Line.SetPosition(1, owner.transform.TransformDirection(Vector3.forward));
                    }

                    yield return(new WaitForSeconds(ownerAnimator.GetCurrentAnimatorStateInfo(0).length));
                }