public IEnumerator WaitPrompt() { // Create listener for WaitForUIButtons object var waitForButton = new WaitForUIButtons(mainMenuUI.transform.Find("LevelTextContainer").transform.Find("Continue").GetComponent <Button>()); yield return(waitForButton.Reset()); // resume game and hide LevelTextContainer if (waitForButton.PressedButton == mainMenuUI.transform.Find("LevelTextContainer").transform.Find("Continue").GetComponent <Button>()) { mainMenuUI.transform.Find("LevelTextContainer").GetComponent <CanvasGroup>().interactable = false; mainMenuUI.transform.Find("LevelTextContainer").GetComponent <CanvasGroup>().alpha = 0; Resume(); } }
private IEnumerator InitializePlayer(GameObject Target) { string final2 = checkIsland + playerName; var json2 = new WebClient().DownloadString(final2); yield return(json2); dynamic data2 = JObject.Parse(json2); if (data2.HasIsland == 0) { selectIslandGroup.SetActive(true); var waitForButton = new WaitForUIButtons(SelectIsland); yield return(waitForButton.Reset()); if (waitForButton.PressedButton) { selectIslandGroup.SetActive(false); } Obstacle = Obstacles[Random.Range(0, Obstacles.Length)]; Vector3 position2 = Vector3.zero; bool validPosition = false; int spawnAttempts = 0; while (!validPosition) { spawnAttempts++; position2 = new Vector3(Random.Range(maxX1, maxX2), 0, Random.Range(maxY1, maxY2)); validPosition = true; Collider[] colliders = Physics.OverlapSphere(position2, obstacleCheckRadius); foreach (Collider col in colliders) { if (col.tag == "Obstacle") { validPosition = false; } } if (spawnAttempts > 7) { maxX1 -= 200; maxX2 += 200; maxY1 += 200; maxY2 -= 200; } } if (validPosition) { string final = addIsland + playerName + "&Center_X=" + position2.x + "&Center_Y=" + position2.y + 2 + "&Center_Z=" + position2.z + "&IslandPosX=" + position2.x + "&IslandPosY=" + position2.y + "&IslandPosZ=" + position2.z + "&IslandType=" + islandTypeInt; StartCoroutine(SetIsland(final)); CmdSpawnIsland(position2, islandTypeInt); var x = position2.x; var y = position2.y; var z = position2.z; Target.transform.position = new Vector3(x, y, z); setCamPos(); } } else { selectIslandGroup.SetActive(false); string posString = highscoreURL + name; var json = new WebClient().DownloadString(posString); dynamic data = JObject.Parse(json); float x = data.Pos_X; float y = data.Pos_Y; float z = data.Pos_Z; Target.transform.position = new Vector3(x, y, z); setCamPos(); } }
IEnumerator UseSpell(Spell spell) { if (battleState != BattleState.PlayerTurn) { yield break; } double playerWisdom = player.GetComplessiveStats().Wisdom; double playerStrength = player.GetComplessiveStats().Strength; double damage = playerWisdom * 0.8 + playerStrength * 0.3 + spell.AttackDamage; spellMnD.text = spell.Name + ", \nMana: " + spell.ManaUsage.ToString() + ", \nDamage: " + damage.ToString(); spellCombo.text = "Combo: "; List <KeyCode> keyCodes = spell.Combo; foreach (KeyCode kcode in keyCodes) { switch (kcode) { case KeyCode.UpArrow: spellCombo.text += "⇧ "; break; case KeyCode.RightArrow: spellCombo.text += "⇨ "; break; case KeyCode.LeftArrow: spellCombo.text += "⇦ "; break; case KeyCode.DownArrow: spellCombo.text += "⇩ "; break; default: spellCombo.text += kcode.ToString() + " "; break; } } bool comboSuceded = false; var waitForButton = new WaitForUIButtons(okButton, backButton); yield return(waitForButton.Reset()); if (waitForButton.PressedButton == okButton) { List <KeyCode> pressedKeys = new List <KeyCode>(); yield return(new WaitForSeconds(0.6f)); float startTime = Time.time; panelTimer.enabled = !panelTimer.enabled; while (pressedKeys.Count < spell.Combo.Count && Time.time - startTime <= spell.ComboTimer) { yield return(null); panelTimer.fillAmount = (Time.time - startTime) / spell.ComboTimer; foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKey(kcode)) { pressedKeys.Add(kcode); switch (kcode) { case KeyCode.UpArrow: comboDone.text += "⇧ "; break; case KeyCode.RightArrow: comboDone.text += "⇨ "; break; case KeyCode.LeftArrow: comboDone.text += "⇦ "; break; case KeyCode.DownArrow: comboDone.text += "⇩ "; break; default: comboDone.text += kcode.ToString() + " "; break; } Input.ResetInputAxes(); } } } panelTimer.enabled = !panelTimer.enabled; if (pressedKeys.SequenceEqual(spell.Combo)) { comboSuceded = true; } comboDone.text = ""; spellCombo.text = ""; spellMnD.text = ""; hide.SetActive(false); hide1.SetActive(false); if (comboSuceded) { GameManager.Instance.QuestManager.Used(spell.Name); StartCoroutine(ManaAttack(spell)); int spellNumber = player.GetEquippedSpells().Count; for (int i = 0; i < spellNumber; i++) { spellsButtons[i].GetComponent <Button>().interactable = false; } } else { gameChat.text = spell.Name + " failed!"; yield return(new WaitForSeconds(1f)); battleState = BattleState.EnemyTurn; StartCoroutine(EnemyTurn(false)); } } else { //battleState= BattleState.PlayerTurn; } }