/// <summary> /// All Components used by this GameState should be Added in the GameState here /// This will be called in a multithreaded way ! /// </summary> public virtual void Initialize(DeviceContext context) { //Call the Initialized from each Registered component, if needed ! //Will be thread dispatched ! List <Task> _startedTask = new List <Task>(); GameComponents.ForEach(gc => { if (gc.IsInitialized == false) { //Start the Initialize() _startedTask.Add(ThreadsManager.RunAsync(gc.Initialize)); } }); Task.WaitAll(_startedTask.ToArray()); //Call the LoadContents from each Registered component, if needed ! //!! Those methods are not Thread Safe !! => cannot thread dispatch them, can only run once at a time in this thread context foreach (var gc in GameComponents.Where(x => x.IsDefferedLoadContent)) { if (gc.IsInitialized == false) { gc.LoadContent(context); gc.IsInitialized = true; } } IsDirty = false; }
public GameScreen(Game game, List <Library.Character.Name> playerinfo) // TODO: tmp added world to parameters, might solve in a different way later. : base(game) { SyncedGameCollection.InitializeSyncedGameCollection(game); world = new World(Vector2.Zero); GameComponents.Add(SyncedGameCollection.Instance); _map = new Map(Library.Map.Path[Library.Map.Name.Paper], game, world); GameComponents.Add(_map); Rectangle[] rectangles = new Rectangle[] { new Rectangle(140, 20, 40, 40), new Rectangle(1700, 20, 40, 40), new Rectangle(140, 1020, 40, 40), new Rectangle(1700, 1020, 40, 40) }; // Controls for (int i = 0; i < playerinfo.Count; i++) { GameComponents.Add(new ScoreLabel((PlayerIndex)i, rectangles[i], Game)); } // Audio Library.Audio.PlaySong(Library.Audio.Songs.GameSong3); _map.LoadMap(game, playerinfo); // send in player information foreach (var ob in SyncedGameCollection.ComponentCollection) { if (ob is Goal) { (ob as Goal).Scored += GameScreen_Scored; } } }
public FreeRuleConfig() { this.triggers = new TriggerList(); this.commons = new CommonActions(); this.components = new GameComponents(); this.gameComponentMap = new GameComponentMap(); }
public WinScreen(Game game) : base(Library.WinScreens.Background, game) { WinType = TypeOfWin.SuddenDeath; SplashTime = new TimeSpan(10000); GameComponents.Add(new Sprite(Library.WinScreens.SuddenTeam, new Vector2(ResolutionManager.GetCenterPointWidth, ResolutionManager.GetCenterPointHeight), Static_Classes.DrawingHelper.DrawingLevel.Top, Game)); }
public WinScreen(Game game, Library.Colors.ColorName player) : base(Library.WinScreens.Background, game) { WinType = TypeOfWin.TeamVictory; SplashTime = TimeSpan.FromSeconds(5); switch (player) { case Synced.Content.Library.Colors.ColorName.Blue: GameComponents.Add(new Sprite(Library.WinScreens.BlueTeam, new Vector2(ResolutionManager.GetCenterPointWidth, ResolutionManager.GetCenterPointHeight), Color.White, Static_Classes.DrawingHelper.DrawingLevel.Top, true, Game)); break; case Synced.Content.Library.Colors.ColorName.Green: GameComponents.Add(new Sprite(Library.WinScreens.GreenTeam, new Vector2(ResolutionManager.GetCenterPointWidth, ResolutionManager.GetCenterPointHeight), Color.White, Static_Classes.DrawingHelper.DrawingLevel.Top, true, Game)); break; case Synced.Content.Library.Colors.ColorName.Red: GameComponents.Add(new Sprite(Library.WinScreens.RedTeam, new Vector2(ResolutionManager.GetCenterPointWidth, ResolutionManager.GetCenterPointHeight), Color.White, Static_Classes.DrawingHelper.DrawingLevel.Top, true, Game)); break; case Synced.Content.Library.Colors.ColorName.Yellow: GameComponents.Add(new Sprite(Library.WinScreens.YellowTeam, new Vector2(ResolutionManager.GetCenterPointWidth, ResolutionManager.GetCenterPointHeight), Color.White, Static_Classes.DrawingHelper.DrawingLevel.Top, true, Game)); break; default: break; } }
public override void Update(GameTime time) { _input.Update(time); var updateComponent = GameComponents.Where(t => t.Enabled).OrderByDescending(t => t.UpdateOrder).First(); updateComponent.Update(time); }
public override void Draw(SpriteBatch batch, GameTime time) { foreach (var component in GameComponents.Cast <DrawableGameComponent>().OrderBy(t => t.UpdateOrder).Where(t => t.Visible)) { component.Draw(batch, time); } SceneManager.Draw(batch, time); batch.End(); }
//Default Utopia Init method. private void NormalInit() { #region Debug Components #if DEBUG _axis = new Axis(this, 10); // Use to display the X,Y,Z axis GameComponents.Add(_axis); DebugEffect.Init(this); // Default Effect used by debug componant (will be shared) #endif #endregion _clock = new GameClock.Clock(this, 120, GameClock.GameTimeMode.Automatic, (float)Math.PI * 1f, InputHandler); // Clock creation, manage Utopia time GameComponents.Add(_clock); ICamera camera = new FirstPersonCamera(this); // Create a firstPersonCAmera viewer TerraCubeProfile.InitCubeProfiles(); // Init the cube factory WorldFocus = (IWorldFocus)camera; //Set the World Focus on my Camera //Create an entity, link to camera to it. _player = new Entities.Living.Player(this, "s33m3", camera, InputHandler, new DVector3((TerraWorld.Worldsize.X / 2.0) + TerraWorld.WorldStartUpX, 90, (TerraWorld.Worldsize.Z / 2.0f) + TerraWorld.WorldStartUpZ), new Vector3(0.5f, 1.9f, 0.5f), 5f, 30f, 10f) { Mode = Entities.Living.LivingEntityMode.FreeFirstPerson //Defaulted to "Flying" mode }; GameComponents.Add(_player); //Attached the Player to the camera =+> The player will be used as Camera Holder ! camera.CameraPlugin = _player; //The camera is using the _player to get it's world positions and parameters, so the _player updates must be done BEFORE the camera ! GameComponents.Add(camera); _universe = new Univers.Universe(this, _clock, _player, "S33m3's World"); GameComponents.Add(_universe); _fps = new FPS(this); GameComponents.Add(_fps); _gui = new Sprites2D.GUI(this); GameComponents.Add(_gui); _debugInfo = new DebugInfo(this); _debugInfo.Activated = true; _debugInfo.SetComponants(_fps, _clock, _universe, _player); GameComponents.Add(_debugInfo); GameConsole.Initialize(this); //Set Default Camera ! base.ActivCamera = camera; }
public void JoinGame() { foreach (var component in GameComponents.Cast <DrawableGameComponent>()) { component.Enabled = false; component.Visible = false; } var multiplayer = (DrawableGameComponent)GameComponents.First(t => t.GetType() == typeof(MultiplayerComponent)); multiplayer.Enabled = true; multiplayer.Visible = true; }
public void Draw(Microsoft.Xna.Framework.GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation()); spriteBatch.Draw(Texture, Position, null, Color.White, Angle + (float)Math.PI / 2, new Vector2(Texture.Width / 2, Texture.Height / 2), camera.Zoom, SpriteEffects.None, 0); spriteBatch.End(); }
public BaseEventArgs() { this.map = new MyDictionary <string, IParable>(); this.directMap = new MyDictionary <string, IParable>(); this.units = new GameUnitSet(); this.temp = new MyDictionary <string, Stack <IParable> >(); this._functions = new CommonActions(); this._triggers = new GameTriggers(); this._componentMap = new GameComponentMap(); this._components = new GameComponents(); this._bufs = new FreeBufManager(); this._freeContext = new FreeContext(_gameContext); }
/// <summary> /// Make component enabled and visible if possible /// </summary> /// <param name="gc"></param> protected void AddComponent(GameComponent gc) { if (gc == null) { return; } //Should only be called "once", but doesn't hurt to check the collection state before each modification CleanUpComponents(); //Add a component only if not already added if (GameComponents.Contains(gc) == false) { GameComponents.Add(gc); } }
public SplashScreen(Texture2D texture, Game game) : base(game) { //How long to fade in & out DrawOrder = (int)DrawingHelper.DrawingLevel.Top; FadeInTime = TimeSpan.FromSeconds(0.5); FadeOutTime = TimeSpan.FromSeconds(0.5); SplashTime = TimeSpan.FromSeconds(2.1); // Temporary screen variables (Half of screen) int w = ResolutionManager.GetCenterPointWidth; int h = ResolutionManager.GetCenterPointHeight; GameComponents.Add(new Sprite(texture, new Vector2(w, h), Color.White, DrawingHelper.DrawingLevel.Top, true, game)); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation()); spriteBatch.Draw(Texture, Position, Color.White); spriteBatch.End(); foreach (MenuItem item in Items) item.Draw(gameTime, spriteBatch, camera); Cursor.Draw(gameTime, spriteBatch, camera); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); var gameComponents = new GameComponents { graphics = graphics, spriteBatch = spriteBatch }; menuScene.Load(gameComponents); // TODO: use this.Content to load your game content here }
public override void Initialize(SharpDX.Direct3D11.DeviceContext context) { var gui = _iocContainer.Get <GuiManager>(); var selection = _iocContainer.Get <ServerSelectionComponent>(); var webApi = _iocContainer.Get <ClientWebApi>(); GameComponents.Add(gui); GameComponents.Add(selection); selection.BackPressed += SelectionBackPressed; selection.ConnectPressed += SelectionConnectPressed; webApi.ServerListReceived += WebApiServerListReceived; base.Initialize(context); }
//State Initialization => //Add Loading screen animation, and ServerComponent public override void Initialize(SharpDX.Direct3D11.DeviceContext context) { if (PreviousGameState != this) { GameComponents.Clear(); } var loading = _ioc.Get <LoadingComponent>(); _vars = _ioc.Get <RealmRuntimeVariables>(); AddComponent(loading); //Will "Mask" the Components being loaded. AddComponent(_ioc.Get <ServerComponent>()); AddComponent(_ioc.Get <GuiManager>()); base.Initialize(context); }
//SpriteBatch _spriteBatch //{ // get { return (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); } //} #endregion public MenuScreen(Game game) : base(game) { //Menu background DrawOrder = (int)DrawingHelper.DrawingLevel.Back; // Temporary screen variables (Half of screen) int w = ResolutionManager.GetCenterPointWidth; int h = ResolutionManager.GetCenterPointHeight; // Add character selectors GameComponents.Add(new CharacterSelector(PlayerIndex.One, new Rectangle(0, 0, w, h), Color.Blue, Game)); GameComponents.Add(new CharacterSelector(PlayerIndex.Two, new Rectangle(w, 0, w, h), Color.Green, Game)); GameComponents.Add(new CharacterSelector(PlayerIndex.Three, new Rectangle(0, h, w, h), Color.Red, Game)); GameComponents.Add(new CharacterSelector(PlayerIndex.Four, new Rectangle(w, h, w, h), Color.Yellow, Game)); // Background GameComponents.Add(new Sprite(Library.Interface.MenuBackground, Vector2.Zero, DrawingHelper.DrawingLevel.Back, game)); Library.Audio.PlaySong(Library.Audio.Songs.MenuSong1); }
public void Draw(Microsoft.Xna.Framework.GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { //Draws the board. The board has its own camera. spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, BoardCamera.get_transformation()); spriteBatch.Draw(Texture, Position, Color.White); spriteBatch.End(); //Draws all the bricks foreach (GameBrick brick in this.Bricks) { brick.Draw(gameTime, spriteBatch, camera); } //TODO: Remove this.APlayer.Draw(gameTime, spriteBatch, camera); }
public override void LoadContent() { ResourceManager.LoadResource <Texture2D>(this, "ExplosionTexture", "Textures/Explosion"); ResourceManager.LoadResource <Texture2D>(this, "Background", "Textures/Background"); ResourceManager.LoadResource <Texture2D>(this, "Unpowered", "Textures/Unpowered"); ResourceManager.LoadResource <Texture2D>(this, "Powered", "Textures/Powered"); ResourceManager.LoadResource <Texture2D>(this, "Unowned", "Textures/Default"); ResourceManager.LoadResource <Texture2D>(this, "ButtonMenu", "Textures/ButtonMenu"); ResourceManager.LoadResource <Texture2D>(this, "ButtonMenuHovered", "Textures/ButtonMenuHovered"); ResourceManager.LoadResource <Texture2D>(this, "ButtonSettings", "Textures/ButtonSettings"); ResourceManager.LoadResource <Texture2D>(this, "ButtonSettingsHovered", "Textures/ButtonMenuHovered"); ResourceManager.LoadResource <SpriteFont>(this, "ButtonFont", "Fonts/ButtonFont"); ResourceManager.LoadResource <SpriteFont>(this, "DefaultFont", "Fonts/Default"); ResourceManager.LoadResource <Texture2D>(this, "ButtonExit", "Textures/ButtonExit"); ResourceManager.LoadResource <Texture2D>(this, "ButtonExitHovered", "Textures/ButtonExitHovered"); ResourceManager.LoadResource <Texture2D>(this, "ButtonHowToPlay", "Textures/ButtonHTP"); ResourceManager.LoadResource <Texture2D>(this, "ButtonHowToPlayHovered", "Textures/ButtonHTPHovered"); ResourceManager.LoadResource <TextFile>(this, "HowToPlay", "Others/howtoplay"); ResourceManager.LoadResource <SpriteFont>(this, "WinnerFont", "Fonts/WinnerFont"); ResourceManager.LoadResource <SpriteFont>(this, "BoldFont", "Fonts/Bold"); ResourceManager.LoadResource <Sound>(this, "ExplosionSound", "Sounds/ExplosionSound"); _singleplayerGame = new SingleplayerComponent(this, _input, Get <GameWindow>().ClientSize) { DrawOrder = 1, UpdateOrder = 1, Visible = true, Enabled = true }; _mainMenuComponent = new MainMenuComponent(this, _input) { DrawOrder = 2, UpdateOrder = 2, Visible = true, Enabled = true }; GameComponents.Add(_singleplayerGame); GameComponents.Add(_mainMenuComponent); var controlFromHandle = Control.FromHandle(GameWindow.Default.Handle); var form = controlFromHandle as FrmLoading; form?.DestroyControls(); }
public void GenId() { ViewComponents.Sort((a, b) => { return(a.ShowName.CompareTo(b.ShowName)); }); GameComponents.Sort((a, b) => { return(a.ShowName.CompareTo(b.ShowName)); }); int index = 0; foreach (var component in GameComponents) { if (!component.IsUnique) { component.Id = index++; } } GameComponentCount = index; foreach (var component in ViewComponents) { if (!component.IsUnique) { component.Id = index++; } } ViewComponentCount = index; }
public void Awake() { main = this; }
public void Draw(Microsoft.Xna.Framework.GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation()); //Draws the texture. spriteBatch.Draw(Texture, Position, Microsoft.Xna.Framework.Color.White); //Draws the text. spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation()); spriteBatch.DrawString(Font, Text, (this.Type == BrickType.Card ? new Microsoft.Xna.Framework.Vector2(Position.X + 28, Position.Y + 30) : new Microsoft.Xna.Framework.Vector2(Position.X + Texture.Width / 2 - 12, Position.Y + 30)), Color); spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation()); spriteBatch.DrawString(Font, Text, Position, Color); spriteBatch.End(); }
void Start() { // Buttons this.buttonNew = GameObject.Find("Canvas/Menu/ButtonNew"); this.buttonLoad = GameObject.Find("Canvas/Menu/ButtonLoad"); this.buttonSave = GameObject.Find("Canvas/Menu/ButtonSave"); this.buttonSave.SetActive(false); this.mouseDown = false; this.tile = null; this.mapComponent = null; this.temp = null; this.timeCounter = 0; this.gameComponents = new GameComponents(); this.gameComponents.map = null; this.gameComponents.mapTile = null; this.gameComponents.mapComponent = null; this.components = GameObject.Find("components");; // ScrollView this.tilesView = GameObject.Find("tilesView"); this.mapComponentsView = GameObject.Find("mapComponentsView"); GameObject button, model, tilesContent, mapComponentsContent; tilesContent = GameObject.Find("tilesView/Viewport/Content"); mapComponentsContent = GameObject.Find("mapComponentsView/Viewport/Content"); tilesContent.GetComponent <RectTransform>().sizeDelta = new Vector2(20 + 120 * this.gameComponents.tiles.Count, 0.0f); mapComponentsContent.GetComponent <RectTransform>().sizeDelta = new Vector2(20 + 120 * this.gameComponents.mapComponents.Count, 0.0f); int count = 0; List <string> options = new List <string>(); foreach (TileDao tile in this.gameComponents.tiles.Values) { options.Add(tile.name); button = new GameObject(); button.name = "Button" + tile.name; button.transform.SetParent(tilesContent.transform); button.AddComponent <Button>(); button.AddComponent <Image>(); button.GetComponent <RectTransform>().anchorMin = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().anchorMax = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().pivot = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); button.GetComponent <RectTransform>().localPosition = new Vector3(20.0f + 120 * count, -10.0f, 0.0f); UnityEngine.Events.UnityAction action = () => { InsertTile(tile); }; button.GetComponent <Button>().onClick.AddListener(action); model = GameObject.Instantiate(tile.Instantiate().model); model.transform.SetParent(button.transform); model.AddComponent <RectTransform>(); model.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().localScale = new Vector3(95.0f, 95.0f, 1.0f); model.GetComponent <RectTransform>().localPosition = new Vector3(50.0f, 0.0f, 0.0f); count++; } count = 0; button = new GameObject(); button.name = "ButtonEmpty"; button.transform.SetParent(mapComponentsContent.transform); button.AddComponent <Button>(); button.AddComponent <Image>(); button.GetComponent <RectTransform>().anchorMin = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().anchorMax = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().pivot = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); button.GetComponent <RectTransform>().localPosition = new Vector3(20.0f + 120 * count, -10.0f, 0.0f); button.GetComponent <Button>().onClick.AddListener(DeleteMapComponent); GameObject text = new GameObject("empty", typeof(Text)); text.gameObject.transform.SetParent(button.transform); text.GetComponent <RectTransform>().sizeDelta = new Vector2(320.0f, 200.0f); text.GetComponent <RectTransform>().anchorMin = new Vector2(0.0f, 0.0f); text.GetComponent <RectTransform>().anchorMax = new Vector2(1.0f, 1.0f); text.GetComponent <RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); text.GetComponent <RectTransform>().localPosition = new Vector3(0.0f, 0.0f, 0.0f); text.GetComponent <RectTransform>().offsetMin = new Vector2(0.0f, 0.0f); text.GetComponent <RectTransform>().offsetMax = new Vector2(0.0f, 0.0f); text.GetComponent <Text>().font = Font.CreateDynamicFontFromOSFont("Arial", 14); text.GetComponent <Text>().fontSize = 30; text.GetComponent <Text>().fontStyle = FontStyle.Bold; text.GetComponent <Text>().color = Color.red; text.GetComponent <Text>().alignment = TextAnchor.MiddleCenter; text.GetComponent <Text>().text = "X"; count++; foreach (MapComponentDao mapComponent in this.gameComponents.mapComponents.Values) { button = new GameObject(); button.name = "Button" + mapComponent.name; button.transform.SetParent(mapComponentsContent.transform); button.AddComponent <Button>(); button.AddComponent <Image>(); button.GetComponent <RectTransform>().anchorMin = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().anchorMax = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().pivot = new Vector2(0.0f, 0.5f); button.GetComponent <RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); button.GetComponent <RectTransform>().localPosition = new Vector3(20.0f + 120 * count, -10.0f, 0.0f); UnityEngine.Events.UnityAction action = () => { InsertMapComponent(mapComponent); }; button.GetComponent <Button>().onClick.AddListener(action); model = GameObject.Instantiate(mapComponent.Instantiate().model); model.transform.SetParent(button.transform); model.AddComponent <RectTransform>(); model.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().pivot = new Vector2(0.5f, 0.5f); model.GetComponent <RectTransform>().localScale = new Vector3(95.0f, 95.0f, 1.0f); model.GetComponent <RectTransform>().localPosition = new Vector3(50.0f, -30.0f, 0.0f); count++; } GameObject.Find("Canvas/PanelNewMap/Form/TileDefault/DropdownTiles").GetComponent <Dropdown>().AddOptions(options); // NewMap this.PanelNewMap = GameObject.Find("Canvas/PanelNewMap"); this.PanelNewMap.SetActive(false); this.mapComponentsView.SetActive(false); }
protected void CleanUpComponents() { //Remove all disposed components GameComponents.RemoveAll(x => x.IsDisposed); }
public LoadingScreen(Game game) : base(game) { GameComponents.Add(new Sprite(Library.Screens.LoadScreen, Vector2.Zero, DrawingHelper.DrawingLevel.Top, game)); }
public Scene() { _components = new GameComponents<IUpdatableComponent>(this); Scenes.Add(this); this.Initialize(); }
void updateButtonsTag(Button btn, GameComponents.DifficultyLevel level) { var easyStat = stat[level]; if (easyStat.Count > 0) { btn.Tag = string.Format("{0} played: {1}%", easyStat.Count, (int)100 * easyStat.Victory / easyStat.Count); } else { btn.Tag = "not yet played"; } }
public void OnEnable() { main = this; }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, GameComponents.Camera.Camera2d camera) { KeyboardState ks = Keyboard.GetState(); Board.Draw(gameTime, spriteBatch, this.Camera); }
public override void Initialize(DeviceContext context) { GameScope.CurrentGameScope.Disposed += CurrentGameScope_Disposed; var cameraManager = _ioc.Get <CameraManager <ICameraFocused> >(); var timerManager = _ioc.Get <TimerManager>(); _inputsManager = _ioc.Get <InputsManager>(); _inputsManager.ActionsManager.KeyboardAction += ActionsManager_KeyboardAction; var guiManager = _ioc.Get <GuiManager>(); var iconFactory = _ioc.Get <IconFactory>(); var gameClock = _ioc.Get <IClock>(); var inventory = _ioc.Get <InventoryComponent>(); var windRose = _ioc.Get <WindRoseComponent>(); var chat = _ioc.Get <ChatComponent>(); chat.ActivatedChanged += chat_ActivatedChanged; _hud = (RealmsHud)_ioc.Get <Hud>(); _hud.CraftingButton.Pressed += CraftingButton_Pressed; _hud.InventoryButton.Pressed += InventoryButton_Pressed; var skyBackBuffer = _ioc.Get <StaggingBackBuffer>("SkyBuffer"); skyBackBuffer.DrawOrders.UpdateIndex(0, 50, "SkyBuffer"); if (ClientSettings.Current.Settings.GraphicalParameters.LandscapeFog == "SkyFog") { skyBackBuffer.EnableComponent(true); } var skyDome = _ioc.Get <ISkyDome>(); //Rendering time changed depending on landscape fog option, TRUE = Faster drawing (Because we are actively using depth testing) if (ClientSettings.Current.Settings.GraphicalParameters.LandscapeFog == "SkyFog") { skyDome.DrawOrders.UpdateIndex(0, 40); } else { skyDome.DrawOrders.UpdateIndex(0, 990); } var weather = _ioc.Get <IWeather>(); var worldChunks = _ioc.Get <IWorldChunks>(); var worldShadowMap = ClientSettings.Current.Settings.GraphicalParameters.ShadowMap ? _ioc.Get <WorldShadowMap>() : null; var pickingRenderer = _ioc.Get <IPickingRenderer>(); var dynamicEntityManager = _ioc.Get <IVisualDynamicEntityManager>(); _playerEntityManager = (PlayerEntityManager)_ioc.Get <IPlayerManager>(); _playerEntityManager.PlayerCharacter.Inventory.ItemPut += InventoryOnItemPut; _playerEntityManager.PlayerCharacter.Inventory.ItemTaken += InventoryOnItemTaken; _playerEntityManager.NeedToShowInventory += playerEntityManager_NeedToShowInventory; var sharedFrameCB = _ioc.Get <SharedFrameCB>(); _sandboxGameSoundManager = (RealmGameSoundManager)_ioc.Get <GameSoundManager>(); _serverComponent = _ioc.Get <ServerComponent>(); _serverComponent.ConnectionStatusChanged += ServerComponentOnConnectionStausChanged; var fadeComponent = _ioc.Get <FadeComponent>(); var voxelModelManager = _ioc.Get <VoxelModelManager>(); var adminConsole = _ioc.Get <AdminConsole>(); 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 pickingManager = _ioc.Get <PickingManager>(); var cracksRenderer = _ioc.Get <CracksRenderer>(); var postEffectComponent = _ioc.Get <PostEffectComponent>(); 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(_sandboxGameSoundManager); AddComponent(fadeComponent); AddComponent(voxelModelManager); AddComponent(toolRenderer); AddComponent(particuleEngine); AddComponent(ghostedRenderer); AddComponent(crafting); AddComponent(inventoryEvents); AddComponent(pickingManager); AddComponent(cracksRenderer); AddComponent(charSelection); AddComponent(postEffectComponent); if (worldShadowMap != null) { AddComponent(worldShadowMap); } #if DEBUG //Check if the GamePlay Components equal those that have been loaded inside the LoadingGameState foreach (var gc in _ioc.Get <LoadingGameState>().GameComponents.Except(GameComponents)) { if (gc.GetType() != typeof(Realms.Client.Components.GUI.LoadingComponent)) { logger.Warn("Missing GamePlayState component, present inside LoadingGameState : {0}", gc.GetType().ToString()); } } //Check if the GamePlay Components equal those that have been loaded inside the LoadingGameState foreach (var gc in GameComponents.Except(_ioc.Get <LoadingGameState>().GameComponents)) { if (gc.GetType() != typeof(LoadingComponent)) { logger.Warn("Missing LoadingGameState component, present inside GamePlayState : {0}", gc.GetType().ToString()); } } #endif base.Initialize(context); }
public void ResetGame() { SyncedGameCollection.ComponentCollection.Clear(); world.Clear(); GameComponents.Clear(); }
public void Build(GameComponents gameComponents) { this.tiles = new Tile[this.height, this.width]; this.mapTile = new int[this.height, this.width]; this.mapComponent = new int[this.height, this.width]; this.mapComponents = new List <MapComponent>(); if (this.isReflected) { switch (this.directionReflected) { case 'N': ReflectNorth(gameComponents.mapTile, gameComponents.mapComponent); break; case 'S': ReflectSouth(gameComponents.mapTile, gameComponents.mapComponent); break; case 'E': ReflectEast(gameComponents.mapTile, gameComponents.mapComponent); break; case 'W': ReflectWest(gameComponents.mapTile, gameComponents.mapComponent); break; } } else { this.mapTile = gameComponents.mapTile; this.mapComponent = gameComponents.mapComponent; } int i, j; for (i = 0; i < this.height; i++) { for (j = 0; j < this.width; j++) { this.tiles[i, j] = gameComponents.tiles[this.mapTile[i, j]].Instantiate(); if (this.mapComponent[i, j] != 0 && this.tiles[i, j].isWalkable && i > 1 && i < (this.height - 1) && j > 1 && j < (this.width - 1)) { this.tiles[i, j].mapComponent = gameComponents.mapComponents[this.mapComponent[i, j] - 1].Instantiate(); this.tiles[i, j].mapComponent.position = new Vector2(j, i); this.tiles[i, j].isWalkable = false; this.tiles[i, j].canBuild = false; this.mapComponents.Add(this.tiles[i, j].mapComponent); } } } int x, y, lineIni, lineFin, columnIni, columnFin; // Set canBuild = false, where isWalkable = false for (i = 0; i < this.height; i++) { for (j = 0; j < this.width; j++) { if (!this.tiles[i, j].isWalkable) { lineIni = (i - 1) >= 0 ? (i - 1) : i; lineFin = (i + 1) < this.height ? (i + 1) : i; columnIni = (j - 1) >= 0 ? (j - 1) : j; columnFin = (j + 1) < this.width ? (j + 1) : j; for (y = lineIni; y <= lineFin; y++) { for (x = columnIni; x <= columnFin; x++) { this.tiles[y, x].canBuild = false; } } } } } }
protected override void Dispose(bool disposing) { GameComponents.Clear(); base.Dispose(disposing); }
private void Awake() { componentsInstance = this; }
public void RegisterNewComponent(DrawableGameComponent component) { GameComponents.Add(component); }