using System.Collections; using System.Collections.Generic; using UnityEngine; public class Cannister : MonoBehaviour { public int Health = 50; public float rotateSpeed = 100f; public AudioClip Pickup; // Use this for initialization void Start () { } // Update is called once per frame void Update () { transform.Rotate(0,0,Time.deltaTime * rotateSpeed); } void OnTriggerEnter2D(Collider2D collider){ if( this.tag == "HealthCan"){ if (collider.tag == "LeftWing"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.leftwingHealth += Health/2; XwingController.rightwingHealth += Health/2; XwingController.cockpitHealth += Health; Destroy(gameObject); } else if (collider.tag == "RightWing"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.leftwingHealth += Health/2; XwingController.rightwingHealth += Health/2; XwingController.cockpitHealth += Health; Destroy(gameObject); } else if (collider.tag == "Cockpit"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.leftwingHealth += Health/2; XwingController.rightwingHealth += Health/2; XwingController.cockpitHealth += Health; Destroy(gameObject); } } if( this.tag == "Upgrade"){ if(collider.tag == "LeftWing"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.upgradeLevel += 1; Destroy(gameObject); } if(collider.tag == "RightWing"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.upgradeLevel += 1; Destroy(gameObject); } if(collider.tag == "Cockpit"){ AudioSource.PlayClipAtPoint(Pickup, transform.position); XwingController.upgradeLevel += 1; Destroy(gameObject); } } } }