public Camera MainCamera = null; //!< The main viewport camera, which will follow the player /* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent <CPlayerPhysics>(); m_physics.Create(GetComponent <Rigidbody>()); m_cameraClass = MainCamera.GetComponent <CCamera>(); m_wallJump = GetComponent <CWallJump>(); m_animation = GetComponentInChildren <Animation>(); m_playerHealth = MaxHealth; m_idleAnimations[0] = "idle"; m_idleAnimations[1] = "idle1"; m_idleAnimations[2] = "idle2"; m_idleAnimations[3] = "idle3"; m_footSteps = GetComponent <AudioSource>(); }
/* * \brief called by the players update method */ public void onUpdate(ref CPlayerPhysics physics, ref PlayerState playerState) { if (m_canWallJump && Input.GetKeyDown(KeyCode.Space) && m_lastWallJumpObject != null) { physics.Body.AddForce(new Vector3(0.0f, PlayerWallJumpHeight, 0.0f), ForceMode.Impulse); physics.Velocity = (-physics.Direction); playerState = PlayerState.Jumping; } }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref CPlayerPhysics physics, ref PlayerState playerState) { // push the user off the wall, cos they didnt jump in time float ms = (Time.time - m_startWallTime) * 1000.0f; if (physics.IsColliding && ms >= WallHangTime) { physics.Velocity = (-physics.Direction) * 0.1f; m_startWallTime = Time.time; playerState = PlayerState.Standing; } }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref CPlayerPhysics physics, ref PlayerState playerState) { // push the user off the wall, cos they didnt jump in time float ms = (Time.time - m_startWallTime) * 1000.0f; if (physics.IsColliding && ms >= WallHangTime) { physics.Velocity = (-physics.Direction) * 0.1f; m_startWallTime = Time.time; playerState = PlayerState.Standing; } }
/* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { if (INSTANCE == null) { INSTANCE = this; } base.Start(); if (Application.platform == RuntimePlatform.Android) { Screen.orientation = ScreenOrientation.Landscape; } //Time.timeScale = 0.75f; m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent <CPlayerPhysics>(); m_physics.Create(this, GetComponent <Rigidbody>()); //m_cameraClass = MainCamera.GetComponent<CCamera>(); m_animation = GetComponent <CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren <Animation>()); m_playerHealth = MaxHealth; m_characterMesh = this.transform.Find("Player_Mesh"); m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); m_physics.MovingDirection = StartFacing == LeftRight.Left ? 1 : -1; m_ledgeGrabBox = this.transform.Find("Ledge_Grab_Detection"); if (StartCheckPoint != null) { m_lastCheckpoint = StartCheckPoint; } m_dead.didDie = false; m_debug = GetComponent <CPlayerDebug>(); if (m_debug != null) { m_debug.SetPlayer(this); } m_pelvisOffset = this.transform.Find("Player_Mesh/Bip001/Bip001 Pelvis").position - this.transform.position; }
public CCheckPoint StartCheckPoint = null; //!< The start point check point /* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); if (Application.platform == RuntimePlatform.Android) { Screen.orientation = ScreenOrientation.Landscape; } //Time.timeScale = 0.75f; m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent <CPlayerPhysics>(); m_physics.Create(this, GetComponent <Rigidbody>()); m_cameraClass = MainCamera.GetComponent <CCamera>(); m_animation = GetComponent <CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren <Animation>()); m_playerHealth = MaxHealth; m_footSteps = GetComponent <AudioSource>(); m_characterMesh = this.transform.Find("Player_Mesh"); m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); m_ledgeGrabBox = this.transform.Find("Ledge_Grab_Detection"); if (StartCheckPoint != null) { m_lastCheckpoint = StartCheckPoint; m_lastCheckpoint.PlayerCheckPointAlpha = m_playerPositionAlpha; } m_dead.didDie = false; m_debug = GetComponent <CPlayerDebug>(); if (m_debug != null) { m_debug.SetPlayer(this); } }
public Camera MainCamera = null; //!< The main viewport camera, which will follow the player /* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent <CPlayerPhysics>(); m_physics.Create(GetComponent <Rigidbody>()); m_cameraClass = MainCamera.GetComponent <CCamera>(); m_wallJump = GetComponent <CWallJump>(); m_animation = GetComponent <CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren <Animation>()); m_playerHealth = MaxHealth; m_footSteps = GetComponent <AudioSource>(); this.transform.GetChild(0).transform.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); }
public bool CheckLedgeGrab(Collider collision) { if (this.name == "ledge_grab_area" && collision.name == "Ledge_Grab_Detection") { GameObject playerObject = collision.attachedRigidbody.gameObject; if (playerObject == null) { return(false); } CEntityPlayer player = playerObject.GetComponent <CEntityPlayer>(); if (player == null) { return(false); } CPlayerPhysics phy = player.Physics; phy.SetLedgeGrabState(player, PlayerState.LedgeHang, LedgeType); return(true); } return(false); }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref CPlayerPhysics physics, ref PlayerState playerState) { }
/* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent<CPlayerPhysics>(); m_physics.Create(GetComponent<Rigidbody>()); m_cameraClass = MainCamera.GetComponent<CCamera>(); m_wallJump = GetComponent<CWallJump>(); m_animation = GetComponentInChildren<Animation>(); m_playerHealth = MaxHealth; m_idleAnimations[0] = "idle"; m_idleAnimations[1] = "idle0"; m_idleAnimations[2] = "idle1"; m_footSteps = GetComponent<AudioSource>(); }
/* * \brief called by the players update method */ public void onUpdate(ref CPlayerPhysics physics, ref PlayerState playerState) { if (m_canWallJump && Input.GetKeyDown(KeyCode.Space) && m_lastWallJumpObject != null) { physics.Body.AddForce(new Vector3(0.0f, PlayerWallJumpHeight, 0.0f), ForceMode.Impulse); physics.Velocity = (-physics.Direction); playerState = PlayerState.Jumping; } }
/* * \brief Called whilst a collision is taking place */ public void CallOnCollisionStay(Collision collision, ref CPlayerPhysics physics, ref PlayerState playerState) { }
/* * \brief called by the players update method */ public void onUpdate(ref CPlayerPhysics physics, ref PlayerState playerState) { }
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); }
/* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent<CPlayerPhysics>(); m_physics.Create(GetComponent<Rigidbody>()); m_cameraClass = MainCamera.GetComponent<CCamera>(); m_wallJump = GetComponent<CWallJump>(); m_animation = GetComponent<CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren<Animation>()); m_playerHealth = MaxHealth; m_footSteps = GetComponent<AudioSource>(); this.transform.GetChild(0).transform.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); }
/* * \brief called by the players update method */ public void onUpdate(ref CPlayerPhysics physics, ref PlayerState playerState) { }
/* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { if (INSTANCE == null) { INSTANCE = this; } base.Start(); if (Application.platform == RuntimePlatform.Android) Screen.orientation = ScreenOrientation.Landscape; //Time.timeScale = 0.75f; m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent<CPlayerPhysics>(); m_physics.Create(this, GetComponent<Rigidbody>()); //m_cameraClass = MainCamera.GetComponent<CCamera>(); m_animation = GetComponent<CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren<Animation>()); m_playerHealth = MaxHealth; m_characterMesh = this.transform.Find("Player_Mesh"); m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); m_physics.MovingDirection = StartFacing == LeftRight.Left ? 1 : -1; m_ledgeGrabBox = this.transform.Find("Ledge_Grab_Detection"); if (StartCheckPoint != null) { m_lastCheckpoint = StartCheckPoint; } m_dead.didDie = false; m_debug = GetComponent<CPlayerDebug>(); if (m_debug != null) { m_debug.SetPlayer(this); } m_pelvisOffset = this.transform.Find("Player_Mesh/Bip001/Bip001 Pelvis").position - this.transform.position; }
/* * \brief Called when the object is created. At the start. * Only called once per instaniation. */ public override void Start() { base.Start(); if (Application.platform == RuntimePlatform.Android) Screen.orientation = ScreenOrientation.Landscape; //Time.timeScale = 0.75f; m_playerPositionAlpha = InitialAlphaPosition; m_name = "Player"; m_physics = GetComponent<CPlayerPhysics>(); m_physics.Create(this, GetComponent<Rigidbody>()); m_cameraClass = MainCamera.GetComponent<CCamera>(); m_animation = GetComponent<CPlayerAnimation>(); m_animation.OnStart(GetComponentInChildren<Animation>()); m_playerHealth = MaxHealth; m_footSteps = GetComponent<AudioSource>(); m_characterMesh = this.transform.Find("Player_Mesh"); m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0)); m_ledgeGrabBox = this.transform.Find("Ledge_Grab_Detection"); if (StartCheckPoint != null) { m_lastCheckpoint = StartCheckPoint; m_lastCheckpoint.PlayerCheckPointAlpha = m_playerPositionAlpha; } m_dead.didDie = false; m_debug = GetComponent<CPlayerDebug>(); if (m_debug != null) { m_debug.SetPlayer(this); } }