private IEnumerator Add_item(game_item item, Transform _transform, GameObject UIButton, INV_handle add_t) { if (DontDestroy.first.Loading) { yield break; } Transform child = Instantiate(UIButton).transform; Image image = child.GetChild(0).GetComponent <Image>(); Inv_slot ci = child.GetComponent <Inv_slot>(); ci.item = item; item.count = 9999; ci.ai = add_t; child.name = item.name; child.SetParent(_transform); Sprite sd = null; while (sd == null) { if (ITEMS.main.item_icons.TryGetValue(item.id_sprite, out sd)) { image.sprite = sd; } yield return(new WaitForSeconds(3 * Time.deltaTime)); } image.color = item.rarity.color; child.localPosition = Vector3.zero; child.localScale = new Vector3(1, 1, 1); yield return(null); }
public void add_item(game_item item) { weapon_type type = CheckIfWeapon(item.type); game_item temp; item_type t = (type == weapon_type.none) ? item.type : item_type.melee_weapons; if (worn_items.TryGetValue(t, out temp)) { if (temp != null) { stats.DecreseStats(temp.bstats); stats.DecresePStats(temp.pstats); } worn_items[t] = item; } else { worn_items.Add(t, item); } if (type != weapon_type.none) { cc.weapon = type; } asn.AddItem(item); stats.AddStats(item.bstats); stats.AddPStats(item.pstats); //items.Add(item); }
IEnumerator Start() { item = GetComponent <AddItem>(); if (!Basic_dager) { if (GetComponent <CharacterControl>().IsMine) { foreach (game_item itemg in ITEMS.main.GetRandomGear(SpriteGender.male)) { int i = 0; while (!Item_link.main.EquipNewItem(itemg)) { yield return(new WaitForSeconds(Time.deltaTime * 3)); i++; if (i > 50) { print("cannot find slot!"); break; } } } } else { foreach (game_item itemg in ITEMS.main.GetRandomGear(SpriteGender.male)) { item.add_item(itemg); } } //item.add_item(ITEMS.main.GetItemFrom()); } else { game_item starting_weapon = ITEMS.main.GetItemFrom(SpriteGender.male, item_type.melee_weapons, item_rarity.rarity.simple).CopyItem(); if (GetComponent <CharacterControl>().IsMine) { //item.add_item(starting_weapon); int i = 0; while (!Item_link.main.EquipNewItem(starting_weapon)) { yield return(new WaitForSeconds(Time.deltaTime * 3)); i++; if (i > 50) { print("cannot find slot!"); break; } } } else { item.add_item(starting_weapon); } } }
public void CreateStatEnchanter(Basic_Stats stats, UseBoost pstats, string name, Sprite sprite) { game_item NEW_item = new game_item(item_type.consumable, -1, SpriteGender.none, -1, name, stats, pstats, item_rarity.rarity.simple, false); Game_Items[SpriteGender.none][item_type.consumable].Add(NEW_item.Order_ID, NEW_item); item_icons.Add(NEW_item.id_sprite, sprite); }
public void SetItem(game_item cItem) { this.item = cItem; item.slot_pointer = this; IIH.SetSprite(item.id_sprite, cItem.rarity.color); get_type_ITEM = item.type; }
public void SendItem(game_item item) { Inv_slot temp; if (dec.TryGetValue(item.type, out temp)) { temp.ItemAdd(); ConfirmItem(item); } }
public void RemoveItem() { IIH.ResetSprite(); if (type == slot_type.wearable) { link.RemoveItem(item); } this.item = null; }
public void DropItem(Vector3 pos) { ItemDrop.Global_ItemDrop.DropItem(item, pos); //ChatGUI.addLine(item.name + " |" + item.rarity.Item_Level + "lvl|" + " was Dropped!" ); IIH.ResetSprite(); if (type == slot_type.wearable) { link.RemoveItem(item); } this.item = null; }
IEnumerator SET(game_item item) { GotItem = true; yield return(new WaitForSeconds(Time.deltaTime)); while (!loaded) { yield return(new WaitForSeconds(Time.deltaTime)); } slot.SetItem(item); }
public bool EquipNewItem(game_item item) { Inv_slot temp; if (dec.TryGetValue(item.type, out temp)) { temp.SetItem(item); ConfirmItem(item); return(true); } return(false); }
public game_item SwapSlot(game_item sw_item) { game_item temp = item; this.item = sw_item; item.slot_pointer = this; IIH.SetSprite(ITEMS.main.item_icons[item.id_sprite], sw_item.rarity.color); get_type_ITEM = item.type; return(temp); }
public bool ItemAdd() { bool swap = false; if (type_of_ITEM.Length <= 0 || EnumCheck <item_type> .EnumArrayContains(type_of_ITEM, item_Poiner.get_type_ITEM)) { if (item != null && item_Poiner.type != slot_type.all_items_inv) { print(item_Poiner.type); swap = true; this.item = item_Poiner.SwapSlot(item); item.slot_pointer = this; } else { this.item = (item_Poiner.type == slot_type.all_items_inv) ? item_Poiner.item.CopyItem() : item_Poiner.item; item.slot_pointer = this; } } else { return(false); } if (!swap) { if (item.count > 1 || item_Poiner.type == slot_type.all_items_inv) { item = item.CopyItem(); item.count = 1; item_Poiner.ShareItem(1); } else { item.count = 1; item_Poiner.RemoveItem(); } } IIH.SetSprite(ITEMS.main.item_icons[item.id_sprite], item.rarity.color); get_type_ITEM = item.type; if (type == slot_type.wearable) { link.ConfirmItem(item); } return(true); }
public void UseItem(game_item item) { if (item.type == item_type.consumable) { AddItem.MyPlayer.Use_Consumable(item); Inv_slot.ConsumeItem(); } else if (item.type != item_type.none) { link.SendItem(item); Debug.Log("done!"); } }
public void DropItem() { if (type == slot_type.all_items_inv) { return; } ItemDrop.Global_ItemDrop.DropItem(item, AddItem.MyPlayer.transform.position); ChatGUI.addLine(item.name + " |" + item.rarity.Item_Level + "lvl|" + " was Dropped!"); IIH.ResetSprite(); if (type == slot_type.wearable) { link.RemoveItem(item); } this.item = null; }
public SpriteRect AnimLoad(game_item item, int _layer) { Transform child = Instantiate(SpriteContainer).transform; child.name = "weapon_anim_walk"; SpriteRect sr = child.gameObject.AddComponent <SpriteRect>(); child.SetParent(transform); child.localPosition = Vector3.zero; child.localEulerAngles = Vector3.zero; child.localScale = new Vector3(1, 1, 1); sr.LoadSprites(item.id_sprite, _layer); sr.in_layer = _layer; sr.color = new Color(1, 1, 1, 0); return(sr); }
public void Remove_Item(game_item item) { if (item.type == item_type.wand || item.type == item_type.spears || item.type == item_type.bow || item.type == item_type.melee_weapons) { asn.RemoveItem(item_type.melee_weapons); cc.weapon = weapon_type.none; this.worn_items[item_type.melee_weapons] = null; } else { asn.RemoveItem(item.type); this.worn_items[item.type] = null; } stats.DecreseStats(item.bstats); stats.DecresePStats(item.pstats); }
public void TakeItem(game_item item) { Inv_slot temp; if (dec.TryGetValue(item.type, out temp)) { if (temp.item == null) { temp.ItemAdd(); ConfirmItem(item); } else { inv.item_add(); } } else { inv.item_add(); } }
public void CreateStatEnchanter(float agility, float endurance, float strength, float intelligence, float mobility, float health, float hregen, float healing, float magical_dmg, float evashion, float armor, float range, float physical_dmg, string name, Sprite sprite) { Basic_Stats stats = new Basic_Stats(); stats.agility = agility; stats.endurance = endurance; stats.strength = strength; stats.intelligence = intelligence; UseBoost pstats = new UseBoost(armor, healing, health, hregen, evashion, physical_dmg, magical_dmg, range, mobility); game_item NEW_item = null; try { NEW_item = new game_item(item_type.consumable, -1, SpriteGender.none, -1, name, stats, pstats, item_rarity.rarity.simple, false); } catch { Debug.Log("(CreateStatEnchanter) : error creating item"); } try { Game_Items[SpriteGender.none][item_type.consumable].Add(NEW_item.Order_ID, NEW_item); } catch { Debug.Log("(CreateStatEnchanter) : Error in storing item"); } if (NEW_item != null) { item_icons.Add(NEW_item.id_sprite, sprite); } }
public void DropItem(game_item item, Vector2 pos) { foreach (DroppedItem item_d in DroppedItems) { if (!item_d.gameObject.activeSelf) { item_d.gameObject.SetActive(true); item_d.SetItem(item); item_d.transform.position = pos; return; } } Transform child = Instantiate(item_dropped).transform; DroppedItem ditem = child.GetComponent <DroppedItem>(); ditem.SetItem(item); child.SetParent(Items_t); child.localPosition = pos; child.localScale = new Vector3(50, 50, 1); }
public game_item GetItemFrom(SpriteGender gender, item_type type, item_rarity.rarity rarity) { int chance = 0; game_item ret = null; foreach (game_item item in Game_Items[gender][type].Values) { if (item.rarity.Rarity == rarity) { int temp = InGameData.random_int(0, 100); if (temp >= chance) { chance = temp; ret = item; } } } if (ret == null) { Debug.Log(" No Items in " + gender + " ," + type + " with rarity " + rarity); } return(ret); }
private void CreateItems(SpriteData sd) { bool IsArmor = (sd.path.Contains("armor")) ? true : false; bool IsWeapon = (sd.path.Contains("weapons")) ? true : false; int MaxValue = (IsArmor) ? 14 : IsArmor ? 20 : 6; if (sd.path.Contains("walk_melee_weapons")) { walk_anim = new game_item(item_type.none, sd.id, sd.sg, 0, sd.name, Basic_Stats.zero, UseBoost.zero, item_rarity.rarity.normal, false); return; } foreach (item_type type in Enum.GetValues(typeof(item_type))) { if (sd.key.Contains(type.ToString())) { foreach (item_rarity.rarity rare in Enum.GetValues(typeof(item_rarity.rarity))) { if (!IsWeapon && !IsArmor && rare != item_rarity.rarity.normal) { continue; } Basic_Stats stats = new Basic_Stats(); UseBoost pstats = UseBoost.zero; stats.agility = InGameData.rand(0, MaxValue); stats.endurance = InGameData.rand(0, MaxValue); stats.strength = InGameData.rand(0, MaxValue); if (sd.path.Contains("small_range")) { pstats.range = 2f; } else if (sd.path.Contains("normal_range")) { pstats.range = 10f; } else if (sd.path.Contains("large_range")) { pstats.range = 15f; } else if (type == item_type.wand) { pstats.range = 75.0f; } else if (type == item_type.bow) { pstats.range = 75.0f; } else { pstats.range = 0; } stats.intelligence = InGameData.rand(0, MaxValue); pstats.walk_speed = InGameData.rand(0, MaxValue); game_item NEW_item = new game_item(type, sd.id, sd.sg, Game_Items[sd.sg][type].Count, sd.name, stats, pstats, rare, IsArmor); if (sd.sg == SpriteGender.none) { Game_Items[SpriteGender.male][type].Add(NEW_item.Order_ID, NEW_item); Game_Items[SpriteGender.female][type].Add(NEW_item.Order_ID, NEW_item); } Game_Items[sd.sg][type].Add(NEW_item.Order_ID, NEW_item); } break; } } }
public void PickItem(game_item item) { link.TakeItem(item); }
public void Use_Consumable(game_item item) { stats.AddStats(item.bstats); stats.AddPStats(item.pstats); }
public List <game_item> GetRandomGear(SpriteGender gender, item_rarity.rarity rarity) { List <game_item> ret = new List <game_item>(); float Weapon = 0; item_type weap = item_type.none; foreach (item_type type in Enum.GetValues(typeof(item_type))) { if ((int)type <= 0) { continue; } try { if (type == item_type.melee_weapons || type == item_type.spears || type == item_type.wand || type == item_type.bow) { float t = InGameData.rand(0, 100); if (t > Weapon) { Weapon = t; weap = type; } continue; } else if (type == item_type.shilds || type == item_type.arrows) { continue; } if (InGameData.random_int(0, 32) % 8 == 3) { continue; } game_item ti = GetItemFrom(gender, type, rarity); if (ti != null) { ret.Add(GetItemFrom(gender, type, rarity).CopyItem()); } } catch { } } int temp2 = Game_Items[gender][weap].Count; int rand2 = InGameData.random_int(0, temp2); ret.Add(GetItemFrom(gender, weap, rarity).CopyItem()); if (weap == item_type.bow) { ret.Add(GetItemFrom(gender, item_type.arrows, rarity).CopyItem()); } else if (weap == item_type.melee_weapons || weap == item_type.spears) { if (InGameData.random_int(0, 32) % 8 == 3) { return(ret); } ret.Add(GetItemFrom(gender, item_type.shilds, rarity).CopyItem()); } return(ret); }
public void RemoveItem(game_item item) { AddItem.MyPlayer.Remove_Item(item); }
public void SetItem(game_item item) { StartCoroutine(SET(item)); }
public void AddItem(game_item item) { try { SpriteRect sr; if (item.type == item_type.wand || item.type == item_type.spears || item.type == item_type.bow || item.type == item_type.melee_weapons) { sr = Wearable_items[item_type.melee_weapons]; if (item.type == item_type.melee_weapons) { sr.in_layer = hair_l + 3; weapon_anim.color = Color.white; } else { sr.in_layer = hair_l + 1; weapon_anim.color = new Color(1, 1, 1, 0); } } else { sr = Wearable_items[item.type]; } sr.LoadSprites(item.id_sprite, sr.in_layer); sr.color = item.rarity.color; } catch { Transform child = Instantiate(SpriteContainer).transform; if (item.type == item_type.wand || item.type == item_type.melee_weapons || item.type == item_type.spears || item.type == item_type.bow) { child.name = "(weapon slot)"; } else { child.name = item.type.ToString(); } SpriteRect sr = child.gameObject.AddComponent <SpriteRect>(); child.SetParent(transform); child.localPosition = Vector3.zero; child.localEulerAngles = Vector3.zero; child.localScale = new Vector3(1, 1, 1); sr.LoadSprites(item.id_sprite, layers); sr.in_layer = layer; sr.color = item.rarity.color; layers++; if (item.type == item_type.wand || item.type == item_type.spears) { Wearable_items.Add(item_type.melee_weapons, sr); } else { Wearable_items.Add(item.type, sr); } } }
public void ConfirmItem(game_item item) { AddItem.MyPlayer.add_item(item); }