Ejemplo n.º 1
0
    public void StopPlayers()
    {
        foreach (GameObject player in players)
        {
            if (player != null)
            {
                //This is for multiplayer because scripts are different name
                if (player.name == "Player")
                {
                    PlayerMovement playerMovement = player.GetComponent <PlayerMovement>();
                    PlayerShooting playerShooting = player.GetComponentInChildren <PlayerShooting>();
                    //this is to stop walking animation
                    playerMovement.AnimateWalk(0, 0);

                    playerMovement.enabled = false;
                    playerShooting.enabled = false;
                }
                else
                {
                    Player2Movement player2Movement = player.GetComponent <Player2Movement>();
                    Player2Shooting player2Shooting = player.GetComponentInChildren <Player2Shooting>();

                    //this is to stop walking animation
                    player2Movement.AnimateWalk(0, 0);

                    player2Movement.enabled = false;
                    player2Shooting.enabled = false;
                }
            }
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     weaponAmmoP1  = P1.GetComponent <LineRenderer>();
     weaponAmmoP2  = P2.GetComponent <LineRenderer>();
     p1ShootScript = P1.GetComponent <PlayerShooting>();
     p2ShootScript = P2.GetComponent <Player2Shooting>();
     p1AudioShoot  = P1.GetComponent <AudioSource>();
     p2AudioShoot  = P2.GetComponent <AudioSource>();
 }
Ejemplo n.º 3
0
    public void StopPlayersAndDie()
    {
        Animator    playerAnim;
        AudioSource playerAudio;



        foreach (GameObject player in players)
        {
            if (player != null)
            {
                playerAnim  = player.GetComponent <Animator>();
                playerAudio = player.GetComponent <AudioSource>();

                //This is for multiplayer because scripts are different name
                if (player.name == "Player")
                {
                    PlayerMovement playerMovement = player.GetComponent <PlayerMovement>();
                    PlayerShooting playerShooting = player.GetComponentInChildren <PlayerShooting>();

                    playerMovement.enabled = false;
                    playerShooting.enabled = false;
                }
                else
                {
                    Player2Movement player2Movement = player.GetComponent <Player2Movement>();
                    Player2Shooting player2Shooting = player.GetComponentInChildren <Player2Shooting>();

                    player2Movement.enabled = false;
                    player2Shooting.enabled = false;
                }



                if (!win)
                {
                    playerAnim.SetTrigger("Die");
                    if (player.name == "Player")
                    {
                        playerAudio.clip = player.GetComponent <PlayerHealth>().deathClip;
                    }
                    else
                    {
                        playerAudio.clip = player.GetComponent <Player2Health>().deathClip;
                    }

                    playerAudio.Play();
                }
            }
        }
    }
Ejemplo n.º 4
0
    void Awake()
    {
        anim        = GetComponent <Animator>();
        playerAudio = GetComponent <AudioSource>();

        //References the script movement and shooting
        playerMovement = GetComponent <Player2Movement>();
        playerShooting = GetComponentInChildren <Player2Shooting>();

        //Set current health to starting (100 by default)
        currentHealth = startingHealth;

        //Gets the animator's hud for die screen animation
        hudAnim = hud.GetComponent <Animator>();
    }