public void Draw(SpriteBatch sb, Camera2D camera) { Texture2D texture = SpriteLoader.GetTexture(TextureId); sb.Draw(texture, new Rectangle((int)Position.X, (int)Position.Y, Width, Height), new Rectangle(Width * frame, Height * frameRow, Width, Height), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.5f); sb.Draw(texture, attackBox, new Rectangle(Width, Height, Width, Height), Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.5f); // Debugging purposes }
public void Draw(SpriteBatch sb, int playerY, Camera2D Camera) { // Background sb.Draw(SpriteLoader.GetTexture(TextureID), new Rectangle(0, 0, Width, Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0.0f); // Objects foreach (Object obj in Objects) { if (Camera.IsInView(obj.Position, SpriteLoader.GetTexture(obj.TextureId))) { obj.Draw(sb, playerY); } } // NPCs foreach (NPC npc in NPCs) { if (Camera.IsInView(npc.Position, SpriteLoader.GetTexture(npc.TextureId))) { npc.Draw(sb, playerY); } } // Exits foreach (Exit ext in Exits) { if (Camera.IsInView(ext.Position, SpriteLoader.GetTexture(ext.TextureId))) { ext.Draw(sb, playerY); } } }
public void Update(Player player, Camera2D Camera) { if (player.CheckIfAttackConnected) { foreach (NPC npc in NPCs) { if (Camera.IsInView(npc.Position, SpriteLoader.GetTexture(npc.TextureId))) { if (Collision.CheckCollision(player.GetAttackBox(), new Rectangle((int)npc.Position.X, (int)npc.Position.Y, SpriteLoader.GetTexture(npc.TextureId).Width, SpriteLoader.GetTexture(npc.TextureId).Height))) { // SET NPC Health to whatever! // Handle if below set amount npc.Position = new Vector2(-1000, -1000); } } } player.CheckIfAttackConnected = false; } if (player.CheckIfMovementCollision) { foreach (Object obj in Objects) { if (Camera.IsInView(obj.Position, SpriteLoader.GetTexture(obj.TextureId))) { if (Collision.CheckCollision(new Rectangle((int)player.Position.X, (int)player.Position.Y, player.Width, player.Height), obj.source)) { // Undo Player movement player.ResetPosition(); } } } player.CheckIfMovementCollision = false; } }
public BlueSword(int x, int y) { X = x; Y = y; TextureId = 6; // Set size Texture2D texture = SpriteLoader.GetTexture(TextureId); if (texture.Width < Width) { X += Math.Abs(Width - texture.Width) / 2; Width = texture.Width; } }
public static void Draw(SpriteBatch sb, Camera2D camera) { for (int i = 0; i < 10; i++) { X = 100 + ((i * size) + (i * dist)); // Draw Quickbar Texture2D texture = SpriteLoader.GetTexture(7); sb.Draw(texture, camera.ScreenToWorld(new Rectangle(X, Y, size, size)), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1.0f); // Draw Item if (i < items.Count) { items[i].Draw(sb, camera); } } }
public virtual void Draw(SpriteBatch sb, int playerY) { float Z; float diff = Math.Abs(playerY - Position.Y) / 1000; // Above player if (Position.Y <= playerY) { Z = (0.5f - diff); } // Below player else { Z = Z = (0.5f + diff); } Texture2D texture = SpriteLoader.GetTexture(TextureId); //sb.Draw(texture, new Rectangle(X, Y, texture.Width, texture.Height), Color.White); sb.Draw(texture, new Rectangle((int)Position.X, (int)Position.Y, texture.Width, texture.Height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, Z); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); // Load Sprites SpriteLoader.LoadTextures(Content); }
public void Draw(SpriteBatch sb) { sb.Draw(SpriteLoader.GetTexture(TextureId), source, new Rectangle(Width * XFrame, Height * YFrame, Width, Height), Color.CornflowerBlue, 0, Vector2.Zero, SpriteEffects.None, 1.0f); }
public virtual void Draw(SpriteBatch sb, Camera2D camera) { Texture2D texture = SpriteLoader.GetTexture(TextureId); sb.Draw(texture, camera.ScreenToWorld(new Rectangle(X, Y, Width, Height)), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 1.0f); }
public void SetSources() { foreach (Object obj in Objects) { if (obj.source == new Rectangle(0, 0, 0, 0)) { obj.source = new Rectangle((int)obj.Position.X, (int)obj.Position.Y, SpriteLoader.GetTexture(obj.TextureId).Width, SpriteLoader.GetTexture(obj.TextureId).Height); } } // Exits foreach (Exit ext in Exits) { if (ext.source == new Rectangle(0, 0, 0, 0)) { ext.source = new Rectangle((int)ext.Position.X, (int)ext.Position.Y, SpriteLoader.GetTexture(ext.TextureId).Width, SpriteLoader.GetTexture(ext.TextureId).Height); } } }