Exemple #1
0
    private void Shoot()
    {
        GameObject projectile = Instantiate(bulletPrefab, transform.position, transform.rotation) as GameObject;

        AudioSource pew = GetComponent <AudioSource>();

        pew.Play();

        Rigidbody body = projectile.GetComponent <Rigidbody>();

        body.velocity = Camera.main.transform.forward * 60.0f;

        PlayerAttrs playerAttrs = playerInstance.GetComponent <PlayerAttrs>();

        if (playerAttrs != null)
        {
            projectile.GetComponent <BulletAttrs>().shooter = playerAttrs.team_number;
        }
    }
Exemple #2
0
    private void OnCollisionEnter(Collision collision)
    {
        // once we get this to a point where we need to detect collision between bullets and players we'll do that here but for now we'll just make them stop dead in their tracks.
        Debug.Log("Collision.");

        Rigidbody body = GetComponent <Rigidbody>();

        body.velocity = Vector3.zero;

        PlayerAttrs playerAttrs = collision.gameObject.GetComponent <PlayerAttrs>();

        // collision between bullet and player
        if (playerAttrs != null && GetComponent <BulletAttrs>().shooter != playerAttrs.team_number && !GetComponent <BulletAttrs>().done)
        {
            // take health down and destroy the bullet
            collision.gameObject.GetComponent <PlayerAttrs>().health_remaining -= 10;
            collision.gameObject.GetComponent <AudioSource>().Play();
        }

        GetComponent <BulletAttrs>().done = true;
    }
Exemple #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            PlayerAttrs pa = other.GetComponent <PlayerAttrs>();

            Debug.Log(placeText.text);

            if (string.Equals(placeText.text, "CheckPoint 1!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "pepper"))
                {
                    pa.checkpoints.Add("pepper");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "CheckPoint 2!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "salt"))
                {
                    pa.checkpoints.Add("salt");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "CheckPoint 3!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "chilly"))
                {
                    pa.checkpoints.Add("chilly");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "CheckPoint 4!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "pickles"))
                {
                    pa.checkpoints.Add("pickles");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "CheckPoint 5!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "oregano"))
                {
                    pa.checkpoints.Add("oregano");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "CheckPoint 6!"))
            {
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "masala"))
                {
                    pa.checkpoints.Add("masala");
                }
                Debug.Log(pa.checkpoints.Count);
            }
            else if (string.Equals(placeText.text, "Final"))
            {
                Debug.Log("Hey welcome to final!\n");
                string last = pa.checkpoints[pa.checkpoints.Count - 1];
                if (!string.Equals(last, "final"))
                {
                    pa.checkpoints.Add("final");
                }
                Debug.Log(pa.checkpoints.Count);
            }
        }
    }