/// <summary> /// Parse the interactive elements array from MapComplementaryInformationsDataMessage. /// </summary> public void ParseInteractiveElements(BlueSheep.Common.Protocol.Types.InteractiveElement[] interactiveElements) { foreach (BlueSheep.Common.Protocol.Types.InteractiveElement element in interactiveElements) { if (element.elementTypeId == 85) { m_Account.Safe = element; } Elements.InteractiveElement Ielement = new Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)); InteractiveElements.Add(Ielement, -1); if (Ielement.EnabledSkills.Count > 0) { foreach (var layer in this.Data.Layers) { foreach (var cell in layer.Cells) { foreach (var layerElement in cell.Elements) { if (layerElement is GraphicalElement) { GraphicalElement graphicalElement = (GraphicalElement)layerElement; if (graphicalElement.Identifier == Ielement.Id) { InteractiveElements[Ielement] = cell.CellId; } } } } } } } }
/// <summary> /// Update the state of an interactive element. /// </summary> public void UpdateInteractiveElement(BlueSheep.Common.Protocol.Types.InteractiveElement element) { Elements.InteractiveElement Ielement = new Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List <InteractiveElementSkill>(element.enabledSkills), new List <InteractiveElementSkill>(element.disabledSkills)); Tuple <Elements.InteractiveElement, int> temp = new Tuple <Elements.InteractiveElement, int>(null, 0); foreach (KeyValuePair <Elements.InteractiveElement, int> pair in InteractiveElements) { if (pair.Key.Id == Ielement.Id) { temp = new Tuple <Elements.InteractiveElement, int>(pair.Key, pair.Value); } } if (temp.Item1 != null) { InteractiveElements.Remove(temp.Item1); InteractiveElements.Add(Ielement, temp.Item2); } else { InteractiveElements.Add(Ielement, -1); } }
public UsableElement(int cellId, InteractiveElement element, List <InteractiveElementSkill> skills) { CellId = cellId; Element = element; Skills = skills; }
public bool GoGather(List<int> ressources, JobUC job) { List<int> ListeRessourcesID = ressources; List<int> ListDistance = new List<int>(); List<UsableElement> ListUsableElement = new List<UsableElement>(); Current_Job = job; try { if (ListeRessourcesID.Count > 0) { foreach (var RessourceID in ListeRessourcesID) { foreach (var UsableElement in account.Map.UsableElements) { foreach (InteractiveElement InteractiveElement in account.Map.InteractiveElements.Values) { if (UsableElement.Value.Element.Id == InteractiveElement.Id && InteractiveElement.IsUsable) { if (InteractiveElement.TypeId == RessourceID && account.Map.NoEntitiesOnCell(UsableElement.Value.CellId)) { ListUsableElement.Add(UsableElement.Value); ListDistance.Add(GetRessourceDistance((int)UsableElement.Value.Element.Id)); } } } } } } else { foreach (var UsableElement in account.Map.UsableElements) { foreach (InteractiveElement InteractiveElement in account.Map.InteractiveElements.Values) { if (UsableElement.Value.Element.Id == InteractiveElement.Id && InteractiveElement.IsUsable) { if (account.Map.NoEntitiesOnCell(UsableElement.Value.CellId)) { ListUsableElement.Add(UsableElement.Value); ListDistance.Add(GetRessourceDistance((int)UsableElement.Value.Element.Id)); } } } } } if (ListDistance.Count > 0) { foreach (UsableElement UsableElement in TrierDistanceElement(ListDistance, ListUsableElement)) { if (UsableElement.Element.IsUsable == false) continue; Id = (int)UsableElement.Element.Id; SkillInstanceUid = UsableElement.Skills[0].skillInstanceUid; Current_El = UsableElement.Element; //resourceName = UsableElement.Element.TypeId; if (GetRessourceDistance((int)UsableElement.Element.Id) == 1 || IsFishing) { if (Moved) { account.Map.UseElement(Id, SkillInstanceUid); } else { account.Map.UseElement((int)UsableElement.Element.Id, UsableElement.Skills[0].skillInstanceUid); } Moved = false; IsFishing = false; account.ModifBar(6, 0, 0, "Récolte"); return true; } if ((account.Inventory.HasFishingRod == false && account.Map.MoveToElement((int)UsableElement.Element.Id, 1)) || (account.Inventory.HasFishingRod == true && account.Map.MoveToElement((int)UsableElement.Element.Id, account.Inventory.WeaponRange))) { account.ModifBar(6, 0, 0, "Récolte"); Id = (int)UsableElement.Element.Id; SkillInstanceUid = UsableElement.Skills[0].skillInstanceUid; IsFishing = true; return true; } } } } catch (Exception Ex) { account.Log(new ErrorTextInformation(Ex.Message), 0); } Id = -1; SkillInstanceUid = -1; IsFishing = false; Current_El = null; return false; }
/// <summary> /// Update the state of an interactive element. /// </summary> public void UpdateInteractiveElement(BlueSheep.Common.Protocol.Types.InteractiveElement element) { Elements.InteractiveElement Ielement = new Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List<InteractiveElementSkill>(element.enabledSkills), new List<InteractiveElementSkill>(element.disabledSkills)); Tuple<Elements.InteractiveElement, int> temp = new Tuple<Elements.InteractiveElement, int>(null, 0); foreach (KeyValuePair<Elements.InteractiveElement, int> pair in InteractiveElements) { if (pair.Key.Id == Ielement.Id) temp = new Tuple<Elements.InteractiveElement, int>(pair.Key, pair.Value); } if (temp.Item1 != null) { InteractiveElements.Remove(temp.Item1); InteractiveElements.Add(Ielement, temp.Item2); } else InteractiveElements.Add(Ielement, -1); }
/// <summary> /// Parse the interactive elements array from MapComplementaryInformationsDataMessage. /// </summary> public void ParseInteractiveElements(BlueSheep.Common.Protocol.Types.InteractiveElement[] interactiveElements) { foreach (BlueSheep.Common.Protocol.Types.InteractiveElement element in interactiveElements) { if (element.elementTypeId == 85) m_Account.Safe = element; Elements.InteractiveElement Ielement = new Elements.InteractiveElement((uint)element.elementId, element.elementTypeId, new List<InteractiveElementSkill>(element.enabledSkills), new List<InteractiveElementSkill>(element.disabledSkills)); InteractiveElements.Add(Ielement, -1); if (Ielement.EnabledSkills.Count > 0) { foreach (var layer in this.Data.Layers) { foreach (var cell in layer.Cells) { foreach (var layerElement in cell.Elements) { if (layerElement is GraphicalElement) { GraphicalElement graphicalElement = (GraphicalElement)layerElement; if (graphicalElement.Identifier == Ielement.Id) InteractiveElements[Ielement] = cell.CellId; } } } } } } }
/// <summary> /// Perform the gathering of the specified ressources. /// </summary> /// <param name="ressources"> /// List of the ressources'id. /// </param> /// /// <param name="job"> /// The job used. /// </param> public bool GoGather(List<int> ressources, JobUC job) { List<int> ListeRessourcesID = ressources; List<int> ListDistance = new List<int>(); List<UsableElement> ListUsableElement = new List<UsableElement>(); Current_Job = job; try { if (ListeRessourcesID.Count > 0) { foreach (var RessourceID in ListeRessourcesID) { foreach (var UsableElement in account.MapData.UsableElements) { foreach (InteractiveElement InteractiveElement in account.MapData.InteractiveElements.Keys) { if (UsableElement.Value.Element.Id == InteractiveElement.Id && InteractiveElement.IsUsable) { if (InteractiveElement.TypeId == RessourceID && account.MapData.NoEntitiesOnCell(UsableElement.Value.CellId)) { ListUsableElement.Add(UsableElement.Value); ListDistance.Add(GetRessourceDistance((int)UsableElement.Value.Element.Id)); } } } } } } else { foreach (var UsableElement in account.MapData.UsableElements) { foreach (InteractiveElement InteractiveElement in account.MapData.InteractiveElements.Keys) { if (UsableElement.Value.Element.Id == InteractiveElement.Id && InteractiveElement.IsUsable) { if (account.MapData.NoEntitiesOnCell(UsableElement.Value.CellId)) { ListUsableElement.Add(UsableElement.Value); ListDistance.Add(GetRessourceDistance((int)UsableElement.Value.Element.Id)); } } } } } if (ListDistance.Count > 0) { foreach (UsableElement UsableElement in TrierDistanceElement(ListDistance, ListUsableElement)) { if (UsableElement.Element.IsUsable == false || m_BannedId.Contains((int)UsableElement.Element.Id)) continue; Id = (int)UsableElement.Element.Id; SkillInstanceUid = UsableElement.Skills[0].skillInstanceUid; Current_El = UsableElement.Element; int distance = GetRessourceDistance((int)UsableElement.Element.Id); account.Log(new DebugTextInformation("[Gather] Distance from element " + UsableElement.Element.Id + " = " + distance), 0); if (distance == -1) { continue; } if (account.MapData.CanGatherElement(Id, distance)) { account.SetStatus(Status.Gathering); account.Map.UseElement(Id, SkillInstanceUid); return true; } else if (account.Map.MoveToElement((int)UsableElement.Element.Id, account.Inventory.WeaponRange)) { return true; } else continue; } } } catch (Exception Ex) { account.Log(new ErrorTextInformation(Ex.Message), 0); } Id = -1; SkillInstanceUid = -1; Current_El = null; return false; }