public ShootCommand(Creature attacker, Creature target, Map map, IRandomNumberGenerator randomNumberGenerator) { this.randomNumberGenerator = randomNumberGenerator; this.deffender = target; this.attacker = attacker; this.map = map; }
public MoveCommand(Creature creature, Direction moveDirection, Map map) { this.creature = creature; this.moveDirection = moveDirection; this.map = map; this.interactIfCreature = true; }
public GameService(int mapSizeX, int mapSizeY, string playerName)//char[,] initialMap) { this.playerName = playerName; Random r = RandomNumberGenerator.GlobalRandom; Generator = new MapGenerator(mapSizeX, mapSizeY); Creatures = new List<Creature>(); Player = new Creature(40) { CreatureType = "Hero", MeleeWeapon = new MeleeWeapon(){Damage=3, BrokeChance=0.001}, RangedWeapon = new RangedWeapon(){Damage=2, Range=3, Chance=0.5, Ammo=15}, GrenadeWeapon = new GrenadeWeapon{Damage=5, Range=5, Spread=2, Ammo=2} }; Player.MianownikName = "Gracz"; Player.BiernikName = "gracza"; Map = Generator.GenerateMap(Player);// new Map(initialMap); CreatureVisitor.map = Map; Creatures.AddRange(Generator.GeneratedCreatures); bool playerPlaced = false; while (playerPlaced == false) { playerPlaced = Map[r.Next(Map.MapWidth), r.Next(Map.MapHeight)].putCreature(Player); } }
public ThrowCommand(Creature thrower, Field targetField, Map map, IRandomNumberGenerator randomNumberGenerator) { this.thrower = thrower; this.targetField = targetField; this.map = map; this.randomNumberGenerator = randomNumberGenerator; }
public MapDrawer(Grid grid, int rows, int columns, Map map) { this.mapModel = map; this.RowCount = rows; this.ColumnCount = columns; fields = new GuiMapField[rows, columns]; for (int i = 0; i < RowCount; ++i) { for (int j = 0; j < ColumnCount; ++j) { GuiMapField field = null; if (map.IsWithinBounds(i, j)) { field = new GuiMapField(map, map[i,j]);// map[i, j]); } else { field = new GuiMapField(map, null); } fields[i,j] = field; field.SetValue(Grid.RowProperty, i); field.SetValue(Grid.ColumnProperty, j); grid.Children.Add(field); } } }
public void MyTestInitialize() { map = TestObjects.GetTestMap(); CreatureVisitor.map = map; target = new Creature(10) { MeleeWeapon = new MeleeWeapon() { Damage = 5 }, RangedWeapon = new RangedWeapon() { Damage = 5, Range = 5, Chance = 0.5} }; map[0, 0].putCreature(target); }
public void MyTestInitialize() { map = TestObjects.GetTestMap(); attacker = new Creature(10) { RangedWeapon = new RangedWeapon() { Damage = 5, Range = 1, Chance = 0.5 } }; deffender = new Creature(10); map[0,0].putCreature(attacker); map[0,1].putCreature(deffender); }
public static bool CanShoot(Map map, Creature attacker, Creature target) { if (attacker.RangedWeapon != null && map.getDistanceBetweenFields(attacker.Field, target.Field) <= attacker.RangedWeapon.Range && map.isSightBetweenFields(attacker.Field, target.Field)) return true; return false; }
public void MyTestInitialize() { map = TestObjects.GetTestMap(); attacker = new Creature(10){MeleeWeapon = new MeleeWeapon(){Damage=1}}; deffender = new Creature(10); map[0,0].putCreature(attacker); map[0,1].putCreature(deffender); }
public Room(Controller controller, Map map, Point cornerLeftUp, Point cornerRightDown) { this.controller = controller; this.map = map; cornerNW = cornerLeftUp; cornerSE = cornerRightDown; width = cornerSE.X - cornerNW.X; height = cornerSE.Y - cornerNW.Y; }
public Player(Controller controller) { this.controller = controller; state = Keyboard.GetState(); position = new Point(0, 0); health = maxHealth; delay = maxDelay; map = controller.map; }
public Camera(Controller controller, Point position, int tileSize) { this.controller = controller; this.tileSize = tileSize; this.position = position; this.graphics = controller.graphics; map = controller.map; scale = map.scale; maxTilesX = (int)Math.Ceiling(((float)graphics.PreferredBackBufferWidth / ((float)tileSize * scale))); maxTilesY = (int)Math.Ceiling(((float)graphics.PreferredBackBufferHeight / ((float)tileSize * scale))); }
public Controller(GraphicsDeviceManager graphics) { this.graphics = graphics; map = new Map(this, STARTMAPSIZE + level * 2); player = new Player(this); camera = new Camera(this, player.position, 32); player.health = player.maxHealth; map.CreateRandomLevel(3 + (int)level / 2, 2 + (int)level / 10, 2 + (int)level / 10, 3 + (int)level / 10, 3 + (int)level / 10); inv = new Inventory(this); inventory = inv.inventory; }
public AI(Map map, Creature player, Creature creature) { this.map = map; this.player = player; this.creature = creature; Random r = new Random(); if(r.Next(2) == 0) Sniper = true; else Sniper = false; }
public void MapGeneratedTest() { // arrange int mapSizeX = 30; int mapSizeY = 40; MapGenerator Generator = new MapGenerator(mapSizeX, mapSizeY); // act map = Generator.GenerateMap(player); // assert Assert.AreEqual(mapSizeX, map.MapWidth); Assert.AreEqual(mapSizeY, map.MapHeight); }
public MoveCommand(Creature creature, int xDir, int yDir, Map map, bool interactIfCreature) { Direction moveDirection = Direction.Down; if (xDir == -1 && yDir == -1) moveDirection = Direction.LeftUp; if (xDir == -1 && yDir == 0) moveDirection = Direction.Left; if (xDir == -1 && yDir == 1) moveDirection = Direction.LeftDown; if (xDir == 0 && yDir == -1) moveDirection = Direction.Up; if (xDir == 0 && yDir == 0) moveDirection = Direction.Stop; if (xDir == 0 && yDir == 1) moveDirection = Direction.Down; if (xDir == 1 && yDir == -1) moveDirection = Direction.RightUp; if (xDir == 1 && yDir == 0) moveDirection = Direction.Right; if (xDir == 1 && yDir == 1) moveDirection = Direction.RightDown; this.creature = creature; this.moveDirection = moveDirection; this.map = map; this.interactIfCreature = interactIfCreature; }
public Map GenerateMap(Creature player) { mapTemplate = new char[SizeX, SizeY]; // na początku wszystko jest terenem po którym można chodzić + obwódka ze ścian for (int i = 0; i < SizeX; ++i) for (int j = 0; j < SizeY; ++j) if (i == 0 || j == 0 || i == SizeX - 1 || j == SizeY - 1) mapTemplate[i, j] = '#'; else mapTemplate[i, j] = '.'; List<Building> buildings = new List<Building>(); for (int i = 0; i < maxBuildingNumber; ++i) { bool success = false; int counter = 0; while (success == false && counter < maxBuildingCounter) { Building b = Building.NewRandomBuilding(2, 2, SizeX - 2, SizeY - 2); if (!intersects(b, buildings)) { success = true; buildings.Add(b); } ++counter; } } foreach(Building b in buildings) b.DrawOnTemplate(mapTemplate); foreach (Building b in buildings) b.DrawDoors(mapTemplate); Map map = new Map(mapTemplate); foreach (Building b in buildings) b.GenerateLoot(map); int pointsCounter = 0; int tryCounter = 0; while (pointsCounter < PointObjectsCount) { ++tryCounter; if (buildings.Count == 0 || tryCounter > 10) { map[1, 1].placeObject(new Points() { Value = 10 }); ++pointsCounter; } foreach(Building b in buildings) { if (b.GeneratePoints(map) == true) ++pointsCounter; if (pointsCounter >= PointObjectsCount) break; } } foreach (Building b in buildings) { GeneratedCreatures.AddRange(b.GenerateCreatures(map, player)); } return map; }
public bool GeneratePoints(Map m) { if (SizeX > 2 && SizeY > 2) { int x = X + 1 + r.Next(SizeX - 2); int y = Y + 1 + r.Next(SizeY - 2); m[x,y].placeObject(new Points() { Value = 10 }); return true; } return false; }
public GuiMapField(Map m, Field field) { this.map = m; this.Field = field; }
public List<Creature> GenerateCreatures(Map map, Creature player) { List<Creature> cList = new List<Creature>(); if (SizeX > 2 && SizeY > 2) { int creatureCount = Math.Min((SizeX - 2) * (SizeY - 2), 1 + r.Next(4)); for (int i = 0; i < creatureCount; ++i) { Creature enemy = new CreatureGenerator().GetRandomCreature(); bool success = false; while (success == false) { success = map[X + 1 + r.Next(SizeX - 2), Y + 1 + r.Next(SizeY - 2)].putCreature(enemy); } AI ai = new AI(map, player, enemy); enemy.AI = ai; cList.Add(enemy); } } return cList; }
public AttackCommand(Creature attacker, Creature target, Map map) { this.deffender = target; this.attacker = attacker; this.map = map; }
public void GenerateLoot(Map m) { if (SizeX > 2 && SizeY > 2) { int lootCount = r.Next(3); for (int i = 0; i < lootCount; ++i) { int x = X + 1 + r.Next(SizeX - 2); int y = Y + 1 + r.Next(SizeY - 2); new LootGenerator().generateLoot(m[x, y]); } } }
public void MapTestInitialize() { map = TestObjects.GetTestMap(); }
public Creature GenerateRandomCreature(Map map, Creature player) { Random r = RandomNumberGenerator.GlobalRandom; Creature enemy = new CreatureGenerator().GetRandomCreature(); bool success = false; while(success == false) { success = map[r.Next(map.MapWidth), r.Next(map.MapHeight)].putCreature(enemy); } AI ai = new AI(map, player, enemy); enemy.AI = ai; return enemy; }
public void MapTestInitialize() { map = TestObjects.GetTestMap(); player = new Creature(10) { MeleeWeapon = new MeleeWeapon() { Damage = 1 }, RangedWeapon = new RangedWeapon() {Ammo = 1}, GrenadeWeapon = new GrenadeWeapon() { Ammo = 1 } }; map[0,0].putCreature(player); }
public void MapTestInitialize() { map = new Map(TestObjects.mapConfig); player = new Creature(10) { MeleeWeapon = new MeleeWeapon() { Damage = 5 } }; }
public Item(Controller controller, Point position, Map.Element baseElem) { this.controller = controller; this.position = position; this.baseElem = baseElem; Rarity rarity = RollRarity(); int random; switch (rarity) { case Rarity.Common: random = controller.random.Next(commonArray.Length); itemType = commonArray[random]; break; case Rarity.Uncommon: random = controller.random.Next(uncommonArray.Length); itemType = uncommonArray[random]; break; case Rarity.Rare: random = controller.random.Next(rareArray.Length); itemType = rareArray[random]; break; } switch (itemType)//ADDITEM { case ItemType.Potion: { texture = ContentManager.tPotion; itemCat = ItemCat.Consumable; break; } case ItemType.HealingPotion: { texture = ContentManager.tHealingPotion; itemCat = ItemCat.Consumable; break; } case ItemType.PotionRed: { texture = ContentManager.tPotionRed; itemCat = ItemCat.Consumable; break; } case ItemType.BigSword: { texture = ContentManager.tBigSword; itemCat = ItemCat.Weapon; damageStat = 5; break; } case ItemType.Shield: { texture = ContentManager.tShield; itemCat = ItemCat.Armor; defenseStat = 1; break; } case ItemType.PlateArmor: { texture = ContentManager.tPlateArmor; itemCat = ItemCat.Armor; defenseStat = 4; break; } case ItemType.BrokenSword: { texture = ContentManager.tBrokenSword; itemCat = ItemCat.Weapon; damageStat = 2; break; } } if (itemCat == ItemCat.Armor || itemCat == ItemCat.Weapon) { if (controller.random.Next(BONUSCHANCE) == BONUSCHANCE - 1) { if (damageStat > 0) { bonusStat = controller.random.Next(damageStat) + 1; damageStat += bonusStat; } if (defenseStat > 0) { bonusStat = controller.random.Next(defenseStat) + 1; defenseStat += bonusStat; } } } }