/*private void FixedUpdate() * { * rigidBody.MovePosition(Physics.gravity); * Debug.Log(rigidBody.velocity); * }*/ // Use this for initialization void Start() { playerController = FindObjectOfType <PlayerController>(); while (playerController == null) { playerController = FindObjectOfType <PlayerController>(); } // Set parent originalParent = transform.parent; // Assign the original layer of this game object originalLayer = gameObject.layer; // Determine current worldstate if (transform.position.z - 0 < .1f) { currentWorldState = WorldChanger.WorldState.Present; } else if (transform.position.z - 50 < .1f) { currentWorldState = WorldChanger.WorldState.Past; } else if (transform.position.z - 100 < .1f) { currentWorldState = WorldChanger.WorldState.Future; } }
// Enlarge the indicator relative to the world state when world change completes private void UpdateIndicatorScale(WorldChanger.WorldState worldState) { float growSize = 1.5f; if (indicatorType == worldState && gameManager.hasPresentWisp) { StartCoroutine(GrowIndicator(growSize, 0.2f)); } else { StartCoroutine(ShrinkIndicator(1.0f, 0.2f)); // Shrink other indicators scale to normal size } /* * // Enlarge the new world indicator * if (indicatorType == worldState && gameManager.hasPresentWisp) * { * StartCoroutine(GrowIndicator(growSize, 0.2f)); * } * else if (indicatorType == worldState && gameManager.hasFutureWisp) * { * StartCoroutine(GrowIndicator(growSize, 0.2f)); * } * else if (indicatorType == worldState && gameManager.hasPastWisp) * { * StartCoroutine(GrowIndicator(growSize, 0.2f)); * } */ }
// method for time warp event audio void timeWarpSound(WorldChanger.WorldState ws) { randomizePitch(playerSound); int randomIndex = Random.Range(0, timeWarps.Length); playerSound.PlayOneShot(timeWarps[randomIndex]); }
private bool CheckWorldCollisions(WorldChanger.WorldState worldState) { Vector3 colliderExtents = transform.lossyScale * .49f; // Evaluate the world state that player is transferring to. switch (worldState) { // cast present ray & evaluate case WorldChanger.WorldState.Present: Vector3 presentPos = new Vector3(transform.position.x, transform.position.y, 0); if (Application.isEditor) { ExtDebug.DrawBox(presentPos, colliderExtents, transform.rotation, Color.blue); } if (currentWorldState != WorldChanger.WorldState.Present && Physics.CheckBox(presentPos, colliderExtents, transform.rotation, Layers.Players)) { //Debug.Log("Colliding present..."); return(false); } break; // cast past ray & evaluate case WorldChanger.WorldState.Past: Vector3 pastPos = new Vector3(transform.position.x, transform.position.y, 50); if (Application.isEditor) { ExtDebug.DrawBox(pastPos, colliderExtents, transform.rotation, Color.blue); } if (currentWorldState != WorldChanger.WorldState.Past && Physics.CheckBox(pastPos, colliderExtents, transform.rotation, Layers.Players)) { //Debug.Log("Colliding past..."); return(false); } break; // cast future ray & evaluate case WorldChanger.WorldState.Future: Vector3 futurePos = new Vector3(transform.position.x, transform.position.y, 100); if (Application.isEditor) { ExtDebug.DrawBox(futurePos, colliderExtents, transform.rotation, Color.blue); } if (currentWorldState != WorldChanger.WorldState.Future && Physics.CheckBox(futurePos, colliderExtents, transform.rotation, Layers.Players)) { //Debug.Log("Colliding future..."); return(false); } break; } //Debug.Log("No Collide..."); return(true); }
private void EvaluateTransitionComplete(WorldChanger.WorldState currentState) { // Reset the layer if object is always transferrable type if (interactType == InteractableType.AlwaysTransferable) { //Debug.Log("transition complete"); Layers.ChangeLayers(gameObject, originalLayer); //Debug.Log("Revert layer"); } }
private void OnWorldChangeStart(WorldChanger.WorldState newWorldState) { // Set active the one we are transitioning too if (newWorldState == WorldChanger.WorldState.Present) { PresentEZParallax.SetActive(true); } else if (newWorldState == WorldChanger.WorldState.Past) { PastEZParallax.SetActive(true); } else if (newWorldState == WorldChanger.WorldState.Future) { FutureEZParallax.SetActive(true); } }
private void OnWorldChangeComplete(WorldChanger.WorldState newWorldState) { // Disable the parallaxes that aren't in use if (WorldChanger.CurrentWorldState != WorldChanger.WorldState.Present) { PresentEZParallax.SetActive(false); } if (WorldChanger.CurrentWorldState != WorldChanger.WorldState.Past) { PastEZParallax.SetActive(false); } if (WorldChanger.CurrentWorldState != WorldChanger.WorldState.Future) { FutureEZParallax.SetActive(false); } }
private void EvaluateTransitionStart(WorldChanger.WorldState worldState) { // If the interaction type of this object is non transferable then cancel the pushpull operation of the player if (interactType == InteractableType.NonTransferable && playerController.pushpullObject == this) { playerController.CancelPushingPulling(); } if (interactType == InteractableType.Transferable) { currentWorldState = worldState; } // If the object interation type is Always Transferable, evaluate if (interactType == InteractableType.AlwaysTransferable && CheckWorldCollisions(worldState)) { // if player is not currently pushing/pulling this object... if (playerController.pushpullObject != this) { // Set layer to ViewAlways so it always displays Layers.ChangeLayers(gameObject, Layers.ViewAlways); // Determine the new Z position of the object after world change switch (worldState) { case WorldChanger.WorldState.Present: transform.position = new Vector3(transform.position.x, transform.position.y, 0); currentWorldState = WorldChanger.WorldState.Present; break; case WorldChanger.WorldState.Past: transform.position = new Vector3(transform.position.x, transform.position.y, 50); currentWorldState = WorldChanger.WorldState.Past; break; case WorldChanger.WorldState.Future: transform.position = new Vector3(transform.position.x, transform.position.y, 100); currentWorldState = WorldChanger.WorldState.Future; break; } } } }
// start new ambiance in current time void ambianceChange(WorldChanger.WorldState ws) { if (ws == WorldChanger.WorldState.Present) { cameraAudioStop("Past Camera"); cameraAudioStop("Future Camera"); cameraAudioStart("Present Camera"); } else if (ws == WorldChanger.WorldState.Past) { cameraAudioStop("Present Camera"); cameraAudioStop("Future Camera"); cameraAudioStart("Past Camera"); } else if (ws == WorldChanger.WorldState.Future) { cameraAudioStop("Past Camera"); cameraAudioStop("Present Camera"); cameraAudioStart("Future Camera"); } }