Example #1
0
        protected void Dispose()
        {
            if (this.Looters == null)
            {
                return;
            }
            IList <LooterEntry> looters = this.Looters;

            this.Looters = (IList <LooterEntry>)null;
            for (int index = 0; index < looters.Count; ++index)
            {
                LooterEntry looterEntry = looters[index];
                Character   owner       = looterEntry.Owner;
                if (owner != null)
                {
                    LootHandler.SendLootReleaseResponse(owner, this);
                }
                if (looterEntry.Loot == this)
                {
                    looterEntry.Loot = (Loot)null;
                }
            }

            this.OnDispose();
        }
Example #2
0
        /// <summary>
        /// Lets the given Character roll for the item at the given index
        /// </summary>
        /// <param name="index"></param>
        /// <param name="type"></param>
        public void Roll(Character chr, uint index, LootRollType type)
        {
            LootItem lootItem = this.Items[index];

            if (lootItem.RollProgress == null)
            {
                return;
            }
            lootItem.RollProgress.Roll(chr, type);
            if (!lootItem.RollProgress.IsRollFinished)
            {
                return;
            }
            Character highestParticipant = lootItem.RollProgress.HighestParticipant;

            if (highestParticipant != null)
            {
                LootHandler.SendRollWon(highestParticipant, this, lootItem, lootItem.RollProgress.HighestEntry);
                this.HandoutItem(highestParticipant, lootItem, (BaseInventory)null, (int)byte.MaxValue);
            }
            else
            {
                this.RemoveItem(lootItem);
            }

            lootItem.RollProgress.Dispose();
        }
Example #3
0
        /// <summary>
        /// Returns whether the given looter may loot the given Item.
        /// Make sure the Looter is logged in before calling this Method.
        ///
        /// TODO: Find the right error messages
        /// TODO: Only give every MultiLoot item to everyone once! Also check for quest-dependencies etc.
        /// </summary>
        public InventoryError CheckTakeItemConditions(LooterEntry looter, LootItem item)
        {
            if (item.Taken)
            {
                return(InventoryError.ALREADY_LOOTED);
            }
            if (item.RollProgress != null)
            {
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }
            if (!looter.MayLoot(this))
            {
                return(InventoryError.DontReport);
            }
            ICollection <LooterEntry> multiLooters = item.MultiLooters;

            if (multiLooters != null)
            {
                if (multiLooters.Contains(looter))
                {
                    return(InventoryError.OK);
                }
                if (looter.Owner != null)
                {
                    LootHandler.SendLootRemoved(looter.Owner, item.Index);
                }
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }

            return(!item.Template.CheckLootConstraints(looter.Owner) || this.Method != LootMethod.FreeForAll &&
                   (item.Template.Quality > this.Group.LootThreshold && !item.Passed ||
                    this.Group.MasterLooter != null && this.Group.MasterLooter != looter.Owner.GroupMember)
                ? InventoryError.DONT_OWN_THAT_ITEM
                : InventoryError.OK);
        }
Example #4
0
        /// <summary>
        /// Generates loot for Items and GOs.
        /// </summary>
        /// <param name="lootable">The Object or Unit that is being looted</param>
        /// <returns>The object's loot or null if there is nothing to get or the given Character can't access the loot.</returns>
        public static ObjectLoot CreateAndSendObjectLoot(ILootable lootable, Character initialLooter,
                                                         LootEntryType type, bool heroic)
        {
            var oldLoot = initialLooter.LooterEntry.Loot;

            if (oldLoot != null)
            {
                oldLoot.ForceDispose();
            }
            var looters = FindLooters(lootable, initialLooter);

            var loot = CreateLoot <ObjectLoot>(lootable, initialLooter, type, heroic, 0);            // TODO: pass mapid

            if (loot != null)
            {
                initialLooter.LooterEntry.Loot = loot;
                loot.Initialize(initialLooter, looters, 0);                 // TODO: pass mapid
                LootHandler.SendLootResponse(initialLooter, loot);
            }
            else
            {
                //lootable.OnFinishedLooting();
                // empty Item -> Don't do anything
            }
            return(loot);
        }
    private IEnumerator DropLootCoroutine(GridObject gridObject, Vector3 dropLocation, float delayAppear = 1.0f)
    {
        LootHandler lh = gridObject.gameObject.GetComponent <LootHandler>();

        if (lh != null)
        {
            GameObject lootObjectToDrop = lh.RequestLootDrop(dropLocation, forced: true);

            if (lootObjectToDrop != null)
            {
                MeshRenderer renderer = lootObjectToDrop.GetComponentInChildren <MeshRenderer>();
                renderer.enabled = false;

                gm.AddObjectToGrid(lootObjectToDrop, gm.WorldToGrid(dropLocation));
                gridObjectsInPlay.Add(lootObjectToDrop.GetComponent <Loot>());

                Rotator lootRotator = lootObjectToDrop.GetComponent <Rotator>();
                lootRotator.enabled = true;
                lootRotator.ApplyRotation("Left");

                yield return(new WaitForSeconds(delayAppear));

                renderer.enabled = true;
            }
        }
    }
Example #6
0
        protected void Dispose()
        {
            if (Looters == null)
            {
                return;
            }

            var looters = Looters;

            Looters = null;

            for (var i = 0; i < looters.Count; i++)
            {
                var looter = looters[i];
                var owner  = looter.Owner;
                if (owner != null)
                {
                    LootHandler.SendLootReleaseResponse(owner, this);
                }

                if (looter.Loot == this)
                {
                    looter.Loot = null;
                }
            }

            OnDispose();
        }
Example #7
0
        /// <summary>
        /// Lets the given Character roll for the item at the given index
        /// </summary>
        /// <param name="index"></param>
        /// <param name="type"></param>
        public void Roll(Character chr, uint index, LootRollType type)
        {
            var item = Items[index];

            if (item.RollProgress != null)
            {
                // item is actually being rolled for
                item.RollProgress.Roll(chr, type);

                if (item.RollProgress.IsRollFinished)
                {
                    // handout the item, once the Roll finished
                    var highest = item.RollProgress.HighestParticipant;

                    if (highest != null)
                    {
                        LootHandler.SendRollWon(highest, this, item, item.RollProgress.HighestEntry);
                        HandoutItem(highest, item, null, BaseInventory.INVALID_SLOT);
                    }
                    else
                    {
                        // no one online to receive the item (odd) -> Simply remove it
                        RemoveItem(item);
                    }
                    item.RollProgress.Dispose();
                }
            }
        }
Example #8
0
        /// <summary>
        /// Returns whether the given looter may loot the given Item.
        /// Make sure the Looter is logged in before calling this Method.
        ///
        /// TODO: Find the right error messages
        /// TODO: Only give every MultiLoot item to everyone once! Also check for quest-dependencies etc.
        /// </summary>
        public InventoryError CheckTakeItemConditions(Asda2LooterEntry looter, Asda2LootItem item)
        {
            if (item.Taken)
            {
                return(InventoryError.ALREADY_LOOTED);
            }
            if (!looter.MayLoot(this))
            {
                return(InventoryError.DontReport);
            }
            ICollection <Asda2LooterEntry> multiLooters = item.MultiLooters;

            if (multiLooters != null)
            {
                if (multiLooters.Contains(looter))
                {
                    return(InventoryError.OK);
                }
                if (looter.Owner != null)
                {
                    LootHandler.SendLootRemoved(looter.Owner, item.Index);
                }
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }

            if (!item.Template.CheckLootConstraints(looter.Owner))
            {
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }
            int method = (int)this.Method;

            return(InventoryError.OK);
        }
Example #9
0
 // Use this for initialization
 void Start()
 {
     if (monsterLoot == null)
     {
         monsterLoot = gameObject.GetComponent <LootHandler>();
     }
 }
Example #10
0
 // Use this for initialization
 void Start()
 {
     if (monsterLoot == null)
     {
         monsterLoot = gameObject.GetComponent<LootHandler>();
     }
 }
Example #11
0
        /// <summary>
        /// This gives the money to everyone involved. Will only work the first time its called.
        /// Afterwards <c>IsMoneyLooted</c> will be true.
        /// </summary>
        public void GiveMoney()
        {
            if (this.m_moneyLooted)
            {
                return;
            }
            if (this.Group == null)
            {
                LooterEntry looterEntry = this.Looters.FirstOrDefault <LooterEntry>();
                if (looterEntry != null && looterEntry.Owner != null)
                {
                    this.m_moneyLooted = true;
                    this.SendMoney(looterEntry.Owner, this.Money);
                }
            }
            else
            {
                List <Character> characterList = new List <Character>();
                if (this.UsesRoundRobin)
                {
                    LooterEntry looterEntry = this.Looters.FirstOrDefault <LooterEntry>();
                    if (looterEntry != null && looterEntry.Owner != null)
                    {
                        characterList.Add(looterEntry.Owner);
                        if (this.Lootable is WorldObject)
                        {
                            WorldObject lootable = (WorldObject)this.Lootable;
                        }
                        else
                        {
                            Character owner = looterEntry.Owner;
                        }
                    }
                }
                else
                {
                    foreach (LooterEntry looter in (IEnumerable <LooterEntry>) this.Looters)
                    {
                        if (looter.m_owner != null)
                        {
                            characterList.Add(looter.m_owner);
                        }
                    }
                }

                if (characterList.Count > 0)
                {
                    this.m_moneyLooted = true;
                    uint amount = this.Money / (uint)characterList.Count;
                    foreach (Character character in characterList)
                    {
                        this.SendMoney(character, amount);
                        LootHandler.SendMoneyNotify(character, amount);
                    }
                }
            }

            this.CheckFinished();
        }
Example #12
0
 public DungeonHandlers(FormState state)
 {
     _ah = new ActionHandler();
     _lh = new LootHandler();
     _d  = (state.DungeonType == Enemies.DungeonType.FINAL) ?
           new Dungeon(state.Player.GetLevel(), state.DungeonType, state.Random) :
           new Dungeon(state.dungeonTiers[state.DungeonType], state.DungeonType, state.Random);
 }
Example #13
0
        /// <summary>
        /// Lets the given Character roll
        /// </summary>
        /// <param name="chr"></param>
        /// <param name="type"></param>
        public void Roll(Character chr, LootRollType type)
        {
            if (m_RemainingParticipants.Remove(chr.LooterEntry))
            {
                var roll = Utility.Random(1, LootMgr.HighestRoll);

                m_rolls[new LootRollEntry(roll, type)] = chr.LooterEntry;
                LootHandler.SendRoll(chr, m_loot, m_lootItem, roll, type);
            }
        }
Example #14
0
        public static void StartTheServer()
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Green;
                zoneServer.Monsters     = new List <NonPlayerCharacterClass>();
                zoneServer.Vendors      = new List <VendingMachine>();
                zoneServer.Doors        = new List <Doors>();

                using (SqlWrapper sqltester = new SqlWrapper())
                {
                    if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Database setup not correct");
                        Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage);
                        Console.WriteLine("Please press Enter to exit.");
                        Console.ReadLine();
                        Process.GetCurrentProcess().Kill();
                    }
                    sqltester.CheckDBs();
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Loaded {0} items", ItemHandler.CacheAllItems());
                Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos());
                Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels());

                LootHandler.CacheAllFromDB();
                Tradeskill.CacheItemNames();

                csc.AddScriptMembers();
                csc.CallMethod("Init", null);

                ThreadMgr.Start();
                zoneServer.Start();
                Console.ResetColor();
            }
            catch (MySqlException e)
            {
                Console.WriteLine("MySql Error. Server Cannot Start");
                Console.WriteLine("Exception: " + e.Message);
                string       current = DateTime.Now.ToString("HH:mm:ss");
                StreamWriter logfile = File.AppendText("ZoneEngineLog.txt");
                logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start");
                logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message);
                logfile.Close();
                zoneServer.Stop();
                ThreadMgr.Stop();
                Process.GetCurrentProcess().Kill();
            }
        }
Example #15
0
    public override void ActivateEffect(GameObject activator, float value, Collision2D coll, Collider2D other)
    {
        if (lootHandler == null)
        {
            lootHandler = gameObject.GetComponent<LootHandler>();
        }

        if (lootHandler != null)
        {
            lootHandler.DropLoot();
        }
    }
Example #16
0
        /// <summary>
        /// Adds all initial Looters of nearby Characters who may loot this Loot.
        /// When all of the initial Looters gave up the Loot, the Loot becomes free for all.
        /// </summary>
        public void Initialize(Character chr, IList <LooterEntry> looters, MapId mapid)
        {
            Looters = looters;
            if (IsGroupLoot)
            {
                var groupMember = chr.GroupMember;
                if (groupMember != null)
                {
                    Group     = groupMember.Group;
                    Method    = Group.LootMethod;
                    Threshold = Group.LootThreshold;

                    var decision = Method == LootMethod.MasterLoot ? LootDecision.Master : LootDecision.Rolling;

                    IList <LooterEntry> nearbyLooters = null;

                    // TODO: masterlooter
                    foreach (var item in Items)
                    {
                        if (item.Template.Flags.HasFlag(ItemFlags.MultiLoot) ||
                            item.Template.Quality >= Threshold)
                        {
                            if (UsesRoundRobin)
                            {
                                nearbyLooters = new List <LooterEntry>();
                                Group.GetNearbyLooters(Lootable, chr, nearbyLooters);
                            }
                            else
                            {
                                nearbyLooters = Looters;
                            }
                        }

                        if (item.Template.Flags.HasFlag(ItemFlags.MultiLoot))
                        {
                            item.AddMultiLooters(nearbyLooters);
                        }
                        else if (item.Template.Quality >= Threshold)
                        {
                            item.Decision = decision;
                            if (decision == LootDecision.Rolling)
                            {
                                item.RollProgress = new LootRollProgress(this, item, nearbyLooters);
                                LootHandler.SendStartRoll(this, item, nearbyLooters, mapid);
                            }
                        }
                    }
                    return;
                }
            }
            Method = LootMethod.FreeForAll;
        }
Example #17
0
        /// <summary>
        /// Marks the given Item as taken and removes it from the list of available Items
        /// </summary>
        /// <param name="lootItem"></param>
        public void RemoveItem(LootItem lootItem)
        {
            lootItem.Taken = true;
            ++this.m_takenCount;
            foreach (LooterEntry looter in (IEnumerable <LooterEntry>) this.Looters)
            {
                if (looter.Owner != null)
                {
                    LootHandler.SendLootRemoved(looter.Owner, lootItem.Index);
                }
            }

            this.CheckFinished();
        }
Example #18
0
        /// <summary>
        /// Marks the given Item as taken and removes it from the list of available Items
        /// </summary>
        /// <param name="lootItem"></param>
        public void RemoveItem(LootItem lootItem)
        {
            lootItem.Taken = true;
            ++m_takenCount;
            foreach (LooterEntry looter in Looters)
            {
                if (looter.Owner != null)
                {
                    LootHandler.SendLootRemoved(looter.Owner, lootItem.Index);
                }
            }

            CheckFinished();
        }
Example #19
0
        /// <summary>
        /// Returns whether the given looter may loot the given Item.
        /// Make sure the Looter is logged in before calling this Method.
        ///
        /// TODO: Find the right error messages
        /// TODO: Only give every MultiLoot item to everyone once! Also check for quest-dependencies etc.
        /// </summary>
        public InventoryError CheckTakeItemConditions(LooterEntry looter, LootItem item)
        {
            if (item.Taken)
            {
                return(InventoryError.ALREADY_LOOTED);
            }
            if (item.RollProgress != null)
            {
                // TODO: Still being rolled for
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }
            if (!looter.MayLoot(this))
            {
                return(InventoryError.DontReport);
            }

            var multiLooters = item.MultiLooters;

            if (multiLooters != null)
            {
                if (!multiLooters.Contains(looter))
                {
                    if (looter.Owner != null)
                    {
                        // make sure, Item cannot be seen by client anymore
                        LootHandler.SendLootRemoved(looter.Owner, item.Index);
                    }
                    return(InventoryError.DONT_OWN_THAT_ITEM);
                }
                return(InventoryError.OK);
            }

            if (!item.Template.CheckLootConstraints(looter.Owner))
            {
                return(InventoryError.DONT_OWN_THAT_ITEM);
            }

            if (Method != LootMethod.FreeForAll)
            {
                // definitely Group-Loot
                if ((item.Template.Quality > Group.LootThreshold && !item.Passed) ||
                    (Group.MasterLooter != null &&
                     Group.MasterLooter != looter.Owner.GroupMember))
                {
                    return(InventoryError.DONT_OWN_THAT_ITEM);
                }
            }

            return(InventoryError.OK);
        }
Example #20
0
        /// <summary>
        /// Marks the given Item as taken and removes it from the list of available Items
        /// </summary>
        /// <param name="lootItem"></param>
        public void RemoveItem(LootItem lootItem)
        {
            lootItem.Taken = true;
            m_takenCount++;

            // TODO: Have correct collection of all observing Characters
            foreach (var looter in Looters)
            {
                if (looter.Owner != null)
                {
                    LootHandler.SendLootRemoved(looter.Owner, lootItem.Index);
                }
            }
            CheckFinished();
        }
Example #21
0
    public bool OnInteraction(GameObject player)
    {
        if (!FlagHelper.IsSet(flags, ItemFlags.INTERACTABLE))
        {
            return(false);
        }

        if (FlagHelper.IsSet(flags, ItemFlags.LOOTABLE))
        {
            OnLootStart(player);
            LootHandler.OnLoot(this.gameObject, player);
            OnLootEnd(player);
        }

        return(true);
    }
Example #22
0
        internal void FinalizeStep(QuestStep p_step)
        {
            LootHandler lootHandler = new LootHandler(p_step);

            lootHandler.DistributeRewards(null);
            LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.QUESTLOG_CHANGED, new QuestChangedEventArgs(QuestChangedEventArgs.Type.COMPLETED_QUEST, p_step));
            if (p_step.StaticData.FollowupStep > 0)
            {
                ActivateQuest(p_step.StaticData.FollowupStep);
                LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.IMPLICIT_QUEST_END);
            }
            else
            {
                LegacyLogic.Instance.CharacterBarkHandler.RandomPartyMemberBark(EBarks.FINAL_QUEST);
            }
            LegacyLogic.Instance.TrackingManager.TrackQuestStepCompleted(p_step.StaticData.StaticID);
        }
Example #23
0
        public override bool Use(Character user)
        {
            if (m_go.Entry.IsConsumable)
            {
                m_go.State = GameObjectState.Disabled;
            }

            if (m_go.Loot != null)
            {
                LootHandler.SendLootResponse(user, m_go.Loot);
            }
            else
            {
                LootMgr.CreateAndSendObjectLoot(m_go, user, LootEntryType.GameObject, user.Map.IsHeroic);
            }
            return(true);
        }
Example #24
0
 /// <summary>
 /// Releases the current loot and (maybe) makes it available to everyone else.
 /// </summary>
 public void Release()
 {
     if (m_loot == null)
     {
         return;
     }
     if (m_owner != null)
     {
         LootHandler.SendLootReleaseResponse(m_owner, m_loot);
     }
     m_loot.RemoveLooter(this);
     if (m_loot.Looters.Count == 0)
     {
         m_loot.IsReleased = true;
     }
     Loot = null;
 }
Example #25
0
    void spawnLoot()
    {
        Vector3 position = this.gameObject.transform.position;

        float enemyMeshSizeX = this.gameObject.GetComponent <MeshFilter> ().mesh.bounds.size.x;
        float deltaX         = size / (enemyMeshSizeX * this.gameObject.transform.localScale.x);

        position.x = position.x - (enemyMeshSizeX);

        float randomRange = deltaX;

        for (int i = 0; i < size; i++)
        {
            // Random position for the loot defined by these
            float current1 = (Random.Range(-1 * randomRange, randomRange));
            float current2 = (Random.Range(-1 * randomRange, randomRange));

            // Getting random loot from our loot handler
            GameObject loot = LootHandler.getRandomLoot(shipClass);
            // Spawning loot on the screen at position altered by random value
            Instantiate(loot, position + new Vector3(current1, current2, 0), Quaternion.identity);
        }
    }
Example #26
0
        /// <summary>
        /// Requires loot to already be generated
        /// </summary>
        /// <param name="lootable"></param>
        public void TryLoot(ILootable lootable)
        {
            Release();             // make sure that the Character is not still looting something else

            var loot = lootable.Loot;

            if (loot == null)
            {
                LootHandler.SendLootFail(m_owner, lootable);
                // TODO: Kneel and unkneel?
            }
            else if (MayLoot(loot))
            {
                // we are either already a looter or become a new one
                m_owner.CancelAllActions();
                Loot = loot;

                LootHandler.SendLootResponse(m_owner, loot);
            }
            else
            {
                LootHandler.SendLootFail(m_owner, lootable);
            }
        }
Example #27
0
 public JsonResult GetConfig()
 {
     return(Json(LootHandler.GetConfig()));
 }
Example #28
0
 public ContentResult SetConfig([FromBody] ConfigWrapper config)
 {
     LootHandler.SetConfig(config);
     return(Content("config was set."));
 }
Example #29
0
        /// <summary>
        /// This gives the money to everyone involved. Will only work the first time its called.
        /// Afterwards <c>IsMoneyLooted</c> will be true.
        /// </summary>
        public void GiveMoney()
        {
            if (!m_moneyLooted)
            {
                if (Group == null)
                {
                    // we only have a single looter
                    var looter = Looters.FirstOrDefault();
                    if (looter != null && looter.Owner != null)
                    {
                        m_moneyLooted = true;
                        SendMoney(looter.Owner, Money);
                    }
                }
                else
                {
                    var looters = new List <Character>();
                    if (UsesRoundRobin)
                    {
                        // we only added the RoundRobin member, so we have to find everyone in the radius for the money now

                        var looter = Looters.FirstOrDefault();
                        if (looter != null && looter.Owner != null)
                        {
                            looters.Add(looter.Owner);

                            WorldObject center;
                            if (Lootable is WorldObject)
                            {
                                center = (WorldObject)Lootable;
                            }
                            else
                            {
                                center = looter.Owner;
                            }

                            GroupMember otherMember;
                            var         chrs = center.GetObjectsInRadius(LootMgr.LootRadius, ObjectTypes.Player, false, 0);
                            foreach (Character chr in chrs)
                            {
                                if (chr.IsAlive && (chr == looter.Owner ||
                                                    ((otherMember = chr.GroupMember) != null && otherMember.Group == Group)))
                                {
                                    looters.Add(chr);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (var looter in Looters)
                        {
                            if (looter.m_owner != null)
                            {
                                looters.Add(looter.m_owner);
                            }
                        }
                    }

                    if (looters.Count > 0)
                    {
                        m_moneyLooted = true;

                        var amount = Money / (uint)looters.Count;
                        foreach (var looter in looters)
                        {
                            SendMoney(looter, amount);
                            LootHandler.SendMoneyNotify(looter, amount);
                        }
                    }
                }
                CheckFinished();
            }
        }
Example #30
0
        /// <summary>
        /// Gives the receiver the money and informs everyone else
        /// </summary>
        /// <param name="receiver"></param>
        /// <param name="amount"></param>
        protected void SendMoney(Character receiver, uint amount)
        {
            receiver.AddMoney(amount);

            LootHandler.SendClearMoney(this);
        }
Example #31
0
        /// <summary>
        /// This gives the money to everyone involved. Will only work the first time its called.
        /// Afterwards <c>IsMoneyLooted</c> will be true.
        /// </summary>
        public void GiveMoney()
        {
            if (!m_moneyLooted)
            {
                if (Group == null)
                {
                    // we only have a single looter
                    var looter = Looters.FirstOrDefault();
                    if (looter != null && looter.Owner != null)
                    {
                        m_moneyLooted = true;
                        SendMoney(looter.Owner, Money);
                    }
                }
                else
                {
                    var looters = new List <Character>();
                    if (UsesRoundRobin)
                    {
                        // we only added the RoundRobin member, so we have to find everyone in the radius for the money now

                        var looter = Looters.FirstOrDefault();
                        if (looter != null && looter.Owner != null)
                        {
                            looters.Add(looter.Owner);

                            WorldObject center;
                            if (Lootable is WorldObject)
                            {
                                center = (WorldObject)Lootable;
                            }
                            else
                            {
                                center = looter.Owner;
                            }
                        }
                    }
                    else
                    {
                        foreach (var looter in Looters)
                        {
                            if (looter.m_owner != null)
                            {
                                looters.Add(looter.m_owner);
                            }
                        }
                    }

                    if (looters.Count > 0)
                    {
                        m_moneyLooted = true;

                        var amount = Money / (uint)looters.Count;
                        foreach (var looter in looters)
                        {
                            SendMoney(looter, amount);
                            LootHandler.SendMoneyNotify(looter, amount);
                        }
                    }
                }
                CheckFinished();
            }
        }
Example #32
0
 void Start()
 {
     m_KeysContainer  = GameObject.Find("Keys&Gates&Plates");
     m_CoinsContainer = GameObject.Find("CoinsContainer");
     m_LootHandler    = FindObjectOfType <LootHandler>();
 }