//Since Flare is not implemented, we'll manually say that the time as a plane was [CurrentTime] - [TimeYouBecameAPlane] public void ChangeForm(PlayerMovement.State newForm) //Receive the new state the player has changed to { if (bigData != null) { int index = 0; switch (newForm) { case PlayerMovement.State.WHALE: index = 0; break; case PlayerMovement.State.PLANE: index = 1; break; case PlayerMovement.State.FLARE: //This will not work until Flare is implemented index = 2; break; } timeStateChanged[index] = Time.time; if (bigData.timeSpentInForm != null) { if (index != 0) //If not Whale { index -= 1; bigData.timeSpentInForm[index] = Time.time - timeStateChanged[index]; } } } }
// Update is called once per frame void Update() { currentState = movementComp.playerState; switch (currentState) { case PlayerMovement.State.WHALE: if (!whaleSettingsSet) { WhaleSettings(); whaleSettingsSet = true; } break; case PlayerMovement.State.PLANE: if (!planeSettingsSet) { PlaneSettings(); planeSettingsSet = true; } break; case PlayerMovement.State.FLARE: if (!flareSettingsSet) { FlareSettings(); flareSettingsSet = true; } break; } }
void OnEnable() { sceneSettings = Object.FindObjectOfType <RenderSettings>(); movementComp = GameObject.Find("Gameplay Plane").GetComponentInChildren <PlayerMovement>(); currentState = movementComp.playerState; }
/// <summary> /// Handles state machine for obstacle generation /// </summary> private void Update() { if (playerGenerationState != playerMovementScript.playerState) { playerGenerationState = playerMovementScript.playerState; } GenerationStateMachine(); }
private void OnEnable() { //Instance generation InstantiateSingleton(); playerMovementScript = transform.parent.GetComponentInChildren <PlayerMovement>(); playerGenerationState = playerMovementScript.playerState; planeMovementScript = transform.parent.GetComponent <PlaneMovement>(); oceanScript = GetComponent <OceanPlacement>(); skyScript = GetComponent <SkyPlacement>(); caveScript = GetComponent <CavePlacement>(); }
private void UpdateVisual() { playerState = movementComp.playerState; switch (playerState) { case PlayerMovement.State.WHALE: whaleVisual.SetActive(true); planeVisual.SetActive(false); flareVisual.SetActive(false); directionalLightOcean.SetActive(true); directionalLightSky.SetActive(false); directionalLightCave.SetActive(false); endLightOcean.SetActive(true); endLightSky.SetActive(false); endLightCave.SetActive(false); break; case PlayerMovement.State.PLANE: whaleVisual.SetActive(false); planeVisual.SetActive(true); flareVisual.SetActive(false); directionalLightOcean.SetActive(false); directionalLightSky.SetActive(true); directionalLightCave.SetActive(false); endLightOcean.SetActive(false); endLightSky.SetActive(true); endLightCave.SetActive(false); break; case PlayerMovement.State.FLARE: whaleVisual.SetActive(false); planeVisual.SetActive(false); flareVisual.SetActive(true); directionalLightOcean.SetActive(false); directionalLightSky.SetActive(false); directionalLightCave.SetActive(true); endLightOcean.SetActive(false); endLightSky.SetActive(false); endLightCave.SetActive(true); break; } }
/// <summary> /// Instantiate component references and variables /// </summary> private void OnEnable() { gameManager = GameManager.instance; planeComp = transform.parent.GetComponent <PlaneMovement>(); movementComp = transform.parent.GetComponentInChildren <PlayerMovement>(); deathComp = transform.parent.GetComponentInChildren <PlayerDeath>(); obstacleComp = transform.parent.GetComponentInChildren <ObstaclePlacementState>(); progressionObstacle = Resources.Load <GameObject>("ProgressionObstacle"); target = transform.parent.GetChild(2).transform; smoothSpeed = 0.125f; rotateSpeed = 2f; rollSpeed = 800f; formTimer = 0f; whaleVisual = transform.GetChild(0).GetChild(0).gameObject; planeVisual = transform.GetChild(0).GetChild(1).gameObject; flareVisual = transform.GetChild(0).GetChild(2).gameObject; playerState = movementComp.playerState; }
/// <summary> /// Checks the player's state. /// </summary> private void CheckPlayerState() { _playerState = _player.m_CurrentState; }