示例#1
0
        private void CallToNetwork()
        {
            NetworkCaller.Instance.GetAllSkins((skins, unlocks) =>
            {
                var currentSkin = NetworkCaller.Instance.PlayerData.SkinId;
                foreach (var skinData in skins)
                {
                    var skin            = _skinSetting.GetSkinById(skinData.Id);
                    var skinItem        = Instantiate(_characterItem, _characterList, false);
                    skinItem.Avatar     = skin.skinAvatar;
                    skinItem.IsSelected = skin.id == currentSkin;
                    bool isLocked;
                    skinItem.Id = skin.id;
                    if (skinData.UnlockId <= 0)
                    {
                        isLocked = false;
                    }
                    else
                    {
                        var unlock = unlocks.Find(x => x.Id == skinData.UnlockId);
                        isLocked   = !unlock.IsUnlocked();
                    }


                    skinItem.IsLocked = isLocked;

                    skinItem.OnSelected += () =>
                    {
                        if (!skinItem.IsLocked)
                        {
                            _characterInfoPanel.SkinData = skinData;
                            _characterInfoPanel.SetAvatar(skin.skinAvatar);
                            _characterInfoPanel.Show();
                        }
                        else
                        {
                            var unlock = unlocks.Find(x => x.Id == skinData.UnlockId);
                            _missionPanel.SetMission(unlock.Mission);
                            _missionPanel.Show();
                        }
                    };

                    _characterItemControllers.Add(skinItem);
                }
                _loadingLayer.SetActive(false);
            }, () =>
            {
                NativeDialogManager.Instance.ShowConnectionErrorDialog(CallToNetwork, () =>
                {
                    SceneManager.LoadScene("HomeScene");
                });
            });
        }
示例#2
0
    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);
    }