Exemple #1
0
        private static void HandleLoginRequest(NetworkMessage message)
        {
            // TODO client will send login request again in case of connection timeout
            Log.Info("LOGIN REQUEST");
            GameManager.LoginRequest loginRequest = message.ReadMessage <GameManager.LoginRequest>();

            Player player = GameFlow.Get().GetPlayerFromConnectionId(message.conn.connectionId);

            if (player.m_connectionId != message.conn.connectionId)
            {
                Log.Info($"New player AccountID:{loginRequest.AccountId} PlayerId:{loginRequest.PlayerId} SessionToken:{loginRequest.SessionToken}");
                player = new Player(message.conn, Convert.ToInt64(loginRequest.AccountId));  // PATCH internal -> public Player::Player

                GameFlow.Get().playerDetails[player] = new PlayerDetails(PlayerGameAccountType.Human)
                {
                    m_accountId    = player.m_accountId,
                    m_disconnected = false,
                    m_handle       = "Connecting Player",
                    m_idleTurns    = 0,
                    m_team         = Team.Invalid
                };
                Log.Info($"Registered AccountID:{player.m_accountId}");
            }

            GameManager.LoginResponse loginResponse = new GameManager.LoginResponse()
            {
                Reconnecting          = false,
                Success               = true,
                LastReceivedMsgSeqNum = message.conn.lastMessageIncomingSeqNum
            };

            message.conn.Send((short)MyMsgType.LoginResponse, loginResponse);
        }
        public void OnClientResolutionPhaseCompleted(NetworkConnection conn, GameMessageManager.ClientResolutionPhaseCompleted msg)
        {
            Player    player = GameFlow.Get().GetPlayerFromConnectionId(conn.connectionId);
            ActorData actor  = GameFlowData.Get().FindActorByActorIndex(msg.ActorIndex);

            if (actor.gameObject.GetComponent <PlayerData>().m_player.m_connectionId != conn.connectionId)
            {
                Log.Warning($"OnClientResolutionPhaseCompleted: {actor.DisplayName} does not belong to player {player.m_accountId}!");
            }

            TheatricsPendingClients.Remove(player.m_accountId);
        }
Exemple #3
0
        private IEnumerator PrepareForGame()
        {
            Log.Info("Preparing for game");

            //GameFlowData.Get().enabled = true;
            GameFlowData.Get().gameState = GameState.Deployment;
            yield return(new WaitForSeconds(5));

            GameFlow.Get().CallRpcSetMatchTime(0);
            GameFlowData.Get().Networkm_currentTurn = 0;
            Log.Info("Done preparing for game");
        }
Exemple #4
0
        public void ClientLoaded(NetworkConnection connection, int playerIndex)
        {
            Player player = GameFlow.Get().GetPlayerFromConnectionId(connection.connectionId);

            foreach (ActorData playerActor in GameFlowData.Get().GetAllActorsForPlayer(playerIndex))
            {
                GameObject character = playerActor.gameObject;
                character.GetComponent <PlayerData>().m_player = player;  // PATCH internal -> public PlayerData::m_player
                GameFlow.Get().playerDetails[player]?.m_gameObjects.Add(character);
                Log.Info($"Registered player with account id {player.m_accountId} as player {playerIndex} ({character.name})");
                NetworkServer.AddPlayerForConnection(connection, character, 0);
            }
        }
Exemple #5
0
        internal void OnCastAbility(NetworkConnection conn, int casterIndex, int actionTypeInt, List <AbilityTarget> targets)
        {
            Player      player = GameFlow.Get().GetPlayerFromConnectionId(conn.connectionId);
            ActorData   actor  = GameFlowData.Get().FindActorByActorIndex(casterIndex);
            ActorTurnSM turnSm = actor.gameObject.GetComponent <ActorTurnSM>();

            AbilityData.ActionType actionType = (AbilityData.ActionType)actionTypeInt;

            if (actor.gameObject.GetComponent <PlayerData>().m_player.m_connectionId != conn.connectionId)
            {
                Log.Error($"Illegal OnCastAbility: {actor.DisplayName} does not belong to player {player.m_accountId}!");
                turnSm.CallRpcTurnMessage((int)TurnMessage.ABILITY_REQUEST_REJECTED, 0);
                ClearAbilityRequest(actor, actionType);
                return;
            }

            Log.Info($"OnCastAbility {actor.DisplayName} {actionType} ({targets.Count} targets)");

            // TODO AbilityData.ValidateAbilityOnTarget
            turnSm.CallRpcTurnMessage((int)TurnMessage.ABILITY_REQUEST_ACCEPTED, 0);
            SetAbilityRequest(actor, actionType, targets);

            ArtemisServerMovementManager.Get().UpdatePlayerRemainingMovement(actor);
        }