Esempio n. 1
0
        public void Populate(Enemy enemy, Tuple <Player, int> playerData, Random rnd, string lootState, IList <LootDef> lootDefs)
        {
            BagType   = BagType.Blue;
            Lootstate = lootState;

            double probability = 0;

            var candidates   = enemy.DamageCounter.GetPlayerData().ToList();
            var rng          = rnd.NextDouble();
            var playersCount = candidates.Count;
            var enemyHP      = (int)enemy.ObjectDesc.MaxHP;

            if (playersCount == 1)
            {
                probability = .0001;
            }
            else if (playersCount > 1 && playersCount <= 3)
            {
                probability = .0001 + .0001 * playersCount;
            }
            else
            {
                probability = .0002 + .000005 * playersCount;
            }

            var whitebag = new ILootDef[] { new Drops(new ItemLoot(itemName, probability * (eventChest ? .8 : 1), true)) };

            whitebag[0].Populate(enemy, playerData, rnd, Lootstate, lootDefs);
        }
Esempio n. 2
0
 public IObjectStack CreateObjectStack(BagType bagType, int objectKey, int slot, int amount)
 {
     return(new ObjectStack(bagType, objectKey, slot)
     {
         Count = amount
     });
 }
Esempio n. 3
0
 public TableBagData(ushort objNo,
                     string displayName,
                     string displayNameEn,
                     float throwDexterity,
                     bool isDisplayContents,
                     BagType btype,
                     int startGap,
                     float startprob,
                     float con,
                     int maxGap,
                     string description,
                     string descriptionEn)
 {
     ObjNo             = objNo;
     DisplayName       = displayName;
     DisplayNameEn     = displayNameEn;
     ThrowDexterity    = throwDexterity;
     IsDisplayContents = isDisplayContents;
     Bgtype            = btype;
     StartGap          = startGap;
     Startprob         = startprob;
     Con           = con;
     MaxGap        = maxGap;
     Description   = description;
     DescriptionEn = descriptionEn;
 }
Esempio n. 4
0
    void OnBagTab(ButtonScript obj, object args, int param1, int param2)
    {
        listPanel_.clipOffset = Vector2.zero;
        listPanel_.transform.localPosition = Vector3.zero;
        listPanel_.GetComponent <UIScrollView>().ResetPosition();

        crtBagType = (BagType)param1;
        if (crtBagType == BagType.BT_Item)
        {
            itemSubTab_.isEnabled = false;
            babySubTab_.isEnabled = true;
            //selectedItemSubTabBtnForIndex(param2);
            itemSubTab_CrtPage_ = param2;
        }
        else
        {
            itemSubTab_.isEnabled = true;
            babySubTab_.isEnabled = false;
            //selectedbabySubTabBtnForIndex(param2);
            babySubTab_CrtPage_ = param2;
        }

        itemSubContent_.SetActive(crtBagType == BagType.BT_Item);
        babySubContent_.SetActive(crtBagType == BagType.BT_Baby);

        UpdateSubContent();
    }
Esempio n. 5
0
        public override long Part2(string input)
        {
            parseBags(input);
            var gold = BagType.GetBagType("shiny gold");

            return(countChildren(gold) - 1);
        }
        public static CommonExpandBagTipsView Open(BagType bagType, int cost, System.Action confirmAction, ConsumeTipType type)
        {
            CommonExpandBagTipsView view = UIMgr.instance.Open <CommonExpandBagTipsView>(PREFAB_PATH, EUISortingLayer.Tips);

            view.SetTypeAndCost(bagType, cost, confirmAction, type);
            return(view);
        }
Esempio n. 7
0
        /// <param name="Autofill">If true, then when the player picks up an item that can be stored in this bag, it will automatically be stored if there is space for it.</param>
        public BoundedBag(BagType TypeInfo, ContainerSize Size, bool Autofill)
            : base(BagType.GetTranslatedName(TypeInfo), "", Size, TypeInfo.GetIconTexture(), TypeInfo.IconSourceRect, new Vector2(16, 16), 0.5f, 1f)
        {
            this.TypeInfo = TypeInfo;
            this.SizeInfo = TypeInfo.SizeSettings.FirstOrDefault(x => x.Size == Size);
            if (SizeInfo == null) // This should never happen but just in case...
            {
                SizeInfo = TypeInfo.SizeSettings.First();
            }
            this.Autofill = Autofill;

            _MaxStackSize = ItemBagsMod.UserConfig.GetStandardBagCapacity(Size, TypeInfo);

            DescriptionAlias = string.Format("{0}\n({1})",
                                             BagType.GetTranslatedDescription(TypeInfo),
                                             ItemBagsMod.Translate("CapacityDescription", new Dictionary <string, string>()
            {
                { "count", MaxStackSize.ToString() }
            }));

            if (SizeInfo.Size != Size)
            {
                this.AllowedObjects = new ReadOnlyCollection <AllowedObject>(new List <AllowedObject>());
            }
            else
            {
                this.AllowedObjects = new ReadOnlyCollection <AllowedObject>(SizeInfo.Items.Select(x => new AllowedObject(x)).ToList());
            }
            this.ExcludedAutofillItems = new Dictionary <string, HashSet <ObjectQuality> >();
        }
Esempio n. 8
0
 internal Bag(IReadOnlyList <Item> items, int totalSlots, BagType type, string name)
 {
     TotalSlots = totalSlots;
     FreeSlots  = TotalSlots - items.Count;
     Items      = items;
     Type       = type;
     Name       = name;
 }
Esempio n. 9
0
 public BagType GetPlayerBagItemType(BagType type, int index)
 {
     if (type == BagType.Bag)
     {
         return((BagType)(itemProtoDatas.Find(p => p.ID == GetPlayerBagItemId(type, index)).Bag));
     }
     return(type);
 }
Esempio n. 10
0
 /// <param name="Autofill">If true, then when the player picks up an item that can be stored in this bag, it will automatically be stored if there is space for it.</param>
 public BoundedBag(BagType TypeInfo, ContainerSize Size, bool Autofill)
     : base(BagType.GetTranslatedName(TypeInfo), "", Size, TypeInfo.GetIconTexture(), TypeInfo.IconSourceRect, new Vector2(16, 16), 0.5f, 1f)
 {
     this.TypeInfo = TypeInfo;
     this.Autofill = Autofill;
     this.ExcludedAutofillItems = new Dictionary <string, HashSet <ObjectQuality> >();
     OnSizeChanged += BoundedBag_OnSizeChanged;
 }
Esempio n. 11
0
 private void parseBags(string input)
 {
     BagType.AllTypes.Clear();
     foreach (var line in Utils.splitLines(input))
     {
         BagType.parseDefinition(line);
     }
 }
Esempio n. 12
0
 public List <ItemInfo> GetPlayerBagList(BagType type)
 {
     if (type == BagType.Bag)
     {
         return(GetAllPlayerBagList());
     }
     return(DataManager.GetInstance().GetPlayerBag(type).itemList);
 }
Esempio n. 13
0
        public void Populate(Enemy enemy, Tuple <Player, int> playerData, Random rnd, string lootState, IList <LootDef> lootDefs)
        {
            BagType   = BagType.Pink;
            Lootstate = lootState;

            var pinkBag = new ILootDef[] { new Drops(new TierLoot(tier, itemType, BagType)) };

            pinkBag[0].Populate(enemy, playerData, rnd, lootState, lootDefs);
        }
Esempio n. 14
0
 public void StartCustomMode(ModeGoal goal, BagType bagtype, int width, bool overtuned)
 {
     PersistantVars.pVars.PlaySound(SoundEffects.MENU_SELECT);
     PersistantVars.pVars.goal      = goal;
     PersistantVars.pVars.bagType   = bagtype;
     PersistantVars.pVars.width     = width;
     PersistantVars.pVars.overtuned = overtuned;
     SceneManager.LoadScene("MainGameScene"); //Start game.
 }
Esempio n. 15
0
        public void Populate(Enemy enemy, Tuple <Player, int> playerData, Random rnd, string lootState, IList <LootDef> lootDefs)
        {
            BagType   = BagType.Cyan;
            Lootstate = lootState;

            var cyanBag = !setByTier ? new ILootDef[] { new Drops(new ItemLoot(itemName, 0.1)) }
                : new ILootDef[] { new Drops(new TierLoot(tier, itemType, BagType)) };

            cyanBag[0].Populate(enemy, playerData, rnd, lootState, lootDefs);
        }
Esempio n. 16
0
 private void RecursiveVisitParents(BagType bag, HashSet <string> visited)
 {
     foreach (var parent in bag.AppearIn)
     {
         if (!visited.Contains(parent.Name))
         {
             visited.Add(parent.Name);
             RecursiveVisitParents(parent, visited);
         }
     }
 }
Esempio n. 17
0
            private int RecursiveVisitChildForCount(BagType bag)
            {
                var numBags = 1;

                foreach (var(child, count) in bag.Contains)
                {
                    var childContains = RecursiveVisitChildForCount(child);
                    numBags += count * childContains;
                }
                return(numBags);
            }
Esempio n. 18
0
 private void addParents(HashSet <BagType> possibleParents, BagType bag)
 {
     foreach (var parent in bag.PossibleParents)
     {
         if (!possibleParents.Contains(parent))
         {
             possibleParents.Add(parent);
             addParents(possibleParents, parent);
         }
     }
 }
Esempio n. 19
0
        public override long Part1(string input)
        {
            parseBags(input);

            var gold            = BagType.GetBagType("shiny gold");
            var possibleParents = new HashSet <BagType>();

            addParents(possibleParents, gold);

            return(possibleParents.Count);
        }
Esempio n. 20
0
        public int GetPlayerBagItemUseType(BagType type, int index)
        {
            int id = GetPlayerBagList(type)[index].metaId;

            if (itemProtoDatas.Find(p => p.ID == id) == null)
            {
                DebugUtils.LogError(DebugUtils.Type.UI, "PlayerBagItem is null , the item id is " + id);
            }

            return(itemProtoDatas.Find(p => p.ID == id).UseType);
        }
Esempio n. 21
0
        public int GetPlayerBagItemIsShell(BagType type, int index)
        {
            int id = GetPlayerBagList(type)[index].metaId;

            if (itemProtoDatas.Find(p => p.ID == id).Type == (int)PlayerBagItemType.RuneItem)
            {
                return(0);
            }

            return(itemProtoDatas.Find(p => p.ID == id).IsShell);
        }
Esempio n. 22
0
            private BagType GetOrCreateBag(string name)
            {
                if (Bags.ContainsKey(name))
                {
                    return(Bags[name]);
                }
                var bag = new BagType(name);

                Bags.Add(name, bag);
                return(bag);
            }
 public void SetTypeAndCost(BagType bagType, int cost, System.Action confirmAction, ConsumeTipType type = ConsumeTipType.None)
 {
     _bagType        = bagType;
     _cost           = cost;
     costText.text   = cost.ToString();
     action          = confirmAction;
     _consumeTipType = type;
     if (!ConsumeTipProxy.instance.HasConsumeTipKey(type))
     {
         toggleTip.gameObject.SetActive(false);
     }
 }
Esempio n. 24
0
        public string GetPlayerBagItemDescribe(BagType type, int index)
        {
            int id = GetPlayerBagList(type)[index].metaId;

            if (itemProtoDatas.Find(p => p.ID == id) == null)
            {
                DebugUtils.LogError(DebugUtils.Type.UI, "PlayerBagItem is null , the item id is " + id);
            }

            int desId = itemProtoDatas.Find(p => p.ID == id).DescriptionID;

            return(desId.Localize());
        }
Esempio n. 25
0
    void SpawnNewBag(BagType type)
    {
        GameObject obj = (GameObject)Instantiate(bag, m_bagSpawnPos.position, new Quaternion(0, 0, 0, 0));

        m_Camera.SetCameraXYPos(m_bagSpawnPos.gameObject);
        m_Camera.SetFollowBag(false);
        bag.SetActive(true);
        m_bagAmount -= 1;

        PE.SetBag(obj);
        PE.SetBMPointer(obj.GetComponent <scr_bagMovement>());
        PE.SetSPPointer(obj.GetComponent <spawnParticles>());
    }
Esempio n. 26
0
        private static void LoadModdedBags()
        {
            try
            {
                List <ModdedBag> ModdedBags          = new List <ModdedBag>();
                string           ModdedBagsDirectory = Path.Combine(ModInstance.Helper.DirectoryPath, "assets", "Modded Bags");
                string[]         ModdedBagFiles      = Directory.GetFiles(ModdedBagsDirectory, "*.json", SearchOption.TopDirectoryOnly);
                if (ModdedBagFiles.Length > 0)
                {
                    if (!ModInstance.Helper.ModRegistry.IsLoaded(JAUniqueId))
                    {
                        ModInstance.Monitor.Log("Modded bags could not be loaded because you do not have Json Assets mod installed.", LogLevel.Warn);
                    }
                    else
                    {
                        foreach (string File in ModdedBagFiles)
                        {
                            string    RelativePath = File.Replace(ModInstance.Helper.DirectoryPath + Path.DirectorySeparatorChar, "");
                            ModdedBag ModdedBag    = ModInstance.Helper.Data.ReadJsonFile <ModdedBag>(RelativePath);

                            if (ModdedBag.IsEnabled && (string.IsNullOrEmpty(ModdedBag.ModUniqueId) || ModInstance.Helper.ModRegistry.IsLoaded(ModdedBag.ModUniqueId)))
                            {
                                if (!ModdedBags.Any(x => x.Guid == ModdedBag.Guid))
                                {
                                    ModdedBags.Add(ModdedBag);
                                }
                                else
                                {
                                    ModInstance.Monitor.Log(string.Format("Failed to load modded bag '{0}' because there is already another modded bag with the same Id", ModdedBag.BagName), LogLevel.Warn);
                                }
                            }
                        }

                        ModInstance.Monitor.Log(string.Format("Loaded {0} modded bag(s): {1}", ModdedBags.Count, string.Join(", ", ModdedBags.Select(x => x.BagName))), LogLevel.Info);
                    }
                }

                TemporaryModdedBagTypes = new Dictionary <ModdedBag, BagType>();
                foreach (ModdedBag Bag in ModdedBags)
                {
                    BagType Placeholder = Bag.GetBagTypePlaceholder();
                    TemporaryModdedBagTypes.Add(Bag, Placeholder);
                    BagConfig.BagTypes.Add(Placeholder);
                }
            }
            catch (Exception ex)
            {
                ModInstance.Monitor.Log(string.Format("Error while loading modded bag json files: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error);
            }
        }
Esempio n. 27
0
        public void Populate(Enemy enemy, Tuple <Player, int> playerData, Random rnd, string lootState, IList <LootDef> lootDefs)
        {
            BagType   = BagType.Pink;
            Lootstate = lootState;

            var pinkBag = new[]
            {
                new Drops(
                    new TierLoot(tier, itemType, BagType, true, LootUtils.GetProbability(enemy, LootBagRate.PINK_BAG))
                    )
            };

            pinkBag[0].Populate(enemy, playerData, rnd, lootState, lootDefs);
        }
Esempio n. 28
0
        /* (non-Javadoc)
         * @see br.cos.ufrj.lens.odyssey.tools.psw.metamodels.ocl20.Factory#createBagType(br.cos.ufrj.lens.odyssey.tools.psw.metamodels.core.interfaces.CoreClassifier)
         */
        public BagType createBagType(CoreClassifier elementType)
        {
            BagType result = (BagType)getCollectionType("Bag(" + elementType.getName() + ")");

            if (result == null)
            {
                result = oclPackage.getTypes().getBagType();
                result.setFactory(this);
                result.setElementType(elementType);
                allTypesCreated.Add(result.getName(), result);
            }

            return(result);
        }
Esempio n. 29
0
        public void Populate(Enemy enemy, Tuple <Player, int> playerData, Random rnd, string lootState, IList <LootDef> lootDefs)
        {
            BagType   = BagType.Blue;
            Lootstate = lootState;

            var whitebag = new[]
            {
                new Drops(
                    new ItemLoot(itemName, LootUtils.GetProbability(enemy, LootBagRate.WHITE_BAG, eventChest), false, true)
                    )
            };

            whitebag[0].Populate(enemy, playerData, rnd, Lootstate, lootDefs);
        }
Esempio n. 30
0
        public void SendUseItem(BagType type, int count, long itemId)
        {
            currentBagType = type;
            currentCount   = count;
            currentItemId  = itemId;

            UseItemC2S message = new UseItemC2S();

            message.bagType = type;
            message.count   = count;
            message.itemId  = itemId;

            byte[] data = ProtobufUtils.Serialize(message);
            NetworkManager.SendRequest(MsgCode.UseItemMessage, data);
        }