private void OnCollisionEnter(Collision collision) { Infectable infectable = collision.gameObject.GetComponent <Infectable>(); if (infectable != null) { infectable.ValidateInfectioPlayer(this); } Player hitPlayer = collision.gameObject.GetComponent <Player>(); if (hitPlayer != null) { lastHitPlayer = hitPlayer; timeHitPLayer = Time.time; } }
public void ValidateInfectioNpc(Infectable infectable) { if (infectable == null) { return; } var i1 = infectedBy == null ? 0 : infectedBy.playerIndex; var i2 = infectable.infectedBy == null ? 0 : infectable.infectedBy.playerIndex; RuleManager.collisionType infectRes = RuleManager.Instance.CompareInfectation(i1, i2); if (infectRes == RuleManager.collisionType.MeInfectOther) { Debug.Log(this.name + ": I infect " + infectable.name); infectable.Infect(infectedBy); } else if (infectRes == RuleManager.collisionType.OtherInfectMe) { Debug.Log(this.name + ": I was infected by " + infectable.name); Infect(infectable.infectedBy); } }
private void OnCollisionEnter(Collision collision) { Infectable infectable = collision.gameObject.GetComponent <Infectable>(); ValidateInfectioNpc(infectable); }