/* * \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 override void Update() { if (Input.GetButton("CheckpointNext") && !m_isCheckpointSkipDown) { m_isCheckpointSkipDown = true; if (m_lastCheckpoint != null && m_lastCheckpoint.NextCheckPoint != null) { m_lastCheckpoint = m_lastCheckpoint.NextCheckPoint; } OnDeath(); return; } else if (m_isCheckpointSkipDown && !Input.GetButton("CheckpointNext")) { m_isCheckpointSkipDown = false; } if (Input.GetButton("Reset") && !m_isEscapeDown) { m_isEscapeDown = true; if (CurrentGameState == GameState.Running) { CurrentGameState = GameState.Paused; Time.timeScale = 0.0f; } return; } else if (m_isEscapeDown && !Input.GetButton("Reset")) { m_isEscapeDown = false; } if (m_playerState == PlayerState.FallingFromTower) { return; } m_physics.OnUpdate(ref m_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; }
private void AreYouSureMenu() { string labelText = "Are you sure you want to "; switch (m_pausedMenuState) { case PausedMenuState.MainMenu: labelText += "return to the main menu?"; break; case PausedMenuState.Quit: labelText += "quit the game?"; break; case PausedMenuState.Restart: labelText += "restart the current level?"; break; } ; const float BUTTON_WIDTH = 256; float yPosition = 100; Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText)); Rect labelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y); GUI.Label(labelRect, labelText); yPosition += 96; Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 32); if (GUI.Button(yesRect, "Yes")) { if (m_pausedMenuState == PausedMenuState.Quit) { Application.Quit(); } else if (m_pausedMenuState == PausedMenuState.MainMenu) { Time.timeScale = 1.0f; Application.LoadLevel("Main_Menu"); } else if (m_pausedMenuState == PausedMenuState.Restart) { CCheckPoint cp = m_playerEntity.LastCheckPoint; CCheckPoint startCp = cp; while (cp.IsLevelStart == false) { cp = cp.NextCheckPoint; if (cp == startCp) { Debug.LogError("No check points in list where marked as level start"); return; } } m_playerEntity.LastCheckPoint = cp; m_playerEntity.OnDeath(); m_pausedMenuState = PausedMenuState.Main; Time.timeScale = 1.0f; m_playerEntity.CurrentGameState = GameState.Running; } return; } Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 32); if (GUI.Button(noRect, "No")) { m_pausedMenuState = PausedMenuState.Main; return; } }
/* * \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 override void Update() { if (Input.GetButton("CheckpointNext") && !m_isCheckpointSkipDown) { m_isCheckpointSkipDown = true; if (m_lastCheckpoint != null && m_lastCheckpoint.NextCheckPoint != null) { m_lastCheckpoint = m_lastCheckpoint.NextCheckPoint; } OnDeath(); return; } else if (m_isCheckpointSkipDown && !Input.GetButton("CheckpointNext")) { m_isCheckpointSkipDown = false; } if (Input.GetButton("Reset") && !m_isEscapeDown) { m_isEscapeDown = true; if (CurrentGameState == GameState.Running) { CurrentGameState = GameState.Paused; Time.timeScale = 0.0f; } return; } else if (m_isEscapeDown && !Input.GetButton("Reset")) { m_isEscapeDown = false; } if (m_playerState == PlayerState.FallingFromTower) return; m_physics.OnUpdate(ref m_playerState); }