private void VIPStatusChanged(ClientViewport Viewport, ClientCreature Creature) { if (Viewport != this.Viewport) return; UpdateList(); }
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); } } } } }
private void OnCreatureLight(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Light.Color = (int)props["Color"]; Creature.Light.Level = (int)props["Level"]; }
private void VIPStatusChanged(ClientViewport Viewport, ClientCreature Creature) { if (Viewport != this.Viewport) { return; } UpdateList(); }
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)); }
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); } }
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"] + ")"); } }
/// <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); }
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)); } }
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); } } } }
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); } }
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); }
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); }
/// <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; }
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); } }
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); }
private void OnCreatureSkull(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Skull = (CreatureSkull)props["Skull"]; }
private void OnCreatureShield(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Shield = (PartyShield)props["PartyShield"]; }
private void OnCreatureSpeed(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Speed = (int)props["Speed"]; }
private void OnCreatureTurn(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Direction = (Direction)props["Direction"]; }
private void OnCreatureHealth(Packet props) { ClientCreature Creature = (ClientCreature)props["Creature"]; Creature.Health = (int)props["Health"]; }