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

            shield.ActivateShield(true);
        }

        //Stop blocking with shield
        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.Attack_1();
            }
            else
            {
                playerAnimation.Attack_2();

                soundFX.Attack_2();
            }
        }
    }
Пример #2
0
    void AttackPlayer()
    {
        navAgent.velocity  = Vector3.zero;
        navAgent.isStopped = true;

        enemy_Anim.Walk(false);
        attack_Timer += Time.deltaTime;

        if (attack_Timer > wait_Before_Attack_Time)
        {
            if (Random.Range(0, 2) > 0)
            {
                enemy_Anim.Attack_1();
            }
            else
            {
                enemy_Anim.Attack_2();
            }
            attack_Timer = 0f;
        }
        if (Vector3.Distance(transform.position, playerTarget.position) >
            attack_Distance + chase_After_Attack_Distance)
        {
            navAgent.isStopped = false;
            enemy_State        = EnemyState.CHASE;
        }
    }
Пример #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
    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();
            }
            else
            {
                playerAnimation.Attack_2();
            }
        }
    }
Пример #5
0
 public void Attack(CharacterAnimations animations)
 {
     if (Random.Range(0, 2) > 0)
     {
         animations.Attack_1();
         soundFX.Attack_1();
     }
     else
     {
         animations.Attack_2();
         soundFX.Attack_2();
     }
 }
 // Update is called once per frame
 void Update()
 {   //when you press keys J- defend and K-attack
     if (Input.GetKeyDown(KeyCode.J))
     {
         playerAnimation.UnFreezeAnimation();
         playerAnimation.Defend(true);
     }
     if (Input.GetKeyUp(KeyCode.J))
     {
         playerAnimation.Defend(false);
     }
     if (Input.GetKeyDown(KeyCode.K))
     {
         if (Random.Range(0, 2) > 0)
         {
             playerAnimation.Attack_1();
         }
         else
         {
             playerAnimation.Attack_2();
         }
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(2))
     {
         playerAnimation.Defend(true);
     }
     if (Input.GetMouseButtonUp(2))
     {
         playerAnimation.UnFreezeAnimation();
         playerAnimation.Defend(false);
     }
     if (Input.GetMouseButtonDown(0))
     {
         if (Random.Range(0, 2) > 0)
         {
             playerAnimation.Attack_1();
         }
         else
         {
             playerAnimation.Attack_2();
         }
     }
 }