void OnTriggerEnter(Collider collider) { if (collider.gameObject.CompareTag("Player")) { if (!collected) { collected = true; this.GetComponent <AudioSource>().Play(); Junkman junkman = GameObject.Find("Junkman").GetComponent <Junkman>(); switch (type) { case ItemType.shield: junkman.activateShield(); break; case ItemType.speedUp: junkman.activateNitro(); break; case ItemType.stunner: stunEnemies(); break; } Invoke("Disappear", 0.2f); } } }
public void applyDamage() { GameObject player = GameObject.Find("Junkman"); Junkman jm = player.GetComponent <Junkman>(); if (!jm.isShieldActive()) { jm.updateHealth(-damage); } }
public void OnGUI() { GUI.BeginGroup(new Rect(10, 10, Screen.width - 10, Screen.height - 10)); GameObject player = GameObject.Find("Junkman").gameObject; Junkman junkman = player.GetComponent <Junkman>(); health = "Health: " + junkman.getHealth(); collected = "Collected: " + junkman.getNumberOfCollected() + "/" + GameGlobals.totalJunks; //points = "Points: " + junkman.getPoints(); GUI.Box(new Rect(0, 0, 100, 20), health); GUI.Box(new Rect(0, 25, 100, 20), collected); //GUI.Box(new Rect(0, 50, 100, 20), points); foreach (TowerAI com in towers) { if (com.isPlayerDetected()) { GUI.Box(new Rect(0, 50, 100, 20), "Detected!"); } } foreach (EnemyAI pat in patrollerDetectors) { if (pat.isPlayerDetected()) { GUI.Box(new Rect(0, 50, 100, 20), "Detected!"); } } if (junkman.isShieldActive()) { GUI.Box(new Rect(0, 75, 100, 20), "Shield Active!"); } if (junkman.isNitroActive()) { GUI.Box(new Rect(0, 100, 100, 20), "Nitro Active!"); } if (patrollerAI[0].isStunned()) { GUI.Box(new Rect(0, 125, 100, 20), "Enemies Stunned!"); } //GUI.Box(new Rect(Screen.width - 120, 0, 100, 20), "Speed: " + junkman.getSpeed().ToString()); GUI.Box(new Rect(Screen.width - 120, 0, 100, 20), "Time: " + (GameGlobals.remainingTime)); GUI.EndGroup(); }
private void fire() { GameObject player = GameObject.Find("Junkman"); Junkman jm = player.GetComponent <Junkman>(); GameObject det_obj = player.transform.Find("DetonatorFire").gameObject; Detonator det = det_obj.GetComponent <Detonator>(); det.Explode(); det_obj.GetComponent <AudioSource>().Play(); applyDamage(); if (!jm.isShieldActive()) { damageEffectOn(); } }
void OnTriggerEnter(Collider collider) { if (collider.gameObject.CompareTag("Player")) { if (!collected) { collected = true; this.gameObject.GetComponentInChildren <ParticleEmitter>().emit = false; this.GetComponent <AudioSource>().Play(); Junkman junkman = GameObject.Find("Junkman").GetComponent <Junkman>(); junkman.collectJunk(); //junkman.updatePoints(value); Invoke("Disappear", 0.5f); } } }