void checkMouseClick() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = cam.gameObject.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { GameObject objectHit = hit.transform.gameObject; if (objectHit.tag == "TextBlob") { WordFightWordBlob theBlob = objectHit.GetComponent <WordFightWordBlob> (); //theBlob.tab = tab; theBlob.pickUp(hit.point); //Destroy (objectHit); } else if (objectHit.tag == "RayCastBillboard") { Vector3 worldCoords = hit.point; } } } }
new void Update() { if (state == WordFightControllerState.delay0 && substate == -5) { cam._wa_warpToMarker(this, 4); substate = -4; } if (state == WordFightControllerState.delay0 && substate == -4) // everything black { elapsedTime += Time.deltaTime; if (elapsedTime > 2.6f) { elapsedTime = 0.0f; substate = -3; shadow.faded = false; hero.faded = false; // characters appear } } if (state == WordFightControllerState.delay0 && substate == -3) // characters separate { elapsedTime += Time.deltaTime; if (elapsedTime > 1.6f) { elapsedTime = 0.0f; substate = -2; shadow.displaced = false; hero.displaced = false; cam._wa_moveToMarker(this, 3); } } if (state == WordFightControllerState.delay0 && substate == -2) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.6f) { elapsedTime = 0.0f; substate = -1; shadow.setAnimation(0); hero.setAnimation(0); } } if (state == WordFightControllerState.delay0 && substate == -1) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.2f) { elapsedTime = 0.0f; substate = 0; shadow.setAnimation(1); hero.setAnimation(1); } } if (state == WordFightControllerState.delay0 && substate == 0) { elapsedTime += Time.deltaTime; if (elapsedTime > 0.4f) { if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(AHORAAPRENDERAS)); this.isWaitingForActionToComplete = true; } //shadow.setAnimation (0); //hero.setAnimation (0); ++substate; elapsedTime = 0.0f; } } if (state == WordFightControllerState.delay0 && substate == 1) { elapsedTime += Time.deltaTime; if (elapsedTime > 0.2f) { substate = 0; state = WordFightControllerState.delay; //cam.lerpSpeed = 1.6f; // CAMBIAR TIEMPO DEL ITWEEN ? //shadow.setAnimation (1); //hero.setAnimation (1); } } if (state == WordFightControllerState.delay) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); elapsedTime += Time.deltaTime; if (elapsedTime > 0.5f) { state = WordFightControllerState.zoomToPlayer0; heroFan.open(); cam._wa_moveToMarker(this, 1); } } if (state == WordFightControllerState.zoomToPlayer0) { if (isWaitingForActionToComplete) { return; } // else { string currentLvl = ds.retrieveStringValue("CurrentLevel").Substring(0, 6); int nHeroes = 0; if (ds.retrieveBoolValue("Has" + currentLvl + "Warrior")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Master")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Philosopher")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Explorer")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Sage")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Wizard")) { ++nHeroes; } if (ds.retrieveBoolValue("Has" + currentLvl + "Yogi")) { ++nHeroes; } if (nHeroes == 0) { chispAlert._wa_alert(this, chispaStuff.getString(NOTIENESNINGUN)); substate = 0; this.isWaitingForActionToComplete = true; state = WordFightControllerState.loseFromTheBeginning; } else if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(DEBESELEGIR)); this.isWaitingForActionToComplete = true; state = WordFightControllerState.zoomToPlayer1; substate = 0; } else { state = WordFightControllerState.zoomToPlayer; } } if (state == WordFightControllerState.zoomToPlayer1 && substate == 0) { if (isWaitingForActionToComplete) { return; } if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(JUZGALOS)); } substate = 1; } if (state == WordFightControllerState.zoomToPlayer1 && substate == 1) { if (isWaitingForActionToComplete) { return; } if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(CONQUEHEROE)); } state = WordFightControllerState.zoomToPlayer2; } if (state == WordFightControllerState.zoomToPlayer2) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); } state = WordFightControllerState.zoomToPlayer; } if (state == WordFightControllerState.zoomToPlayer) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = cam.gameObject.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { GameObject objectHit = hit.transform.gameObject; if (objectHit.tag == "Hero") { WordFightHero h = objectHit.GetComponent <WordFightHero> (); chosenHero = h.wisdom; heroFan.keep(h.wisdom); //heroFan.close (); state = WordFightControllerState.delay2; substate = -2; elapsedTime = 0.0f; } } } } if (state == WordFightControllerState.loseFromTheBeginning && substate == 0) { if (Input.GetMouseButtonDown(0)) { chispAlert.close(); fader._wa_fadeOut(this); this.isWaitingForActionToComplete = true; substate = 1; } } if (state == WordFightControllerState.loseFromTheBeginning && substate == 1) { if (!isWaitingForActionToComplete) { ds.storeIntValue("AlphabetReward", -Reward * 6); string ret = ds.retrieveStringValue("ReturnLocation"); SceneManager.LoadScene(ret); } } if (state == WordFightControllerState.delay2 && substate == -2) { elapsedTime += Time.deltaTime; if (elapsedTime > 0.5f) { ++substate; heroFan.closeSlowly(); } } if (state == WordFightControllerState.delay2 && substate == -1) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.5f) { ++substate; heroGlow.glow(); //heroFan.closeSlowly (); } } if (state == WordFightControllerState.delay2 && substate == 0) { elapsedTime += Time.deltaTime; if (elapsedTime > 3.5f) { elapsedTime = 0.0f; //cam._wa_moveToMarker (this, 3); cam._wm_moveToMarker(3); ++substate; if (!chosenHero.Equals(requiredWisdom)) { state = WordFightControllerState.loseFromTheBeginning; substate = 0; chispAlert._wa_alert(this, chispaStuff.getString(NOHASELEGIDO)); fader.setFadeColor(0, 0, 0); //fader.fadeOut (); } else if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(HASELEGIDOSABIA)); ++substate; } } } if (state == WordFightControllerState.delay2 && substate == 1) { ++substate; } if (state == WordFightControllerState.delay2 && substate == 2) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); } ++substate; } if (state == WordFightControllerState.delay2 && substate == 3) { elapsedTime += Time.deltaTime; if (elapsedTime > 0.75f) { elapsedTime = 0.0f; shadowBar.grow(); playerBar._wa_grow(this); //hero.fighting = true; //shadow.fighting = true; hero.showHalo(); shadow.showHalo(); //yingYang._wa_grow (this); timeToNextBlob = FloatRandom.floatRandomRange(minTimeToNextBlob / difficulty, maxTimeToNextBlob / difficulty); ++substate; // Cambiar esto para jugar en serio shadowEnergy = 0.1f; playerEnergy = 1.0f; } } if (state == WordFightControllerState.delay2 && substate == 4) { if (isWaitingForActionToComplete) { return; } if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(TANTOTUSOMBRA)); } ++substate; } if (state == WordFightControllerState.delay2 && substate == 5) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } } if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(TUAURAESLUM)); } ++substate; } if (state == WordFightControllerState.delay2 && substate == 6) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); } yinYang._wa_grow(this); ++substate; } if (state == WordFightControllerState.delay2 && substate == 7) { if (isWaitingForActionToComplete) { return; } hero.fighting = true; shadow.fighting = true; elapsedTime = 0.0f; if (tutorialMode) { ++substate; } else { state = WordFightControllerState.fightStart; } } if (state == WordFightControllerState.delay2 && substate == 8) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.5f) { if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(QUETIENESQUEHACER)); } ++substate; } } if (state == WordFightControllerState.delay2 && substate == 9) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } } if (tutorialMode) { chispAlert._wa_alert(this, chispaStuff.getString(CADAPALABRASERA)); } ++substate; } if (state == WordFightControllerState.delay2 && substate == 10) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } chispAlert._wa_alert(this, chispaStuff.getString(DEBESTOCARLOS)); } elapsedTime = 0.0f; ++substate; } if (state == WordFightControllerState.delay2 && substate == 11) { if (tutorialMode) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); } elapsedTime = 0.0f; ++substate; } if (state == WordFightControllerState.delay2 && substate == 12) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.0f) { yinYang.emitBlob(GenericGoodStuffBank.getNextString(), true); elapsedTime = 0.0f; ++substate; } } if (state == WordFightControllerState.delay2 && substate == 13) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.0f) { emittedBlob = GameObject.Find("WFBlob").GetComponent <WordFightWordBlob> (); emittedBlob.pause(); chispAlert._wa_alert(this, chispaStuff.getString(YINYANGEMITIDOBUENO)); ++substate; } } if (state == WordFightControllerState.delay2 && substate == 14) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); emittedBlob.unpause(); shadowBar.queryClear(); ++substate; } /* wait until player drags word onto yingyang */ if (state == WordFightControllerState.delay2 && substate == 15) { checkMouseClick(); if (shadowBar.queryEvent("HealthBarEvent")) { substate = 17; chispAlert._wa_alert(this, chispaStuff.getString(HASILUMINADO)); } if (emittedBlob == null && shadowBar.targetBarFraction == 1) { yinYang.emitBlob(GenericGoodStuffBank.getNextString(), true); ++substate; } } if (state == WordFightControllerState.delay2 && substate == 16) { GameObject g = GameObject.Find("WFBlob"); if (g != null) { emittedBlob = g.GetComponent <WordFightWordBlob> (); substate = 15; } } if (state == WordFightControllerState.delay2 && substate == 17) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); ++substate; elapsedTime = 0.0f; } if (state == WordFightControllerState.delay2 && substate == 18) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.0f) { yinYang.emitBlob(GenericNaughtyStuffBank.getNextString(), false); elapsedTime = 0.0f; ++substate; } } if (state == WordFightControllerState.delay2 && substate == 19) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.0f) { emittedBlob = GameObject.Find("WFBlob").GetComponent <WordFightWordBlob> (); emittedBlob.pause(); chispAlert._wa_alert(this, chispaStuff.getString(YINYANGEMITIDOMALO)); ++substate; } } if (state == WordFightControllerState.delay2 && substate == 20) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); elapsedTime = 0.0f; ++substate; } if (state == WordFightControllerState.delay2 && substate == 21) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.0f) { emittedBlob.unpause(); ++substate; } } /* wait until naughtyWord has gone away */ if (state == WordFightControllerState.delay2 && substate == 22) { checkMouseClick(); /* blob has hit player. Emit another */ if (emittedBlob == null && playerBar.queryEvent("HealthBarEvent")) { yinYang.emitBlob(GenericNaughtyStuffBank.getNextString(), false); ++substate; return; } if (playerBar.targetBarFraction < 0.5f) { playerBar.targetBarFraction = 0.9f; } /* blob has flown away. To next substate */ if (emittedBlob == null && !playerBar.queryEvent("HealthBarEvent")) { substate = 24; } } if (state == WordFightControllerState.delay2 && substate == 23) { /* spawn new blob */ GameObject g = GameObject.Find("WFBlob"); if (g != null) { emittedBlob = g.GetComponent <WordFightWordBlob> (); substate = 22; } } if (state == WordFightControllerState.delay2 && substate == 24) { chispAlert._wa_alert(this, chispaStuff.getString(CONTINUALABATALLA)); ++substate; } if (state == WordFightControllerState.delay2 && substate == 25) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); state = WordFightControllerState.fightStart; } if (state == WordFightControllerState.fightEndWin && substate == 0) { cam.moveToMarker(2, 5); yinYang.home(); elapsedTime = 0.0f; ++substate; ds.storeIntValue("AlphabetReward", Reward); int defeated = ds.retrieveIntValue("DefeatedShadows"); ++defeated; ds.storeIntValue("DefeatedShadows", defeated); ds.storeBoolValue("WordFightTutorialDone", true); } if (state == WordFightControllerState.fightEndWin && substate == 1) { if (yinYang.isFinishedHoming()) { // yinYang.GetComponent<Renderer> ().enabled = false; // justYin.GetComponent<Renderer> ().enabled = true; // justYang.GetComponent<Renderer> ().enabled = true; //blackSquare.GetComponent<Renderer> ().enabled = true; ++substate; elapsedTime = 0.0f; } } if (state == WordFightControllerState.fightEndWin && substate == 2) { elapsedTime += Time.deltaTime; // Vector3 pos; // pos = justYin.transform.localPosition; // pos.x += Time.deltaTime; // justYin.transform.position = pos; // pos = justYang.transform.localPosition; // pos.x -= Time.deltaTime; // justYang.transform.position = pos; // pos = blackSquare.transform.localScale; // pos.x -= Time.deltaTime; // blackSquare.transform.localScale = pos; if (!faderWhite.GetComponent <FaderItween>().action) { faderWhite.GetComponent <FaderItween> ().action = true; } if (elapsedTime > faderWhite.GetComponent <FaderItween> ().timeTo) { string levelName = ds.retrieveStringValue("CurrentLevel").Substring(0, 6); int nWave = ds.retrieveIntValue(levelName + "ShadowWaveNumber"); ++nWave; ds.storeIntValue(levelName + "ShadowWaveNumber", nWave); // increment wave number //Handheld.PlayFullScreenMovie ("4.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput); if (Version.versionType == VersionType.demo) { string returnLocation = ds.retrieveStringValue("ReturnLocation"); SceneManager.LoadScene(returnLocation); } else { //string currentHero = ds.retrieveStringValue (); int numHero = ds.retrieveIntValue("Has" + requiredWisdom); //ds.storeStringValue ("TheaterFolder", requiredWisdom + numHero); //SceneManager.LoadScene ("Scenes/Theater"); int wins = ds.retrieveIntValue("WordFightWins"); ds.storeIntValue("WordFightWins", ++wins); ds.storeBoolValue("JustWonFight", true); ds.storeBoolValue("FadeWhite", true); string returnLocation = ds.retrieveStringValue("ReturnLocation"); SceneManager.LoadScene(returnLocation); } } } if (state == WordFightControllerState.fightEndLose && substate == 0) { chispAlert._wa_alert(this, chispaStuff.getString(HASPERDIDOLABATALLA)); fader.setFadeColor(0, 0, 0); this.isWaitingForActionToComplete = true; ++substate; } if (state == WordFightControllerState.fightEndLose && substate == 1) { if (isWaitingForActionToComplete) { return; } chispAlert.close(); fader._wa_fadeOut(this); this.isWaitingForActionToComplete = true; ++substate; } if (state == WordFightControllerState.fightEndLose && substate == 2) { if (isWaitingForActionToComplete) { return; } this.isWaitingForActionToComplete = true; ++substate; } if (state == WordFightControllerState.fightEndLose && substate == 3) { if (!this.isWaitingForActionToComplete) { string ret = ds.retrieveStringValue("ReturnLocation"); ds.storeIntValue("AlphabetReward", -Reward); SceneManager.LoadScene(ret); } } if (state == WordFightControllerState.fightStart) { elapsedTime += Time.deltaTime; if (elapsedTime > timeToNextBlob) { elapsedTime = 0.0f; timeToNextBlob = FloatRandom.floatRandomRange(minTimeToNextBlob / difficulty, maxTimeToNextBlob / difficulty); float chance = FloatRandom.floatRandomRange(0.0f, 1.0f); if (chance < 0.5f) { string ns = GenericGoodStuffBank.getNextString(); int a = ns.Length; yinYang.emitBlob(ns, true); } else { string ns = GenericNaughtyStuffBank.getNextString(); int hhh = ns.Length; yinYang.emitBlob(ns, false); } } if (Input.GetMouseButtonDown(0)) { RaycastHit[] hits; Ray ray = cam.gameObject.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); hits = Physics.RaycastAll(ray); for (int i = 0; i < hits.Length; ++i) { GameObject objectHit = hits[i].transform.gameObject; if (objectHit.tag == "TextBlob") { WordFightWordBlob theBlob = objectHit.GetComponent <WordFightWordBlob> (); //theBlob.tab = tab; theBlob.pickUp(hits[i].point); //Destroy (objectHit); } else if (objectHit.tag == "RayCastBillboard") { Vector3 worldCoords = hits[i].point; } } } } }
void Update() { if (state == WFYingYangState.idle) { } if (state == WFYingYangState.homing) { int nTurns = (int)(angle / 360.0f); float normalAngle = angle - 360.0f * nTurns; angle = normalAngle; angle += angleSpeed * Time.deltaTime; angleSpeed += Time.deltaTime * 20.0f; if (angle > 360.0f) { angle = 360.0f; state = WFYingYangState.idle; } this.transform.rotation = Quaternion.Euler(0, 0, angle); } if (state == WFYingYangState.growing) { scale += scaleSpeed * Time.deltaTime; if (scale > maxScale) { scale = maxScale; state = WFYingYangState.spinning; notifyFinishAction(); } angle += angleSpeed * Time.deltaTime; this.transform.localScale = new Vector3(scale, scale, scale); this.transform.rotation = Quaternion.Euler(0, 0, angle); if (angleSpeed > slowAngleSpeed) { angleSpeed = angleSpeed * 0.97f; } } if (state == WFYingYangState.spinning) { if (angleSpeed > slowAngleSpeed) { angleSpeed = angleSpeed * 0.97f; } angle += angleSpeed * Time.deltaTime; this.transform.rotation = Quaternion.Euler(0, 0, angle); } if (state == WFYingYangState.trembling) { angle += angleSpeed * Time.deltaTime; this.transform.rotation = Quaternion.Euler(0, 0, angle); Vector3 newPos = this.transform.position; if (oddFrame) { newPos.y += 0.05f; } else { newPos.y -= 0.05f; } this.transform.position = newPos; oddFrame = !oddFrame; elapsedTime += Time.deltaTime; if (elapsedTime > tremblingTime) { elapsedTime = 0.0f; newPos = this.transform.position; if (oddFrame) { newPos.y += 0.05f; } else { newPos.y -= 0.05f; } this.transform.position = newPos; Vector3 spawnPos = this.transform.position; spawnPos.z += zOffset; GameObject newBlobGO = (GameObject)Instantiate(wordBlobPrefab, spawnPos, Quaternion.Euler(Vector3.zero)); WordFightWordBlob newBlob = newBlobGO.GetComponent <WordFightWordBlob> (); newBlobGO.name = "WFBlob"; newBlob.angle = FloatRandom.floatRandomRange(0.0f, 6.28f); newBlob.initialize(); newBlob.good = nextGood; newBlob.controller = controller; newBlob.yinYang = this; newBlob.cam = cam; newBlob.difficulty = difficulty; if (nextString.Equals("")) { nextString = ""; } newBlob.setText(nextString); state = WFYingYangState.spinning; } } }