Beispiel #1
0
        private void OnAssetsLoadedNotification(GamePlayer player, AssetsLoadedNotification msg)
        {
            player.Connection.Send(56, new ReconnectReplayStatus {
                WithinReconnectReplay = true
            });
            player.Connection.Send(54, new SpawningObjectsNotification
            {
                PlayerId             = player.PlayerId,
                SpawnableObjectCount = NetworkGameObjects.Count
            });
            player.Connection.Send(12, new ObjectSpawnFinishedMessage {
                state = 0
            });

            foreach (GameObject netObj in NetworkGameObjects.Values)
            {
                NetworkIdentity networkIdentityComponent = netObj.GetComponent <NetworkIdentity>();
                networkIdentityComponent.AddObserver(player.Connection);
            }

            player.Connection.Send(56, new ReconnectReplayStatus {
                WithinReconnectReplay = false
            });
            player.Connection.Send(12, new ObjectSpawnFinishedMessage {
                state = 1
            });
            player.IsLoading = false;


            lock (AllPlayersLoadedLock) {
                bool allLoaded = true;
                foreach (LobbyPlayerInfo playerInfo in TeamInfo.TeamPlayerInfo)
                {
                    if (player.PlayerId == playerInfo.PlayerId)
                    {
                        playerInfo.ReadyState = ReadyState.Ready;
                    }

                    if (playerInfo.ReadyState != ReadyState.Ready)
                    {
                        allLoaded = false;
                        Log.Print(LogType.Network, $"{playerInfo.Handle} not loaded");
                    }
                }

                if (allLoaded)
                {
                    Log.Print(LogType.Debug, "All Player loaded successfully");
                    SetGameStatus(GameStatus.Loaded);
                }
                else
                {
                    Log.Print(LogType.Debug, "Not All Player loaded");
                }
            }
        }
Beispiel #2
0
        private void OnAssetsLoadedNotification(GamePlayer player, AssetsLoadedNotification msg)
        {
            player.Connection.Send(56, new ReconnectReplayStatus {
                WithinReconnectReplay = true
            });
            player.Connection.Send(54, new SpawningObjectsNotification
            {
                PlayerId             = player.LoginRequest.PlayerId,
                SpawnableObjectCount = NetObjects.Count
            });

            // ObjectSpawnFinishedMessage 0 instructs the client to hold off on calling OnStartClient
            // until we send ObjectSpawnFinishedMessage 1
            player.Connection.Send(12, new ObjectSpawnFinishedMessage {
                state = 0
            });

            foreach (var netObj in NetObjects.Values)
            {
                var netIdent = netObj.GetComponent <NetworkIdentity>();
                netIdent.AddObserver(player.Connection);
            }

            player.Connection.Send(56, new ReconnectReplayStatus {
                WithinReconnectReplay = false
            });
            player.Connection.Send(12, new ObjectSpawnFinishedMessage {
                state = 1
            });

            // Should wait for all players to have reached this point

            GameFlowData.gameState = GameState.SpawningPlayers;
            foreach (var netObj in NetObjects.Values)
            {
                var netIdent = netObj.GetComponent <NetworkIdentity>();
                netIdent.UNetUpdate();
            }
            foreach (var playerInfo in TeamInfo.TeamPlayerInfo)
            {
                SpawnPlayerCharacter(playerInfo);
                // actors get synclist updates for currentCardIds and modifiedStats
            }

            // check for owning player
            foreach (var actor in GameFlowData.GetAllActorsForPlayer(0))
            {
                player.Connection.Send(4, new OwnerMessage
                {
                    netId = actor.netId,
                    playerControllerId = 0 // ?
                });
            }

            // The following should be sent after all players have loaded
            foreach (var netObj in NetObjects.Values)
            {
                var atsd = netObj.GetComponent <ActorTeamSensitiveData>();
                if (atsd == null)
                {
                    continue;
                }

                // Just send the play to an arbitrary location for now
                atsd.CallRpcMovement(GameEventManager.EventType.Invalid,
                                     new GridPosProp(5, 5, 6), new GridPosProp(5, 5, 5),
                                     null, ActorData.MovementType.Teleport, false, false);
            }

            GameFlowData.gameState = GameState.StartingGame;
            UpdateAllNetObjs();

            GameFlowData.gameState = GameState.Deployment;
            UpdateAllNetObjs();

            GameFlowData.gameState                                = GameState.BothTeams_Decision;
            GameFlowData.Networkm_currentTurn                     = 1;
            GameFlowData.Networkm_willEnterTimebankMode           = true;
            GameFlowData.Networkm_timeRemainingInDecisionOverflow = 5;
            UpdateAllNetObjs();

            GameFlow.CallRpcSetMatchTime(0);
            // kRpcRpcApplyAbilityModById
            foreach (var actor in GameFlowData.GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();
                turnSm.CallRpcTurnMessage(TurnMessage.TURN_START, 0);
            }
            BarrierManager.CallRpcUpdateBarriers();
            GameFlowData.CallRpcUpdateTimeRemaining(21);
        }