Esempio n. 1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            playerAnimation.Defend(true);
            shield.ActivateShield(true);
        }

        if (Input.GetKeyUp(KeyCode.J))
        {
            playerAnimation.UnFreezeAnimation();
            playerAnimation.Defend(false);
            shield.ActivateShield(false);
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            if (Random.Range(0, 2) > 0)
            {
                playerAnimation.Attack_1();
                soundFX.Attack1();
            }
            else
            {
                playerAnimation.Attack_2();
                soundFX.Attack2();
            }
        }
    }
Esempio n. 2
0
    void AttackPlayer()
    {
        navagent.velocity  = Vector3.zero;
        navagent.isStopped = true;
        EnemyAnimations.Walk(false);
        AttackTimer += Time.deltaTime;
        if (AttackTimer > waitbeforeAttckTime)
        {
            if (Random.Range(0, 2) > 0)
            {
                EnemyAnimations.Attack1();
                soundFX.Attack1();
            }
            else
            {
                EnemyAnimations.Attack2();
                soundFX.Attack2();
            }

            AttackTimer = 0f;
        }

        if (Vector3.Distance(Playertarget.position, transform.position) <= attackDistance + chasePlayerafterAttackdistance)
        {
            navagent.isStopped = false;
            enemystate         = EnemyState.CHASE;
        }
    }
Esempio n. 3
0
    } // awake

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J)) // defend
        {
            playerAnimation.Defend(true);

            shield.ActivateShield(true);
        }
        if (Input.GetKeyUp(KeyCode.J)) // defend
        {
            playerAnimation.UnfreezeAnimation();
            playerAnimation.Defend(false);

            shield.ActivateShield(false);
        }

        if (Input.GetKeyDown(KeyCode.K)) // attack
        {
            if (Random.Range(0, 2) > 0)  // Range(inclusive, exclusive) but with float the second param is included
            {
                playerAnimation.Attack_1();
                soundFx.Attack1();
            }
            else
            {
                playerAnimation.Attack_2();
                soundFx.Attack2();
            }
        }
    } // update
Esempio n. 4
0
    void AttackPlayer()
    {
        navAgent.velocity  = Vector3.zero;
        navAgent.isStopped = true;

        enemyAnim.Walk(false);

        attackTimer += Time.deltaTime;

        if (attackTimer > waitBeforeAttackTime)
        {
            if (Random.Range(0, 2) > 0)
            {
                enemyAnim.Attack_1();
                soundFX.Attack1();
            }
            else
            {
                enemyAnim.Attack_2();
                soundFX.Attack2();
            }
            attackTimer = 0f;
        }

        if (Vector3.Distance(transform.position, playerTarget.position) > attackDistance + chasePlayerAfterAttackDistance)
        {
            navAgent.isStopped = false;
            enemyState         = EnemyState.CHASE;
        }
    }