示例#1
0
 void playerEntityManager_NeedToShowInventory(object sender, InventoryEventArgs e)
 {
     if (StatesManager.CurrentState.Name != "Inventory")
     {
         StatesManager.ActivateGameStateAsync("Inventory", true);
     }
 }
示例#2
0
        void MenuLogoutPressed(object sender, EventArgs e)
        {
            ClientSettings.Current.Settings.Token = null;
            ClientSettings.Current.Save();

            StatesManager.ActivateGameStateAsync("Login");
        }
示例#3
0
        void MenuContinuePressed(object sender, EventArgs e)
        {
            var inputManager = _ioc.Get <InputsManager>();

            inputManager.MouseManager.MouseCapture = _captureMouse;

            StatesManager.ActivateGameStateAsync("Gameplay");
        }
示例#4
0
        void MenuExitPressed(object sender, EventArgs e)
        {
            var vars = _ioc.Get <RealmRuntimeVariables>();

            vars.DisposeGameComponents = true;
            vars.MessageOnExit         = null;

            WithPreservePreviousStates = false;
            StatesManager.ActivateGameStateAsync("MainMenu");
        }
示例#5
0
 void serverComponent_ConnectionStausChanged(object sender, ServerConnectionStatusEventArgs e)
 {
     if (e.Status == TcpConnectionStatus.Disconnected && e.Final)
     {
         var serverComponent = _ioc.Get <ServerComponent>();
         var guiManager      = _ioc.Get <GuiManager>();
         logger.Info("Disconnected from the server. Error text: {0}", serverComponent.LastErrorText);
         guiManager.MessageBox("Can't connect to the server. " + serverComponent.LastErrorText, "error");
         StatesManager.ActivateGameStateAsync("MainMenu");
     }
 }
示例#6
0
        //All chunks have been created on the client (They can be rendered)
        void worldChunks_LoadComplete(object sender, EventArgs e)
        {
            _ioc.Get <IWorldChunks>().LoadComplete -= worldChunks_LoadComplete;
            StatesManager.ActivateGameStateAsync("Gameplay");

            //Say to server that the loading phase is finished inside the client
            _ioc.Get <ServerComponent>().EnterTheWorld();

            //Start a client chunk resync phase.
            _ioc.Get <IWorldChunks>().ResyncClientChunks();
        }
示例#7
0
        void MenuMultiplayerPressed(object sender, EventArgs e)
        {
            var guiManager = _ioc.Get <GuiManager>();
            var webApi     = _ioc.Get <ClientWebApi>();

            if (string.IsNullOrEmpty(webApi.Token))
            {
                guiManager.MessageBox("Server authorization was failed. Did you confirm your email? (check the spam folder). You will unable to play multiplayer without confirmation.", "error");
                return;
            }

            _vars.SinglePlayer = false;
            StatesManager.ActivateGameStateAsync("SelectServer");
        }
        void SelectionConnectPressed(object sender, EventArgs e)
        {
            var selection = _iocContainer.Get <ServerSelectionComponent>();
            var vars      = _iocContainer.Get <RealmRuntimeVariables>();

            vars.SinglePlayer = false;

            var item = ServerList[selection.List.SelectedItems[0]];

            vars.CurrentServerAddress      = item.ServerAddress + ":" + item.Port;
            vars.CurrentServerLocalAddress = string.IsNullOrEmpty(item.LocalAddress) ? null : item.LocalAddress + ":" + item.Port;

            logger.Info("Connecting to {0} {1}", item.ServerName, item.ServerAddress);

            StatesManager.ActivateGameStateAsync("LoadingGame");
        }
示例#9
0
        private void CheckForLoginStartUp()
        {
            if (_systemComponentInitialized && _slideShowFinished)
            {
                StatesManager.DeactivateSwitchComponent = true;
                if (StatesManager.ActivateGameState("SystemComponents", true))
                {
                    StatesManager.ForceCurrentState(this);

                    StatesManager.DeactivateSwitchComponent = false;

                    while (string.IsNullOrEmpty(_nextState))
                    {
                        Thread.Sleep(100);
                    }

                    StatesManager.ActivateGameStateAsync(_nextState);
                }
                else
                {
                    logger.Error("Initialization of startUp synchro problem !");
                }
            }
        }
示例#10
0
 void EditorBackPressed(object sender, EventArgs e)
 {
     StatesManager.ActivateGameStateAsync("MainMenu");
 }
示例#11
0
 void singlePlayer_StartingGameRequested(object sender, EventArgs e)
 {
     _vars.SinglePlayer = true;
     StatesManager.ActivateGameStateAsync("LoadingGame");
 }
示例#12
0
 void MenuEditorPressed(object sender, EventArgs e)
 {
     StatesManager.ActivateGameStateAsync("Editor");
 }
示例#13
0
 void settings_BackPressed(object sender, EventArgs e)
 {
     StatesManager.ActivateGameStateAsync(this.PreviousGameState);
 }
示例#14
0
 void MenuSettingsButtonPressed(object sender, EventArgs e)
 {
     StatesManager.ActivateGameStateAsync("Settings");
 }
示例#15
0
        void ActionsManager_KeyboardAction(object sender, ActionsManagerEventArgs e)
        {
            var guiManager = _ioc.Get <GuiManager>();

            if (StatesManager.CurrentState.Name == "Settings")
            {
                return;
            }

            if (e.Action.ActionId == Actions.EngineExit)
            {
                if (StatesManager.CurrentState.Name == "Gameplay")
                {
                    StatesManager.ActivateGameStateAsync("InGameMenu", true);
                }
                else
                {
                    StatesManager.ActivateGameStateAsync("Gameplay");
                }
                return;
            }

            if (StatesManager.CurrentState.Name == "InGameMenu")
            {
                return;
            }

            if (guiManager.ScreenIsLocked == false)
            {
                switch (e.Action.ActionId)
                {
                case UtopiaActions.OpenInventory:
                    if (StatesManager.CurrentState.Name != "Inventory")
                    {
                        StatesManager.ActivateGameStateAsync("Inventory", true);
                    }
                    else
                    {
                        StatesManager.ActivateGameStateAsync("Gameplay");
                    }
                    break;

                case UtopiaActions.OpenCrafting:
                    if (StatesManager.CurrentState.Name != "Crafting")
                    {
                        StatesManager.ActivateGameStateAsync("Crafting", true);
                    }
                    else
                    {
                        StatesManager.ActivateGameStateAsync("Gameplay");
                    }
                    break;

                case UtopiaActions.SelectCharacter:
                    if (StatesManager.CurrentState.Name != "CharSelection")
                    {
                        StatesManager.ActivateGameStateAsync("CharSelection", true);
                    }
                    else
                    {
                        StatesManager.ActivateGameStateAsync("Gameplay");
                    }
                    break;

                default:
                    if (e.Action.ActionId == UtopiaActions.EntityUse && StatesManager.CurrentState.Name == "Inventory")
                    {
                        StatesManager.ActivateGameStateAsync("Gameplay");
                    }
                    break;
                }
            }
        }
 void SelectionButton_Clicked(object sender, System.EventArgs e)
 {
     StatesManager.ActivateGameStateAsync("Gameplay");
 }
示例#17
0
 void MenuSinglePlayerPressed(object sender, EventArgs e)
 {
     _vars.SinglePlayer = true;
     StatesManager.ActivateGameStateAsync("SinglePlayerMenu");
 }
示例#18
0
        private void GameplayComponentsCreation()
        {
            _vars.DisposeGameComponents = true;

            var clientSideworldParam = _ioc.Get <ServerComponent>().GameInformations.WorldParameter;

            var clientFactory = _ioc.Get <EntityFactory>("Client");

            clientFactory.Config = clientSideworldParam.Configuration;

            var      landscapeEntityManager = _ioc.Get <LandscapeBufferManager>();
            FileInfo fi         = new FileInfo(_vars.LocalDataBasePath);
            string   bufferPath = Path.Combine(fi.Directory.FullName, "LandscapeBuffer.proto");

            landscapeEntityManager.SetBufferPath(bufferPath);
            landscapeEntityManager.LoadBuffer();

            IWorldProcessor processor = null;

            switch (clientSideworldParam.Configuration.WorldProcessor)
            {
            case WorldConfiguration.WorldProcessors.Flat:
                processor = new FlatWorldProcessor();
                break;

            case WorldConfiguration.WorldProcessors.Utopia:
                processor = new UtopiaProcessor(clientSideworldParam, _ioc.Get <EntityFactory>("Client"), landscapeEntityManager);
                break;

            default:
                break;
            }

            _ioc.Rebind <WorldConfiguration>().ToConstant(clientSideworldParam.Configuration);

            var worldGenerator = new WorldGenerator(clientSideworldParam, processor);

            _ioc.Rebind <WorldGenerator>().ToConstant(worldGenerator).InSingletonScope();
            _ioc.Rebind <WorldParameters>().ToConstant(clientSideworldParam);

            var commonResources = _ioc.Get <SandboxCommonResources>();

            commonResources.LoadInventoryImages(_ioc.Get <D3DEngine>());

            // be careful with initialization order
            var serverComponent       = _ioc.Get <ServerComponent>();
            var worldFocusManager     = _ioc.Get <WorldFocusManager>();
            var wordParameters        = _ioc.Get <WorldParameters>();
            var visualWorldParameters = _ioc.Get <VisualWorldParameters>(
                new ConstructorArgument("visibleChunkInWorld", new Vector2I(ClientSettings.Current.Settings.GraphicalParameters.WorldSize, ClientSettings.Current.Settings.GraphicalParameters.WorldSize)),
                new ConstructorArgument("player", serverComponent.Player));

            var firstPersonCamera = _ioc.Get <ICameraFocused>("FirstPCamera");
            var thirdPersonCamera = _ioc.Get <ICameraFocused>("ThirdPCamera");
            var cameraManager     = _ioc.Get <CameraManager <ICameraFocused> >(new ConstructorArgument("camera", firstPersonCamera));

            cameraManager.RegisterNewCamera(thirdPersonCamera);

            var timerManager        = _ioc.Get <TimerManager>();
            var inputsManager       = _ioc.Get <InputsManager>();
            var guiManager          = _ioc.Get <GuiManager>();
            var iconFactory         = _ioc.Get <IconFactory>();
            var gameClock           = _ioc.Get <IClock>();
            var chunkStorageManager = _ioc.Get <IChunkStorageManager>(new ConstructorArgument("forceNew", false), new ConstructorArgument("fileName", _vars.LocalDataBasePath));

            var inventory = _ioc.Get <InventoryComponent>();
            var windrose  = _ioc.Get <WindRoseComponent>();

            inventory.PlayerInventoryWindow    = _ioc.Get <PlayerInventory>();
            inventory.ContainerInventoryWindow = _ioc.Get <ContainerInventory>();

            var skyBackBuffer = _ioc.Get <StaggingBackBuffer>("SkyBuffer");

            skyBackBuffer.DrawOrders.UpdateIndex(0, 50, "SkyBuffer");

            var chat    = _ioc.Get <ChatComponent>();
            var hud     = _ioc.Get <Hud>();
            var stars   = _ioc.Get <IDrawableComponent>("Stars");
            var clouds  = _ioc.Get <IDrawableComponent>("Clouds");
            var skyDome = _ioc.Get <ISkyDome>();
            var weather = _ioc.Get <IWeather>();

            var solidCubeMeshFactory      = _ioc.Get <ICubeMeshFactory>("SolidCubeMeshFactory");
            var liquidCubeMeshFactory     = _ioc.Get <ICubeMeshFactory>("LiquidCubeMeshFactory");
            var singleArrayChunkContainer = _ioc.Get <SingleArrayChunkContainer>();
            var landscapeManager          = _ioc.Get <ILandscapeManager2D>();
            var lightingManager           = _ioc.Get <ILightingManager>();
            var chunkMeshManager          = _ioc.Get <IChunkMeshManager>();
            var worldChunks              = _ioc.Get <IWorldChunks>();
            var worldShadowMap           = ClientSettings.Current.Settings.GraphicalParameters.ShadowMap ? _ioc.Get <WorldShadowMap>() : null;
            var chunksWrapper            = _ioc.Get <IChunksWrapper>();
            var fadeComponent            = _ioc.Get <FadeComponent>();
            var pickingRenderer          = _ioc.Get <IPickingRenderer>();
            var playerEntityManager      = (PlayerEntityManager)_ioc.Get <IPlayerManager>();
            var selectedBlocksRenderer   = _ioc.Get <SelectedBlocksRenderer>();
            var chunkEntityImpactManager = _ioc.Get <IChunkEntityImpactManager>();
            var entityPickingManager     = _ioc.Get <IEntityCollisionManager>();
            var dynamicEntityManager     = _ioc.Get <IVisualDynamicEntityManager>();
            var voxelMeshFactory         = _ioc.Get <VoxelMeshFactory>();
            var sharedFrameCB            = _ioc.Get <SharedFrameCB>();
            var itemMessageTranslator    = _ioc.Get <ItemMessageTranslator>();
            var entityMessageTranslator  = _ioc.Get <EntityMessageTranslator>();
            var soundManager             = _ioc.Get <GameSoundManager>();
            var voxelModelManager        = _ioc.Get <VoxelModelManager>();
            var toolRenderer             = _ioc.Get <FirstPersonToolRenderer>();
            var particuleEngine          = _ioc.Get <UtopiaParticuleEngine>();
            var ghostedRenderer          = _ioc.Get <GhostedEntityRenderer>();
            var crafting            = _ioc.Get <CraftingComponent>();
            var charSelection       = _ioc.Get <CharacterSelectionComponent>();
            var inventoryEvents     = _ioc.Get <InventoryEventComponent>();
            var cracksRenderer      = _ioc.Get <CracksRenderer>();
            var postEffectComponent = _ioc.Get <PostEffectComponent>();

            //Assign the various Post Processing effect to the component
            //Ghost PostEffect
            IPostEffect ghost = new PostEffectGhost()
            {
                Name = "Dead"
            };

            postEffectComponent.RegisteredEffects.Add(ghost.Name, ghost);

            landscapeManager.EntityFactory    = clientFactory;
            playerEntityManager.HasMouseFocus = true;
            cameraManager.SetCamerasPlugin(playerEntityManager);
            ((ThirdPersonCameraWithFocus)thirdPersonCamera).CheckCamera += worldChunks.ValidatePosition;
            chunkEntityImpactManager.LateInitialization(serverComponent, singleArrayChunkContainer, worldChunks, chunkStorageManager, lightingManager, visualWorldParameters);

            clientFactory.DynamicEntityManager = _ioc.Get <IVisualDynamicEntityManager>();
            clientFactory.GlobalStateManager   = _ioc.Get <IGlobalStateManager>();

            //Late Inject PlayerCharacter into VisualWorldParameters
            var c = clouds as Clouds;

            if (c != null)
            {
                c.LateInitialization(sharedFrameCB);
            }

            LoadMissingModels(clientSideworldParam.Configuration, voxelModelManager);

            AddComponent(cameraManager);
            AddComponent(serverComponent);
            AddComponent(inputsManager);
            AddComponent(iconFactory);
            AddComponent(timerManager);
            AddComponent(skyBackBuffer);
            AddComponent(playerEntityManager);
            AddComponent(dynamicEntityManager);
            AddComponent(hud);
            AddComponent(guiManager);
            AddComponent(pickingRenderer);
            AddComponent(inventory);
            AddComponent(windrose);
            AddComponent(chat);
            AddComponent(skyDome);
            AddComponent(gameClock);
            AddComponent(weather);
            AddComponent(worldChunks);
            AddComponent(sharedFrameCB);
            AddComponent(soundManager);
            AddComponent(voxelModelManager);
            AddComponent(toolRenderer);
            AddComponent(fadeComponent);
            AddComponent(particuleEngine);
            AddComponent(ghostedRenderer);
            AddComponent(crafting);
            AddComponent(inventoryEvents);
            AddComponent(cracksRenderer);
            AddComponent(charSelection);
            AddComponent(postEffectComponent);

            if (ClientSettings.Current.Settings.GraphicalParameters.ShadowMap)
            {
                AddComponent(worldShadowMap);
            }

            //Will start the initialization of the newly added Components on the states, and Activate them
            StatesManager.ActivateGameStateAsync(this);

            worldChunks.LoadComplete += worldChunks_LoadComplete;

            var engine = _ioc.Get <D3DEngine>();

            inputsManager.MouseManager.MouseCapture = true;
        }
示例#19
0
 void MenuCreditsPressed(object sender, EventArgs e)
 {
     // showing the credits
     StatesManager.ActivateGameStateAsync("Credits");
 }
示例#20
0
 void CreditsBackPressed(object sender, System.EventArgs e)
 {
     // when you press "back" we returning to the main menu
     StatesManager.ActivateGameStateAsync("MainMenu");
 }