コード例 #1
0
ファイル: GameManager.cs プロジェクト: jacko12549/EvoS
        private void HandleGameLoaded()
        {
            Log.Print(LogType.Debug, "All players loaded");

            GameFlowData.gameState = GameState.SpawningPlayers;

            foreach (GameObject netObj in NetworkGameObjects.Values)
            {
                NetworkIdentity networkIdentity = netObj.GetComponent <NetworkIdentity>();
                networkIdentity.UNetUpdate();
            }
            foreach (var playerInfo in TeamPlayerInfo)
            {
                SpawnPlayerCharacter(playerInfo);
                // actors get synclist updates for currentCardIds and modifiedStats
            }

            // check for owning player
            // TODO
            lock (this.GamePlayersByPlayerId) {
                foreach ((int playerID, GamePlayer player) in this.GamePlayersByPlayerId)
                {
                    foreach (ActorData actor in GameFlowData.GetAllActorsForPlayer(playerID))
                    {
                        player.Connection.Send(4, new OwnerMessage
                        {
                            netId = actor.netId,
                            playerControllerId = (short)player.PlayerId
                        });
                    }
                }
            }



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

                // Just send the play to an arbitrary location for now
                actorTeamSensitiveData.CallRpcMovement(GameEventManager.EventType.Invalid,
                                                       new GridPosProp(11, 10, 6), new GridPosProp(11, 10, 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 (ActorData actor in GameFlowData.GetActors())
            {
                var turnSm = actor.gameObject.GetComponent <ActorTurnSM>();
                turnSm.CallRpcTurnMessage(TurnMessage.TURN_START, 0);
            }
            BarrierManager.CallRpcUpdateBarriers();
            GameFlowData.CallRpcUpdateTimeRemaining(21);

            PrintAllNetworkGameObjects();
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: LimitlessRegret/EvoS
        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);
        }