// выбран интерактивный объекет, надо как-то отреагировать чтоли... public bool MoveOnSelectebleObject(GameObject selObject) { if (playerCharacterInfo != null && !playerCharacterInfo.isEndTurn) { // персонаж? Character selCharacter = selObject.transform.gameObject.GetComponentInParent <Character>(); if (selCharacter != null) { // чужой? может быть выбран как цель if (enemyCharacters.ContainsKey(selCharacter) && !selCharacter.IsDead()) { // подсвечиваем if (targetList.Contains(enemyCharacters[selCharacter])) { selCharacter.SwitchSelect(true, selectOutlineTargetColor, selectOutlineWith); } else { selCharacter.SwitchSelect(true, selectOutlineColor, selectOutlineWith); } zoneSelectorTarget.ShowZone(ZoneSelector.CharacterType.Target, enemyCharacters[selCharacter]); characterInfoPanel.Show(selCharacter); return(true); } } } return(false); }
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); }