//If the stunable entity is stays here while its active, zap them void OnTriggerEnter(Collider other) { if (bActive) { if (other.gameObject.GetComponent <PlayerMovement>()) { other.gameObject.GetComponent <PlayerMovement>().mNumShocks++; } Stunable stunOther = other.gameObject.GetComponent <Stunable>(); if (stunOther != null) { stunOther.Stun(); stunOther.mTypeofStun = Stunable.StunType.ShockStun; } } }
void OnTriggerStay(Collider other) { PlayerMovement player = other.GetComponent <PlayerMovement>(); if (bActive) { Stunable stunOther = other.gameObject.GetComponent <Stunable>(); if (stunOther != null) { stunOther.Stun(); stunOther.mTypeofStun = Stunable.StunType.ShockStun; } if (player != null) { if (player.mNumShocks <= 1) { if (!mAffectedPlayer) { player.mShockStartTime = Time.time; player.mInShock = true; player.GetComponent <Stunable>().mTypeofStun = Stunable.StunType.ShockStun; player.mShockBarLength = other.GetComponent <PlayerMovement>().mShockTimer * 10; mAffectedPlayer = true; } } else { mAffectedPlayer = true; } } } else { if (player != null) { player.mInShock = false; mAffectedPlayer = false; player.GetComponent <Stunable>().mTypeofStun = Stunable.StunType.NotStunned; } } player = null; }
//Trigger by the dinos and the zombies when the player dies public void PlayerDeath(GameObject killer, string killerID) { //Check to see if the player has a shield already if (NumberofShields > 0 && (killerID != "Killed by Gas" && killerID != "Killed by Shock")) { Stunable stunOther = killer.gameObject.GetComponent <Stunable>(); if (stunOther != null) { stunOther.Stun(); Sid.transform.position = killer.transform.position; Sid.GetComponent <Animator>().Play("Death"); Sid.transform.position = killer.transform.position; } Sid.transform.position = killer.transform.position; StartCoroutine(WaitForAnim(killer)); } else { //Assets.CustomeScripts.Metrics.AddMetric("Killer ID was:", killerID); FindObjectOfType <CameraFade>().sceneEnding = true; } } // end player death