public override void SceneLoadLocalBegin(string scene, Bolt.IProtocolToken token) { SceneChangeToken sceneChange = (SceneChangeToken)token; if (sceneChange != null) { Debug.Log("loading from scene: " + sceneChange.SceneFrom); Debug.Log("loading to scene: " + sceneChange.SceneTo); Debug.Log("reason: " + sceneChange.Reason); } }
/// <summary> /// Called when a local scene change finishes. /// </summary> /// <param name="map"></param> /// <param name="token"></param> public override void SceneLoadLocalDone(string map, Bolt.IProtocolToken token) { SceneChangeToken sceneChange = (SceneChangeToken)token; if (sceneChange != null) { Debug.Log("loading from scene: " + sceneChange.SceneFrom); Debug.Log("loading to scene: " + sceneChange.SceneTo); Debug.Log("reason: " + sceneChange.Reason); if (sceneChange.Reason == "StartGame") { if (BoltNetwork.isClient) { GameplayStartedEvent evnt = GameplayStartedEvent.Create(Bolt.GlobalTargets.OnlyServer); CredentialToken credentials = ClientManager.Instance.Credentials; evnt.CredentialsToken = credentials; evnt.Send(); } else { // we're the server /* * BoltEntity wizard = GameManager.Instance.SpawnWizard(ClientManager.Instance.Credentials); * wizard.GetComponent<WizardController>().Init(); * wizard.TakeControl(); * * BoltEntity entropyManager = GameManager.Instance.SpawnEntropyManager(); * * entropyManager.TakeControl(); */ // enable the start of setup for the game GameManager.Instance.StartSetup(); } ServerManager.Instance.InitUserStats(); //GameTypeManager.Instance.RoundStart(); //StartMenuGUIManager.Instance.FSM.Transition("Init"); GameGUIManager.Instance.BoltLoadGameScene(); } } }
/// <summary> /// start game session /// NOTE: ONLY CALLED FROM SERVER /// </summary> public void StartGame() { // decide player colors and send to all connected clients int count = 0; foreach (CredentialToken player in ServerManager.Instance.ConnectedUsers) { SerializedColor playerColor = new SerializedColor(possibleColors[count]); PlayerColors[player] = playerColor; count++; } BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, PlayerColors); SetColors setColors = SetColors.Create(Bolt.GlobalTargets.Others); setColors.BinaryData = ms.ToArray(); setColors.Send(); // = SendConnectedClients.Create(connection); //sendClients.BinaryData = ms.ToArray(); //sendClients.Send(); SceneChangeToken token = new SceneChangeToken(); token.Reason = "StartGame"; token.SceneTo = MainGameScene; token.SceneFrom = Application.loadedLevelName; Debug.Log("Starting game from gamemanager..."); //Instantiate(EndGameManagerPrefab); //Instantiate(GameTypeManagerPrefab); BoltNetwork.LoadScene("Game", token); }