// Update is called once per frame new void Update() { BaseUpdate(); lastTime = currentTime; currentTime = Data.GetTigerSong().time; if (currentTime > songSegmentEndTime) { LoadNextScene(); } if (!itsOver) { if (beatIndexPlayer < beatTimes.Count) { // the player has to be able to see the hurdles ahead of time float startTime = beatTimes[beatIndexPlayer] - beatRadiusVisualHint; float endTime = beatTimes[beatIndexPlayer] + beatRadiusVisualHint; // kick off the hurdle for shanty if (currentTime > startTime) { Hurdle shantyHurdle = Instantiate(hurdle.gameObject).GetComponent <Hurdle>(); StartCoroutine(KickOffHurdle(beatIndexPlayer, shantyHurdle, beatTimes, rightEdge.transform, leftEdge.transform)); Hurdle moxieHurdle = Instantiate(a.gameObject).GetComponent <Hurdle>(); StartCoroutine(KickOffHurdle(beatIndexPlayer, moxieHurdle, beatTimes, aStart, aEnd)); beatIndexPlayer++; } } } }
private void PlacementObject() { Random random = new Random(); MyHunter = new Bear(300, new Point { X = random.Next(PlayerHero.Position.X + 2, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 2, PlayerField.Height) }, 20); MyHunter = new Wolf(200, new Point { X = random.Next(PlayerHero.Position.X + 2, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 2, PlayerField.Height) }, 15); MyBarrier = new Tree(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 100); MyBarrier = new Hole(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 100); MyBonus = new Apple(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 30); MyBonus = new Cherry(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 20); MyBonus = new Carrot(new Point { X = random.Next(PlayerHero.Position.X + 1, PlayerField.Width), Y = random.Next(PlayerHero.Position.Y + 3, PlayerField.Height) }, 50); }
protected void Update() { BaseUpdate(); lastTime = currentTime; currentTime = Data.GetTigerSong().time; if (currentTime > songSegmentEndTime) { LoadNextScene(); } if (!itsOver) { if (beatIndexPlayer < beatTimes.Count) { // the player has to be able to see the hurdles ahead of time float startTime = beatTimes[beatIndexPlayer] - beatRadiusVisualHint; float endTime = beatTimes[beatIndexPlayer] + beatRadiusVisualHint; // kick off the hurdle if (currentTime > startTime) { Hurdle newHurdle = Instantiate(hurdle.gameObject).GetComponent <Hurdle>(); StartCoroutine(KickOffHurdle(beatIndexPlayer, newHurdle)); beatIndexPlayer++; } } if (aTimes.Count > 0 && aIndex < aTimes.Count) { // the player has to be able to see the hurdles ahead of time float startTime = beatTimes[aIndex] - beatRadiusVisualHint; float endTime = beatTimes[aIndex] + beatRadiusVisualHint; // kick off the hurdle if (currentTime > startTime) { BeatObject newHurdle = Instantiate(a.gameObject).GetComponent <BeatObject>(); StartCoroutine(KickOffBeatObject(aIndex, newHurdle)); aIndex++; } } } }
/// <summary> /// Kick off something the player needs to interact with /// </summary> /// <param name="myHurdleIndex"></param> /// <param name="myHurdle"></param> /// <returns></returns> private IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle, List <float> times, Transform start, Transform end, Transform disappearSpot = null, bool isFish = false) { bool madeYellow = false; float visualStartTime = times[myHurdleIndex] - beatRadiusVisualHint; float visualEndTime = times[myHurdleIndex] + beatRadiusVisualHint; float inputStartTime = times[myHurdleIndex] - beatInputLead; float inputEndTime = times[myHurdleIndex] + beatInputLag; bool inputSuccess = false; bool missed = false; Command correctCode = Command.Fire; if (myHurdle.CorrectCommand == "up") { correctCode = Command.Up; } else if (myHurdle.CorrectCommand == "down") { correctCode = Command.Down; } else { Debug.LogError("unhandled direction!"); } while (currentTime < visualEndTime) { if (currentTime > inputStartTime && !madeYellow) { madeYellow = true; myHurdle.MakeReady(); } // success if (currentTime > inputStartTime && currentTime < inputEndTime && (CommandsStartedThisFrame.ContainsKey(correctCode))) { success.Play(); inputSuccess = true; myHurdle.MakeCorrect(); // shout a success shout int successShoutIndex = Random.Range(0, successShouts.Count); if (lastSuccessShout == successShoutIndex) { successShoutIndex++; if (successShoutIndex >= successShouts.Count) { successShoutIndex = 0; } } outputText.text = successShouts[successShoutIndex]; lastSuccessShout = successShoutIndex; } // miss.. else if (currentTime > inputEndTime && !inputSuccess && !missed) { missed = true; // todo toss the hurdle myHurdle.MakeWrong(); // shout a miss shout int missShoutIndex = Random.Range(0, missShouts.Count); if (lastMissShout == missShoutIndex) { missShoutIndex++; if (missShoutIndex >= missShouts.Count) { missShoutIndex = 0; } } outputText.text = missShouts[missShoutIndex]; lastMissShout = missShoutIndex; numMistakes++; mistake.Play(); } float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime); myHurdle.transform.position = Vector3.Lerp(start.position, end.position, hurdleProgress); // disappear when you move past the spot and you're successful if (disappearSpot != null && myHurdle.GetState() == Hurdle.HurdleState.Correct) { // objects moving right if (disappearSpot.position.x > start.position.x) { if (myHurdle.transform.position.x > disappearSpot.position.x) { // disappear myHurdle.SetVisible(false); } } else { if (myHurdle.transform.position.x < disappearSpot.position.x) { // disappear myHurdle.SetVisible(false); } } } yield return(0); } if (numMistakes > allowedMistakes) { StartCoroutine(Failure()); } yield return(new WaitForSeconds(0.2f)); Destroy(myHurdle.gameObject); }
/// <summary> /// Kick off something the player needs to interact with /// </summary> /// <param name="myHurdleIndex"></param> /// <param name="myHurdle"></param> /// <returns></returns> private IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle, List <float> times, Transform start, Transform end, bool isFish) { Hurdle mirrorHurdle = Instantiate(myHurdle.gameObject).GetComponent <Hurdle>(); Vector3 mirrorStart = new Vector3(-start.position.x, start.position.y, start.position.z); Vector3 mirrorEnd = new Vector3(-end.position.x, end.position.y, end.position.z); mirrorHurdle.transform.localScale = new Vector3(-1, 1, 1); bool madeYellow = false; float visualStartTime = times[myHurdleIndex] - beatRadiusVisualHint; float visualEndTime = times[myHurdleIndex] + beatRadiusVisualHint; float inputStartTime = times[myHurdleIndex] - beatInputLead; float inputEndTime = times[myHurdleIndex] + beatInputLag; bool inputSuccess = false; bool missed = false; Command correctCode = Command.Fire; if (myHurdle.CorrectCommand == "up") { correctCode = Command.Up; } else if (myHurdle.CorrectCommand == "down") { correctCode = Command.Down; } else { Debug.LogError("unhandled code!"); } while (currentTime < visualEndTime) { if (currentTime > inputStartTime && !madeYellow) { madeYellow = true; myHurdle.MakeReady(); mirrorHurdle.MakeReady(); } // success if (currentTime > inputStartTime && currentTime < inputEndTime && (CommandsStartedThisFrame.ContainsKey(correctCode))) { success.Play(); inputSuccess = true; // make the hurdle green if (isFish) { // they do the fish flippy thing instead of just disappearing, flying into moxie's mouth ((FishHurdle)myHurdle).SetGoSpot(fishEatSpot.transform.position); ((FishHurdle)myHurdle).MakeCorrect(); ((FishHurdle)mirrorHurdle).SetGoSpot(fishEatSpot.transform.position); ((FishHurdle)mirrorHurdle).MakeCorrect(); } else { myHurdle.MakeCorrect(); mirrorHurdle.MakeCorrect(); } // shout a success shout int successShoutIndex = Random.Range(0, successShouts.Count); if (lastSuccessShout == successShoutIndex) { successShoutIndex++; if (successShoutIndex >= successShouts.Count) { successShoutIndex = 0; } } outputText.text = successShouts[successShoutIndex]; lastSuccessShout = successShoutIndex; } // miss.. else if (currentTime > inputEndTime && !inputSuccess && !missed) { missed = true; myHurdle.MakeWrong(); mirrorHurdle.MakeWrong(); // shout a miss shout int missShoutIndex = Random.Range(0, missShouts.Count); if (lastMissShout == missShoutIndex) { missShoutIndex++; if (missShoutIndex >= missShouts.Count) { missShoutIndex = 0; } } outputText.text = missShouts[missShoutIndex]; lastMissShout = missShoutIndex; numMistakes++; mistake.Play(); } if (isFish && myHurdle.GetState() == Hurdle.HurdleState.Correct) { // if you're a fish and you're correctly answered, do nothing } else { // move the hurdle float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime); myHurdle.transform.position = Vector3.Lerp(start.position, end.position, hurdleProgress); mirrorHurdle.transform.position = Vector3.Lerp(mirrorStart, mirrorEnd, hurdleProgress); } yield return(0); } if (numMistakes > allowedMistakes) { StartCoroutine(Failure()); } yield return(new WaitForSeconds(0.2f)); Destroy(myHurdle.gameObject); Destroy(mirrorHurdle.gameObject); }
// Update is called once per frame new void Update() { BaseUpdate(); lastTime = currentTime; currentTime = Data.GetTigerSong().time; if (currentTime > songSegmentEndTime) { LoadNextScene(); } if (!itsOver) { if (beatIndexPlayer < beatTimes.Count) { // the player has to be able to see the hurdles ahead of time float startTime = beatTimes[beatIndexPlayer] - beatRadiusVisualHint; float endTime = beatTimes[beatIndexPlayer] + beatRadiusVisualHint; // kick off the hurdle if (currentTime > startTime) { Hurdle newHurdle = Instantiate(hurdle.gameObject).GetComponent <Hurdle>(); StartCoroutine(KickOffHurdle(beatIndexPlayer, newHurdle, beatTimes, rightEdge.transform, leftEdge.transform, false)); beatIndexPlayer++; } } if (aTimes.Count > 0 && aIndex < aTimes.Count) { // the player has to be able to see the hurdles ahead of time float startTime = aTimes[aIndex] - beatRadiusVisualHint; float endTime = aTimes[aIndex] + beatRadiusVisualHint; // kick off the hurdle if (currentTime > startTime) { Hurdle newHurdle = Instantiate(a.gameObject).GetComponent <Hurdle>(); StartCoroutine(KickOffHurdle(aIndex, newHurdle, aTimes, aStart, aEnd, true)); aIndex++; } } // play a beat on the beat /* * if ( * currentTime > beatTimes[beatIndexInternal] * && * lastTime < beatTimes[beatIndexInternal] * ) * { * success.Play(); * beatIndexInternal++; * if (beatIndexInternal >= beatTimes.Count) * { * itsOver = true; * } * } */ } }
/// <summary> /// Kick off something the player needs to interact with /// </summary> /// <param name="myHurdleIndex"></param> /// <param name="myHurdle"></param> /// <returns></returns> protected IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle) { bool madeYellow = false; float visualStartTime = beatTimes[myHurdleIndex] - beatRadiusVisualHint; float visualEndTime = beatTimes[myHurdleIndex] + beatRadiusVisualHint; float inputStartTime = beatTimes[myHurdleIndex] - beatInputLead; float inputEndTime = beatTimes[myHurdleIndex] + beatInputLag; bool inputSuccess = false; bool missed = false; while (currentTime < visualEndTime) { if (currentTime > inputStartTime && !madeYellow) { madeYellow = true; myHurdle.MakeReady(); } // success if (currentTime > inputStartTime && currentTime < inputEndTime && CommandsStartedThisFrame.ContainsKey(Command.Up)) { success.Play(); inputSuccess = true; // make the hurdle green myHurdle.MakeCorrect(); // shout a success shout int successShoutIndex = Random.Range(0, successShouts.Count); if (lastSuccessShout == successShoutIndex) { successShoutIndex++; if (successShoutIndex >= successShouts.Count) { successShoutIndex = 0; } } outputText.text = successShouts[successShoutIndex]; lastSuccessShout = successShoutIndex; } // miss.. else if (currentTime > inputEndTime && !inputSuccess && !missed) { missed = true; // todo toss the hurdle myHurdle.MakeWrong(); // shout a miss shout int missShoutIndex = Random.Range(0, missShouts.Count); if (lastMissShout == missShoutIndex) { missShoutIndex++; if (missShoutIndex >= missShouts.Count) { missShoutIndex = 0; } } outputText.text = missShouts[missShoutIndex]; lastMissShout = missShoutIndex; numMistakes++; mistake.Play(); } float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime); myHurdle.transform.position = Vector3.Lerp(rightEdge.transform.position, leftEdge.transform.position, hurdleProgress); yield return(0); } if (numMistakes > allowedMistakes) { StartCoroutine(Failure()); } yield return(new WaitForSeconds(0.2f)); Destroy(myHurdle.gameObject); }