void Start() { end.Exit += OnRestart; //MasterAudio.StopPlaylist(); Debug.Log("yolo"); StartCoroutine( Util.AfterOneFrame(() => { SceneManager.Instance.gameScene.Enter += () => { Debug.Log("yes"); MasterAudio.PlaySound("song"); camera.enabled = true; play.SwitchTo(); }; } )); StartCoroutine( Util.AfterOneFrame(() => { SceneManager.Instance.gameScene.Exit += () => { camera.enabled = false; end.SwitchTo(); }; } )); }
public void HitObstacle(Hole hole) { if (!jumping.Active && !recovering.Active) { wiping.SwitchTo(); animator.Play("Wipeout"); } }
void HandleInput() { if (Input.GetKey(left)) { // the bro is leaning right, but that means the cart moves left on the screen, // so the natural key mapping is the reverse leaningRight.SwitchTo(); } else if (Input.GetKey(right)) { leaningLeft.SwitchTo(); } else { idleLateral.SwitchTo(); } if (Input.GetKey(up)) { leaningBack.SwitchTo(); } else if (Input.GetKey(down)) { leaningForward.SwitchTo(); } else { idleVertical.SwitchTo(); } }
public void Stopped() { // wiped out, so translate off the back of the screen rockyRoad.enabled = false; cart.enabled = false; stopped.SwitchTo(); }
IEnumerator RespawnAfterTime(float time) { dead.SwitchTo(); animator.Play("Idle"); rockyRoad.enabled = true; cart.enabled = true; transform.position = startPosition + new Vector3(1, .5f, 0) * 2.5f; yield return(new WaitForSeconds(time)); float t = 0; var startPos = transform.position; recovering.SwitchTo(); while (t < 1) { transform.position = Vector3.Lerp(startPos, startPosition, t); t += Time.deltaTime; yield return(null); } yield return(new WaitForSeconds(0.5f)); riding.SwitchTo(); }
IEnumerator Jumping() { float t = 0; var startPos = transform.position; while (t < 0.5f) { Debug.Log(Mathf.Sin(t / 2.0f)); var theta = t / 0.5f * Mathf.PI; //transform.position = new Vector3(startPos.x, startPos.y + Mathf.Sin (theta) * 0.15f * MountainGame.Instance.speed * Time.deltaTime, startPos.z); transform.position += Mathf.Cos(theta) * .7f * MountainGame.Instance.speed * Time.deltaTime * Vector3.up; t += Time.deltaTime; yield return(null); } riding.SwitchTo(); }
public void Fall() { if (!jumping.Active) { falling.SwitchTo(); animator.Play("Fall"); } }
public void PlayElevatorScene(string floorName) { Debug.Log(floorName); nextLevel = floorName; state.SwitchTo(); screen.material = elevatorMaterial; movie.onFinished += EndElevatorScene; movie.Play(); }
void Jump() { MasterAudio.PlaySound("jump"); if (!jumping.Active && riding.Active) { jumping.SwitchTo(); StartCoroutine(Jumping()); } }
public bool SwitchFrom() { if (!Active) { return(false); } if (exitTo) { return(exitTo.SwitchTo()); } else { return(false); /*return Machine.ChangeState(null);*/ } }
void Start() { StartCoroutine(Util.AfterOneFrame(() => titleScene.SwitchTo())); }