private void DrawComponent(Object2D component, ref Object2D parent) { if (component.GetType() == typeof(GraphicObject)) { DrawGraphicComponent((component as GraphicObject), ref parent); } else if (component.GetType() == typeof(MinimapObject)) { DrawMinimapObject((component as MinimapObject), ref parent); } else if (component.GetType() == typeof(TextObject)) { if (parent.GetType() == typeof(GraphicObject)) DrawTextComponent((component as TextObject), (parent as GraphicObject)); } else if (component.GetType() == typeof(TextBoxObject)) { if(parent.GetType() == typeof(GraphicObject)) DrawTextBoxComponent((component as TextBoxObject), (parent as GraphicObject)); } else if (component.GetType() == typeof(ListBox)) { if(parent.GetType() == typeof(GraphicObject)) DrawListBox((component as ListBox), (parent as GraphicObject)); } else if (component.GetType() == typeof(AnimatedObject)) { if(parent.GetType() == typeof(GraphicObject)) DrawAnimatedObject((component as AnimatedObject), (parent as GraphicObject)); } if(component.GetType() == typeof(GraphicObject)) DrawComponent((component as GraphicObject).Children, ref component); }
private void DrawGraphicComponent(GraphicObject component, ref Object2D parent) { if (component.TextureLocation != "") { if (component.TextureLocation.StartsWith("@")) { if (component.TextureLocation == "@AppleTexture") { if (GameHandler.Inventory.NumberOfApples > 0) component.Texture = Game.Content.Load<Texture2D>("Sprites\\Apple"); else component.Texture = Game.Content.Load<Texture2D>("Sprites\\NullItems\\NullApple"); } if(component.TextureLocation == "@GoldenAppleTexture") { if (GameHandler.Inventory.NumberOfGoldenApples > 0) component.Texture = Game.Content.Load<Texture2D>("Sprites\\GoldenApple"); else component.Texture = Game.Content.Load<Texture2D>("Sprites\\NullItems\\NullGoldenApple"); } if(component.TextureLocation == "@SpringWaterTexture") { if (GameHandler.Inventory.NumberOfSpringWater > 0) component.Texture = Game.Content.Load<Texture2D>("Sprites\\SpringWater"); else component.Texture = Game.Content.Load<Texture2D>("Sprites\\NullItems\\NullSpringWater"); } if(component.TextureLocation == "@HoneyTexture") { if (GameHandler.Inventory.NumberOfHoney > 0) component.Texture = Game.Content.Load<Texture2D>("Sprites\\Honey"); else component.Texture = Game.Content.Load<Texture2D>("Sprites\\NullItems\\NullHoney"); } if (component.TextureLocation == "@ChilliTexture") { if (GameHandler.Inventory.NumberOfChilli > 0) component.Texture = Game.Content.Load<Texture2D>("Sprites\\Chilli"); else component.Texture = Game.Content.Load<Texture2D>("Sprites\\NullItems\\NullChilli"); } if (component.TextureLocation == "@PlayerCanFlyIcon") { if (GameHandler.Player.canFly) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/FlyingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@PlayerCanClimbIcon") { if (GameHandler.Player.canClimb) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/ClimingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@PlayerCanSwimIcon") { if (GameHandler.Player.canSwim) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/SwimmingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@SelectedCanFly") { if (GameHandler.Inventory.SelectedDNA != null) { if (GameHandler.Inventory.SelectedDNA.canFly) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/FlyingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@SelectedCanClimb") { if (GameHandler.Inventory.SelectedDNA != null) { if (GameHandler.Inventory.SelectedDNA.canClimb) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/ClimingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@SelectedCanSwim") { if (GameHandler.Inventory.SelectedDNA != null) { if (GameHandler.Inventory.SelectedDNA.canSwim) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/SwimmingIcon"); else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } else component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/BlankIcon"); } if (component.TextureLocation == "@CurrentAttributeInUse") { if (GameHandler.CurrentAttributeInUse != Attributes.None) { if(GameHandler.Player.canFly) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/FlyingIcon"); else { if (GameHandler.CurrentAttributeInUse == Attributes.FlyingAndClimbing) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/ClimingIcon"); if (GameHandler.CurrentAttributeInUse == Attributes.FlyingAndSwimming) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/SwimmingIcon"); } } else { component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/Icons/IconBackground"); } } } else if (component.Texture == null) component.Texture = Game.Content.Load<Texture2D>("Interface/Assets/" + (component as GraphicObject).TextureLocation); } else if (component.Texture == null) component.Texture = new Texture2D(Game.GraphicsDevice, 1, 1); if (((component.GetType() == typeof(GraphicObject)) || component.GetType() == typeof(Scroller)) && (parent.GetType() == typeof(GraphicObject))) { component.Size.X = ((parent as GraphicObject).Size.X / 100 * component.iSize.X); component.Size.Y = ((parent as GraphicObject).Size.Y / 100 * component.iSize.Y); component.Position.X = ((parent as GraphicObject).Size.X / 100 * component.iPosition.X) - (component.Size.X / 2); component.Position.Y = ((parent as GraphicObject).Size.Y / 100 * component.iPosition.Y) - (component.Size.Y / 2); component.Position += (parent as GraphicObject).Position; } /* if(component.isCentered) component.offset = new Vector2(component.Size.X, component.Size.Y) / 2; */ if (component.fullscreen) { component.Position.X = 0; component.Position.Y = 0; component.Size.X = Game.GraphicsDevice.Viewport.Width; component.Size.Y = Game.GraphicsDevice.Viewport.Height; SpriteManager.Draw(component.Texture, Configuration.Bounds, Color.White); } else { if (component.isClickable) { Rectangle textureRect = new Rectangle((int)component.Position.X, (int)component.Position.Y, (int)component.Size.X, (int)component.Size.Y); if(textureRect.Contains(new Point(InputHandler.MouseX, InputHandler.MouseY))) SpriteManager.Draw(component.Texture, new Rectangle((int)component.Position.X - 10, (int)component.Position.Y - 10, (int)component.Size.X+20, (int)component.Size.Y+20), null, Color.White); else SpriteManager.Draw(component.Texture, new Rectangle((int)component.Position.X, (int)component.Position.Y, (int)component.Size.X, (int)component.Size.Y), null, Color.White); } else SpriteManager.Draw(component.Texture, new Rectangle((int)component.Position.X, (int)component.Position.Y, (int)component.Size.X, (int)component.Size.Y), null, Color.White); } }
private void UpdateComponent(Object2D component, GameTime gameTime) { if (component.GetType() == typeof(GraphicObject) || component.GetType() == typeof(Scroller)) { UpdateComponent((component as GraphicObject).Children, gameTime); if ((component as GraphicObject).isClickable) ClickableComponent((component as GraphicObject)); } if (component.GetType() == typeof(AnimatedObject)) UpdateAnimation((component as AnimatedObject), gameTime); }