public override void Close()
 {
     base.Close();
     InventoryHandler.SendExchangeLeaveMessage(this.Character.Client, base.DialogType, false);
     this.Character.CloseDialog(this);
     this.TaxCollector.OnDialogClosed(this);
     this.TaxCollector.Guild.AddXP((long)this.TaxCollector.GatheredExperience);
     TaxCollectorHandler.SendTaxCollectorMovementMessage(this.TaxCollector.Guild.Clients, false, this.TaxCollector, this.Character.Name);
     this.TaxCollector.Delete();
 }
Exemple #2
0
        public bool AddTaxCollectorSpawn(Character character)
        {
            if (!character.GuildMember.HasRight(GuildRightsBitEnum.GUILD_RIGHT_HIRE_TAX_COLLECTOR))
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_NO_RIGHTS));
                return(false);
            }

            if (character.Guild.TaxCollectors.Count >= character.Guild.MaxTaxCollectors)
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_MAX_REACHED));
                return(false);
            }

            if (character.Position.Map.TaxCollector != null)
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_ALREADY_ONE));
                return(false);
            }

            m_lastRemovedTaxCollectors.Clean();
            if (m_lastRemovedTaxCollectors.FirstOrDefault(x => x.First.GuildId == character.Guild.Id && x.First.MapId == character.Map.Id) != null)
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_CANT_HIRE_YET));
                return(false);
            }

            if (!character.Position.Map.AllowCollector)
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_CANT_HIRE_HERE));
                return(false);
            }

            if (character.IsInFight())
            {
                character.Client.Send(new TaxCollectorErrorMessage((sbyte)TaxCollectorErrorReasonEnum.TAX_COLLECTOR_ERROR_UNKNOWN));
                return(false);
            }

            var position = character.Position.Clone();

            var taxCollectorNpc = new TaxCollectorNpc(m_idProvider.Pop(), position.Map.GetNextContextualId(), position, character.Guild, character);

            WorldServer.Instance.IOTaskPool.AddMessage(() => Database.Insert(taxCollectorNpc.Record));

            m_taxCollectorSpawns.Add(taxCollectorNpc.GlobalId, taxCollectorNpc.Record);
            m_activeTaxCollectors.Add(taxCollectorNpc);

            taxCollectorNpc.Map.Enter(taxCollectorNpc);
            character.Guild.AddTaxCollector(taxCollectorNpc);

            TaxCollectorHandler.SendTaxCollectorMovementMessage(taxCollectorNpc.Guild.Clients, TaxCollectorMovementTypeEnum.TAX_COLLECTOR_HIRED, taxCollectorNpc, character.Id, character.Name);

            return(true);
        }