Ejemplo n.º 1
0
        public MapObjectStatic(int staticTileID, int sortInfluence, Position3D position)
            : base(position)
        {
            ItemID = staticTileID;
            SortTiebreaker = sortInfluence;

            _itemData = Data.TileData.ItemData[ItemID & 0x3FFF];

            // Set threshold.
            int background = (_itemData.Background) ? 0 : 1;
            if (!_itemData.Background)
                SortThreshold++;
            if (!(_itemData.Height == 0))
                SortThreshold++;
            if (_itemData.Surface)
                SortThreshold--;

            // get no draw flag
            if (_itemData.Name == "nodraw" || ItemID <= 0)
                _noDraw = true;

            // set up draw variables
            _draw_texture = Data.Art.GetStaticTexture(ItemID);
            _draw_width = _draw_texture.Width;
            _draw_height = _draw_texture.Height;
            _draw_X = (_draw_width >> 1) - 22;
            _draw_Y = (int)(Z * 4) + _draw_height - 44;
            _draw_hue = Vector2.Zero;
            _pickType = PickTypes.PickStatics;
            _draw_flip = false;
        }
Ejemplo n.º 2
0
        public string GetDungeonName()
        {
            if (IsMoney)
            {
                return(Text.FormatKey("MONEY_AMOUNT", Value));
            }
            else
            {
                Data.ItemData entry = Data.DataManager.Instance.GetItem(Value);

                string prefix = "";
                if (entry.Icon > -1)
                {
                    prefix += ((char)(entry.Icon + 0xE0A0)).ToString();
                }
                if (Cursed)
                {
                    prefix += "\uE10B";
                }

                string nameStr = entry.Name.ToLocal();
                if (entry.MaxStack > 1)
                {
                    nameStr += " (" + HiddenValue + ")";
                }

                return(String.Format("{0}[color=#FFCEFF]{1}[color]", prefix, nameStr));
            }
        }
Ejemplo n.º 3
0
 public ItemEntity(Data.ItemData data)
 {
     Component = data.PrefabComponent;
     Score     = data.Score;
     ItemColor = data.ItemColor;
     ItemMode  = data.ItemMode;
 }
Ejemplo n.º 4
0
 public override string ToString()
 {
     Data.ItemData entry = Data.DataManager.Instance.GetItem(ID);
     if (entry.MaxStack > 1)
     {
         return((Cursed ? "[X]" : "") + entry.Name.ToLocal() + " (" + HiddenValue + ")");
     }
     else
     {
         return((Cursed ? "[X]" : "") + entry.Name.ToLocal());
     }
 }
Ejemplo n.º 5
0
 public int GetSellValue()
 {
     Data.ItemData entry = Data.DataManager.Instance.GetItem(ID);
     if (entry.MaxStack > 1)
     {
         return(entry.Price * HiddenValue);
     }
     else
     {
         return(entry.Price);
     }
 }
Ejemplo n.º 6
0
 public override string GetName()
 {
     Data.ItemData entry = Data.DataManager.Instance.GetItem(ID);
     if (entry.MaxStack > 1)
     {
         return((entry.Icon > -1 ? ((char)(entry.Icon + 0xE0A0)).ToString() : "") + (Cursed ? "\uE10B" : "") + entry.Name.ToLocal() + " (" + HiddenValue + ")");
     }
     else
     {
         return((entry.Icon > -1 ? ((char)(entry.Icon + 0xE0A0)).ToString() : "") + (Cursed ? "\uE10B" : "") + entry.Name.ToLocal());
     }
 }
Ejemplo n.º 7
0
        public static int TotalEncumbrance(GameManager gameManager, Creature cre)
        {
            int totalEnc  = 0;
            var inventory = cre.GetComponent <Creature>().Inventory;

            for (int i = 0; i < inventory.Count; i++)
            {
                var           item = inventory[i];
                Data.ItemData data = gameManager.GameData.ItemData[item.ItemKey];
                totalEnc += data.Weight * item.Count;
            }

            return(totalEnc);
        }
Ejemplo n.º 8
0
 private void OnClickItemKindButton(Data.ItemKind kind)
 {
     for (int i = 0; i < Book.transform.childCount; ++i)
     {
         Destroy(Book.transform.GetChild(i).gameObject);
     }
     foreach (var produce in AlchemyManager.Instance.formulas)
     {
         Data.ItemData p = Data.DataManager.Instance.itemInfo[produce.result];
         if (p.item_kind.Equals(kind))
         {
             var button = GameObject.Instantiate(ProducePrefab, Book.transform);
             button.GetComponent <Image>().sprite = p.image;
             button.onClick.AddListener(() => ProduceButton(produce));
         }
     }
 }
Ejemplo n.º 9
0
 public void SetItem(InvItem item)
 {
     Data.ItemData entry = Data.DataManager.Instance.GetItem(item.ID);
     Description.Text = entry.Desc.ToLocal();
     SalePrice.Text   = Text.FormatKey("MENU_ITEM_VALUE", Text.FormatKey("MONEY_AMOUNT", item.GetSellValue()));
     if (entry.Rarity > 0)
     {
         string rarityStr = "";
         for (int ii = 0; ii < entry.Rarity; ii++)
         {
             rarityStr += "\uE10C";
         }
         Rarity.Text = Text.FormatKey("MENU_ITEM_RARITY", rarityStr);
     }
     else
     {
         Rarity.Text = "";
     }
 }
Ejemplo n.º 10
0
 public string GetDungeonName()
 {
     if (IsMoney)
     {
         return(Text.FormatKey("MONEY_AMOUNT", Value));
     }
     else
     {
         Data.ItemData entry = Data.DataManager.Instance.GetItem(Value);
         if (entry.MaxStack > 1)
         {
             return((entry.Icon > -1 ? ((char)(entry.Icon + 0xE0A0)).ToString() : "") + (Cursed ? "\uE10B" : "") + entry.Name.ToLocal() + " (" + HiddenValue + ")");
         }
         else
         {
             return((entry.Icon > -1 ? ((char)(entry.Icon + 0xE0A0)).ToString() : "") + (Cursed ? "\uE10B" : "") + entry.Name.ToLocal());
         }
     }
 }
Ejemplo n.º 11
0
        public static bool CanLearnSkill(Character character, Character user, int invSlot)
        {
            Data.BaseMonsterForm entry = Data.DataManager.Instance.GetMonster(character.BaseForm.Species).Forms[character.BaseForm.Form];
            int itemNum = -1;

            if (invSlot > BattleContext.EQUIP_ITEM_SLOT)
            {
                itemNum = DungeonScene.Instance.ActiveTeam.GetInv(invSlot).ID;
            }
            else if (invSlot == BattleContext.EQUIP_ITEM_SLOT)
            {
                itemNum = user.EquippedItem.ID;
            }
            else if (invSlot == BattleContext.FLOOR_ITEM_SLOT)
            {
                //item on the ground
                int     mapSlot = ZoneManager.Instance.CurrentMap.GetItem(user.CharLoc);
                MapItem mapItem = ZoneManager.Instance.CurrentMap.Items[mapSlot];
                itemNum = mapItem.Value;
            }

            Data.ItemData  itemData = Data.DataManager.Instance.GetItem(itemNum);
            ItemIndexState effect   = itemData.ItemStates.GetWithDefault <ItemIndexState>();

            //check for already knowing the skill
            for (int ii = 0; ii < character.BaseSkills.Count; ii++)
            {
                if (character.BaseSkills[ii].SkillNum == effect.Index)
                {
                    return(false);
                }
            }

            if (!Data.DataManager.Instance.DataIndices[Data.DataManager.DataType.Skill].Entries[effect.Index].Released)
            {
                return(false);
            }

            return(entry.TeachSkills.Contains(new Data.LearnableSkill(effect.Index)));
        }
Ejemplo n.º 12
0
        public WithdrawMenu(int defaultChoice, bool continueOnChoose, OnMultiChoice storageChoice)
        {
            this.continueOnChoose = continueOnChoose;
            this.storageChoice    = storageChoice;
            availableItems        = new List <int>();
            List <MenuChoice> flatChoices = new List <MenuChoice>();

            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Storage.Length; ii++)
            {
                int index = ii;
                if (DataManager.Instance.Save.ActiveTeam.Storage[ii] > 0)
                {
                    availableItems.Add(index);
                    Data.ItemData entry     = Data.DataManager.Instance.GetItem(ii);
                    MenuText      menuText  = new MenuText(DataManager.Instance.GetItem(ii).GetIconName(), new Loc(2, 1));
                    MenuText      menuCount = new MenuText("(" + DataManager.Instance.Save.ActiveTeam.Storage[ii] + ")", new Loc(ItemMenu.ITEM_MENU_WIDTH - 8 * 4, 1), DirV.Up, DirH.Right, Color.White);
                    flatChoices.Add(new MenuElementChoice(() => { choose(index); }, true, menuText, menuCount));
                }
            }
            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.BoxStorage.Count; ii++)
            {
                int index = ii + DataManager.Instance.DataIndices[DataManager.DataType.Item].Count;
                availableItems.Add(index);
                flatChoices.Add(new MenuTextChoice(DataManager.Instance.Save.ActiveTeam.BoxStorage[ii].GetDisplayName(), () => { choose(index); }));
            }

            defaultChoice = Math.Min(defaultChoice, flatChoices.Count - 1);
            int startChoice         = defaultChoice % SLOTS_PER_PAGE;
            int startPage           = defaultChoice / SLOTS_PER_PAGE;
            List <MenuChoice[]> inv = SortIntoPages(flatChoices, SLOTS_PER_PAGE);

            summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            int withdrawLimit = continueOnChoose ? DataManager.Instance.Save.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone) - DataManager.Instance.Save.ActiveTeam.GetInvCount() : -1;

            Initialize(new Loc(16, 16), ItemMenu.ITEM_MENU_WIDTH, Text.FormatKey("MENU_STORAGE_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, withdrawLimit);
        }
Ejemplo n.º 13
0
        public BuyChosenMenu(List <int> selections, int origIndex, int itemID, OnMultiChoice chooseSlots)
        {
            this.origIndex  = origIndex;
            this.selections = selections;
            action          = chooseSlots;

            List <MenuTextChoice> choices = new List <MenuTextChoice>();

            choices.Add(new MenuTextChoice(Text.FormatKey("MENU_SHOP_BUY"), BuyAction));

            if (selections.Count == 1)
            {
                Data.ItemData entry = Data.DataManager.Instance.GetItem(itemID);

                if (entry.UsageType == Data.ItemData.UseType.Learn)
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_INFO"), () => { MenuManager.Instance.AddMenu(new TeachInfoMenu(itemID), false); }));
                }
            }

            choices.Add(new MenuTextChoice(Text.FormatKey("MENU_EXIT"), ExitAction));

            Initialize(new Loc(ItemMenu.ITEM_MENU_WIDTH + 16, 16), CalculateChoiceLength(choices, 72), choices.ToArray(), 0);
        }
Ejemplo n.º 14
0
 public ItemComponent CreateItem(Data.ItemData itemData, Vector3 position)
 {
     return(CreateItem(new Entity.ItemEntity(itemData), position));
 }
Ejemplo n.º 15
0
 public Component.ItemComponent CreateItem(Data.ItemData data, Vector3 barthPosition)
 {
     return(CreateItem(new Entity.ItemEntity(data), barthPosition));
 }
Ejemplo n.º 16
0
        public GameObject SpawnItem(string key, Vector3 position, Quaternion rotation)
        {
            if (!GameData.ItemData.ContainsKey(key))
            {
                Debug.LogError("SpawnItem: invalid key \"" + key + "\"");
                return(null);
            }

            Data.ItemData item       = GameData.ItemData[key];
            GameObject    itemObject = Instantiate(item.ItemPrefab, position, rotation);

            itemObject.transform.parent = CurrentFloorObject.transform;
            itemObject.GetComponent <Rigidbody>().isKinematic = false;

            CurrentFloorObject.GetComponent <DungeonLevel>().UpdateLights();

            itemObject.GetComponent <Interaction.PickupItem>().CollidedFast += delegate(GameObject collidedWith, float timeSinceLastCollision)
            {
                MakeALoudNoise(itemObject.transform.position);

                Creature creature = null;
                if (collidedWith.transform.parent != null)
                {
                    creature = collidedWith.transform.parent.GetComponent <Creature>();
                }

                if (creature)
                {
                    // Creatures are allowed to cheat a bit to survive flying rocks in the darkness :P
                    creature.SuspiciousPosition = playerCreature.Position;

                    creature.TakeDamage(item.ThrowingDamage);
                    MessageBuffer.AddMessage(Color.magenta, "The flying " + item.Name + " hits " + creature.Data.Name + "!");

                    if (item.Breakable)
                    {
                        if (item.Experience > 0)
                        {
                            MessageBuffer.AddMessage(Color.white, "The experience does not make " + creature.Data.Name + " smarter.");
                        }
                        if (item.Healing > 0)
                        {
                            MessageBuffer.AddMessage(Color.white, "The " + creature.Data.Name + " recovers some health.");
                        }
                        if (item.Poisoning > 0)
                        {
                            MessageBuffer.AddMessage(Color.green, "The " + creature.Data.Name + " is poisoned.");
                        }
                        creature.RecoverHealth(item.Healing);
                        creature.Poison += item.Poisoning;
                    }
                    if (creature.Hp < 1)
                    {
                        MessageBuffer.AddMessage(Color.white, "The " + item.Name + " killed " + creature.Data.Name + " on impact.");
                        addExperience(KillCreature(creature));
                    }
                }
                else
                {
                    // Noise message is not displayed when hitting creature to reduce message spam
                    if (timeSinceLastCollision > 2.0f)
                    {
                        MessageBuffer.AddMessage(Color.magenta, "The moving " + item.Name + " caused a loud noise!");
                    }
                }

                if (item.Breakable)
                {
                    MessageBuffer.AddMessage(Color.white, "The " + item.Name + " shattered into small pieces.");
                    GameObject.Destroy(itemObject);
                }

                if (BackgroundMusic.Instance)
                {
                    BackgroundMusic.Instance.PlaySoundEffectAt("hit", itemObject.transform.position);
                }
            };

            lightingDirty = 1;

            return(itemObject);
        }
Ejemplo n.º 17
0
        public ItemUnderfootMenu(int mapItemSlot)
        {
            this.mapItemSlot = mapItemSlot;
            MapItem mapItem  = ZoneManager.Instance.CurrentMap.Items[mapItemSlot];
            string  itemName = mapItem.GetDungeonName();

            List <MenuTextChoice> choices = new List <MenuTextChoice>();

            bool invFull = (DungeonScene.Instance.ActiveTeam.GetInvCount() >= DungeonScene.Instance.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone));
            bool hasItem = (DungeonScene.Instance.FocusedCharacter.EquippedItem.ID > -1);

            if (mapItem.IsMoney)
            {
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_GROUND_GET"), PickupAction));
            }
            else
            {
                Data.ItemData entry = Data.DataManager.Instance.GetItem(mapItem.Value);
                //disable pick up for full inv
                //disable swap for empty inv
                bool canGet = (DungeonScene.Instance.ActiveTeam.GetInvCount() < DungeonScene.Instance.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone));
                if (!canGet && entry.MaxStack > 1)
                {
                    //find an inventory slot that isn't full stack
                    foreach (InvItem item in DungeonScene.Instance.ActiveTeam.EnumerateInv())
                    {
                        if (item.ID == mapItem.Value && item.Cursed == mapItem.Cursed && item.HiddenValue < entry.MaxStack)
                        {
                            canGet = true;
                            break;
                        }
                    }
                }
                bool hasItems = (DungeonScene.Instance.ActiveTeam.GetInvCount() > 0);

                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_GROUND_GET"), PickupAction, canGet, canGet ? Color.White : Color.Red));
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_REPLACE"), ReplaceAction, hasItems, hasItems ? Color.White : Color.Red));

                switch (entry.UsageType)
                {
                case Data.ItemData.UseType.Eat:
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_EAT"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White));
                    break;
                }

                case Data.ItemData.UseType.Drink:
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_DRINK"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White));
                    break;
                }

                case Data.ItemData.UseType.Use:
                case Data.ItemData.UseType.UseOther:
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_USE"), UseSelfAction, !mapItem.Cursed, mapItem.Cursed ? Color.Red : Color.White));
                    break;
                }

                case Data.ItemData.UseType.Learn:
                {
                    //if the character is teaching to himself, need to disable this choice if not compatible
                    bool canLearn = TeachMenu.CanLearnSkill(DungeonScene.Instance.FocusedCharacter, DungeonScene.Instance.FocusedCharacter, BattleContext.FLOOR_ITEM_SLOT);
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_LEARN"), UseSelfAction, canLearn && !mapItem.Cursed, (canLearn && !mapItem.Cursed) ? Color.White : Color.Red));
                    break;
                }
                }

                //hold item
                bool allowHold = (!invFull || hasItem);
                if (hasItem)
                {
                    ItemData equipEntry = DataManager.Instance.GetItem(DungeonScene.Instance.FocusedCharacter.EquippedItem.ID);
                    if (equipEntry.CannotDrop)
                    {
                        allowHold = false;
                    }
                }
                choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_HOLD"), HoldAction, allowHold, allowHold ? Color.White : Color.Red));

                if (entry.UsageType == Data.ItemData.UseType.Throw)
                {
                    int choiceIndex = choices.Count - 1;
                    choices.Insert(choiceIndex, new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction));
                }
                else
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_ITEM_THROW"), ThrowAction));
                }
                if (entry.UsageType == Data.ItemData.UseType.Learn)
                {
                    choices.Add(new MenuTextChoice(Text.FormatKey("MENU_INFO"), InfoAction));
                }
            }
            choices.Add(new MenuTextChoice(Text.FormatKey("MENU_EXIT"), ExitAction));

            if (!mapItem.IsMoney)
            {
                summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                              new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));
                summaryMenu.SetItem(new InvItem(mapItem.Value, mapItem.Cursed, mapItem.HiddenValue));
            }

            int menuwidth = CalculateChoiceLength(choices, 72);

            Initialize(new Loc(GraphicsManager.ScreenWidth - 16 - menuwidth, 16), menuwidth, choices.ToArray(), 0, itemName);
        }
Ejemplo n.º 18
0
 private void ShowItemStats(Data.ItemData item)
 {
     descriptionText.text = string.Format("Melee damage: {0}\nThrowing damage: {1}\nDefence: {2}\n\nWeight: {3}\n\n{4}", item.MeleeDamage, item.ThrowingDamage, item.Defence, item.Weight, item.Description);
 }
Ejemplo n.º 19
0
        private void RefreshView()
        {
            for (int i = 0; i < guiItems.Count; i++)
            {
                GameObject.Destroy(guiItems[i]);
            }
            guiItems.Clear();

            UpdateStatusTexts();

            var player = gameManager.playerObject.GetComponent <Creature>();

            descriptionText.text = player.Inventory.Count == 0 ? "Your inventory is empty." : "";

            // Instantiate items in inventory
            for (int i = 0; i < player.Inventory.Count; i++)
            {
                var obj           = GameObject.Instantiate(gameManager.inventoryGuiItemPrefab);
                var backgroundImg = obj.GetComponent <UnityEngine.UI.Image>();
                obj.transform.SetParent(inventoryCanvas.transform);
                obj.transform.localScale = Vector3.one;
                obj.GetComponent <RectTransform>().localPosition = new Vector3(170, 288 - i * 30f, 0);
                guiItems.Add(obj);

                InventoryItem invItem = player.Inventory[i];
                Data.ItemData item    = gameManager.GameData.ItemData[invItem.ItemKey];
                obj.transform.GetChild(0).GetComponent <TMPro.TextMeshProUGUI>().text = "" + invItem.Count + "x " + System.Globalization.CultureInfo.InvariantCulture.TextInfo.ToTitleCase(item.Name);

                var itemHandler = obj.GetComponent <UIItemHandler>();

                if (player.HasItemInSlot(invItem, EquipSlot.LeftHand))
                {
                    itemHandler.LeftHandImage.SetActive(true);
                }
                if (player.HasItemInSlot(invItem, EquipSlot.RightHand))
                {
                    itemHandler.RightHandImage.SetActive(true);
                }

                itemHandler.MouseEnter += delegate
                {
                    backgroundImg.color = new Color(0.7f, 0.7f, 0.7f);
                    ShowItemStats(item);
                    highlightedItem = invItem;
                };
                itemHandler.MouseExit += delegate
                {
                    backgroundImg.color  = new Color(1f, 1f, 1f);
                    descriptionText.text = "";
                    highlightedItem      = null;
                };
                itemHandler.MouseClick += delegate(PointerEventData eventData)
                {
                    EquipSlot slot = eventData.button == PointerEventData.InputButton.Left ? EquipSlot.LeftHand : EquipSlot.RightHand;

                    if (player.HasItemInSlot(invItem, slot))
                    {
                        gameManager.PlayerUnequip(slot);
                        gameManager.MessageBuffer.AddMessage(Color.white, "You unequipped the " + gameManager.GameData.ItemData[invItem.ItemKey].Name.ToLower() + " from your " + slot.ToString().Replace("Hand", "").ToLower() + " hand.");
                    }
                    else
                    {
                        gameManager.PlayerEquip(invItem, slot);
                        gameManager.MessageBuffer.AddMessage(Color.white, "You equipped the " + gameManager.GameData.ItemData[invItem.ItemKey].Name.ToLower() + " to your " + slot.ToString().Replace("Hand", "").ToLower() + " hand.");
                    }
                    RefreshView();
                };
            }
        }
Ejemplo n.º 20
0
 public Produce(Data.ItemData materialInfo, ItemKind kind)
 {
     this.materialInfo = materialInfo;
     this.kind         = kind;
 }