public Image(Texture2D texture, Rectangle rectangle, string tag = "") { this.rectangle = rectangle; this.texture = texture; this.tag = tag; this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); this.isActive = true; }
public Image(Texture2D texture, Vector2 centerPosition, string tag = "") { this.rectangle = Tools.Tools.GetRectangle.Rectangle(centerPosition, texture); this.texture = texture; this.tag = tag; this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); this.isActive = true; }
public Line(Point start, Point end, int thickness, Texture2D texture2D, string tag) { this.start = start; this.end = end; this.thickness = thickness; this.animation = new Animation(texture2D); this.tag = tag; this.isActive = true; CreateLine(); this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); }
public Minimimap(Dictionary <int, Color> minimapColors, int[,] map, Vector2 centerPosition, int scaleFactor, IEntity player) { // Implementation { this.player = player; Color[] colors = ToArrayOfColors(minimapColors, map); Texture2D mapTexture = CreateTexture(colors, map.GetLength(1), map.GetLength(0)); this.texture = Tools.Tools.Texture.ScaleTexture(mapTexture, scaleFactor); this.rectangle = Tools.Tools.GetRectangle.Rectangle(centerPosition, texture); this.tag = ""; this.isActive = true; this.dxUpdateSystem = (InputState lastInputState, InputState inputState) => UpdateSystem(); this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); this.miniPlayerTexture = Tools.Tools.Texture.CreateColorTexture(Color.Red, scaleFactor, scaleFactor); } // Helpers Color[] ToArrayOfColors(Dictionary <int, Color> minimapColors, int[,] map) { List <Color> colors = new List <Color>(); for (int row = 0; row < map.GetLength(0); row++) { for (int element = 0; element < map.GetLength(1); element++) { if (minimapColors[map[row, element]] != null) { colors.Add(minimapColors[map[row, element]]); } } } return(colors.ToArray()); } Texture2D CreateTexture(Color[] colors, int W, int H) { GraphicsDevice graphicsDevice = ChristianGame.graphicsDevice; Texture2D texture2D = new Texture2D(graphicsDevice, W, H, false, SurfaceFormat.Color); texture2D.SetData(colors); return(texture2D); } }
public Label(Rectangle rectangle, SpriteFont spriteFont, string text, TextAlignment textAlignment, string tag, Texture2D texture = null, int lineSpacing = 10, bool isActive = true) { this.rectangle = rectangle; this.spriteFont = spriteFont; this.text = text; this.texture = texture; this.textAlignment = textAlignment; this.spriteFont.LineSpacing = lineSpacing; this.textPosition = GetTextPosition(); this.tag = tag; this.isActive = isActive; //this.dxUiUpdateSystem = (InputState lastInputState, InputState inputState) => UpdateSystem(lastInputState, inputState); this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); }
public Entity( Texture2D texture2D, Vector2 centerPosition, bool isActive = true, string tag = "", Vector2?force = null, Vector2?gravity = null, DxUpdateSystem dxUpdateSystem = null, DxDrawSystem dxDrawSystem = null) { this.characterState = CharacterState.IdleRight; this.animation = new Animation(texture2D); this.rigidbody = new Rigidbody( centerPosition: centerPosition, entity: this, force: force ); this.isActive = isActive; this.tag = tag; this.dxUpdateSystem = dxUpdateSystem; this.dxDrawSystem = dxDrawSystem; }
public FadeIn(byte fadeSpeed = 10, bool isActive = true) { this.rectangle = ChristianGame.GetScene.camera.rectangle; this.fadeSpeed = (byte)fadeSpeed; this.color = Color.Black; this.texture = ChristianTools.Tools.Tools.Texture.CreateColorTexture(color); this.fadeFinish = false; this.isActive = isActive; this.dxUpdateSystem = (InputState lastInputState, InputState inputState) => UpdateSystem(lastInputState, inputState); this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); }
public void Initialize(Vector2?playerPosition = null) { subAtlas_1 = Tools.Texture.CropTexture( originalTexture: Tools.Texture.GetTexture("MyAtlasTexture"), extractRectangle: new Rectangle(0, 0, 50, 50) ); subAtlas_2 = Tools.Texture.CropTexture( originalTexture: Tools.Texture.GetTexture("MyAtlasTexture"), extractRectangle: new Rectangle(50, 0, 50, 50) ); subAtlas_3 = Tools.Texture.CropTexture( originalTexture: Tools.Texture.GetTexture("MyAtlasTexture"), extractRectangle: new Rectangle(0, 50, 50, 50) ); subAtlas_4 = Tools.Texture.CropTexture( originalTexture: Tools.Texture.GetTexture("MyAtlasTexture"), extractRectangle: new Rectangle(50, 50, 50, 50) ); circle_1 = Tools.Texture.CreateCircleTexture(Color.Green, 3); circle_2 = Tools.Texture.CreateCircleTexture(Color.Green, 4); circle_3 = Tools.Texture.CreateCircleTexture(Color.Green, 25); circle_4 = Tools.Texture.CreateCircleTexture(Color.Green, 26); triangle_Up = Tools.Texture.CreateTriangle( color: Color.Red, Width: 40, Height: 40, pointDirection: Tools.Texture.PointDirection.Up ); triangle_Down = Tools.Texture.CreateTriangle( color: Color.Red, Width: 40, Height: 40, pointDirection: Tools.Texture.PointDirection.Down ); triangle_Right = Tools.Texture.CreateTriangle( color: Color.Red, Width: 40, Height: 40, pointDirection: Tools.Texture.PointDirection.Right ); triangle_Left = Tools.Texture.CreateTriangle( color: Color.Red, Width: 40, Height: 40, pointDirection: Tools.Texture.PointDirection.Left ); fontMap = Tools.Texture.GetTexture("MyFont_130x28_PNG"); fontMap_Green = Tools.Texture.ReColorTexture(fontMap, Color.Green); fontMap_Red = Tools.Texture.ReColorTexture(fontMap, Color.Red); textureNormal = Tools.Texture.GetTexture("MyAtlasTexture"); textureFlippedHorizontal = Tools.Texture.FlipHorizontal(textureNormal); this.UIs = new List <IUI>() { new Button( rectangle: new Rectangle(0, 470, 230, 30), text: "<- Menu", defaultTexture: WK.Texture.LightGray, mouseOverTexture: WK.Texture.Gray, spriteFont: WK.Font.font_7, tag: "goToMenu", OnClickAction: () => Game1.ChangeToScene(WK.Scene.Menu) ) }; this.dxDrawSystem = (SpriteBatch spriteBatch) => DrawSystem(spriteBatch); }