private CreatureItem ParseCreatureData(BinaryReader r) { var c = new CreatureItem(); c.NextObjectID = r.ReadUInt16(); c.NextPossessionObjectID = new ObjectID(r.ReadUInt16()); c.Type = (CreatureType)r.ReadByte(); byte data = r.ReadByte(); c.Creature1Position = (TilePosition)(data & twoBitsMask); c.Creature2Position = (TilePosition)((data >> 2) & twoBitsMask); c.Creature3Position = (TilePosition)((data >> 4) & twoBitsMask); c.Creature4Position = (TilePosition)((data >> 6) & twoBitsMask); c.HitPointsCreature1 = r.ReadUInt16(); c.HitPointsCreature2 = r.ReadUInt16(); c.HitPointsCreature3 = r.ReadUInt16(); c.HitPointsCreature4 = r.ReadUInt16(); ushort data1 = r.ReadUInt16(); c.IsImportant = ((data1 >> 10) & oneBitMask) == 1; c.Direction = (Direction)((data1 >> 8) & twoBitsMask); c.CreaturesCount = ((data1 >> 5) & twoBitsMask); return(c); }
public virtual IEnumerable <Creature> AddCreatureToTile(CreatureItem creatureData, Tile tile, Point position) { var factory = builder.Factories.CreatureFactories[(int)creatureData.Type]; var res = new List <Creature>(); foreach (var tuple in GetCreatures(creatureData)) { var space = factory.Layout.AllSpaces.First(s => tuple.Item1.ToDirections().All(s.Sides.Contains)); var creature = factory.Create(new CreatureInitializer { HitPoints = tuple.Item2, Location = factory.Layout.GetSpaceElement(space, tile), RelationToken = builder.CreatureToken, EnemiesTokens = builder.ChampionToken.ToEnumerable(), PossessionItems = tuple.Item3 }); creature.Renderer = builder.Factories.RenderersSource.GetCreatureRenderer(creature, factory.Texture); res.Add(creature); } return(res); }
private IList <CreatureItem> ReadCreaturesData(BinaryReader r) { var c = new CreatureItem[Data.CreaturesCount]; for (int i = 0; i < c.Length; i++) { c[i] = ParseCreatureData(r); } return(c); }
public IEnumerable<Creature> AddCreature(CreatureItem creature, Tile tile) { var creatureDescriptor = builder.Data.CreatureDescriptors[(int)creature.Type]; var duration = creatureDescriptor.MovementDuration * 1000 / 6; duration = MathHelper.Clamp(duration, 500, 1200); var layout = GetGroupLayout(creature); var res = new List<Creature>(); foreach (var tuple in creature.GetCreaturesInfo().Take(creature.CreaturesCount + 1)) { var space = layout.AllSpaces.First(s => tuple.Item1.ToDirections().All(s.Sides.Contains)); res.Add(new Creature(layout, new FourthSpaceRouteElement(space, tile), builder.CreatureToken, builder.ChampionToken.ToEnumerable(), duration, creatureDescriptor.DetectionRange, creatureDescriptor.SightRange)); } return res; }
public IGroupLayout GetGroupLayout(CreatureItem creature) { return(Small4GroupLayout.Instance); switch (creature.Type) { //1 case CreatureType.GiantScorpion_Scorpion: case CreatureType.StoneGolem: case CreatureType.BlackFlame: case CreatureType.Couatl: case CreatureType.WaterElemental: case CreatureType.Oitu: case CreatureType.LordChaos: case CreatureType.RedDragon_Dragon: case CreatureType.LordOrder_: case CreatureType.GreyLord: return(new Large1GroupLayout()); //4 case CreatureType.SwampSlime_SlimeDevil: case CreatureType.Giggler: case CreatureType.WizardEye_FlyingEye: case CreatureType.Screamer: case CreatureType.Rockpile_RockPile: case CreatureType.Ghost_Rive: case CreatureType.Mummy: case CreatureType.Skeleton: case CreatureType.Vexirk: case CreatureType.Trolin_AntMan: case CreatureType.GiantWasp_Muncher: case CreatureType.AnimatedArmour_DethKnight: case CreatureType.Materializer_Zytaz: case CreatureType.Demon_Demon: return(Small4GroupLayout.Instance); //2 case CreatureType.MagentaWorm_Worm: case CreatureType.PainRat_Hellhound: case CreatureType.Ruster: return(new Medium2GroupLayout()); default: throw new ArgumentOutOfRangeException(); } }
public IGroupLayout GetGroupLayout(CreatureItem creature) { return Small4GroupLayout.Instance; switch (creature.Type) { //1 case CreatureType.GiantScorpion_Scorpion: case CreatureType.StoneGolem: case CreatureType.BlackFlame: case CreatureType.Couatl: case CreatureType.WaterElemental: case CreatureType.Oitu: case CreatureType.LordChaos: case CreatureType.RedDragon_Dragon: case CreatureType.LordOrder_: case CreatureType.GreyLord: return new Large1GroupLayout(); //4 case CreatureType.SwampSlime_SlimeDevil: case CreatureType.Giggler: case CreatureType.WizardEye_FlyingEye: case CreatureType.Screamer: case CreatureType.Rockpile_RockPile: case CreatureType.Ghost_Rive: case CreatureType.Mummy: case CreatureType.Skeleton: case CreatureType.Vexirk: case CreatureType.Trolin_AntMan: case CreatureType.GiantWasp_Muncher: case CreatureType.AnimatedArmour_DethKnight: case CreatureType.Materializer_Zytaz: case CreatureType.Demon_Demon: return Small4GroupLayout.Instance; //2 case CreatureType.MagentaWorm_Worm: case CreatureType.PainRat_Hellhound: case CreatureType.Ruster: return new Medium2GroupLayout(); default: throw new ArgumentOutOfRangeException(); } }
public IEnumerable <Creature> AddCreature(CreatureItem creature, Tile tile) { var creatureDescriptor = builder.Data.CreatureDescriptors[(int)creature.Type]; var duration = creatureDescriptor.MovementDuration * 1000 / 6; duration = MathHelper.Clamp(duration, 500, 1200); var layout = GetGroupLayout(creature); var res = new List <Creature>(); foreach (var tuple in creature.GetCreaturesInfo().Take(creature.CreaturesCount + 1)) { var space = layout.AllSpaces.First(s => tuple.Item1.ToDirections().All(s.Sides.Contains)); res.Add(new Creature(layout, new FourthSpaceRouteElement(space, tile), builder.CreatureToken, builder.ChampionToken.ToEnumerable(), duration, creatureDescriptor.DetectionRange, creatureDescriptor.SightRange)); } return(res); }
protected IGrabableItem[][] GetPossesions(CreatureItem creatureData, int creatureCount) { var possessions = creatureData.PossessionItems.Select(x => builder.ItemCreator.CreateItem(x)); var que = new Queue <IGrabableItem>(possessions); var possesionsCountForCreature = que.Count / creatureCount; return(Enumerable.Range(0, creatureCount).Select((j, x) => { if (j < creatureCount - 1) { return Enumerable.Range(0, possesionsCountForCreature).Select(zz => que.Dequeue()).ToArray(); } else { return que.ToArray(); } }) .ToArray()); }
} // Attack() public static void UseItem(int userId, int itemId) { Creature user = Combatants.SingleOrDefault(x => x.Id == userId); CreatureItem item = user.Items.SingleOrDefault(x => x.ItemId == itemId); if (item.Item.ItemType == Enumerators.ItemTypeEnum.Healing) { user.HitPoints += item.Item.Strength; if (user.HitPoints > user.MaxHP) { user.HitPoints = user.MaxHP; } AddToLog(new string($"{user.Name} używa {item.Item.Name}, które przywraca {item.Item.Strength} punktów zdrowia.")); } else if (item.Item.ItemType == Enumerators.ItemTypeEnum.Mana) { user.Mana += item.Item.Strength; if (user.Mana > user.MaxMana) { user.Mana = user.MaxMana; } AddToLog(new string($"{user.Name} używa {item.Item.Name}, które przywraca {item.Item.Strength} punktów many.")); } user.ActionPoints -= item.Item.ActionCost; if (item.Qty == 1) { user.Items.Remove(item); } else { item.Qty -= 1; } } // UseItem()
protected IEnumerable <Tuple <TilePosition, int, IGrabableItem[]> > GetCreatures(CreatureItem creatureData) { int creatureCount = creatureData.CreaturesCount + 1; var possesions = GetPossesions(creatureData, creatureCount); return(creatureData.GetCreaturesInfo().Zip(possesions, (x, y) => Tuple.Create(x.Item1, x.Item2, y))); }
public IGrabableItem CreateCreature(CreatureItem creature) { throw new InvalidOperationException("Not supported."); }
public ItemData CreateCreature(CreatureItem creature) { currentTile.Creatures.Add(creature); return(creature); }
private CreatureItem ParseCreatureData(BinaryReader r) { var c = new CreatureItem(); c.NextObjectID = r.ReadUInt16(); c.NextPossessionObjectID = r.ReadUInt16(); c.Type = (CreatureType)r.ReadByte(); byte data = r.ReadByte(); c.Creature1Position = (TilePosition)(data & twoBitsMask); c.Creature2Position = (TilePosition)((data >> 2) & twoBitsMask); c.Creature3Position = (TilePosition)((data >> 4) & twoBitsMask); c.Creature4Position = (TilePosition)((data >> 6) & twoBitsMask); c.HitPointsCreature1 = r.ReadUInt16(); c.HitPointsCreature2 = r.ReadUInt16(); c.HitPointsCreature3 = r.ReadUInt16(); c.HitPointsCreature4 = r.ReadUInt16(); ushort data1 = r.ReadUInt16(); c.IsImportant = ((data1 >> 10) & oneBitMask) == 1; c.Direction = (Direction)((data1 >> 8) & twoBitsMask); c.CreaturesCount = ((data1 >> 5) & twoBitsMask); return c; }
private IList<CreatureItem> ReadCreaturesData(BinaryReader r) { var c = new CreatureItem[Data.CreaturesCount]; for (int i = 0; i < c.Length; i++) c[i] = ParseCreatureData(r); return c; }