예제 #1
0
        private void DrawablePortStateManager_ProcessMessage(object sender, NetworkMessageContainer message)
        {
            switch (message.MessageType)
            {
            case MessageTypes.PortDockApproval:
            {
                Clear();
                var data = message.MessageData as PortEntryData;

                // TODO: Implement reading this data, though much of this is used purely in the UI.

                break;
            }

            case MessageTypes.ClientLoginSuccess:
            {
                var data = message.MessageData as MessageClientLogin;
                if (data == null)
                {
                    ClientLogger.LogError("Could not deserialize MessageClientLogin: " + message.MessageData);
                    return;
                }

                _clientPlayerInfoManager.PlayerID     = data.PlayerInfo.PlayerID;
                _clientPlayerInfoManager.ActiveShipID = data.PlayerInfo.ActiveShipID;

                break;
            }
            }
        }
예제 #2
0
        protected async Task OnBtnLoginClicked()
        {
            try {
                //var eUser = await httpClient.PostJsonAsync<EUser>(SDefines.BaseURL + "/api/v1/SUsers/Authenticate", e);
                var eUser = await usersService.Authenticate(e);

                if (eUser != null)
                {
                    NavigationManager.NavigateTo(ClientDefines.RouteDashboard);
                }
            } catch (Exception ex) {
                ClientLogger.LogError(ex);
            }
        }
예제 #3
0
        protected override void _playableStateManager_MessageReceived(object sender, NetworkMessageContainer e)
        {
            base._playableStateManager_MessageReceived(sender, e);

            switch (e.MessageType)
            {
            case MessageTypes.PlanetLandApproval:
            {
                var data = e.MessageData as PlanetEntryData;
                if (data == null)
                {
                    ClientLogger.LogError("Could not deserialize PlanetEntryData: " + e.MessageData);
                    return;
                }

                ReadIncomingPlanet(data);

                _targetingService.RegisterObject(_clientShipManager.PlayerShip);
                break;
            }

            case MessageTypes.ColonyCaptured:
            {
                var data = e.MessageData as MessageColonyCaptured;
                if (data == null)
                {
                    ClientLogger.LogError("Could not deserialize MessageColonyCaptured: " + e.MessageData);
                    return;
                }

                ColonyCaptured(data);
                break;
            }

            case MessageTypes.ColonizeRequestApproval:
            {
                var data = e.MessageData as MessageColonizeRequestApproval;
                if (data == null)
                {
                    ClientLogger.LogError("Could not deserialize MessageColonizeRequestApproval: " + e.MessageData);
                    return;
                }

                ColonizeRequestApproval(data);
                break;
            }
            }
        }
예제 #4
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 private static void Main(string[] args)
 {
     try
     {
         using (var game = new WindowsMain(ClientEnvironmentType.Development))
         {
             game.Run();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
         ClientLogger.LogError(e);
     }
 }
예제 #5
0
        /// <summary>
        /// Reads the incoming system from message.
        /// Todo: Kill me please.
        /// </summary>
        /// <param name="msg">The lidgren networking message.</param>
        public SystemEntryData ReadIncomingSystem(SystemEntryData data)
        {
            if (data == null)
            {
                ClientLogger.LogError("Trying to read incoming system but received null data.");
                return(null);
            }

            SystemName = data.AreaName;
            _clientShipManager.CurrentAreaId = data.Id;
            _spaceManager.InitializeSun(data.StarData.Radius, data.StarData.Density, data.StarData.InnerGravityStrength, data.StarData.OuterGravityStrength, data.StarData.Type);
            _spaceManager.CreateBorderAndSunGravity(data.AreaSize);

            _targetingService.DisableTargetSetting();

            #region Planet Data

            foreach (PlanetData_SystemView p in data.Planets)
            {
                _spaceManager.CreatePlanet(p.Distance, p.MaxTrip, p.PlanetType, p.CurrentTrip, p.Scale, p.Id, data.Id, false);
                _physicsManager.World.ProcessChanges();
            }


            #endregion

            #region Moon Data

            foreach (MoonData_SystemView p in data.Moons)
            {
                _spaceManager.CreatePlanet(p.Distance, p.MaxTrip, p.PlanetType, p.CurrentTrip, p.Scale, p.Id, p.IDToOrbit, true);
                _physicsManager.World.ProcessChanges();
            }
            #endregion

            #region Warphole Data

            foreach (WarpholeData w in data.Warpholes)
            {
                _spaceManager.CreateWarphole(w.XPos, w.YPos, w.WarpIndex, w.DestinationAreaID);
            }

            #endregion

            #region Structure Data

            foreach (StructureData s in data.Structures)
            {
                var structure = InstantiateStructure(s);
            }

            #endregion

            #region Port Data
            foreach (PortData_SystemView p in data.Ports)
            {
                _spaceManager.CreatePort(p.Distance, p.MaxTrip, PlanetTypes.Port, p.CurrentTrip, 1, p.Id, data.Id, p.IsMoon);
            }

            #endregion

            _floatyAreaObjectManager.InstantiateFloatyAreaObjects(data.FloatyAreaObjects);
            if (_clientShipManager.PlayerShip != null)
            {
                _clientShipManager.RecreatePlayerShip(_physicsManager.World);
                _clientShipManager.PlayerShip.Position = new Vector2(data.NewPlayerXPos, data.NewPlayerYPos);
            }
            _clientShipManager.areaSecurityLevel = data.SecurityLevel;

            foreach (var s in data.Ships)
            {
                MessageReader.InstantiateShip(s, _physicsManager.World, _clientShipManager, false);
            }

            _targetingService.EnableTargetSetting();

            _areaDataReceived = true;

            return(data);
        }