Exemplo n.º 1
0
        private void StartNewOneSecondTurn(GameSession gameSession)
        {
            turn = gameSession.Turn;
            Logger.Debug($"[StartNewOneSecondTurn] {turn}");

            OnEndTurn?.Invoke(gameSession);

            foreach (var message in gameSession.GetCurrentTurnEvents())
            {
                if (message.IsPause)
                {
                    PauseSession();
                }

                if (message.Type == GameEventTypes.AnomalyFound)
                {
                    OnAnomalyFound?.Invoke(message, gameSession);
                }

                if (message.Type == GameEventTypes.OpenDialog)
                {
                    OnOpenDialog?.Invoke(message, gameSession);
                }

                // TODO: LAST - ADD NpcSpaceShipFound logic to Container and open window with message
                if (message.Type == GameEventTypes.NpcSpaceShipFound)
                {
                    OnFoundSpaceship?.Invoke(message, gameSession);
                }
            }
        }
Exemplo n.º 2
0
        public void GetDataFromServer()
        {
            if (_inProgress)
            {
                return;
            }

            _inProgress = true;

            var sessionData = new GameSessionRefresh().RequestGameSession(_gameServer, Environment.Session.Id);

            Logger.Info($"sessionData {sessionData.Turn} = {sessionData.CelestialObjects.Count} - {sessionData.GameEvents.Count}.");

            var gameSession = new GameSession(sessionData);

            Environment.RefreshGameSession(gameSession);

            OnEndTurn?.Invoke(Environment);

            if (sessionData.IsPause)
            {
                _inProgress = false;
                return;
            }

            // Send to server all commands from previous turn.
            CommandsSending();

            Logger.Info($"sessionData {Environment.Session.Turn} = {Environment.Session.CelestialObjects.Count} - {Environment.Session.GameEvents.Count}.");

            ExecuteGameEvents(Environment.Session);

            _inProgress = false;
        }
Exemplo n.º 3
0
    public void EndTurn(Piece movedPiece, int x1, int y1, int x2, int y2)
    {
        MovePieces?.Invoke(movedPiece, x2, y2);
        CheckForKing(movedPiece, x1, y2);

        // Our message
        if (Client != null && Client.isHost == IsWhiteTurn)
        {
            string msg = "CMOV|";
            msg += x1 + "|";
            msg += y1 + "|";
            msg += x2 + "|";
            msg += y2.ToString();
            Client.Send(msg);
        }

        // Сканировать на возможный ход (если убили). Для продолжения хода.
        if (HasForcedMoves(x2, y2) && HasKilled)
        {
            HasKilled = false;
            return;
        }

        HasKilled   = false;
        IsWhiteTurn = !IsWhiteTurn;
        OnEndTurn?.Invoke(IsWhiteTurn, Client);
        CheckVictory();
    }
Exemplo n.º 4
0
        public void StartNewGameSession()
        {
            _ui.StartNewGameSession();

            _gameSession = Initialization();

            OnBattleInitialization?.Invoke(_gameSession.DeepClone());
            OnEndTurn?.Invoke(_gameSession.DeepClone());
        }
    /// <summary>
    /// ターン終了時に呼ぶ
    /// </summary>
    public static void EndTurn()
    {
        // ターンを開始せずに終了した場合はまず強制的にターンを開始する
        if (!m_isTurnStarted)
        {
            BeginTurn();
        }

        OnEndTurn?.Invoke();
        m_isTurnStarted = false;
    }
Exemplo n.º 6
0
    public void EndTurn()
    {
        timeWaited = timeTurn;

        if (!InfinitTurn)
        {
            turnCounter++;
        }

        OnEndTurn?.Invoke();
    }
Exemplo n.º 7
0
 /// <summary>
 /// what to do when a player turn ends
 /// </summary>
 public void EndTurn()
 {
     currentstate = m_fsm.Current.ToString();
     GameManager.Instance.lastattacker = GameManager.Instance.activeplayer;
     if (m_fsm.ChangeState(PlayerStates.ENDTURN))
     {
         // Debug.WriteLine("I'M ENDING MY TURN");
         onEndTurn.Invoke();
     }
     else
     {
         Debug.WriteLine("SOMETHING WENT WRONG :(");
     }
 }
 public void EndTurn()
 {
     PlayerSkillEffectStatuses.ForEach(x => x.remainedRound--);
     PlayerSkillEffectStatuses.RemoveAll(x => x.remainedRound < 0);
     for (int i = 0; i < Monsters.Count; i++)
     {
         MonstersSkillEffectStatuses[i].ForEach(effector => effector.remainedRound--);
         MonstersSkillEffectStatuses[i].RemoveAll(effector =>
         {
             effector.effector.End(MonsterBattleFactors[i]);
             return(effector.remainedRound < 0);
         });
     }
     OnEndTurn?.Invoke();
     StartTurn();
 }
Exemplo n.º 9
0
    IEnumerator AIFSM()
    {
        currentAIPhase = AIPhase.Idle;
        if (!nextRoomInvestigate)
        {
            nextRoomInvestigate = GetNextRoom();
        }
        if ((!nextDoorTarget))
        {
            nextDoorTarget = GetNextDoor();
        }
        //Debug.Log($"it's my turn {characterRef.ColorName} with {nextRoomInvestigate.RoomName}");
        yield return(StartCoroutine(IAMove()));

        yield return(StartCoroutine(IAEndMove()));

        yield return(StartCoroutine(IASuggest()));

        OnEndTurn?.Invoke();
    }
Exemplo n.º 10
0
 public void EndTurn()
 {
     state.EndTurn(this);
     OnEndTurn?.Invoke();
 }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        if (inputArray[1] == "Defend")
        {
            defenseP1 = damageMitigation;
        }

        if (inputArray[2] == "Defend")
        {
            defenseP2 = damageMitigation;
        }

        if (started && nextRound < Time.time)
        {
            switch (inputArray[1])
            {
            case "Attack":
                p2Health.TakeDamage(damageAttack - defenseP2);
                p1.Attack();
                break;

            case "Defend":
                p1.Defend();
                break;

            case "Charge":
                p1.Charge();
                //p1Energy.addEnergy();
                break;

            case "Evade":
                p1.Evade();
                break;

            default:
                //idle;
                break;
            }

            switch (inputArray[2])
            {
            case "Attack":
                p1Health.TakeDamage(damageAttack - defenseP1);
                p2.Attack();
                break;

            case "Defend":
                p2.Defend();
                break;

            case "Charge":
                p2.Charge();
                //p2Energy.addEnergy();
                break;

            case "Evade":
                p2.Evade();
                break;

            default:
                //idle;
                break;
            }

            defenseP1 = 0;
            defenseP2 = 0;

            Debug.Log($"p1 action:{inputArray[1]}, p2 action:{inputArray[2]}");

            inputArray[1] = "";
            inputArray[2] = "";

            /*
             * if (turnTime > minTurnTime)
             *  turnTime -= decreaseRate;
             */
            lastRound = nextRound;
            nextRound = Time.time + turnTime;

            if (OnEndTurn != null)
            {
                OnEndTurn.Invoke();
            }
        }

        UpdateTimeCounter();
    }