// Update is called once per frame void Update() { if (GoToScene.GetSceneName() != "Menu") { if (input.text != "" && child.text.StartsWith(input.text)) { string modified = tempHolder.Insert(input.text.Length, rtCloseTag); test2 = modified.Insert(0, rtOpenTag); if (test2 != "" && test2 != enemyText.text) { enemyText.text = test2; } } if (input.text == "") { enemyText.text = child.text; } if (sf2 != null) { if (sf2.speed > 0) { gameObject.GetComponent <SpriteRenderer>().flipX = false; } else { gameObject.GetComponent <SpriteRenderer>().flipX = true; } } if (collided) { transform.localScale -= new Vector3(1, 1, 1) * Time.deltaTime * 10; if (transform.localScale.x <= 0) { Destroy(gameObject); } WordCheck.existingWords.Remove(child.text); child.text = ""; } if (child.text == "" || Global.killAll) { died = true; anim.SetInteger("State", 1); if (Global.health <= 0) { Destroy(gameObject); } if (!isPlaying) { Global.multiplier = 2; audio.PlayOneShot(dead); isPlaying = true; } if (anim.GetCurrentAnimatorStateInfo(0).IsName("Empty")) { Destroy(gameObject); } } } }
private void OnCollisionExit2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { GoToScene.ChangeScene(SceneType.none, this); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { GoToScene.ChangeScene(type, this); } }
private void Update() { if (finish) { text.text = finalText; rI.color = blackColor; elapse += Time.deltaTime; if (elapse >= timeTransition) { elapse = 0f; //Finish the scene and go to next one if (sceneName != "") { GoToScene goToScene = new GoToScene(); goToScene.ChangeScene(sceneName); } } else { //increment visibility blackColor = new Color(0f, 0f, 0f, elapse / timeTransition); whiteColor = new Color(1f, 1f, 1f, elapse / timeTransition); } } }
void SpawnMonsters() { if (timertospawn > 0) { timertospawn -= Time.deltaTime; } else if (timertospawn <= 0 && Global.numberOfMonsters > 0 && waveStart <= -1) { if (Global.difficultyLevel < 2) { timertospawn = Random.Range(1f, 2f); } else if (Global.difficultyLevel >= 2 && Global.difficultyLevel < 3) { timertospawn = Random.Range(1f, 2f); } else { timertospawn = Random.Range(1f, 1.3f); } if (GoToScene.GetSceneName() != "3") { int spawner = Random.Range(0, spawnPoints.Length); Vector3 spawnLocation; spawnLocation = spawnPoints[spawner].transform.localPosition; GameObject myRoadInstance; if (monsterSpawn.Length <= 0) { myRoadInstance = Instantiate(Resources.Load(ToSpawn)) as GameObject; } else { myRoadInstance = Instantiate(Resources.Load(monsterSpawn[Random.Range(0, monsterSpawn.Length)])) as GameObject; } myRoadInstance.transform.localPosition = spawnLocation; if (myRoadInstance.transform.position.x > player.transform.position.x) { myRoadInstance.GetComponent <SpriteRenderer>().flipX = true; } myRoadInstance.transform.SetParent(canvas.transform, false); Global.wordLimit--; } } }
public void BackToMenu() { GoToScene.GoTo("Menu"); gameObject.SetActive(false); Global.wordLimit = Global.wordLimitSet; Global.health = 100; Global.bossHealth = 300; Time.timeScale = 1; }
public void RestartGame() { GoToScene.GoTo(GoToScene.GetSceneName()); Global.health = 100; Global.wordLimit = Global.wordLimitSet; Global.bossHealth = 300; Global.score -= 100; Time.timeScale = 1; }
private void Start() { WebSocketListener.Instance().Subscribe(this); LobbyInfoController lobbyInfo = LobbyInfoController.Instance(); updatePlayers(lobbyInfo.msg.players.ToArray(), lobbyInfo.msg.readyStatus); WebSocketListener.Instance().StartListening(lobbyInfo.msg.id, lobbyInfo.playerName, () => {}); Goto = FindObjectOfType <GoToScene>(); }
void Start() { goToScene = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene; cronometro = GameObject.Find("Cronometro").GetComponent(typeof(Cronometro)) as Cronometro; textLevel.text = "Nivel " + GlobalVariables.nivelActual; walk = GameObject.Find("Player").GetComponent <Autowalk>(); //cuando se ponga en boton borrar GlobalVariables.GameIsPause = true; walk.enabled = false; valoresPanel(); }
void CheckWord() { foreach (GameObject o in objects) { if (o.GetComponentInChildren <Text>().text == input.text && o.GetComponentInChildren <Text>().text != "") { if (!trigger) { wordsCleared--; Global.numberOfMonsters--; trigger = true; if (GoToScene.GetSceneName() != "3") { existingWords.Remove(o.GetComponentInChildren <Text>().text); } multiplerTimer = 2; if (multiplerTimer > 0) { Global.enemyKilledWithinMultipler++; Global.score += 10 * Global.enemyKilledWithinMultipler; } else { Global.score += 10; } } if (trigger) { timer -= Time.deltaTime; o.GetComponentInChildren <Text>().color = Color.red; if (timer <= 0.1f) { o.GetComponentInChildren <Text>().text = ""; trigger = false; input.text = ""; timer = 0.2f; } } } else { o.GetComponentInChildren <Text>().color = Color.white; } } }
void Start() { textLevel.text = "Nivel " + GlobalVariables.nivelActual + " superado"; goToScene = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene; CalcularTiempo(); DibujarGemas(); if (GlobalVariables.nivelActual == 6) { btns.SetActive(false); btnfin.SetActive(true); } CalcularValoracion(); DesbloquearNivel(); ClearLevel(); }
// Update is called once per frame void Update() { if (anim.GetCurrentAnimatorStateInfo(0).IsName("Empty")) { if (GoToScene.GetSceneName() == "1") { Global.difficultyLevel += 0.1f; GoToScene.GoTo("2"); } if (GoToScene.GetSceneName() == "2") { Global.difficultyLevel += 0.1f; GoToScene.GoTo("3"); } Destroy(gameObject); } }
void CheckBossWord() { if (bossText.GetComponentInChildren <Text>().text == input.text && bossText.GetComponentInChildren <Text>().text != "") { if (!trigger) { trigger = true; Global.numberOfMonsters--; } if (trigger) { timer -= Time.fixedDeltaTime; bossText.GetComponentInChildren <Text>().color = Color.blue; if (timer <= 0) { bossText.GetComponentInChildren <Text>().text = ""; if (GoToScene.GetSceneName() == "1") { Global.bossHealth -= 10; Global.health += 5; } else { Global.bossHealth -= 10; Global.health += 3; } trigger = false; input.text = ""; timer = 0.1f; Instantiate(Resources.Load("Gain health"), new Vector3(bossText.transform.localPosition.x, 0, -56), Quaternion.identity); audio.PlayOneShot(bossHurt); } } } else { bossText.GetComponentInChildren <Text>().color = Color.white; } }
void Start() { if (GoToScene.GetSceneName() == "1") { Global.health = 100; Global.score = 0; } Global.killAll = false; blood = GameObject.FindGameObjectWithTag("Blood").GetComponent <Canvas>(); defeatCanvas.SetActive(false); defeatC = defeatCanvas.GetComponent <Canvas>(); if (GoToScene.GetSceneName() == "3") { wonCanvas.SetActive(false); } if (wonCanvas != null) { wonC = wonCanvas.GetComponent <Canvas>(); wonC.GetComponent <CanvasGroup>().alpha = 0; } defeatC.GetComponent <CanvasGroup>().alpha = 0; blood.enabled = false; timertospawn = 1f; trigger = false; timer = 0f; waveStart = 3.5f; cooldownText = cooldownText.GetComponent <Text>(); previousTimer = -1; audio = GameObject.FindGameObjectWithTag("SFX").GetComponent <AudioSource>(); bgm = GameObject.FindGameObjectWithTag("Audio").GetComponent <AudioSource>(); player = GameObject.FindGameObjectWithTag("Player"); playCountdown2 = false; Global.wordLimit = PlayerPrefs.GetInt("WordLimit"); wordsCleared = Global.wordLimit; Global.numberOfMonsters = Global.wordLimit; cleared.enabled = false; spawnPoints = GameObject.FindGameObjectsWithTag("SpawnPlatform"); }
string rtCloseTag = "</color>"; //Rich text closing tag // Use this for initialization void Start() { died = false; rtOpenTag = "<color=" + clearTextColor + ">"; cam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); player = GameObject.FindGameObjectWithTag("Player"); anim = gameObject.GetComponent <Animator>(); audio = GameObject.FindGameObjectWithTag("SFX").GetComponent <AudioSource>(); if (GoToScene.GetSceneName() != "Menu") { input = GameObject.FindGameObjectWithTag("Input").GetComponent <InputField>(); } speed = Random.Range(13, 20); child = transform.GetChild(0).GetComponentInChildren <Text>(); enemyText = transform.GetChild(0).GetChild(0).GetComponent <Text>(); if (ListOFWords.words.Count > 0) { int random = Random.Range(0, ListOFWords.words.Count); string randomText = ListOFWords.words[random]; if (child.text != randomText) { child.text = randomText; enemyText.text = randomText; } ListOFWords.words.RemoveAt(random); WordCheck.existingWords.Add(child.text); } child.color = Color.white; if (enemyText.text == "") { enemyText.text = child.text; } isPlaying = false; collided = false; tempHolder = enemyText.text; }
void Start() { iclickable = new GoToScene(sceneName); Initialize(); }
void Start() { goToScene = GameObject.Find("GoToScene").GetComponent(typeof(GoToScene)) as GoToScene; cronometro = GameObject.Find("Cronometro").GetComponent(typeof(Cronometro)) as Cronometro; }
private void Start() { Api = FindObjectOfType <RestApi>(); Goto = FindObjectOfType <GoToScene>(); }
// Update is called once per frame void Update() { Global.health = Mathf.Clamp(Global.health, 0, 100); if (Input.GetKeyUp(KeyCode.Delete) || Input.GetKeyUp(KeyCode.Tab)) { input.text = ""; } if (Time.timeScale != 0) { input.ActivateInputField(); } else { input.DeactivateInputField(); } if (Global.health <= 0) { Global.health = 0; } if (Global.health <= 0 && !defeatCanvas.active) { defeatCanvas.SetActive(true); if (defeat != null) { audio.PlayOneShot(defeat); } } if (Global.bossHealth <= 0 && !wonCanvas.active) { wonCanvas.SetActive(true); if (victory != null) { audio.PlayOneShot(victory); } Time.timeScale = 0; } playerHealth.text = "Health: " + Global.health.ToString(); if (Global.numberOfMonsters >= 0) { wordsLeft.text = Global.numberOfMonsters.ToString() + " Words Left"; } if (GoToScene.GetSceneName() == "3" && Global.bossHealth <= 0) { cleared.enabled = true; cleared.text = " "; if (cleared.GetComponent <Text>().fontSize < 40) { cleared.GetComponent <Text>().fontSize += 1; } else { if (wonC.GetComponent <CanvasGroup>().alpha <= 1) { wonC.GetComponent <CanvasGroup>().alpha += 0.02f; } } } if (Global.health <= 0) { cleared.enabled = true; cleared.text = "Defeated!"; if (cleared.GetComponent <Text>().fontSize < 40) { cleared.GetComponent <Text>().fontSize += 1; } else { if (defeatC.GetComponent <CanvasGroup>().alpha <= 1) { defeatC.GetComponent <CanvasGroup>().alpha += 0.02f; } Time.timeScale = 0; } } if (wordsCleared <= 0 && GoToScene.GetSceneName() != "3") { ChangeWave(); } ShowBlood(); SpawnMonsters(); Global.timer += Time.deltaTime; if (GoToScene.GetSceneName() == "1") { StartCountdown(); } else if (waveStart != -1) { waveStart = -1; } objects = GameObject.FindGameObjectsWithTag("Monster"); if (GoToScene.GetSceneName() == "3") { bossText = GameObject.FindGameObjectWithTag("Boss"); } myText = input.text; if (GoToScene.GetSceneName() != "3") { AutoCompleteHint(); } scoreText.text = "Score: " + Global.score.ToString(); if (wonText != null) { wonText.text = "You defeated the boss!" + '\n' + "You score was " + Global.score.ToString(); } posY += Time.deltaTime * 10; ComboMultiplier(); CheckWord(); if (GoToScene.GetSceneName() == "3") { CheckBossWord(); } }
void SetWords() { Regex r = new Regex("^[a-zA-Z0-9]*$"); if (loadedWords.Count >= 1) { lowestWordCount = loadedWords[0].Length; } foreach (string word in loadedWords) { int n = word.Length; StringBuilder sb = new StringBuilder(word); //Easy if (Global.difficultyLevel < 2) { if (GoToScene.GetSceneName() == "1") { if (n >= 1 && n <= 2) { if (!Global.allowUpperCase) { if (word == word.ToLower()) { words.Add(word); } } else { words.Add(word); for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 20) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } if (GoToScene.GetSceneName() == "2") { if (n >= 2 && n <= 5) { if (!Global.allowUpperCase) { if (word == word.ToLower()) { words.Add(word); } } else { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 20) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } if (GoToScene.GetSceneName() == "3") { if (n >= 6 && n <= 8) { bossWords.Add(word); } if (n >= 5 && n <= 7) { if (!Global.allowUpperCase) { words.Add(word); } else if (Global.allowUpperCase) { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 20) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } } } //Normal if (Global.difficultyLevel >= 2 && Global.difficultyLevel < 3) { if (GoToScene.GetSceneName() == "1") { if (n >= 4 && n <= 6) { if (!Global.allowUpperCase) { words.Add(word); } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 40) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } } if (GoToScene.GetSceneName() == "2") { if (n >= 6 && n <= 8) { if (!Global.allowUpperCase) { words.Add(word); } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 40) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } } if (GoToScene.GetSceneName() == "3") { if (n >= 6 && n <= 8) { if (!Global.allowUpperCase) { words.Add(word); } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 40) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } if (n >= 4) { bossWords.Add(word); } } } } //Hard if (Global.difficultyLevel >= 3) { if (GoToScene.GetSceneName() == "1") { if (n >= 5 && n <= 7) { if (!Global.allowUpperCase) { if (word == word.ToLower()) { words.Add(word); } } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 70) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } } if (GoToScene.GetSceneName() == "2") { if (n >= 6 && n <= 9) { if (!Global.allowUpperCase) { if (word == word.ToLower()) { words.Add(word); } } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 70) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } } } if (GoToScene.GetSceneName() == "3") { if (n >= 6) { if (!Global.allowUpperCase) { if (word == word.ToLower()) { words.Add(word); } } else { words.Add(word); { for (int i = 0; i < n; i++) { int random = Random.Range(0, 100); if (random < 70) { sb[i] = char.ToUpper(word[i]); } } words.Add(sb.ToString()); } } if (n >= 6) { bossWords.Add(word); } } } } } }