private void Awake() { zoneSelectorPlayer = Instantiate(zoneSelectorPrefab).GetComponent <ZoneSelector>(); zoneSelectorTarget = Instantiate(zoneSelectorPrefab).GetComponent <ZoneSelector>(); GameObject obj = Instantiate(characterInfoPanelPrefab); characterInfoPanel = obj.GetComponent <CharacterInfoPanel>(); characterInfoPanel.Hide(); }
private void OnSkinTapped(int skinId) { NetworkCaller.Instance.SelectSkin(skinId, () => { var updatedSkinId = NetworkCaller.Instance.PlayerData.SkinId; _characterItemControllers.ForEach(x => { x.IsSelected = x.Id == updatedSkinId; x.Reload(); }); _characterInfoPanel.Hide(); }, () => { NativeDialogManager.Instance.ShowConnectionErrorDialog(() => { OnSkinTapped(skinId); }, () => { }); }); }
IEnumerator GameLoop() { // yield return new WaitForSecondsRealtime(2.0f); // print("корутина стартанула"); while (!CheckEndGame()) { foreach (var _player in playerCharacters) { player = _player.Key; cameraMoveScript.SetTarget(player.transform); playerCharacterInfo = _player.Value; FindTargetList(player, enemyCharacters, targetList); // подготовка playerCharacterInfo.TurnReset(); if (targetList.Count > 0) { currentTarget = targetList[0].character; currentTargetCharacterInfo = targetList[0]; playerCharacterInfo.hasTarget = true; } else { currentTarget = null; currentTargetCharacterInfo = null; playerCharacterInfo.hasTarget = false; } // включение всякого UI uiLevelScript.ShowMenu(true); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Player, playerCharacterInfo); player.SwitchSelect(true, selectOutlinePlayerColor, selectOutlineWith); // ждём хода while (!playerCharacterInfo.isEndTurn) { if (player.IsIdle() && playerCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterFire) { playerCharacterInfo.characterState = CharacterInfo.CharacterState.CharacterIdle; playerCharacterInfo.Update(false); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Player, playerCharacterInfo); if (characterInfoPanel.isShow()) { characterInfoPanel.Show(currentTarget); } } if (player.IsIdle() && playerCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterMove) { playerCharacterInfo.characterState = CharacterInfo.CharacterState.CharacterIdle; //обновляем список доступных целей после передвижения FindTargetList(player, enemyCharacters, targetList); // есть ли цели playerCharacterInfo.hasTarget = (targetList.Count > 0); playerCharacterInfo.Update(playerCharacterInfo.canFire); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Player, playerCharacterInfo); } if ((!playerCharacterInfo.canFire || (playerCharacterInfo.canFire && !playerCharacterInfo.hasTarget)) && !playerCharacterInfo.canMove && playerCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterIdle) { playerCharacterInfo.isEndTurn = true; } yield return(null); } // выключаем UI zoneSelectorPlayer.HideZone(); characterInfoPanel.Hide(); uiLevelScript.ShowMenu(false); player.SwitchSelect(false); player = null; playerCharacterInfo = null; if (currentTarget != null) { currentTarget.SwitchSelect(false); } } foreach (var _enemy in enemyCharacters) { enemy = _enemy.Key; cameraMoveScript.SetTarget(enemy.transform); if (enemy.IsDead()) { continue; } enemyCharacterInfo = _enemy.Value; enemyCharacterInfo.TurnReset(); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Enemy, enemyCharacterInfo); //FindTargetList(enemy.Key, playerCharacters, targetList); // ждём хода while (!enemyCharacterInfo.isEndTurn) { if (enemy.IsIdle() && enemyCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterFire) { enemyCharacterInfo.characterState = CharacterInfo.CharacterState.CharacterIdle; enemyCharacterInfo.Update(false); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Enemy, enemyCharacterInfo); } if (enemy.IsIdle() && enemyCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterMove) { enemyCharacterInfo.characterState = CharacterInfo.CharacterState.CharacterIdle; //обновляем список доступных целей после передвижения enemyCharacterInfo.Update(playerCharacterInfo.canFire); zoneSelectorPlayer.ShowZone(ZoneSelector.CharacterType.Enemy, enemyCharacterInfo); } if (!enemyCharacterInfo.canFire && !enemyCharacterInfo.canMove && enemyCharacterInfo.characterState == CharacterInfo.CharacterState.CharacterIdle) { enemyCharacterInfo.isEndTurn = true; } yield return(null); if (enemy.IsIdle() && !enemyCharacterInfo.isEndTurn) { findEnemyTurn(enemy); } } // выключаем UI zoneSelectorPlayer.HideZone(); enemy.SwitchSelect(false); enemy = null; enemyCharacterInfo = null; if (currentTarget != null) { currentTarget.SwitchSelect(false); } } } // аниматор танца List <Character> charList = (gameState == GameState.Lose) ? enemyCharacters.Keys.ToList() : playerCharacters.Keys.ToList(); foreach (Character character in charList) { if (!character.IsDead()) { character.Win(); } } // ждём 3 сек и выводим окно об окончании игры yield return(new WaitForSeconds(3.0f)); uiMenuWinLoseScript.ShowMenu(gameState == GameState.Win); }