Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        /// <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;
        }