예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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());
        }
예제 #9
0
        }         // 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()
예제 #10
0
        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)));
        }
예제 #11
0
 public IGrabableItem CreateCreature(CreatureItem creature)
 {
     throw new InvalidOperationException("Not supported.");
 }
예제 #12
0
 public ItemData CreateCreature(CreatureItem creature)
 {
     currentTile.Creatures.Add(creature);
     return(creature);
 }
예제 #13
0
        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;
        }
예제 #14
0
        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;
        }