public void CallOnTriggerStay(Collider collider, ref PlayerState playerState) { CSceneObject obj = collider.gameObject.GetComponent <CSceneObject>(); if (obj == null && collider.gameObject != null && collider.gameObject.transform.parent != null) { GameObject parent = collider.gameObject.transform.parent.gameObject; if (parent != null) { obj = parent.GetComponent <CSceneObject>(); } } if (obj != null && obj.IsLadder && (m_ladderClimb.State != LadderState.JumpOff)) { m_ladderClimb.CallOnTriggerStay(collider, ref playerState); if (m_ladderClimb.State != LadderState.None) { m_body.constraints = RigidbodyConstraints.FreezeAll; } else { m_collisionState = CollisionState.OnFloor; } return; } }
private Vector3 m_wallJumpPoint = Vector3.zero; //!< #endregion Fields #region Methods /* * \brief Called when the player enters a collosion */ public void CallOnCollisionEnter(CEntityPlayer player, Collision collision, ref PlayerState playerState) { if (playerState != PlayerState.Jumping) return; CSceneObject sceneObject = collision.gameObject.GetComponent<CSceneObject>(); if (sceneObject && (m_lastWallJumpObject == null || m_lastWallJumpObject != sceneObject) && sceneObject.CanWallJump) { m_canWallJump = true; m_lastWallJumpObject = sceneObject; m_wallJumpPoint = player.transform.position; playerState = PlayerState.WallJumping; } else { m_canWallJump = false; } }
public void CallOnTriggerStay(Collider collider, ref GruntState playerState) { CSceneObject obj = collider.gameObject.GetComponent <CSceneObject>(); if (obj == null && collider.gameObject != null && collider.gameObject.transform.parent != null) { GameObject parent = collider.gameObject.transform.parent.gameObject; if (parent != null) { obj = parent.GetComponent <CSceneObject>(); } } if (obj != null && obj.KillPlayerOnTouch) { //m_grunt.PushPlayerFromTower(); } }
/* * \brief Called when the player enters a collosion */ public void CallOnCollisionEnter(CEntityPlayer player, Collision collision, ref PlayerState playerState) { if (playerState != PlayerState.Jumping) { return; } CSceneObject sceneObject = collision.gameObject.GetComponent <CSceneObject>(); if (sceneObject && (m_lastWallJumpObject == null || m_lastWallJumpObject != sceneObject) && sceneObject.CanWallJump) { m_canWallJump = true; m_lastWallJumpObject = sceneObject; m_wallJumpPoint = player.transform.position; playerState = PlayerState.WallJumping; } else { m_canWallJump = false; } }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref PlayerState playerState, ref float playerAlpha) { m_collisionState = CollisionState.None; foreach (ContactPoint contact in collision) { Debug.DrawRay(contact.point, contact.normal); // if (contact.otherCollider != null && contact.otherCollider.gameObject != null) { CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>(); if (platform != null && m_platform == null) { m_platform = platform; m_platform.resetDeltaA(); } } // CSceneObject obj = null; if (contact.otherCollider) { obj = contact.otherCollider.gameObject.GetComponent <CSceneObject>(); if (obj == null && contact.otherCollider.gameObject.transform.parent != null) { GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject; if (parent != null) { obj = parent.GetComponent <CSceneObject>(); } } } if (contact.thisCollider != null && contact.thisCollider.gameObject != null && contact.thisCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab)) { if (CSceneObject.CheckLedgeGrab(collision)) { continue; } } if (contact.otherCollider != null && contact.otherCollider.gameObject != null && contact.otherCollider.gameObject.name == "Ledge_Grab_Detection" && (obj == null || obj.CanLedgeGrab)) { if (CSceneObject.CheckLedgeGrab(collision)) { continue; } } // wall jumping if (obj != null && obj.CanWallJump == true && m_jumpState != JumpState.Landed && !isNearly(contact.normal.y, 1.0f, 0.2f) && !isNearly(contact.normal.y, -1.0f, 0.1f)) { m_collisionState = CollisionState.OnWall; playerState = PlayerState.WallJumpStart; m_jumpTimer = (Time.time * 1000.0f); m_body.constraints = RigidbodyConstraints.FreezeAll; m_velocity = 0.0f; m_wallJump.StartHangTime = Time.time * 1000.0f; } // floor check else if (isNearly(contact.normal.y, 1.0f, 0.8f)) { m_collisionState = CollisionState.OnFloor; if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1) { m_velocity = (m_movingDirection * 0.15f); m_velocityLockTimer = (Time.time * 1000.0f); } // 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; } } // head check else if (isNearly(contact.normal.y, -1.0f, 0.1f)) { m_collisionState = CollisionState.OnRoof; } // wall check else { if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha)) { m_collisionState = CollisionState.OnWall; break; } } } if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != PlayerState.WallJumpStart) { m_velocity = -(m_movingDirection * 0.15f); } if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f)) { m_jumpState = JumpState.Landed; if (m_ladderClimb.State != LadderState.AtBase) { m_ladderClimb.State = LadderState.None; } else { playerState = PlayerState.UpALadder; } if (m_player.GetPlayerState() != PlayerState.Turning) { m_player.SetPlayerState(PlayerState.Standing); } //m_ledgeGrabBox.collider.enabled = true; } }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref GruntState playerState, ref float playerAlpha) { m_collisionState = CollisionState.None; foreach (ContactPoint contact in collision) { Debug.DrawRay(contact.point, contact.normal); // if (contact.otherCollider != null && contact.otherCollider.gameObject != null) { CSceneObjectPlatform platform = contact.otherCollider.gameObject.GetComponent <CSceneObjectPlatform>(); if (platform != null && m_platform == null) { m_platform = platform; m_platform.resetDeltaA(); } } // CSceneObject obj = null; if (contact.otherCollider) { obj = contact.otherCollider.gameObject.GetComponent <CSceneObject>(); if (obj == null && contact.otherCollider.gameObject.transform.parent != null) { GameObject parent = contact.otherCollider.gameObject.transform.parent.gameObject; if (parent != null) { obj = parent.GetComponent <CSceneObject>(); } } } // floor check else if (isNearly(contact.normal.y, 1.0f, 0.8f)) { m_collisionState = CollisionState.OnFloor; if (!isNearly(contact.normal.y, 1.0f, 0.15f) && collision.contacts.Length == 1) { if (m_grunt.GetGruntState() == GruntState.Walking) { if (m_grunt.GetGruntPlayerDetected()) { m_velocity = (m_movingDirection * 0.6f); } else { m_velocity = (m_movingDirection * 0.15f); } m_velocityLockTimer = (Time.time * 1000.0f); } } if (contact.otherCollider) { // 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; } } } // head check else if (isNearly(contact.normal.y, -1.0f, 0.1f)) { m_collisionState = CollisionState.OnRoof; } // wall check else { if (isFacingCollision(m_movingDirection, m_body.transform.position, contact.point, playerAlpha)) { m_collisionState = CollisionState.OnWall; break; } } } if (m_collisionState == CollisionState.OnWall && m_jumpState == JumpState.Jumping && playerState != GruntState.WallJumpStart) { m_velocity = -(m_movingDirection * 0.15f); } if (m_collisionState == CollisionState.OnFloor && ((Time.time * 1000.0f) - m_jumpTimer > 200.0f)) { m_jumpState = JumpState.Landed; if (m_grunt.GetGruntState() != GruntState.Turning) { m_grunt.SetGruntState(GruntState.Standing); } } }
// Use this for initialization void Start() { obj = GetComponent<CSceneObject>(); }
/* * \brief Called when the player leaves a collosion */ public void CallOnCollisionExit(Collision collision, ref PlayerState playerState) { m_canWallJump = false; m_startWallTime = Time.time; m_lastWallJumpObject = null; }
/* * \brief Resets all wall jump memebers to there inital state */ public void Reset() { m_canWallJump = false; m_startWallTime = Time.time; m_lastWallJumpObject = null; }
public static bool CheckLedgeGrab(Collision collision) { foreach (ContactPoint contact in collision) { Collider ledgeGrab = null; CSceneObject sceneLedge = null; if (contact.otherCollider != null && contact.otherCollider.gameObject.name == "Ledge_Grab_Detection") { ledgeGrab = contact.otherCollider; if (contact.thisCollider != null && contact.thisCollider.gameObject != null) { sceneLedge = contact.thisCollider.gameObject.GetComponent <CSceneObject>(); } } else if (contact.thisCollider != null && contact.thisCollider.gameObject.name == "Ledge_Grab_Detection") { ledgeGrab = contact.thisCollider; if (contact.otherCollider != null && contact.otherCollider.gameObject != null) { sceneLedge = contact.otherCollider.gameObject.GetComponent <CSceneObject>(); } } if (sceneLedge == null || !sceneLedge.CanLedgeGrab) { if (ledgeGrab != null) { ledgeGrab.enabled = false; } continue; } if (ledgeGrab != null) { if (CPlayerPhysics.isNearly(contact.normal.normalized.y, -1.0f, 0.1f)) { // player hit the ledge grab area GameObject player = contact.otherCollider.gameObject.transform.parent.gameObject; if (player != null) { CEntityPlayer playerEntity = player.GetComponent <CEntityPlayer>(); if (playerEntity != null && playerEntity.GetPlayerState() != PlayerState.LedgeHang && playerEntity.GetPlayerState() != PlayerState.LedgeClimb && playerEntity.GetPlayerState() != PlayerState.LedgeClimbComplete ) { CPlayerPhysics phy = playerEntity.Physics; phy.SetLedgeGrabState(playerEntity, PlayerState.LedgeHang); contact.otherCollider.enabled = false; return(true); } } } else { ledgeGrab.enabled = false; return(false); } } } return(false); }
// Use this for initialization void Start() { obj = GetComponent <CSceneObject>(); }
/* * \brief Called when the player leaves a collosion */ public void CallOnCollisionExit(Collision collision, ref PlayerState playerState) { m_canWallJump = false; m_startWallTime = Time.time; m_lastWallJumpObject = null; }
/* * \brief Resets all wall jump memebers to there inital state */ public void Reset() { m_canWallJump = false; m_startWallTime = Time.time; m_lastWallJumpObject = null; }