/// <summary> /// Attempts to find the spawn at the specified MAP coordinate. /// </summary> /// <param name="x">The X MAP coordinate</param> /// <param name="y">The Y MAP coordinate</param> /// <param name="threshhold">Search tolerance</param> /// <returns>The closest spawn to the specified map coordinates, or null if there are no spawns within the search tolerance.</returns> public GameSpawn FindSpawn(float x, float y, float threshhold) { float closestDistance = -1; GameSpawn closestSpawn = null; foreach (KeyValuePair <uint, GameSpawn> pair in Spawns) { if (!pair.Value.Hidden || m_data.Engine.ShowHiddenSpawns) { //calculate the distance between where the mouse cursor is and the center of the spawn float distance = CalcDistance(pair.Value, x, y); //if this is currently the closest then cache the spawn if (closestDistance < 0 || distance < closestDistance) { closestDistance = distance; closestSpawn = pair.Value; } } } //if closest spawn is within the requested threshold then return it if (closestDistance > 0 && closestDistance < threshhold) { return(closestSpawn); } return(null); }
/// <summary>Clears all spawn information</summary> public void Clear() { Spawns.Clear(); Target = null; Player = null; Selected = null; Highlighted = null; Update(); }
/// <summary>Adds the spawn to the collection.</summary> public void Add(GameSpawn spawn) { if (!Spawns.ContainsKey(spawn.ID)) { Spawns.Add(spawn.ID, spawn); m_data.Engine.Data.Hunts.Bind(spawn); m_data.Engine.Data.Replacements.Bind(spawn); } }
/// <summary>Clears all spawn information</summary> public void Clear() { Spawns.Clear(); Target = null; Player = null; Selected = null; Highlighted = null; Update(); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.X == panMouseOrigin.X && e.Y == panMouseOrigin.Y) { //selected clicked spawn, or deselect if nothing clicked GameSpawn spawn = MapEngine.FindSpawn(e.X, e.Y); if (spawn != MapEngine.Game.Selected) { MapEngine.Game.Selected = spawn; this.Invalidate(); } } panMode = false; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (panMode) { MapEngine.ViewLocation = new PointF( (float)(panViewOrigin.X - (float)(panMouseOrigin.X - e.X)), (float)(panViewOrigin.Y - (float)(panMouseOrigin.Y - e.Y)) ); } else { //highlight the hovered spawn GameSpawn spawn = MapEngine.FindSpawn(e.X, e.Y); if (spawn != MapEngine.Game.Highlighted) { MapEngine.Game.Highlighted = spawn; this.Invalidate(); } } }
public void ShowContextMenu(GameSpawn context, Point location) { m_contextspawn = context; MapMenu.Show(this, location); }
//renders an individual spawn to the buffer private void DrawSpawn(Graphics g, GameSpawn spawn) { //cache certain applicability checks bool STH = spawn == m_game.Target || spawn == m_game.Highlighted || spawn == m_game.Selected; bool STHAH = STH || spawn.Alert || spawn.Hunt; bool STHP = STH; if ((m_showSpawns || STHAH) && (!spawn.Hidden || m_showHiddenSpawn)) { //calc the screen coords. result is rounded to help deal with anti-aliasing issues. float x = (float)Math.Round(CalcClientCoordX(spawn.Location.X)); float y = (float)Math.Round(CalcClientCoordY(spawn.Location.Y)); float ox, oy; float size = 0; float radius = 0; //calculate the size to render the spawn if (spawn.Icon != null) { size = Math.Max(spawn.Icon.Width, spawn.Icon.Height); } else { switch (spawn.Type) { case SpawnType.Player: size = m_playerSize; break; case SpawnType.NPC: size = m_NPCSize; break; case SpawnType.MOB: size = m_MOBSize; break; default: size = 4.0f; break; } if (STH) size += m_spawnSelectSize; if (spawn.RaidMember || spawn.GroupMember) size += m_spawnMemberSize; if (spawn.Alert) size += m_alertSize; if (spawn.Hunt) size += m_huntSize; } radius = size / 2; if (spawn.Icon != null) { //since an icon is set, draw it instead of a standard shape g.DrawImage(spawn.Icon, x - radius, y - radius); if (STHP) g.DrawRectangle(pSelected, x - radius - 1, y - radius - 1, size + 1, size + 1); //prevent fuzzy edges in hq mode } else { //draw the spawn shape based on its type switch (spawn.Type) { case SpawnType.Player: //draw the player box. if the current target draw an outline around it. if (!m_usePlayerColor) { pCachePlayer.Color = spawn.FillColor; bPlayer = pCachePlayer.Brush; } g.FillRectangle(bPlayer, x - radius, y - radius, size, size); //alter the border to reflect various player states if (STHP) pCacheSpawnBorder.Color = pSelected.Color; else if (spawn.GroupMember) pCacheSpawnBorder.Color = m_GroupMemColor; else if (spawn.RaidMember) pCacheSpawnBorder.Color = m_RaidMemColor; else pCacheSpawnBorder.Color = pCachePlayer.Color; //prevent fuzzy edges g.DrawRectangle(pCacheSpawnBorder, x - radius, y - radius, size, size); break; case SpawnType.NPC: g.FillEllipse(bNPC, x - radius, y - radius, size, size); if (STH) g.DrawEllipse(pSelected, x - radius, y - radius, size, size); //prevent fuzzy edges in hq mode if (m_drawAlertRanges && spawn.Alert) g.DrawEllipse(pAlertRing, x - (size + m_alertSize) / 2, y - (size + m_alertSize) / 2, (size + m_alertSize), (size + m_alertSize)); break; case SpawnType.MOB: g.FillEllipse(bMOB, x - radius, y - radius, size, size); if (STH) g.DrawEllipse(pSelected, x - radius, y - radius, size, size); //prevent fuzzy edges in hq mode if (m_drawAlertRanges && spawn.Alert) g.DrawEllipse(pAlertRing, x - (size + m_alertSize) / 2, y - (size + m_alertSize) / 2, (size + m_alertSize), (size + m_alertSize)); break; } } //draw heading line if required if ((m_drawHeadings || STHAH) && spawn.Type != SpawnType.Hidden) { oy = (float)(Math.Sin(spawn.Heading) * size); ox = (float)(Math.Cos(spawn.Heading) * size); g.DrawLine(pHeading, x, y, x + ox, y + oy); } //Should the quick info be displayed? bool showInfo = STHAH || spawn.DEBUG != ""; if (!showInfo) { showInfo = showInfo || (m_infoAllPlayers && spawn.Type == SpawnType.Player); showInfo = showInfo || (m_infoAllNPCs && spawn.Type == SpawnType.NPC); showInfo = showInfo || (m_infoAllEnemies && spawn.Type == SpawnType.MOB); } //If so then build the template and write it out if (showInfo) { Font fInfoText; Brush bInfoText; switch (spawn.Type) { case SpawnType.Player: fInfoText = m_playerTextFont; bInfoText = bTextPlayer; break; case SpawnType.NPC: fInfoText = m_NPCTextFont; bInfoText = bTextNPC; break; case SpawnType.MOB: fInfoText = m_MOBTextFont; bInfoText = bTextMOB; break; default: fInfoText = SystemFonts.DefaultFont; bInfoText = bSelected; break; } if (STH) bInfoText = bSelected; //build the output string using the custom template string output = m_infoTemplate; //output = rxInfoName.Replace(output, spawn.Name); if (spawn.Replacement) output = rxInfoName.Replace(output, spawn.RepName); else output = rxInfoName.Replace(output, spawn.Name); output = rxInfoHpp.Replace(output, spawn.HealthPercent.ToString()); output = rxInfoDistance.Replace(output, spawn.Distance.ToString("0.##")); output = rxNewLine.Replace(output, "\n"); output = rxInfoID.Replace(output, spawn.ID.ToString("X")); /// IHM EDIT //if debugging and a debug string is set on the spawn, then append it to the info text regardless of the template #if DEBUG if (spawn.DEBUG != "") output += (output == "" ? "" : "\n") + spawn.DEBUG; #endif //measure the string and draw it on to the buffer if (output != "") { SizeF infoSize = g.MeasureString(output, fInfoText); ox = x + radius + 3; oy = y - (infoSize.Height / 2); if (STHAH && m_drawTextOutline) DrawOutlineString(g, output, fInfoText, bSelectedOutline, ox, oy, 4); g.DrawString(output, fInfoText, bInfoText, ox, oy); } } } }
//renders the special player graphic to the buffer // this spawn represents YOU the user which displays heading information and drawn in a manner different from the other spawns private void DrawPlayer(Graphics g, GameSpawn spawn) { float ox = CalcClientCoordX(spawn.Location.X); float oy = CalcClientCoordY(spawn.Location.Y); float x, y; float size = (m_playerSize + m_spawnSelectSize); float arrowSize = size * 0.7f; float arrowHeadSize = arrowSize * 0.8f; //draw bounding circle if (m_drawYOUFill) { g.FillEllipse(bYOUFill, ox - size, oy - size, size * 2, size * 2); g.DrawEllipse(pYOU, ox - size, oy - size, size * 2, size * 2); } //draw arrow shaft y = (float)(Math.Sin(spawn.Heading) * arrowSize); x = (float)(Math.Cos(spawn.Heading) * arrowSize); g.DrawLine(pYOU, ox - x, oy - y, ox + x, oy + y); //draw the arrow head DrawArrowHead(g, pYOU, ox + x, oy + y, spawn.Heading, 10f, arrowHeadSize); }
/// <summary>Calculate the distance between two spawns</summary> public float CalcDistance(GameSpawn source, GameSpawn dest) { return(CalcDistance(source.Location.X, source.Location.Y, dest.Location.X, dest.Location.Y)); }
/// <summary>Determine if ANY hunt applies to the specified spawn.</summary> public bool isHunt(GameSpawn spawn) { foreach (KeyValuePair<string, MapHunt> pair in m_hunts) { if (pair.Value.isMatch(spawn)) return true; } return false; }
/// <summary>Calculate the distance between a spawn and an arbitrary set of MAP coordinates.</summary> public float CalcDistance(GameSpawn source, float x, float y) { return CalcDistance(source.Location.X, source.Location.Y, x, y); }
/// <summary>Determines if the spawn matches this hunt.</summary> public bool isMatch(GameSpawn spawn) { /// IHM EDIT //if (spawn.Type == SpawnType.MOB || spawn.Type == SpawnType.Hidden) //If regex is A-F see if it matches only the ID. Does anyone hunt a mob by name with only one letter?! if (ToString() == "A" || ToString() == "B" || ToString() == "C" || ToString() == "D" || ToString() == "E" || ToString() == "F") return m_regex.IsMatch(spawn.ID.ToString("X")); //if not search both the name or the ID (if it is an hex number it will never match the name and the other way around) else return m_regex.IsMatch(spawn.Name) || m_regex.IsMatch(spawn.ID.ToString("X")); /*else //If not a MOB or hidden spawn don't search based on A-F if (ToString() == "A" || ToString() == "B" || ToString() == "C" || ToString() == "D" || ToString() == "E" || ToString() == "F") return false; //search players and NPCs based on name else return m_regex.IsMatch(spawn.Name);*/ //return m_regex.IsMatch(spawn.Name); }
/// <summary>Determine if ANY hunt applies to the specified spawn.</summary> public bool isReplacement(GameSpawn spawn) { foreach (KeyValuePair<string, MapReplacement> pair in m_replacements) { if (pair.Value.isMatch(spawn)) { spawn.RepName = pair.Value.ReplacedName; return true; } } spawn.RepName = ""; return false; }
/// <summary>Bind the spawn to the hunt collection. Additive only.</summary> public void Bind(GameSpawn spawn) { spawn.Replacement = isReplacement(spawn); }
/// <summary> /// Sets the target spawn by its ID /// </summary> /// <param name="ID">The ID of the spawn</param> /// <param name="batch">If true, the map will not automatically update</param> public void setTarget(uint ID, bool batch) { if (Target != null && Target.ID == ID) return; if (ID == 0) { Target = null; } else if (Spawns.ContainsIndex(ID)) { Target = Spawns[ID]; } if (!batch && Updated != null) Updated(); }
/// <summary>Adds the spawn to the collection.</summary> public void Add(GameSpawn spawn) { if (!Spawns.ContainsKey(spawn.ID)) { Spawns.Add(spawn.ID, spawn); m_data.Engine.Data.Hunts.Bind(spawn); m_data.Engine.Data.Replacements.Bind(spawn); } }
/// <summary>Calculate the distance between a spawn and an arbitrary set of MAP coordinates.</summary> public float CalcDistance(GameSpawn source, float x, float y) { return(CalcDistance(source.Location.X, source.Location.Y, x, y)); }
/// <summary>Calculate the distance between two spawns</summary> public float CalcDistance(GameSpawn source, GameSpawn dest) { return CalcDistance(source.Location.X, source.Location.Y, dest.Location.X, dest.Location.Y); }
/// <summary>Bind the spawn to the hunt collection. Additive only.</summary> public void Bind(GameSpawn spawn) { if (isHunt(spawn)) spawn.Hunt = true; }