public Arrow(Texture2D texture, Vector2 location, Direction dir, IEntity shooter, Room room) { Shooter = shooter; Vector2 loc = location; if (dir == Direction.North || dir == Direction.South) { loc += new Vector2(sourceAdjustX, 0); } else { loc += new Vector2(0, sourceAdjustY); } if (dir == Direction.South || dir == Direction.East) { tipOffset = width * DirectionExtension.ToVector2(dir) + height * DirectionExtension.ToVector2(dir); } Location = new Rectangle((int)loc.X, (int)loc.Y, (int)(width * Game1.Scale), (int)(height * Game1.Scale)); LocationDraw = new Rectangle((int)loc.X, (int)loc.Y, (int)(width * Game1.Scale), (int)(height * Game1.Scale)); Texture = texture; this.dir = dir; this.room = room; source = new Rectangle(xOffset, yOffset, width, height); origin = new Vector2(width / 2, height / 2); rotation = 0; defaultAngle = (float)Math.PI / 2; }
public void HandleCollision(IWeapon weapon, ISprite border, Direction side, Game1 game) { if (weapon is Bomb bomb && border is Wall wall && bomb.Exploding && wall.CanBeBombed) { wall.BombWall(); foreach (ISprite sprite in game.Rooms[game.levelMachine.GetAdjacentRoom(game.RoomIndex, side)].LoadLevel.RoomSprite.RoomSprites) { if (sprite is Wall adjWall && adjWall.Side == DirectionExtension.OppositeDirection(side)) { adjWall.BombWall(); } } } }
public SwordBeam(Texture2D texture, Vector2 location, Direction dir, IEntity source, Room room) { if (source is IPlayer link) { Damage = link.WeaponDamage; } else { Damage = 2; } Shooter = source; this.room = room; this.dir = dir; this.texture = texture; Location = new Rectangle((int)location.X, (int)location.Y, (int)(width * Game1.Scale), (int)(height * Game1.Scale)); adjust = 4 * DirectionExtension.ToVector2(dir); if (dir == Direction.North || dir == Direction.South) { width = 7; height = 16; sources = new List <Rectangle> { new Rectangle(1, 154, width, height), new Rectangle(36, 154, width, height), new Rectangle(71, 154, width, height), new Rectangle(106, 154, width, height) }; } else { width = 16; height = 7; sources = new List <Rectangle> { new Rectangle(10, 159, width, height), new Rectangle(45, 159, width, height), new Rectangle(80, 159, width, height), new Rectangle(115, 159, width, height) }; } spriteEffects = new List <SpriteEffects>() { 0, SpriteEffects.FlipVertically, 0, SpriteEffects.FlipHorizontally }; }