Пример #1
0
        public void DrawCreature(SpriteBatch Batch, GameTime Time, ClientCreature Creature, Vector2 Offset, Color clr)
        {
            if (Creature.Outfit.LookItem != 0)
            {
                DrawSprite(Batch, Time, null, GameData.GetItemSprite(Creature.Outfit.LookItem), 1, -1, Offset, clr);
            }
            else if (Creature.Outfit.LookType != 0)
            {
                GameSprite Sprite = GameData.GetCreatureSprite(Creature.Outfit.LookType);

                Offset.X += Sprite.RenderOffset;
                Offset.Y += Sprite.RenderOffset;
                if (Sprite != null)
                {
                    for (int cx = 0; cx != Sprite.Width; ++cx)
                    {
                        for (int cy = 0; cy != Sprite.Height; ++cy)
                        {
                            GameImage Image = Sprite.GetImage(
                                cx, cy,
                                Creature.Direction, Creature.Outfit,
                                (int)(Time.TotalGameTime.TotalMilliseconds / Sprite.AnimationSpeed)
                                );

                            Rectangle rect = new Rectangle((int)Offset.X - 32 * cx, (int)Offset.Y - 32 * cy, 32, 32);
                            DrawImage(Batch, Image, rect, clr);
                        }
                    }
                }
            }
        }
Пример #2
0
        private void OnCreatureLight(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Light.Color = (int)props["Color"];
            Creature.Light.Level = (int)props["Level"];
        }
Пример #3
0
        private void VIPStatusChanged(ClientViewport Viewport, ClientCreature Creature)
        {
            if (Viewport != this.Viewport)
            {
                return;
            }

            UpdateList();
        }
Пример #4
0
        public Color LifeColorForCreature(ClientCreature Creature)
        {
            ColorGradient cg = UIContext.Skin.Gradient("Health");

            if (cg != null)
            {
                return(cg.Sample(Creature.HealthPercent));
            }
            return(new Color(255, 255, 255));
        }
Пример #5
0
        private void OnVIPState(Packet props)
        {
            ClientCreature Creature = null;

            if (!VIPList.TryGetValue((UInt32)props["CreatureID"], out Creature))
            {
                Creature             = new ClientCreature((UInt32)props["CreatureID"]);
                VIPList[Creature.ID] = Creature;
            }
            Creature.Name   = (String)props["Name"];
            Creature.Online = (Boolean)props["Online"];
            if (VIPStatusChanged != null)
            {
                VIPStatusChanged(this, Creature);
            }
        }
Пример #6
0
        private void OnVIPLogout(Packet props)
        {
            ClientCreature Creature = VIPList[(UInt32)props["CreatureID"]];

            if (Creature != null)
            {
                Creature.Online = false;
                if (VIPStatusChanged != null)
                {
                    VIPStatusChanged(this, Creature);
                }
            }
            else
            {
                Log.Warning("Receieved vip login for unknown creature (" + props["CreatureID"] + ")");
            }
        }
Пример #7
0
        /// <summary>
        /// Reads a Creature and returns it. This includes Outfit & Light etc.
        /// </summary>
        /// <param name="nmsg">Message to read from.</param>
        /// <param name="props">The read properties will be inserted into this property object.</param>
        /// <returns></returns>
        private ClientCreature ReadCreature(NetworkMessage nmsg, UInt32 CreatureID)
        {
            ClientCreature Creature = null;

            if (CreatureID == Player.ID)
            {
                Creature = Player;
            }
            else if (!KnownCreatures.TryGetValue(CreatureID, out Creature))
            {
                Creature = new ClientCreature(CreatureID);
                KnownCreatures.Add(CreatureID, Creature);
            }
            else
            {
                ;
            }

            Creature.Health    = nmsg.ReadByte();
            Creature.Direction = (Direction)nmsg.ReadByte();

            // TODO: This is U16 for later versions
            Creature.Outfit.LookType = (int)nmsg.ReadByte();
            if (Creature.Outfit.LookType == 0)
            {
                // looktypeEx
                Creature.Outfit.LookItem = nmsg.ReadU16();
            }
            else
            {
                Creature.Outfit.LookHead = nmsg.ReadByte();
                Creature.Outfit.LookBody = nmsg.ReadByte();
                Creature.Outfit.LookLegs = nmsg.ReadByte();
                Creature.Outfit.LookFeet = nmsg.ReadByte();
            }

            Creature.Light.Level = nmsg.ReadByte();
            Creature.Light.Color = nmsg.ReadByte();

            Creature.Speed = nmsg.ReadU16();

            Creature.Skull  = (CreatureSkull)nmsg.ReadByte();
            Creature.Shield = (PartyShield)nmsg.ReadByte();

            return(Creature);
        }
Пример #8
0
        private ClientThing ReadThing(NetworkMessage nmsg)
        {
            UInt16 clientID = nmsg.ReadU16();

            if (clientID == 0x62)
            {
                // Known creature
                //Packet props = new Packet("KnownCreature");
                UInt32 creatureID = nmsg.ReadU32();
                //props["Creature"] = KnownCreatures[creatureID];

                return(ReadCreature(nmsg, creatureID));
            }
            else if (clientID == 0x61)
            {
                // New creature
                //Packet props = new Packet("NewCreature");

                // Creature ID to kill
                UInt32 ForgetID   = nmsg.ReadU32();
                UInt32 creatureID = nmsg.ReadU32();
                if (ForgetID != 0)
                {
                    KnownCreatures.Remove(ForgetID);
                }

                //props["ForgetCreatureID"] = ForgetID;
                String name = nmsg.ReadString();

                ClientCreature creature = ReadCreature(nmsg, creatureID);
                //props["Creature"] = creature;
                creature.Name = name;

                return(creature);
            }
            else if (clientID == 0x63)
            {
                throw new CreatureTurn2Exception();
            }
            else
            {
                return(ReadItem(nmsg, clientID));
            }
        }
Пример #9
0
        private void ProbeTileForCreatures(ClientTile Tile)
        {
            if (Tile.CreatureCount == 0)
            {
                return;
            }

            foreach (ClientThing Thing in Tile.Objects)
            {
                if (Thing is ClientCreature)
                {
                    ClientCreature Creature = (ClientCreature)Thing;
                    if (!Creatures.ContainsKey(Creature.ID))
                    {
                        Creatures.Add(Creature.ID, Creature);
                    }
                }
            }
        }
Пример #10
0
        private void OnCreatureMove(Packet props)
        {
            MapPosition OldPosition = (MapPosition)props["OldPosition"];
            int         StackIndex  = (int)props["OldStackIndex"];
            MapPosition ToPosition  = (MapPosition)props["Position"];

            ClientTile FromTile = Map[OldPosition];
            ClientTile ToTile   = Map[ToPosition];

            if (FromTile == null || ToTile == null)
            {
                Log.Warning("OnCreatureMove - Tile is missing.");
                return;
            }

            ClientCreature Creature = (ClientCreature)FromTile.GetByIndex(StackIndex);

            FromTile.Remove(Creature);
            ToTile.Add(Creature, true);

            Creature.Move(OldPosition, ToPosition);
        }
Пример #11
0
        public void DrawCreatureBars(SpriteBatch Batch, ClientCreature Creature, Vector2 Offset)
        {
            if (Creature.Name != "")
            {
                GameSprite Sprite    = GameData.GetCreatureSprite(Creature.Outfit.LookType);
                Vector2    TextSize  = UIContext.StandardFont.MeasureString(Creature.Name);
                Color      LifeColor = LifeColorForCreature(Creature);

                // Put at the center of the sprite
                Offset.X += Sprite.Width * 16;
                Offset.Y -= Sprite.Height * 16;

                // Render offsets are negative
                Offset.X += Sprite.RenderOffset;
                Offset.Y += Sprite.RenderOffset;

                // Render the text
                Vector2 TextOffset = Offset;
                // Move it above the health bar
                TextOffset.X  = (int)(TextOffset.X - TextSize.X / 2);
                TextOffset.Y -= 16;
                DrawBoldedText(Batch, Creature.Name, TextOffset, false, LifeColor);

                //
                Rectangle BlackBar = new Rectangle(
                    (int)(Offset.X - 14),
                    (int)Offset.Y,
                    28, 4
                    );
                UIContext.Skin.DrawBorderedRectangle(Batch, BlackBar, Color.Black);

                Rectangle InsideBar = BlackBar.Subtract(new Margin(1));
                if (Creature.MaxHealth > 0)
                {
                    InsideBar.Width = InsideBar.Width * Creature.Health / Creature.MaxHealth;
                }
                UIContext.Skin.DrawBorderedRectangle(Batch, InsideBar, LifeColor);
            }
        }
Пример #12
0
        private void OnCreatureSkull(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Skull = (CreatureSkull)props["Skull"];
        }
Пример #13
0
        private void OnCreatureShield(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Shield = (PartyShield)props["PartyShield"];
        }
Пример #14
0
        private void OnCreatureSpeed(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Speed = (int)props["Speed"];
        }
Пример #15
0
        private void OnCreatureHealth(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Health = (int)props["Health"];
        }
Пример #16
0
        private void OnCreatureTurn(Packet props)
        {
            ClientCreature Creature = (ClientCreature)props["Creature"];

            Creature.Direction = (Direction)props["Direction"];
        }