private void HandleMapItemClick(OldMapItem mi) { if ((_mainCharacter.ID != mi.OwningPlayerID && mi.OwningPlayerID != 0) && (mi.IsNPCDrop && (DateTime.Now - mi.DropTime).TotalSeconds <= OldWorld.Instance.NPCDropProtectTime) || (!mi.IsNPCDrop && (DateTime.Now - mi.DropTime).TotalSeconds <= OldWorld.Instance.PlayerDropProtectTime)) { OldCharacter charRef = _parentMapRenderer.GetOtherPlayerByID((short)mi.OwningPlayerID); EOResourceID msg = charRef == null ? EOResourceID.STATUS_LABEL_ITEM_PICKUP_PROTECTED : EOResourceID.STATUS_LABEL_ITEM_PICKUP_PROTECTED_BY; string extra = charRef == null ? "" : charRef.Name; EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, msg, extra); } else { var item = OldWorld.Instance.EIF[mi.ItemID]; if (!EOGame.Instance.Hud.InventoryFits(mi.ItemID)) { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT); } else if (_mainCharacter.Weight + item.Weight * mi.Amount > _mainCharacter.MaxWeight) { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.DIALOG_ITS_TOO_HEAVY_WEIGHT); } else if (!_game.API.GetItem(mi.UniqueID)) //server validates drop protection anyway { EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } } }
private void _drawMiniMap() { Texture2D miniMapText = EOGame.Instance.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 45, true); OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; _spriteBatch.Begin(); for (int row = Math.Max(c.Y - 30, 0); row <= Math.Min(c.Y + 30, Map.Properties.Height); ++row) { for (int col = Math.Max(c.X - 30, 0); col <= Math.Min(c.X + 30, Map.Properties.Width); ++col) { Rectangle miniMapRectSrc = new Rectangle(0, 0, miniMapText.Width / 9, miniMapText.Height); bool isEdge = false; Vector2 loc = _getMiniMapDrawCoordinates(col, row, c); if (c.X == col && c.Y == row) { //draw orange thing miniMapRectSrc.Offset((int)MiniMapGfx.Orange * miniMapRectSrc.Width, 0); } else { isEdge = _drawObjectAndActorIcons(col, row, ref miniMapRectSrc); } _drawGridBox(isEdge, miniMapText, loc, miniMapRectSrc); } } _spriteBatch.End(); }
public static void Show(PacketAPI api, OldCharacter character, PaperdollDisplayData data) { if (Instance != null) { return; } Instance = new EOPaperdollDialog(api, character, data); Instance.DialogClosing += (o, e) => Instance = null; }
public OldMouseCursorRenderer(EOGame game, OldMapRenderer parentMapRenderer) { _game = game; _parentMapRenderer = parentMapRenderer; _contextMenu = new EOMapContextMenu(_game.API); _mainCharacter = OldWorld.Instance.MainPlayer.ActiveCharacter; }
private void _learn(Skill skill) { OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; bool skillReqsMet = true; foreach (short x in skill.SkillReq) { if (x != 0 && c.Spells.FindIndex(_sp => _sp.ID == x) < 0) { skillReqsMet = false; } } //check the requirements if (c.Stats.Str < skill.StrReq || c.Stats.Int < skill.IntReq || c.Stats.Wis < skill.WisReq || c.Stats.Agi < skill.AgiReq || c.Stats.Con < skill.ConReq || c.Stats.Cha < skill.ChaReq || c.Stats.Level < skill.LevelReq || c.Inventory.Find(_ii => _ii.ItemID == 1).Amount < skill.GoldReq || !skillReqsMet) { EOMessageBox.Show(DialogResourceID.SKILL_LEARN_REQS_NOT_MET, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); return; } if (skill.ClassReq > 0 && c.Class != skill.ClassReq) { EOMessageBox.Show(DialogResourceID.SKILL_LEARN_WRONG_CLASS, " " + OldWorld.Instance.ECF.Data[skill.ClassReq].Name + "!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader); return; } EOMessageBox.Show(DialogResourceID.SKILL_LEARN_CONFIRMATION, " " + OldWorld.Instance.ESF.Data[skill.ID].Name + "?", EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, (o, e) => { if (e.Result != XNADialogResult.OK) { return; } if (!m_api.LearnSpell(skill.ID)) { Close(); ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } }); }
public MouseCursorRenderer(EOGame game, OldMapRenderer parentMapRenderer) { _game = game; _parentMapRenderer = parentMapRenderer; _mouseCursor = game.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 24, true); _itemHoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75) { Visible = true, Text = "", ForeColor = Color.White, DrawOrder = (int)ControlDrawLayer.BaseLayer + 3, AutoSize = false }; _cursorSourceRect = new Rectangle(0, 0, _mouseCursor.Width / 5, _mouseCursor.Height); _contextMenu = new EOMapContextMenu(_game.API); _mainCharacter = OldWorld.Instance.MainPlayer.ActiveCharacter; }
private static void Main(string[] args) { Console.WriteLine("Mediator Pattern"); IChatMediator chatMediator = new ChatMediator(); // Didn't use var to explicity show the types. ICharacter bart = new YoungCharacter(chatMediator, "Bart"); ICharacter grandpa = new OldCharacter(chatMediator, "Grandpa Abraham Simpson"); ICharacter lisa = new YoungCharacter(chatMediator, "Lisa"); chatMediator.AddCharacter(bart); chatMediator.AddCharacter(grandpa); chatMediator.AddCharacter(lisa); bart.SendMessage("Grandpa, why don't you tell a story?"); lisa.SendMessage("Yeah Grandpa, you lived a long and interesting life."); grandpa.SendMessage("That's a lie and you know it."); Console.ReadLine(); }
private void _handleDoubleClick() { OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; bool useItem = false; switch (m_itemData.Type) { //equippable items case ItemType.Accessory: case ItemType.Armlet: case ItemType.Armor: case ItemType.Belt: case ItemType.Boots: case ItemType.Bracer: case ItemType.Gloves: case ItemType.Hat: case ItemType.Necklace: case ItemType.Ring: case ItemType.Shield: case ItemType.Weapon: byte subLoc = 0; if (m_itemData.Type == ItemType.Armlet || m_itemData.Type == ItemType.Ring || m_itemData.Type == ItemType.Bracer) { if (c.PaperDoll[(int)m_itemData.GetEquipLocation()] == 0) { subLoc = 0; } else if (c.PaperDoll[(int)m_itemData.GetEquipLocation() + 1] == 0) { subLoc = 1; } else { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED); break; } } else if (m_itemData.Type == ItemType.Armor && m_itemData.Gender != c.RenderData.gender) { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_EQUIP_DOES_NOT_FIT_GENDER); break; } //check stat requirements int[] reqs = new int[6]; string[] reqNames = { "STR", "INT", "WIS", "AGI", "CON", "CHA" }; if ((reqs[0] = m_itemData.StrReq) > c.Stats.Str || (reqs[1] = m_itemData.IntReq) > c.Stats.Int || (reqs[2] = m_itemData.WisReq) > c.Stats.Wis || (reqs[3] = m_itemData.AgiReq) > c.Stats.Agi || (reqs[4] = m_itemData.ConReq) > c.Stats.Con || (reqs[5] = m_itemData.ChaReq) > c.Stats.Cha) { int reqIndex = reqs.ToList().FindIndex(x => x > 0); ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_EQUIP_THIS_ITEM_REQUIRES, $" {reqs[reqIndex]} {reqNames[reqIndex]}"); break; } //check class requirement if (m_itemData.ClassReq > 0 && m_itemData.ClassReq != c.Class) { ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_EQUIP_CAN_ONLY_BE_USED_BY, OldWorld.Instance.ECF[m_itemData.ClassReq].Name); break; } if (c.EquipItem(m_itemData.Type, (short)m_itemData.ID, (short)m_itemData.DollGraphic)) { if (!m_api.EquipItem((short)m_itemData.ID, subLoc)) { EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } } else { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED); } break; //usable items case ItemType.Teleport: if (!OldWorld.Instance.ActiveMapRenderer.MapRef.Properties.CanScroll) { EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_NOTHING_HAPPENED); break; } if (m_itemData.ScrollMap == OldWorld.Instance.MainPlayer.ActiveCharacter.CurrentMap && m_itemData.ScrollX == OldWorld.Instance.MainPlayer.ActiveCharacter.X && m_itemData.ScrollY == OldWorld.Instance.MainPlayer.ActiveCharacter.Y) { break; //already there - no need to scroll! } useItem = true; break; case ItemType.Heal: case ItemType.HairDye: case ItemType.Beer: useItem = true; break; case ItemType.CureCurse: //note: don't actually set the useItem bool here. Call API.UseItem if the dialog result is OK. if (c.PaperDoll.Select(id => OldWorld.Instance.EIF[id]) .Any(rec => rec.Special == ItemSpecial.Cursed)) { EOMessageBox.Show(DialogResourceID.ITEM_CURSE_REMOVE_PROMPT, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, (o, e) => { if (e.Result == XNADialogResult.OK && !m_api.UseItem((short)m_itemData.ID)) { ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } }); } break; case ItemType.EXPReward: useItem = true; break; case ItemType.EffectPotion: useItem = true; break; //Not implemented server-side //case ItemType.SkillReward: // break; //case ItemType.StatReward: // break; } if (useItem && !m_api.UseItem((short)m_itemData.ID)) { ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } m_recentClickCount = 0; }
private EOPaperdollDialog(PacketAPI api, OldCharacter character, PaperdollDisplayData data) : base(api) { if (Instance != null) { throw new InvalidOperationException("Paperdoll is already open!"); } Instance = this; CharRef = character; Texture2D bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 49); _setSize(bgSprites.Width, bgSprites.Height / 2); Color[] dat = new Color[DrawArea.Width * DrawArea.Height]; bgTexture = new Texture2D(Game.GraphicsDevice, DrawArea.Width, DrawArea.Height); bgSprites.GetData(0, DrawArea.WithPosition(new Vector2(0, CharRef.RenderData.gender * DrawArea.Height)), dat, 0, dat.Length); bgTexture.SetData(dat); //not using caption/message since we have other shit to take care of //ok button XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(276, 253), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)) { Visible = true }; ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK); ok.SetParent(this); dlgButtons.Add(ok); //items for (int i = (int)EquipLocation.Boots; i < (int)EquipLocation.PAPERDOLL_MAX; ++i) { var info = OldWorld.Instance.EIF[CharRef.PaperDoll[i]]; Rectangle itemArea = _getEquipLocRectangle((EquipLocation)i); //create item using itemArea if (CharRef.PaperDoll[i] > 0) { // ReSharper disable once UnusedVariable PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, info, (EquipLocation)i); //auto-added as child of this dialog } else { // ReSharper disable once UnusedVariable PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, null, (EquipLocation)i); } } //labels next XNALabel[] labels = { new XNALabel(new Rectangle(228, 22, 1, 1), Constants.FontSize08pt5) { Text = CharRef.Name.Length > 0 ? char.ToUpper(CharRef.Name[0]) + CharRef.Name.Substring(1) : "" }, //name new XNALabel(new Rectangle(228, 52, 1, 1), Constants.FontSize08pt5) { Text = data.Home.Length > 0 ? char.ToUpper(data.Home[0]) + data.Home.Substring(1) : "" }, //home new XNALabel(new Rectangle(228, 82, 1, 1), Constants.FontSize08pt5) { Text = (OldWorld.Instance.ECF[CharRef.Class] ?? new ECFRecord()).Name ?? "" }, //class new XNALabel(new Rectangle(228, 112, 1, 1), Constants.FontSize08pt5) { Text = data.Partner.Length > 0 ? char.ToUpper(data.Partner[0]) + data.Partner.Substring(1) : "" }, //partner new XNALabel(new Rectangle(228, 142, 1, 1), Constants.FontSize08pt5) { Text = CharRef.Title.Length > 0 ? char.ToUpper(CharRef.Title[0]) + CharRef.Title.Substring(1) : "" }, //title new XNALabel(new Rectangle(228, 202, 1, 1), Constants.FontSize08pt5) { Text = data.Guild.Length > 0 ? char.ToUpper(data.Guild[0]) + data.Guild.Substring(1) : "" }, //guild new XNALabel(new Rectangle(228, 232, 1, 1), Constants.FontSize08pt5) { Text = data.Rank.Length > 0 ? char.ToUpper(data.Rank[0]) + data.Rank.Substring(1) : "" } //rank }; labels.ToList().ForEach(_l => { _l.ForeColor = ColorConstants.LightGrayText; _l.SetParent(this); }); ChatIcon icon = OldChatRenderer.GetChatTypeFromPaperdollIcon(data.Icon); m_characterIcon = OldChatTab.GetChatIcon(icon); //should not be centered vertically: only display in game window //first center in the game display window, then move it 15px from top, THEN call end constructor logic //if not done in this order some items DrawAreaWithOffset field does not get updated properly when setting DrawLocation Center(Game.GraphicsDevice); DrawLocation = new Vector2(DrawLocation.X, 15); endConstructor(false); }
public void TakeDamageFrom(OldCharacter opponent, int damage, int pctHealth) { m_damageCounter.SetValue(damage, pctHealth); //NPCs don't know heal spells NPC.SetOpponent(opponent); }
private SessionExpDialog() : base((PacketAPI)null) { bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 61); _setSize(bgTexture.Width, bgTexture.Height); m_icons = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true); m_signal = new Rectangle(0, 15, 15, 15); m_icon = new Rectangle(0, 0, 15, 15); XNAButton okButton = new XNAButton(smallButtonSheet, new Vector2(98, 214), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)); okButton.OnClick += (sender, args) => Close(okButton, XNADialogResult.OK); okButton.SetParent(this); XNALabel title = new XNALabel(new Rectangle(20, 17, 1, 1), Constants.FontSize08pt5) { AutoSize = false, Text = OldWorld.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE), ForeColor = ColorConstants.LightGrayText }; title.SetParent(this); XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8]; for (int i = 48; i <= 160; i += 16) { leftSide[(i - 48) / 16] = new XNALabel(new Rectangle(38, i, 1, 1), Constants.FontSize08pt5) { AutoSize = false, ForeColor = ColorConstants.LightGrayText }; leftSide[(i - 48) / 16].SetParent(this); rightSide[(i - 48) / 16] = new XNALabel(new Rectangle(158, i, 1, 1), Constants.FontSize08pt5) { AutoSize = false, ForeColor = ColorConstants.LightGrayText }; rightSide[(i - 48) / 16].SetParent(this); } leftSide[0].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP); leftSide[1].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL); leftSide[2].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED); leftSide[3].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP); leftSide[4].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG); leftSide[5].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG); leftSide[6].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL); leftSide[7].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL); OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter; rightSide[0].Text = $"{c.Stats.Experience}"; rightSide[1].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1]}"; rightSide[2].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1] - c.Stats.Experience}"; rightSide[3].Text = $"{c.TodayExp}"; rightSide[4].Text = $"{(int) (c.Stats.Experience/(c.Stats.Usage/60.0))}"; int sessionTime = (int)(DateTime.Now - EOGame.Instance.Hud.SessionStartTime).TotalMinutes; rightSide[5].Text = $"{(sessionTime > 0 ? (c.TodayExp/sessionTime) : 0)}"; rightSide[6].Text = $"{c.TodayBestKill}"; rightSide[7].Text = $"{c.TodayLastKill}"; Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText()); Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText()); Center(Game.GraphicsDevice); DrawLocation = new Vector2(DrawLocation.X, 15); endConstructor(false); }
public EOSpriteSheet(INativeGraphicsManager gfxManager, OldCharacter charToWatch) { _gfxManager = gfxManager; _charRef = charToWatch; }
public TradeDialog(PacketAPI apiHandle) : base(apiHandle) { bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 50); _setSize(bgTexture.Width, bgTexture.Height); Instance = this; DialogClosing += (sender, args) => Instance = null; m_main = OldWorld.Instance.MainPlayer.ActiveCharacter; m_leftItems = new List <ListDialogItem>(); m_rightItems = new List <ListDialogItem>(); m_leftPlayerID = 0; m_rightPlayerID = 0; m_leftPlayerName = new XNALabel(new Rectangle(20, 14, 166, 20), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, ForeColor = ColorConstants.LightGrayText }; m_leftPlayerName.SetParent(this); m_rightPlayerName = new XNALabel(new Rectangle(285, 14, 166, 20), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, ForeColor = ColorConstants.LightGrayText }; m_rightPlayerName.SetParent(this); m_leftPlayerStatus = new XNALabel(new Rectangle(195, 14, 79, 20), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING), ForeColor = ColorConstants.LightGrayText }; m_leftPlayerStatus.SetParent(this); m_rightPlayerStatus = new XNALabel(new Rectangle(462, 14, 79, 20), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING), ForeColor = ColorConstants.LightGrayText }; m_rightPlayerStatus.SetParent(this); m_leftScroll = new OldScrollBar(this, new Vector2(252, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 }; m_rightScroll = new OldScrollBar(this, new Vector2(518, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 }; //BUTTONSSSS XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(356, 252), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)); ok.OnClick += _buttonOkClicked; ok.SetParent(this); dlgButtons.Add(ok); XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(449, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel)); cancel.OnClick += _buttonCancelClicked; cancel.SetParent(this); dlgButtons.Add(cancel); Timer localTimer = new Timer(state => { if (m_recentPartnerRemoves > 0) { m_recentPartnerRemoves--; } }, null, 0, 5000); DialogClosing += (o, e) => { if (e.Result == XNADialogResult.Cancel) { if (!m_api.TradeClose()) { ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_TRADE_ABORTED); } localTimer.Dispose(); }; Center(Game.GraphicsDevice); DrawLocation = new Vector2(DrawLocation.X, 30); endConstructor(false); }
private Vector2 _getMiniMapDrawCoordinates(int x, int y, OldCharacter c) { return(new Vector2((x * 13) - (y * 13) + 288 - (c.X * 13 - c.Y * 13), (y * 7) + (x * 7) + 144 - (c.Y * 7 + c.X * 7))); }