Пример #1
0
        public void Start()
        {
            instance = this;

            // TODO Look into state usage on server side
            // Creating Teardown because GameFlowData checks if it isn't the current state, and null == null
            AppState_GameTeardown.Create();

            Log.Info("Starting Server...");
            UIFrontendLoadingScreen.Get().StartDisplayError("Starting Server...");
            NetworkServer.useWebSockets = true;
            NetworkServer.Listen(Port);

            // Regiser Network Handlers
            GameMessageManager.RegisterAllHandlers();

            // Load map bundle
            AssetBundle MapsBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, @"Bundles\scenes\maps.bundle"));

            GameObject artemisServerObject = new GameObject("ArtemisServerComponent");

            artemisServerComponent = artemisServerObject.AddComponent <ArtemisServerComponent>();
            GameObject.DontDestroyOnLoad(artemisServerObject);

            WebsocketManager.Init();
            ClientGamePrefabInstantiatorFix();
        }
Пример #2
0
        private void LoadMap()
        {
            string map = GameInfo.GameConfig.Map.ToString();

            UIFrontendLoadingScreen.Get().StartDisplayError("Loading " + map);
            SceneManager.LoadScene(map, LoadSceneMode.Single);
        }
Пример #3
0
 public void OnTurnTick()
 {
     UISounds.GetUISounds().Play("ui_notification_turn_start");
     UILoadingScreenPanel.Get()?.SetVisible(false);          // was no `?`
     if (UIFrontendLoadingScreen.Get().gameObject.activeSelf)
     {
         UIFrontendLoadingScreen.Get().StartDisplayFadeOut();
     }
 }
Пример #4
0
 private WebsocketManager()
 {
     UIFrontendLoadingScreen.Get().StartDisplayError("trying to connect to bridge server ", "at address: " + BridgeServerAddress);
     ws            = new WebSocketSharp.WebSocket(BridgeServerAddress);
     ws.OnMessage += Ws_OnMessage;
     ws.OnError   += Ws_OnError;
     ws.OnOpen    += Ws_OnOpen;
     ws.Connect();
 }
Пример #5
0
        private void Ws_OnOpen(object sender, EventArgs e)
        {
            Log.Info("Successfully connected to lobby's bridge server");
            UIFrontendLoadingScreen.Get().StartDisplayError("connected to bridge server");
            MemoryStream stream = new MemoryStream();

            stream.WriteByte((byte)BridgeMessageType.InitialConfig);
            string addressAndPort = Artemis.ArtemisServer.Address + ":" + Artemis.ArtemisServer.Port;

            stream.Write(GetByteArray(addressAndPort), 0, addressAndPort.Length);

            byte[] buffer = stream.ToArray();
            ws.Send(buffer);
        }
Пример #6
0
        public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            Log.Info($"Loaded scene map ({mode}): {scene.name}");
            UIFrontendLoadingScreen.Get().StartDisplayError($"{scene.name} loaded");

            // Disable VisualsLoader so we dont go to the enviroment scene
            if (VisualsLoader.Get() != null)
            {
                VisualsLoader.Get().enabled = false;  // Breaks client UI (at least) if not disabled
            }

            // Avoid creating characters two times because OnSceneLoaded() gets called two times because VisualsLoader changes the current scene...
            if (this.IsMapLoaded)
            {
                Log.Error("Exiting on scene loaded, already loaded");
                return;
            }
            IsMapLoaded = true;
            InitializeGame(scene);
        }