private void CheckKillOnTouch(Collision collision) { if (!KillPlayerOnTouch) { return; } foreach (ContactPoint contact in collision) { GameObject player = null; if (contact.otherCollider != null && contact.otherCollider.gameObject.name == "Player Spawn") { player = contact.otherCollider.gameObject; } if (contact.thisCollider != null && contact.thisCollider.gameObject.name == "Player Spawn") { player = contact.thisCollider.gameObject; } if (player == null) { continue; } CEntityPlayer entityPlayer = player.GetComponent <CEntityPlayer>(); if (entityPlayer == null) { return; } entityPlayer.PushPlayerFromTower(); } }
/* * \brief Works out if a value is almost another value (for floating point accuracy) */ public void CallOnCollisionEnter(Collision collision) { m_collisionState = CollisionState.None; foreach (ContactPoint contact in collision) { m_platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>(); if (m_platform != null) { m_platform.resetDeltaA(); } if (isNearly(contact.normal.y, 1.0f, 0.2f)) { m_collisionState = CollisionState.OnFloor; if (m_player.GetPlayerState() == PlayerState.OnLadder) { GetLadder.state = LadderState.AtBase; m_player.SetPlayerState(PlayerState.Standing); } // are we on a special material? m_footMaterial = FootMaterial.Stone; if (contact.otherCollider.tag == "Wood Object") { m_footMaterial = FootMaterial.Wood; } else if (contact.otherCollider.tag == "Metal Object") { m_footMaterial = FootMaterial.Metal; } } else if (isNearly(contact.normal.y, -1.0f, 0.2f)) { m_collisionState = CollisionState.OnRoof; if (contact.otherCollider != null && contact.otherCollider.GetComponent <CSceneObjectPlatform>() != null) { m_player.PushPlayerFromTower(); } } else { if (m_player.GetPlayerState() != PlayerState.OnLadder) { m_collisionState = CollisionState.OnWall; } } } if (m_collisionState == CollisionState.OnFloor) { if (m_jumpState != JumpState.Landed) { m_player.GetPlayerAnimation().PlayFootstepAudio(m_footMaterial); } m_jumpState = JumpState.Landed; if (GetLadder.state == LadderState.JumpingOff) { GetLadder.state = LadderState.None; } if (m_player.GetPlayerState() != PlayerState.Turning && m_player.GetPlayerState() != PlayerState.OnLadder && !m_player.PullingLever(false)) { m_player.SetPlayerState(PlayerState.Standing); } } }