예제 #1
0
        public static void GiveStartingItems(Player p)
        {
            Character       character       = CharMgr.GetPlayerCharacter(p);
            CreateCharacter createCharacter = (CreateCharacter)p.menuMgr.menuLevel[3];

            ClassCatalog.PortableClass startClass = ClassCatalog.startingClass[createCharacter.startingClass];

            List <string> items = new List <string>();

            items.AddRange(startClass.consumable);
            items.AddRange(startClass.ring);
            items.AddRange(startClass.incantation);

            if (SuppliesCatalog.supplies[createCharacter.startingSupplies].loot != null)
            {
                items.AddRange(SuppliesCatalog.supplies[createCharacter.startingSupplies].loot);
            }

            int consumableSlot  = 0;
            int ringSlot        = 0;
            int incantationSlot = 0;

            foreach (string item in items)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    string name  = item;
                    int    count = 1;

                    int slashIdx = item.IndexOf('/');
                    if (slashIdx != -1)
                    {
                        name = item.Substring(0, slashIdx);
                        if (!int.TryParse(item.Substring(slashIdx + 1), out count))
                        {
                            Logger.LogWarn($"[API] Failed adding item {item} to player inventory in NewGame: Could not parse number of items");
                            continue;
                        }
                    }

                    if (count <= 0)
                    {
                        Logger.LogWarn($"[API] Failed adding item {item} to player inventory in NewGame: {count} is not a valid item count");
                        continue;
                    }

                    InvLoot loot = new InvLoot();
                    loot.InitFromName(name);

                    if (loot.catalogIdx == -1)
                    {
                        Logger.LogWarn($"[API] Failed adding item {item} to player inventory in NewGame: Item not in loot catalog");
                        continue;
                    }

                    int invIdx = p.playerInv.Add(loot, false, count);

                    if (invIdx == -1)
                    {
                        Logger.LogWarn($"[API] Failed adding {item} to player inventory in NewGame: Generic error in PlayerInv.Add");
                        continue;
                    }

                    if (loot.category == LootCatalog.CATEGORY_CONSUMABLE)
                    {
                        if (consumableSlot < character.equipment.consumable.Length)
                        {
                            character.equipment.consumable[consumableSlot].SetFromInventory(invIdx, character);
                            consumableSlot++;
                        }
                    }
                    else if (loot.category == LootCatalog.CATEGORY_RING)
                    {
                        if (ringSlot < character.equipment.ring.Length)
                        {
                            character.equipment.ring[ringSlot].SetFromInventory(invIdx, character);
                            ringSlot++;
                        }
                    }
                    else if (loot.category == LootCatalog.CATEGORY_MAGIC)
                    {
                        if (incantationSlot < character.equipment.incantation.Length)
                        {
                            character.equipment.consumable[incantationSlot].SetFromInventory(invIdx, character);
                            incantationSlot++;
                        }
                    }
                }
            }
        }
예제 #2
0
 public static void NewGame(Player p)
 {
 }