void OnTriggerEnter(Collider obj)
 {
     if (obj.gameObject.tag == "boulder")
     {
         Debug.Log("collided with boulder.");
         Player_ship.Sub(2, 1);
         Destroy(obj.gameObject);
     }
     if (obj.gameObject.tag == "addammo")
     {
         Player_ship.Add(3, 1);
         Destroy(obj.gameObject);
     }
     if (obj.gameObject.tag == "addshield")
     {
         Player_ship.Add(2, 1);
         Destroy(obj.gameObject);
     }
     if (obj.gameObject.tag == "addspecial1")
     {
         Player_ship.Add(4, 1);
         Destroy(obj.gameObject);
     }
     if (obj.gameObject.tag == "addspecial2")
     {
         Player_ship.Add(5, 1);
         Destroy(obj.gameObject);
     }
     if (obj.gameObject.tag == "coin")
     {
         Player_ship.Add(6, 1);
         Destroy(obj.gameObject);
     }
 }
Esempio n. 2
0
 IEnumerator Fire()
 {
     while (true)
     {
         if (Input.GetAxis("Jump") == 1)
         {
             if (Player_ship.ammo > 0)
             {
                 audio.Play();
                 Object.Instantiate(bullet, new Vector3(ship.rigidbody.position.x, ship.rigidbody.position.y + 2, ship.rigidbody.position.z - 4f), Quaternion.Euler(90, 0, 0));
                 Player_ship.Sub(3, 1);
                 yield return(new WaitForSeconds(0.25f));
             }
             else
             {
                 Debug.Log("No Ammo!");
             }
         }
         else if (Input.GetKeyDown(KeyCode.Z))
         {
             if (Player_ship.special1 > 0)
             {
                 StartCoroutine(Lazers.Particles());
                 StartCoroutine(lazer_collider.Collide());
             }
             else
             {
                 Debug.Log("No Special Ammo 1");
             }
         }
         else if (Input.GetKeyDown(KeyCode.X))
         {
             if (Player_ship.special2 > 0)
             {
                 audio.Play();
                 Object.Instantiate(missile, new Vector3(ship.rigidbody.position.x, ship.rigidbody.position.y + 2, ship.rigidbody.position.z - 4f), Quaternion.identity);
             }
             else
             {
                 Debug.Log("No Special Ammo 2");
             }
         }
         yield return(null);
     }
 }
Esempio n. 3
0
 void Death(int x)
 {
     if (x == 1)
     {
         Player_ship.Add(1, 1);
         Destroy(gameObject);
     }
     else if (x == 2)
     {
         Player_ship.Sub(2, 1);
         Destroy(gameObject);
     }
     else if (x == 0)
     {
         Player_ship.Add(1, 1);
         Destroy(gameObject);
     }
 }
Esempio n. 4
0
    void OnCollisionEnter(Collision obj)
    {
        if (obj.gameObject.tag == "Player" || obj.gameObject.tag == "bullet" || obj.gameObject.tag == "missile")
        {
            Debug.Log("Collided with player.");
            switch (id)
            {            //ammo,shields,s1,s2
            case 1:
                Player_ship.Add(3, 20);
                Destroy(gameObject);
                break;

            case 2:
                Player_ship.Add(2, 1);
                Destroy(gameObject);
                break;

            case 3:
                Player_ship.Add(4, 1);
                Destroy(gameObject);
                break;

            case 4:
                Player_ship.Add(5, 1);
                Destroy(gameObject);
                break;

            case 5:
                Player_ship.Add(6, 1);
                Destroy(gameObject);
                break;
            }
        }
        else
        {
            Debug.Log("Collided");
        }
    }