コード例 #1
0
        private void sell_item()
        {
            int index = Window.index;

            // Change gold
            Global.battalion.gold += item_cost();
            redraw_gold();
            // Removes item
            Item_Data sold_item = actor.drop_item(index);

            if (Global.game_system.preparations && Global.battalion.convoy_id > -1)
            {
                Global.game_battalions.add_sold_home_base_item(sold_item);
            }
            // Redraw text and images
            refresh_sell();
            if (can_sell)
            {
                set_text(Shop_Messages.Sell_Else);
            }
            else
            {
                set_text(Shop_Messages.Anything_Else);
                this.trading = false;
            }
        }
コード例 #2
0
ファイル: Status_Item.cs プロジェクト: Nagraal/Tactile-Engine
        public virtual void set_image(Game_Actor actor, Item_Data item_data)
        {
            if (item_data.non_equipment)
            {
                Icon.texture = null;
                Name.text    = "";
                Uses.text    = "";
                Slash.text   = "";
                Use_Max.text = "";
            }
            else
            {
                Data_Equipment item = item_data.to_equipment;
                // Icon
                if (Global.content_exists(@"Graphics/Icons/" + item.Image_Name))
                {
                    Icon.texture = Global.Content.Load <Texture2D>(string.Format(@"Graphics/Icons/{0}", item.Image_Name));
                    Icon.columns = (int)(Icon.texture.Width / Icon.size.X);
                }
                Icon.index = item.Image_Index;
                // Name
                Name.text = item.Name;
                // Uses
                Uses.text    = item_data.Uses < 0 ? "--" : item_data.Uses.ToString();
                Slash.text   = "/";
                Use_Max.text = item.Uses < 0 ? "--" : item.Uses.ToString();

                set_text_color(actor, item);
            }
        }
コード例 #3
0
        private int item_cost(int index)
        {
            int       price     = 0;
            Item_Data item_data = this.item_data(index);

            return(item_data.item_cost(On_Buy, Buy_Price_Mod));
        }
コード例 #4
0
        public Data_Equipment equipment(Item_Data data)
        {
            if (data.is_weapon)
            {
                if (Global.data_weapons.ContainsKey(data.Id))
                {
                    return(Global.data_weapons[data.Id]);
                }
#if DEBUG
                else
                {
                    return(DebugWeapon);
                }
#endif
            }
            else if (data.is_item)
            {
                if (Global.data_items.ContainsKey(data.Id))
                {
                    return(Global.data_items[data.Id]);
                }
#if DEBUG
                else
                {
                    return(DebugItem);
                }
#endif
            }
            return(null);
        }
コード例 #5
0
        protected void refresh_stacked_items(bool sameUses = false)
        {
            List <SupplyItem> supplies = new List <SupplyItem>();

            SupplyList.Clear();
            get_items(supplies);

            List <int> item_counts = new List <int>();

            // Goes through all item data and finds any the match
            for (int i = 0; i < supplies.Count; i++)
            {
                Item_Data item_data = supplies[i].get_item();
                SupplyList.Add(supplies[i]);
                item_counts.Add(1);
                // Checks the following items after the current one, and adds one to the count for each with the same id
                while ((i + 1) < supplies.Count &&
                       item_data.Id == supplies[i + 1].get_item().Id&&
                       // Block stacking actor items for now
                       supplies[i].Convoy &&
                       // Same actor
                       supplies[i].ActorId == supplies[i + 1].ActorId &&
                       // If caring about uses, the uses must also match
                       (!sameUses || (item_data.Uses == supplies[i + 1].get_item().Uses)))
                {
                    item_counts[item_counts.Count - 1]++;
                    i++;
                }
            }

            CommandWindow.refresh_stacked_items(new List <SupplyItem>(SupplyList),
                                                this.actor, item_counts, sameUses);
        }
コード例 #6
0
    IEnumerator Equip_Item_Pushing()
    {
        yield return(new WaitForSeconds(0.05f));

        if (items[selected_Index].ID == 30001 || items[selected_Index].ID == 30002)
        {
            equip_Items[0] = items[selected_Index];
            slot[selected_Index].transform.GetChild(0).transform.
            SetParent(equip_Slot_Panel.transform.GetChild(0).gameObject.transform);
            equip_Slot_Panel.transform.GetChild(0).transform.GetChild(1).transform.localPosition = Vector3.zero;
            equip_Slot_Panel.transform.GetChild(0).transform.GetChild(1).transform.GetChild(0).gameObject.SetActive(false);
            equip_Slot_Panel.transform.GetChild(0).transform.GetChild(0).GetComponent <Text>().text =
                equip_Items[0].ITEM_COUNT.ToString();
        }
        if (items[selected_Index].ID == 30003)
        {
            equip_Items[1] = items[selected_Index];
            slot[selected_Index].transform.GetChild(0).transform.
            SetParent(equip_Slot_Panel.transform.GetChild(1).gameObject.transform);
            equip_Slot_Panel.transform.GetChild(1).transform.GetChild(1).transform.localPosition = Vector3.zero;
            equip_Slot_Panel.transform.GetChild(1).transform.GetChild(1).transform.GetChild(0).gameObject.SetActive(false);
            equip_Slot_Panel.transform.GetChild(1).transform.GetChild(0).GetComponent <Text>().text =
                equip_Items[1].ITEM_COUNT.ToString();
        }
        items[selected_Index] = new Item_Data();
        Json_Data_Saving();
        equip_Type_Info_Panel.SetActive(false);
    }
コード例 #7
0
        public void jump_to(Item_Data item_data)
        {
            // Jump to the correct page
            int new_type = supply_type_of_item(-1, item_data);

            change_page(new_type);

            // Jump to the actual item
            for (int i = 0; i < SupplyList.Count; i++)
            {
                if (item_data.same_item(SupplyList[i].get_item()))
                {
                    if (Constants.Gameplay.CONVOY_ITEMS_STACK == Convoy_Stack_Types.Full ||
                        item_data.Uses == SupplyList[i].get_item().Uses)
                    {
                        this.index = i;
                        CommandWindow.immediate_index = this.index;
                        CommandWindow.refresh_scroll();

                        refresh_loc();
                        break;
                    }
                }
            }
        }
コード例 #8
0
    private void Update()
    {
        if (playerInventory.ItemContainer.itemSlots[17].item == null)
        {
            if (LoadedWeapon)
            {
                PhotonNetwork.Destroy(LoadedWeapon);
            }
        }


        if (playerInventory.ItemContainer.itemSlots[17].item)
        {
            if (LoadedWeapon)
            {
                LoadedWeaponItemData = LoadedWeapon.GetComponent <WeaponStats>().returnItemData();
                bool isWeaponSame = (playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.Equals(LoadedWeaponItemData);
                if (!isWeaponSame)
                {
                    Debug.Log((playerInventory.ItemContainer.itemSlots[17].item as EquipmentItem).itemData.attack);
                    Debug.Log(LoadedWeaponItemData.attack);
                    SetWeaponItem(playerInventory.ItemContainer.itemSlots[17].item, false);
                    //
                }
            }
        }
    }
コード例 #9
0
    // 아이템 해제시 실행되는 함수
    public void Button_Equip_Type_Item_Pressed_Off()
    {
        bool is_Empty = false;

        for (int i = 0; i < items.Length; i++)
        {
            if (items[i].ID == -1)
            {
                is_Empty = true;
            }
        }
        if (is_Empty)
        {
            Destroy(equip_Slot_Panel.transform.GetChild(selected_Index).transform.GetChild(1).gameObject);
            equip_Slot_Panel.transform.GetChild(selected_Index).transform.GetChild(0).GetComponent <Text>().text
                = 0.ToString();
            for (int i = 0; i < items.Length; i++)
            {
                if (items[i].ID == -1)
                {
                    items[i] = equip_Items[selected_Index];
                    Item_Into_The_Slot_Setting(i, items[i].ITEM_COUNT);
                    break;
                }
            }
            equip_Items[selected_Index] = new Item_Data();
            Json_Data_Saving();
            equip_Type_Info_Panel.SetActive(false);
        }
        else
        {
            inventory_Isfull_Panel.SetActive(true);
        }
    }
コード例 #10
0
    private void Init_DataBase(string dataBaseName)//adds test items to DB and writes out the JSON file
    {
        ItemCollection_Data newItemCollection = new ItemCollection_Data();

        Item_Data testIitemData  = Create_Item(1, "Steak", "Inventory_Steak", "Steak.....Mmmmm", ItemType.Consumable, true, 1);
        Item_Data testIitemData2 = Create_Item(2, "Silver Key", "Inventory_Key", "A shiny key", ItemType.Junk, false, 1);
        Item_Data testIitemData3 = Create_Item(3, "Sword", "Weapons_Sword", "An iron sword", ItemType.Weapon, false, 1, "{Strenght : 5}");
        Item_Data testIitemData4 = Create_Item(4, "Bow", "Weapons_Bow", "A short bow", ItemType.Weapon, false, 1);
        Item_Data testIitemData5 = Create_Item(5, "Armour", "Equipment_Vest", "Rusty armour", ItemType.Armour, false, 1, "{Armour : 5}");
        Item_Data testIitemData6 = Create_Item(6, "Medal", "Rewards_MedalStar", "Old war medal", ItemType.Trinket, false, 1);
        Item_Data testIitemData7 = Create_Item(7, "Helm", "Equipment_Helmet", "Rusty iron helmet", ItemType.Head, false, 1, "{Health : 5}");

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

        items.Add(testIitemData);
        items.Add(testIitemData2);
        items.Add(testIitemData3);
        items.Add(testIitemData4);
        items.Add(testIitemData5);
        items.Add(testIitemData6);
        items.Add(testIitemData7);

        newItemCollection.items = items;

        string jsonItemDB = JsonUtility.ToJson(newItemCollection);

        File.WriteAllText(Application.dataPath + DATAPATH + dataBaseName + FILETYPE, jsonItemDB);
        RetrieveDataFiles("Item_DataBase");
    }
コード例 #11
0
        public int item_count(Item_Data item_data)
        {
            int count = 0;

            if (this.has_convoy)
            {
                for (int i = 0; i < Global.game_battalions.convoy(Convoy_Id).Count; i++)
                {
                    if (item_data.same_item(Global.game_battalions.convoy(Convoy_Id)[i]))
                    {
                        count++;
                    }
                }
            }
            foreach (int actor_id in Actors)
            {
                foreach (Item_Data actor_item in Global.game_actors[actor_id].items)
                {
                    if (item_data.same_item(actor_item))
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
コード例 #12
0
        public Item_Data remove_item_from_convoy(int id, int index)
        {
            Item_Data item_data = Convoys[id].Data[index];

            Convoys[id].Data.RemoveAt(index);
            return(item_data);
        }
コード例 #13
0
        private bool optimize_staff(InventoryOptimizePasses pass,
                                    Game_Actor actor, List <WeaponType> weapon_types, List <Item_Data> staves)
        {
            if (staves.Any() && !actor.is_full_items)
            {
                var staff_subset = staves
                                   .Select(x => Tuple.Create(x, optimize_actor_weapon_value(pass, actor, x.to_weapon, weapon_types)))
                                   .OrderByDescending(x => x.Item2)
                                   .AsEnumerable();
                int minimum    = staff_subset.First().Item2;
                var staff_list = staff_subset
                                 .Where(x => x.Item2 == minimum)
                                 .Select(x => x.Item1)
                                 .ToList();
                staff_list.Sort(delegate(Item_Data a, Item_Data b)
                {
                    return(item_sort(b, a, false));
                });

                if (staff_subset.Any())
                {
                    Item_Data best_match = staff_list.First();
                    switch (pass)
                    {
                    case InventoryOptimizePasses.HealingStaff:
                        if (!best_match.to_weapon.Heals())
                        {
                            return(false);
                        }
                        break;

                    case InventoryOptimizePasses.StatusStaff:
                        if (!best_match.to_weapon.is_attack_staff())
                        {
                            return(false);
                        }
                        break;

                    case InventoryOptimizePasses.UtilityStaff:
                        if (best_match.to_weapon.Heals() || best_match.to_weapon.is_attack_staff())
                        {
                            return(false);
                        }
                        break;

                    default:
                        return(false);
                    }

                    actor.gain_item(best_match);
                    Data.Remove(best_match);
                    // Removes from weapon set
                    staves.Remove(best_match);
                    weapon_types.Remove(best_match.to_weapon.main_type());
                    return(true);
                }
            }
            return(false);
        }
コード例 #14
0
        private bool optimize_item(InventoryOptimizePasses pass,
                                   Game_Actor actor, List <Item_Data> items)
        {
            if (items.Any() && !actor.is_full_items)
            {
                var item_subset = items
                                  .Select(x => Tuple.Create(x, optimize_actor_item_value(pass, actor, x.to_item)))
                                  .OrderByDescending(x => x.Item2)
                                  .AsEnumerable();
                int minimum   = item_subset.First().Item2;
                var item_list = item_subset
                                .Where(x => x.Item2 == minimum)
                                .Select(x => x.Item1)
                                .ToList();
                item_list.Sort(delegate(Item_Data a, Item_Data b)
                {
                    return(item_sort(b, a, false));
                });

                if (item_list.Any())
                {
                    Item_Data best_match = item_list.First();
                    switch (pass)
                    {
                    case InventoryOptimizePasses.HealingItem:
                        if (!best_match.to_item.can_heal_hp())
                        {
                            return(false);
                        }
                        break;

                    case InventoryOptimizePasses.Accessory:
                        if (best_match.to_item.Skills.Count == 0)
                        {
                            return(false);
                        }
                        break;

                    case InventoryOptimizePasses.DanceRing:
                        if (!best_match.to_item.Dancer_Ring)
                        {
                            return(false);
                        }
                        break;

                    default:
                        return(false);
                    }

                    actor.gain_item(best_match);
                    Data.Remove(best_match);
                    // Removes from item set
                    items.Remove(best_match);
                    return(true);
                }
            }
            return(false);
        }
コード例 #15
0
 public bool convoy_has_item(Item_Data item_data)
 {
     if (!this.has_convoy)
     {
         return(false);
     }
     return(Global.game_battalions.convoy(Convoy_Id)
            .Any(x => x.same_item(item_data)));
 }
コード例 #16
0
 internal Item_Metrics(Item_Metrics other)
 {
     Turn     = other.Turn;
     Team     = other.Team;
     ActorId  = other.ActorId;
     ClassId  = other.ClassId;
     ItemData = new Item_Data(other.ItemData);
     ItemName = other.ItemName;
     Loc      = other.Loc;
 }
コード例 #17
0
 public Item_Metrics(int turn, Game_Unit unit, Item_Data item_data)
 {
     Turn     = turn;
     Team     = unit.team;
     ActorId  = unit.actor.id;
     ClassId  = unit.actor.class_id;
     ItemData = item_data;
     ItemName = item_data.to_equipment.full_name();
     Loc      = unit.loc;
 }
コード例 #18
0
 public void add_item_to_convoy(Item_Data item, bool force = false, int id = -1)
 {
     if (id == -1)
     {
         id = Global.battalion.convoy_id;
     }
     if (force || !Convoys[id].is_full)
     {
         Convoys[id].Data.Add(item);
     }
 }
コード例 #19
0
    public int Value;          // { get; set; }

    public Item(Item_Data data)
    {
        this.ID   = data.id;
        this.Name = data.name;
        //this.Icon = SpriteAtlasManager.Instance.GetSprite(data.iconName);//Resources.Load<Sprite>("Sprites/ItemIcons/Icons/128px/" + data.iconName); //NB!!! Need to Atlas these
        GetItemSprite(data.iconName);
        this.Description = data.description;
        this.ItemType    = data.itemType;
        this.Stackable   = data.stackable;
        this.Value       = data.value;
    }
コード例 #20
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #21
0
ファイル: Save_Data.cs プロジェクト: Leniton/RPG-Item-Manager
 public void DeleteData(Item_Data data)
 {
     if (File.Exists(Caminho + c + data.ItemName + ".json"))
     {
         File.Delete(Caminho + c + data.ItemName + ".json");
         AllData = LoadAll();
     }
     else
     {
         print(Directory.GetFiles(Caminho, "*.json")[1]);
     }
 }
コード例 #22
0
 public Armour_Item(Item_Data data)
 {
     ID   = data.id;
     Name = data.name;
     //Icon = SpriteAtlasManager.Instance.GetSprite(data.iconName); //Resources.Load<Sprite>("Sprites/ItemIcons/Icons/128px/" + data.iconName);
     GetItemSprite(data.iconName);
     Description = data.description;
     ItemType    = data.itemType;
     Stackable   = data.stackable;
     Value       = data.value;
     armourData  = data.itemJson;
 }
コード例 #23
0
    // Use this for initialization
    void Start()
    {
        enableWindow       = false;
        defaultScreenRes.x = 1920;                                  //declare max screen ratio
        defaultScreenRes.y = 1080;                                  //declare max screen ratio

        GameObject go = GameObject.FindGameObjectWithTag("Player"); //Find player

        controller = go.GetComponent <HeroController>();

        questData   = GameObject.Find("QuestData").GetComponent <Quest_Data>();
        itemData    = GameObject.Find("Item_Data").GetComponent <Item_Data>();
        monsterData = GameObject.Find("MonsterData").GetComponent <Monster_Data>();
    }
コード例 #24
0
    public void OnClick()
    {
        if (Slot_Item != null)
        {
            Item_Data temp = ItemManager.Get_Item_Data(Slot_Item);


            explain_Window.OnWindow();

            explain_Window.Item_name.text = temp.itemName;
            explain_Window.item_desc.text = temp.itemDesc;
            //explain_Window.Explain_image.sprite = itemImage.sprite;
        }
    }
コード例 #25
0
 // 아이템 장착전 장착슬롯에 아이템 잇는지 여부 확인 (있으면 먼저 인벤토리에 전 장착아이템 푸싱)
 private void Equip_Items_Checkfor_Slot_Before_Setting(int _index)
 {
     Destroy(equip_Slot_Panel.transform.GetChild(_index).transform.GetChild(1).gameObject);
     for (int i = 0; i < items.Length; i++)
     {
         if (items[i].ID == -1)
         {
             items[i] = equip_Items[_index];
             Item_Into_The_Slot_Setting(i, items[i].ITEM_COUNT);
             break;
         }
     }
     equip_Items[_index] = new Item_Data();
 }
コード例 #26
0
ファイル: Shop_Item.cs プロジェクト: Nagraal/Tactile-Engine
        protected virtual void set_text_color(Game_Actor actor, Data_Equipment item, Item_Data item_data, int price)
        {
            bool useable;

            if (item.is_weapon && actor != null)
            {
                useable = actor.is_equippable(item as Data_Weapon);
            }
            else
            {
                useable = true;
            }

            set_text_color(useable, buyable_text(price, item_data));
        }
コード例 #27
0
    Item_Data Create_Item(int id, string name, string iconName, string description, ItemType type, bool stackable, int value) // Create item Method
    {
        Item_Data testItem = new Item_Data();

        testItem.id          = id;
        testItem.name        = name;
        testItem.iconName    = iconName;
        testItem.description = description;
        testItem.itemType    = type;
        //Stats/ItemType
        testItem.stackable = stackable;
        testItem.value     = value;
        Debug.Log("Created-" + testItem.name);
        return(testItem);
    }
コード例 #28
0
        public static Item_Metrics read(BinaryReader reader)
        {
            Item_Metrics result = new Item_Metrics();

            if (!Global.LOADED_VERSION.older_than(0, 4, 6, 9))
            {
                result.Turn = reader.ReadInt32();
            }
            result.Team     = reader.ReadInt32();
            result.ActorId  = reader.ReadInt32();
            result.ClassId  = reader.ReadInt32();
            result.ItemData = Item_Data.read(reader);
            result.ItemName = reader.ReadString();
            result.Loc      = result.Loc.read(reader);
            return(result);
        }
コード例 #29
0
ファイル: WeaponStats.cs プロジェクト: CameronPerrin/Anathema
    public Item_Data returnItemData()
    {
        Item_Data data = new Item_Data();

        data.object_name   = name;
        data.attack        = attack;
        data.item_value    = item_value;
        data.attack_speed  = attack_speed;
        data.crit_chance   = crit_chance;
        data.range         = range;
        data.item_type     = item_type;
        data.magic_defense = magic_defense;
        data.move_speed    = move_speed;
        data.bleed_chance  = bleed_chance;

        return(data);
    }
コード例 #30
0
 public bool ItemOwned(Item_Data itemData)
 {
     if (convoy_has_item(itemData))
     {
         return(true);
     }
     foreach (int actorId in Actors)
     {
         foreach (Item_Data actorItem in Global.game_actors[actorId].items)
         {
             if (itemData.same_item(actorItem))
             {
                 return(true);
             }
         }
     }
     return(false);
 }