コード例 #1
0
    //everything that enables the archer's arrow shooting, stamina usage and cooldown
    void ArcherAttack()
    {
        if (currentStaminaPoints > attackStamina && Time.time > nextAttack && Input.GetKeyDown(attack))
        {
            animator.SetBool("isArcherAttacking", true);

            GameObject instArcherArrow          = Instantiate(archerArrow, transform.position + offset, Quaternion.identity) as GameObject;
            Rigidbody  instArcherArrowRigidbody = instArcherArrow.GetComponent <Rigidbody>();
            instArcherArrowRigidbody.AddForce(transform.forward * arrowSpeed);

            //setting the cooldown before the next attack can be activated
            nextAttack = Time.time + attackCooldown;

            //runs the method from "global_stamina" to use an amount of stamina points
            global_stamina stamina_globalInstance = GetComponent <global_stamina>();
            stamina_globalInstance.AttackStamina();

            BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.ArcherAttack);
        }
        else
        {
            animator.SetBool("isArcherAttacking", false);
        }
    }
コード例 #2
0
    //everything that enables the tank's attack movement, stamina usage and cooldown
    void TankAttack()
    {
        if (currentStaminaPoints > attackStamina && Time.time > nextAttack && Input.GetKeyDown(attack))
        {
            animator.SetBool("isTankAttacking", true);
            //start clockwise rotation of sword with a Coroutine;
            //StartCoroutine(RotateMe(Vector3.up * 90, 0.8f));

            //setting time before second swing


            //setting the cooldown before the next attack can be activated
            nextAttack = Time.time + attackCooldown;

            //runs the method from "global_stamina" to use an amount of stamina points
            global_stamina stamina_globalInstance = GetComponent <global_stamina>();
            stamina_globalInstance.AttackStamina();

            BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.TankAttack);
        }
        else
        {
            animator.SetBool("isTankAttacking", false);
        }
    }
コード例 #3
0
    public void RespawnPlayer1()
    {
        if (playerOne == 1)
        {
            animatorPlayerOne = GameObject.Find("ArcherPlayer1(Clone)").GetComponent <Animator>();
            animatorPlayerOne.SetBool("isRespawning", true);
            Instantiate(archerPlayer1, spawnPlayer1.transform);
            StartCoroutine(COStunPause(1.2f));

            BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming);
        }

        if (playerOne == 2)
        {
            animatorPlayerOne = GameObject.Find("KnightPlayer1(Clone)").GetComponent <Animator>();
            animatorPlayerOne.SetBool("isRespawning", true);
            Instantiate(knightPlayer1, spawnPlayer1.transform);
            StartCoroutine(COStunPause(1.2f));

            BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming);
        }

        if (playerOne == 3)
        {
            animatorPlayerOne = GameObject.Find("TankPlayer1(Clone)").GetComponent <Animator>();
            animatorPlayerOne.SetBool("isRespawning", true);
            Instantiate(tankPlayer1, spawnPlayer1.transform);
            StartCoroutine(COStunPause(1.2f));

            BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming);
        }
    }
コード例 #4
0
 void CallDodging()
 {
     if (isDodging == true)
     {
         BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
         characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Dodging);
     }
 }
コード例 #5
0
 void CallFootsteps()
 {
     if (isWalking == true)
     {
         BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
         characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Walking);
     }
 }
コード例 #6
0
    private void OnTriggerEnter(Collider collider)
    {
        GameObject objectCollided = collider.gameObject;

        if (objectCollided.CompareTag("Attacker") && currentHP > 0)
        {
            attackDamage = objectCollided.GetComponentInParent <global_stats>().attackDamage;
            currentHP   -= attackDamage;

            BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Flinching);
        }
    }
コード例 #7
0
    void DoDamage()
    {
        if (currentHP <= 0)
        {
            print("dead: " + gameObject);

            BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>();
            characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Death);

            if (playerNumber == 1)
            {
                global_kill_counter.Instance.ScoreCounterPlayer1();
                global_respawn.Instance.RespawnPlayer1();
            }

            if (playerNumber == 2)
            {
                global_kill_counter.Instance.ScoreCounterPlayer2();
                global_respawn.Instance.RespawnPlayer2();
            }

            Destroy(gameObject);
        }
    }
コード例 #8
0
 // Start is called before the first frame update
 void Start()
 {
     Instance = this;
 }