public void SetDisplayItemsFromRenderData(CharRenderData newRenderData) { EquipItem(ItemType.Boots, (short)(World.Instance.EIF.GetItemRecordByDollGraphic(ItemType.Boots, newRenderData.boots) ?? new ItemRecord()).ID, newRenderData.boots, true); EquipItem(ItemType.Armor, (short)(World.Instance.EIF.GetItemRecordByDollGraphic(ItemType.Armor, newRenderData.armor) ?? new ItemRecord()).ID, newRenderData.armor, true); EquipItem(ItemType.Hat, (short)(World.Instance.EIF.GetItemRecordByDollGraphic(ItemType.Hat, newRenderData.hat) ?? new ItemRecord()).ID, newRenderData.hat, true); EquipItem(ItemType.Shield, (short)(World.Instance.EIF.GetItemRecordByDollGraphic(ItemType.Shield, newRenderData.shield) ?? new ItemRecord()).ID, newRenderData.shield, true); EquipItem(ItemType.Weapon, (short)(World.Instance.EIF.GetItemRecordByDollGraphic(ItemType.Weapon, newRenderData.weapon) ?? new ItemRecord()).ID, newRenderData.weapon, true); }
public Character(PacketAPI api, int id, CharRenderData data) { m_packetAPI = api; ID = id; RenderData = data ?? new CharRenderData(); Inventory = new List<InventoryItem>(); Spells = new List<CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; }
public Character(PacketAPI api, int id, CharRenderData data) { m_packetAPI = api; ID = id; RenderData = data ?? new CharRenderData(); Inventory = new List <InventoryItem>(); Spells = new List <CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; }
public Character() { //mock all members with non-null fields //PacketAPI cannot be mocked... Inventory = new List<InventoryItem>(); Spells = new List<CharacterSpell>(); PaperDoll = new short[1]; Stats = new CharStatData(); RenderData = new CharRenderData(); Name = PaddedGuildTag = GuildName = GuildRankStr = ""; }
public Character() { //mock all members with non-null fields //PacketAPI cannot be mocked... Inventory = new List <InventoryItem>(); Spells = new List <CharacterSpell>(); PaperDoll = new short[1]; Stats = new CharStatData(); RenderData = new CharRenderData(); Name = PaddedGuildTag = GuildName = GuildRankStr = ""; }
//public void SetGamePlayerID(int newId) //{ // GamePlayerID = newId; //} public bool SetActiveCharacter(PacketAPI api, int id) { if (ActiveCharacter != null) { Logger.Log("Setting Active Character to new ID {0}", id); } CharRenderData activeData = CharData.FirstOrDefault(d => d.id == id); if (activeData == null) { return(false); } ActiveCharacter = new Character(api, id, activeData); return(true); }
//constructs a character from a packet sent from the server public Character(PacketAPI api, CharacterData data) { //initialize lists m_packetAPI = api; Inventory = new List<InventoryItem>(); Spells = new List<CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; Name = data.Name; ID = data.ID; CurrentMap = data.Map; X = data.X; Y = data.Y; PaddedGuildTag = data.GuildTag; RenderData = new CharRenderData { facing = data.Direction, level = data.Level, gender = data.Gender, hairstyle = data.HairStyle, haircolor = data.HairColor, race = data.Race }; Stats = new CharStatData { maxhp = data.MaxHP, hp = data.HP, maxtp = data.MaxTP, tp = data.TP }; EquipItem(ItemType.Boots, 0, data.Boots, true); EquipItem(ItemType.Armor, 0, data.Armor, true); EquipItem(ItemType.Hat, 0, data.Hat, true); EquipItem(ItemType.Shield, 0, data.Shield, true); EquipItem(ItemType.Weapon, 0, data.Weapon, true); RenderData.SetSitting(data.Sitting); RenderData.SetHidden(data.Hidden); }
//constructs a character from a packet sent from the server public Character(PacketAPI api, CharacterData data) { //initialize lists m_packetAPI = api; Inventory = new List <InventoryItem>(); Spells = new List <CharacterSpell>(); PaperDoll = new short[(int)EquipLocation.PAPERDOLL_MAX]; Name = data.Name; ID = data.ID; CurrentMap = data.Map; X = data.X; Y = data.Y; PaddedGuildTag = data.GuildTag; RenderData = new CharRenderData { facing = data.Direction, level = data.Level, gender = data.Gender, hairstyle = data.HairStyle, haircolor = data.HairColor, race = data.Race }; Stats = new CharStatData { maxhp = data.MaxHP, hp = data.HP, maxtp = data.MaxTP, tp = data.TP }; EquipItem(ItemType.Boots, 0, data.Boots, true); EquipItem(ItemType.Armor, 0, data.Armor, true); EquipItem(ItemType.Hat, 0, data.Hat, true); EquipItem(ItemType.Shield, 0, data.Shield, true); EquipItem(ItemType.Weapon, 0, data.Weapon, true); RenderData.SetSitting(data.Sitting); RenderData.SetHidden(data.Hidden); }
public void ProcessCharacterData(CharacterRenderData[] dataArray) { CharData = new CharRenderData[dataArray.Length]; for (int i = 0; i < CharData.Length; ++i) { CharData[i] = new CharRenderData { name = dataArray[i].Name, id = dataArray[i].ID, level = dataArray[i].Level, gender = dataArray[i].Gender, hairstyle = dataArray[i].HairStyle, haircolor = dataArray[i].HairColor, race = dataArray[i].Race, admin = (byte)dataArray[i].AdminLevel, boots = dataArray[i].Boots, armor = dataArray[i].Armor, hat = dataArray[i].Hat, shield = dataArray[i].Shield, weapon = dataArray[i].Weapon }; } }
/// <summary> /// Construct a character renderer in-game /// </summary> /// <param name="charToRender">The character data that should be wrapped by this renderer</param> public EOCharacterRenderer(Character charToRender) { //this has been happening when shit gets disconnected due to invalid sequence or internal packet id if (charToRender == null) { EOGame.Instance.LostConnectionDialog(); return; } spriteSheet = new EOSpriteSheet(charToRender); _char = charToRender; _data = charToRender.RenderData; Texture2D tmpSkin = spriteSheet.GetSkin(false, out m_skinSourceRect); if (_char != World.Instance.MainPlayer.ActiveCharacter) { drawArea = new Rectangle( _char.OffsetX + 304 - World.Instance.MainPlayer.ActiveCharacter.OffsetX, _char.OffsetY + 91 - World.Instance.MainPlayer.ActiveCharacter.OffsetY, m_skinSourceRect.Width, m_skinSourceRect.Height); //set based on size of the sprite and location of charToRender } else { drawArea = new Rectangle((618 - m_skinSourceRect.Width) / 2 + 4, (298 - m_skinSourceRect.Height) / 2 - 29, m_skinSourceRect.Width, m_skinSourceRect.Height); noLocUpdate = true; //make sure not to update the drawArea rectangle in the update method } Data.SetUpdate(true); _prevKeyState = Keyboard.GetState(); //get the top pixel! Color[] skinData = new Color[m_skinSourceRect.Width * m_skinSourceRect.Height]; tmpSkin.GetData(0, m_skinSourceRect, skinData, 0, skinData.Length); int i = 0; while (i < skinData.Length && skinData[i].A == 0) i++; //account for adjustment in drawing the skin in the draw method TopPixel = (Data.gender == 0 ? 12 : 13) + (i == skinData.Length - 1 ? 0 : i / m_skinSourceRect.Height); m_chatBubble = new EOChatBubble(this); m_damageCounter = new DamageCounter(this, GetType()); }
/// <summary> /// Construct a character renderer pre-game (character creation dialog, character list) /// </summary> /// <param name="drawLocation">Where to draw it</param> /// <param name="data">Render data to use for drawing</param> public EOCharacterRenderer(Vector2 drawLocation, CharRenderData data) : base(drawLocation, null) { noLocUpdate = true; _char = new Character(null, -1, data); spriteSheet = new EOSpriteSheet(_char); //when this is a part of a dialog, the drawareaoffset will be set accordingly and is used in the draw method //otherwise, it will just draw it at the absolute location specified by drawArea drawArea = new Rectangle((int) drawLocation.X, (int) drawLocation.Y, 1, 1); Data.SetUpdate(true); if (data.name.Length > 0) { //362, 167 abs loc levelLabel = new XNALabel(new Rectangle(-32, 75, 1, 1), "Microsoft Sans Serif", 8.75f) { ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c), // ReSharper disable SpecifyACultureInStringConversionExplicitly Text = data.level.ToString() // ReSharper restore SpecifyACultureInStringConversionExplicitly }; levelLabel.SetParent(this); //504, 93 abs loc nameLabel = new XNALabel(new Rectangle(104, 2, 89, 22), "Microsoft Sans Serif", 8.5f) { ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c), Text = ((char) (data.name[0] - 32)) + data.name.Substring(1), TextAlign = System.Drawing.ContentAlignment.MiddleCenter, AutoSize = false }; nameLabel.SetParent(this); adminGraphic = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 22); if (data.admin == 1) { adminRect = new Rectangle(252, 39, 17, 17); } else if (data.admin > 1) { adminRect = new Rectangle(233, 39, 17, 17); } else { adminRect = null; } } }