// Coroutine for tuto (hand) private IEnumerator tutoCoroutine() { yield return(new WaitForSeconds(2)); tutoScript.hand.setHandKind(TutoHandScript.HandKind.HandClick); yield return(new WaitForSeconds(0.3f)); tutoScript.hand.setHandKind(TutoHandScript.HandKind.HandNormal); PrimaryCog goodOne = cogs[0]; for (int i = 0; i < cogs.Length; i++) { if (cogs[i].getCogId() == cogToFind.getCogId()) { goodOne = cogs[i]; } } goodOne.GetComponent <SpriteRenderer>().color = win; setGoodCogFind(goodOne); hasWon(true); isPause = true; tutoScript.hand.gameObject.SetActive(false); PlayTuto(); myscore.value = 0; winBg.enabled = false; setAllUnselectable(); }
// First dialogue and tutorial. private void firstPlayTuto() { isPause = true; tutoScript.setBubbleVisibility(false); tutoScript.readyCallback = delegate() { tutoScript.setBubbleVisibility(true); tutoScript.say(Dialogue.dialogue1); }; tutoScript.outCallback = delegate() { // Unset game isPause = false; setAllUnselectable(); // Tuto PrimaryCog goodOne = cogs[0]; for (int i = 0; i < cogs.Length; i++) { if (cogs[i].getCogId() == cogToFind.getCogId()) { goodOne = cogs[i]; } } Vector3 worldPos = goodOne.transform.position; tutoScript.hand.moveToWorldPosition(worldPos, 1.8f); StartCoroutine(tutoCoroutine()); }; tutoScript.getIn(); }
// Applise a smooth transition to the goodOne. private void setGoodCogFind(PrimaryCog goodOne) { goodOne.setSelectable(false); goodOne.gameObject.AddComponent <SmoothTranslation> (); SmoothTranslation st = goodOne.GetComponent <SmoothTranslation> (); st.sceneGenerator = this; st.duration = 1; st.from = goodOne.transform.position; st.to = cogFinalPosition.position; }
// Called when a cog is selected by user. public void cogSelected(PrimaryCog cog) { // State: StartRound -> EndRound state = State.EndofRound; isPause = true; if (cog.getCogId() == cogToFind.getCogId()) { // Update cogs setGoodCogFind(cog); cog.GetComponent <SpriteRenderer>().color = win; // User won the round hasWon(true); } else { // Update cogs PrimaryCog goodOne = null; for (int i = 0; i < cogs.Length; i++) { if (cogs[i].getCogId() == cogToFind.getCogId()) { goodOne = cogs[i]; } } if (goodOne) { setGoodCogFind(goodOne); goodOne.GetComponent <SpriteRenderer>().color = goodCogColor; } cog.GetComponent <SpriteRenderer>().color = lost; // user lost the round hasWon(false); } }