public static void InitializeDialogueSystem(Viewport viewport) { //dialogueBox = Game1.content.Load<Texture2D>("textures\\ui\\dialogue_box"); dialogueBox = DebugTextures.GenerateRectangle(200, 50, new Color(new Vector4(0.15686274509803921568627450980392f, 0.15686274509803921568627450980392f, 0.15686274509803921568627450980392f, 1f))); DialogueBoxPosition = new Vector2(-dialogueBox.Width / 2, Game1.gameHeight / 4); DialoguePosition = DialogueBoxPosition * Game1.resolutionScale + new Vector2(viewport.Width, viewport.Height) / 2 + new Vector2(15, 25); //Game1.instance.resolutionScale; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); DebugTextures.LoadTextures(GraphicsDevice); Text.defaultFont = Content.Load <SpriteFont>("fonts\\npc1"); Text.guiFont = Content.Load <SpriteFont>("fonts\\gui"); Cell.CreateGrid(new Point(-3200, -3200), 500, 500); Dialogue.InitializeDialogueSystem(graphics.GraphicsDevice.Viewport); map = new Map(); screenCenter = new Vector2(gameWidth / 2f, gameHeight / 2f); character = new Character(); map.npcs.Add(new NPC(new Vector2(100, -100), DebugTextures.GenerateRectangle(16, 32, Color.Yellow), "Hello world!!", "Great to see you decided to play this game!!")); map.npcs.Add(new NPC(new Vector2(150, 10), DebugTextures.GenerateRectangle(16, 32, Color.Yellow), "Hello, my name is tommy! I used to live in peace", "watering me plants in me garden everyday, until the unpredictable struck")); map.enemies.Add(new PeasantSoldier(50f, 0.005f, 200f, 300f, 100, screenCenter, DebugTextures.GenerateRectangle(16, 16, Color.DarkGray), character)); map.enemies.Add(new PeasantSoldier(86, 0.004f, 200f, 300f, 100, new Vector2(53, 3466), DebugTextures.GenerateRectangle(16, 16, Color.GreenYellow), character)); map.enemies.Add(new PeasantSoldier(70f, 0.004f, 200f, 300f, 100, new Vector2(62, 23), DebugTextures.GenerateRectangle(16, 16, Color.DarkRed), character)); map.enemies.Add(new PeasantSoldier(69f, 0.004f, 200f, 300f, 100, new Vector2(97, 2), DebugTextures.GenerateRectangle(16, 16, Color.Red), character)); map.enemies.Add(new PeasantSoldier(82f, 0.004f, 200f, 300f, 100, new Vector2(64, 0), DebugTextures.GenerateRectangle(16, 16, Color.Yellow), character)); map.enemies.Add(new PeasantSoldier(56f, 0.004f, 200f, 300f, 100, new Vector2(2, 49), DebugTextures.GenerateRectangle(16, 16, Color.Blue), character)); Vector2 pos = Cell.SnapToGrid(Vector2.One * 40); map.objects.Add(new Wall(pos, 64, 64, true)); Raycast.RayCastTest(); }
public Character() { isInteracting = false; position = new Vector2(200, 200); gun = new Gun(10f, 10f, true, position, new Bullet(7.5f, BulletType.Normal), "character"); sprite = DebugTextures.GenerateRectangle(16, 32, Color.PaleVioletRed); A = Vector2.Zero; // top left B = new Vector2(sprite.Width, 0); // top right C = new Vector2(0, sprite.Width); // bottom left D = new Vector2(sprite.Width, sprite.Height); // bottom right origin = new Vector2(sprite.Width / 2f, sprite.Height / 2f); camera = new Camera(new Vector2(0, 0), -500, 500, -500, 500); health = maxHealth; gui = new Gui(maxHealth); prevKeyState = Keyboard.GetState(); prevMouseState = Mouse.GetState(); collider = new Collider(position, sprite.Width, sprite.Height, "character", this); Game1.instance.map.colliders.Add(collider); cell = Cell.GetCell(position); cell.colliders.Add(collider); }
public Bar(int width, int height, Color color1, Color color2, Color backgroundColor, int borderThickness = 0, float startValue = 0f) { Value = startValue; this.color1 = color1; this.color2 = color2; this.width = width; this.height = height; progress = DebugTextures.GenerateRectangle(width, height, Color.White); if (borderThickness > 0) { border = DebugTextures.GenerateHollowRectangele(width, height, borderThickness, Color.Black); origin = new Vector2(border.Width / 2f, border.Height / 2f); } if (backgroundColor != Color.Transparent) { this.backgroundColor = backgroundColor; background = DebugTextures.GenerateRectangle(progress.Width, progress.Height, Color.White); transparent = false; } else { transparent = true; } if (color2 == null) { color2 = color1; } }
public HealthBar() { Value = 1f; sprite = DebugTextures.GenerateHollowRectangele(10, 5, 1, Color.Black); progress = DebugTextures.GenerateRectangle(10, 5, Color.White); origin = new Vector2(sprite.Width / 2f, sprite.Height / 2f); }
public void DrawDebug(SpriteBatch batch) { if (debugSprite != null) { batch.Draw(debugSprite, position, null, Color.White, 0f, debugOrigin, 1f, SpriteEffects.None, 0f); // fiiix mee } Texture2D tx = DebugTextures.GenerateRectangle(10, 10, Color.White); batch.Draw(tx, position, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); // fiiix mee }
public void Initialize(Vector2 position, float rotation, Vector2 forwardDirection) { sprite = DebugTextures.GenerateRectangle(8, 3, Color.Black); origin = new Vector2(sprite.Width / 2f, sprite.Height / 2f); this.position = position; this.rotation = rotation + MathHelper.PiOver2; this.forwardDirection = forwardDirection; }
public void Draw(SpriteBatch batch) { DebugTextures.DrawDebugLine(batch, a, b, Color.White, 1); batch.Draw(sprite, intersectPos, null, Color.Red, 0f, origin, 1f, SpriteEffects.None, 1f); if (closeCells != null) { foreach (var c in closeCells) { c.Draw(batch, Color.Yellow); } } }
public static void CreateGrid(Point startingPoint, int rows, int columns) { Cell.startingPoint = startingPoint; grid = new Cell[rows, columns]; for (int y = 0; y < columns; y++) { for (int x = 0; x < rows; x++) { grid[x, y] = new Cell(x * cellWidth + startingPoint.X, y * cellHeight + startingPoint.Y); } } CellSprite = DebugTextures.GenerateHollowRectangele(cellWidth, cellHeight, 1, Color.White); SpriteOrigin = new Vector2(cellWidth / 2f, cellHeight / 2f); }
public SceneObject(int width, int height, bool stationary) { this.width = width; this.height = height; this.stationary = stationary; collider = new Collider(position, width, height, "sceneobject", this); Game1.instance.map.colliders.Add(collider); sprite = DebugTextures.GenerateRectangle(width, height, Color.PowderBlue); origin = new Vector2(width / 2f, height / 2f); cell = Cell.GetCell(position); cell.colliders.Add(collider); }
public Gun(float damage, float fireRate, bool autoFire, Vector2 position, Bullet bullet, params string[] avoid) { this.damage = damage; this.fireRate = fireRate; this.autoFire = autoFire; this.position = position; this.bullet = bullet; this.avoid = avoid; //sprite = Game1.content.Load<Texture2D>("textures\\laser_pistol"); sprite = DebugTextures.GenerateRectangle(5, 10, Color.DarkGreen); origin = new Vector2(sprite.Width / 2f, sprite.Height / 2f); bullets = new List <Bullet>(); prevMouseState = Mouse.GetState(); }
public static void RayCastTest() { sprite = DebugTextures.GenerateRectangle(4, 4, Color.White); origin = new Vector2(sprite.Width / 2f, sprite.Height / 2f); }
public static Rectangle[] CollidingRectangle(Vector2 position, Cell[] cellCheck, int width, int height, out Collider[] colInfo) // need multiple collider objects!! { List <Rectangle> colliders = null; List <Collider> colInfos = null; Rectangle rect1 = new Rectangle((int)position.X - width / 2, (int)position.Y - height / 2, width, height); foreach (var cell in cellCheck) { if (cell.colliders.Count > 0) { foreach (var co in cell.colliders) { Rectangle rect2 = new Rectangle((int)co.position.X - co.width / 2, (int)co.position.Y - co.height / 2, co.width, co.height); if (rect1 == rect2) { continue; } if (Game1.instance.debugDrawing) { debugTexture = DebugTextures.GenerateHollowRectangele(rect1.Width, rect1.Height, 1, Color.White); colPosition = rect1.Center.ToVector2(); colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); } Rectangle col = Rectangle.Intersect(rect1, rect2); if (!col.IsEmpty) { if (colliders == null) { colliders = new List <Rectangle>(); } if (co.owner != null) { if (colInfos == null) { colInfos = new List <Collider>(); } colInfos.Add(co); } colliders.Add(col); if (Game1.instance.debugDrawing) { debugTexture = DebugTextures.GenerateHollowRectangele(col.Width, col.Height, 1, Color.White); colPosition = col.Center.ToVector2(); colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); } } } } } /*foreach (var co in Game1.instance.map.colliders) // loop through every possible collidable object (has to be more efficient in the fututre) * { * * #region debug * * if (Game1.instance.debugDrawing) * { * //debugTexture = DebugTextures.GenerateHollowRectangele(rect1.Width, rect1.Height, 2, Color.White); * //colPosition = rect1.Location.ToVector2(); * //colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); * } * #endregion * }*/ if (colliders == null) { colInfo = null; return(null); } if (colInfos != null) { colInfo = colInfos.ToArray(); } else { colInfo = null; } return(colliders.ToArray()); }
/// <summary> /// is an object colliding with any of the scene objects? /// </summary> /// <param name="position">origin</param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static Rectangle[] CollidingRectangle(Vector2 position, Cell[] cellCheck, int width, int height) // needs to return multiple tags if colliding with multiple objects (return collider instead of rectangle) { List <Rectangle> colliders = null; Rectangle rect1 = new Rectangle((int)position.X - width / 2, (int)position.Y - height / 2, width, height); foreach (var cell in cellCheck) { if (cell.colliders.Count > 0) { foreach (var co in cell.colliders) { Rectangle rect2 = new Rectangle((int)co.position.X - co.width / 2, (int)co.position.Y - co.height / 2, co.width, co.height); if (rect1 == rect2) // remember that this may be causing issues for different objects with the same size { continue; } if (Game1.instance.debugDrawing) { debugTexture = DebugTextures.GenerateHollowRectangele(rect1.Width, rect1.Height, 1, Color.White); colPosition = rect1.Center.ToVector2(); colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); } Rectangle col = Rectangle.Intersect(rect1, rect2); if (!col.IsEmpty) { if (colliders == null) { colliders = new List <Rectangle>(); } colliders.Add(col); if (Game1.instance.debugDrawing) { debugTexture = DebugTextures.GenerateHollowRectangele(col.Width, col.Height, 1, Color.White); colPosition = col.Center.ToVector2(); colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); } } } } } /*foreach (var co in Game1.instance.map.colliders) // loop through every possible collidable object (has to be more efficient in the fututre) * { * * #region debug * * if (Game1.instance.debugDrawing) * { * //debugTexture = DebugTextures.GenerateHollowRectangele(rect1.Width, rect1.Height, 2, Color.White); * //colPosition = rect1.Location.ToVector2(); * //colOrigin = new Vector2(debugTexture.Width / 2f, debugTexture.Height / 2f); * } * #endregion * }*/ if (colliders == null) { return(null); } return(colliders.ToArray()); }
public static Button Debug(string text, int width, int height, Color color, onPressed onPressed) { return(new Button(latestButtonPosition + new Vector2(width * 1.5f, 0), text, false, DebugTextures.GenerateRectangle(width, height, color), GUI.defaultFont, onPressed)); }