Beispiel #1
0
    public void increaseResource(LootTypes tp)
    {
        switch (tp)
        {
        case LootTypes.A:
            ResourceA++;
            break;

        case LootTypes.B:
            ResourceB++;
            break;

        case LootTypes.C:
            ResourceC++;
            break;

        case LootTypes.D:
            ResourceD++;
            break;

        default:
            break;
        }
        return;
    }
Beispiel #2
0
 public void Init(LootTypes knd, MonoBehaviour parent)
 {
     kind = knd;
     Debug.Log("Resource" + knd.ToString() + ".png");
     sprite    = Resources.Load <Sprite>("Resource" + knd.ToString());
     par       = parent;
     transform = gameObject.GetComponent <Transform> ();
 }
Beispiel #3
0
    public static Loot GetRandomLoot(MonoBehaviour par, GameObject go)
    {
        LootTypes lootT = (LootTypes)typeof(LootTypes).GetRandomEnumValue();

        if (lootT == LootTypes.HEALTH)
        {
            lootT = LootTypes.D;
        }
        GameObject go2  = new GameObject();
        Loot       loot = go2.AddComponent <Loot>();

        loot.Init(lootT, par);
        return(loot);
    }
Beispiel #4
0
 public void CollectResource(LootTypes lootT)
 {
     if (lootT != LootTypes.HEALTH)
     {
         UnFadeChildren();
         asrc.clip = pickupSnd;
         asrc.Play();
         fadeOut = Time.time + 10f;
         rm.increaseResource(lootT);
     }
     else
     {
         asrc.clip = pickupSnd;
         asrc.Play();
         if (health < healthCapacity)
         {
             health++;
         }
     }
 }
        public static void SendLoot(this Player p, ulong Guid)
        {
            WorldObject obj = Database.Creatures.TryGet <WorldObject>(Guid) ??
                              Database.GameObjects.TryGet <WorldObject>(Guid) ??
                              Database.Items.TryGet <WorldObject>(Guid) ??
                              null;

            if (obj == null)
            {
                return;
            }

            LootTypes         lootType = LootTypes.LOOT_TYPE_NOTALLOWED;
            uint              money    = 0;
            List <LootObject> loot     = new List <LootObject>();
            sbyte             slot     = 1;

            if (obj.IsTypeOf(ObjectTypes.TYPE_UNIT)) //Creature Loot
            {
                p.CurrentLootTarget = Guid;
                Creature mob = (Creature)obj;

                if (mob.Loot.Count > 0 || mob.Money > 0)
                {
                    foreach (LootObject lo in mob.Loot.ToArray())
                    {
                        if (lo.Lootable(p))
                        {
                            loot.Add(lo);
                        }
                        else
                        {
                            mob.Loot.Remove(lo);
                        }
                    }

                    lootType = LootTypes.LOOT_TYPE_CORPSE;
                }

                if (mob.Loot.Count == 0 && mob.Money == 0)
                {
                    LootRelease(mob, p);
                }

                money = mob.Money;
            }
            else if (obj.IsTypeOf(ObjectTypes.TYPE_GAMEOBJECT))
            {
                GameObject go = (GameObject)obj;
                if (go.LootRecipient != p)
                {
                    return;
                }

                p.CurrentLootTarget = obj.Guid;

                go.GenerateLoot();
                foreach (LootObject lo in go.Loot.ToArray())
                {
                    if (lo.Lootable(p))
                    {
                        loot.Add(lo);
                    }
                    else
                    {
                        go.Loot.Remove(lo);
                    }

                    lootType = LootTypes.LOOT_TYPE_SKINNING;
                }

                if (go.Loot.Count == 0)
                {
                    LootRelease(go, p);
                }
            }
            else if (obj.IsTypeOf(ObjectTypes.TYPE_ITEM))
            {
            }

            PacketWriter pw = new PacketWriter(Opcodes.SMSG_LOOT_RESPONSE);

            pw.WriteUInt64(obj.Guid);
            pw.WriteUInt8((byte)lootType);
            pw.WriteUInt32(money);
            pw.WriteUInt8((byte)loot.Count);
            foreach (LootObject li in loot)
            {
                p.QueryItemCheck(li.Item.Entry);

                pw.WriteUInt8((byte)slot);
                pw.WriteUInt32(li.Item.Template.Entry);
                pw.WriteUInt32(li.Count);
                pw.WriteUInt32(li.Item.Template.DisplayID);
                pw.WriteUInt32(0);
                pw.WriteUInt32(0);
                slot++;
            }
            GridManager.Instance.SendSurrounding(pw, p);
        }
Beispiel #6
0
        private async Task Loot(uint corpseId)
        {
            Stealth.Client.FindTypeEx(0xFFFF, 0xFFFF, corpseId, true);
            var itemsFound = Stealth.Client.GetFindList();

            foreach (var item in itemsFound)
            {
                bool transfer = false;
                if (LootTypes.Contains(Stealth.Client.GetType(item)))
                {
                    transfer = true;
                }

                if (!transfer)
                {
                    var tooltip = Stealth.Client.GetTooltip(item);
                    foreach (var tooltipValue in LootTooltipValues)
                    {
                        if (tooltip.ToLower().Contains(tooltipValue.ToLower()))
                        {
                            transfer = true;
                            break;
                        }
                    }
                }

                if (transfer)
                {
                    ct = new CancellationTokenSource();
                    _currMovingItem = item;
                    await Task.Delay(1000);

                    Stealth.Client.MoveItem(item, 0, _backpackId, 0, 0, 0);
                    try
                    {
                        await Task.Delay(5000, ct.Token);
                    }
                    catch (TaskCanceledException) { }
                }
            }

            //foreach (var type in LootTypes)
            //{
            //    Stealth.Client.FindTypeEx(type, 0xFFFF, corpseId, true);
            //    var itemsFound = Stealth.Client.GetFindList();

            //    foreach(var item in itemsFound)
            //    {
            //        ct = new CancellationTokenSource();
            //        _currMovingItem = item;
            //        await Task.Delay(1000);
            //        Stealth.Client.MoveItem(item, 0, _backpackId, 0,0,0);

            //        try
            //        {
            //            await Task.Delay(5000, ct.Token);
            //        }
            //        catch (TaskCanceledException){}
            //    }
            //}

            lootingQueue.Remove(corpseId);
        }
Beispiel #7
0
 // Use this for initialization
 public static Loot GetLoot(LootTypes knd, MonoBehaviour par)
 {
     return(new Loot(knd, par));
 }
Beispiel #8
0
 public Loot(LootTypes knd, MonoBehaviour parent)
 {
 }