public game_item(item_type _type, int _id_sprite, SpriteGender _gender, int _Order_ID, string _name, Basic_Stats stats, UseBoost pstats, item_rarity.rarity _rarity, bool Is_armor, int item_level = 0) { ID = ITEM_COUNTER; ITEM_COUNTER++; bstats = stats; this.pstats = pstats; IsArmor = Is_armor; NAME = _name; type = _type; id_sprite = _id_sprite; gender = _gender; ORD = _Order_ID; slot_pointer = null; count = 1; if (_id_sprite == -1) { id_sprite = CONSUMABLE_SP_ID; CONSUMABLE_SP_ID--; } if (ORD == -1) { ORD = CONSUMABLE_SP_ID; } rarity = new item_rarity(bstats, _rarity, item_level); }
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); }
public Card(string name, card_type type, event_type[] events, item_type itemType) { this.itemType = itemType; this.logic_event = type; this.events = events == null ? new event_type[] { } : events; this.name = name; }
public ReturnValueRepo Create(string name) { var result = new ReturnValueRepo(); var cat = InventoryDatabase.item_type.FirstOrDefault(s => s.item_type_name.Equals(name)); if (cat == null) { var newCat = new item_type() { item_type_name = name }; InventoryDatabase.item_type.Add(newCat); if (InventoryDatabase.SaveChanges() > 0) { result.Success = true; result.Param1 = newCat.item_type_id.ToString(); } } else { result.Message = "Type already exist!"; } return(result); }
public Item(int id, string name, item_type type, rarity rarity, int min_rarity, int max_rarity, int level, string description, string icon, string sprite_male, string sprite_female, int health, int resource, int damage, int value) { this.id = id; this.name = name; this.rarity = rarity; this.level = level; this.description = description; this.type = type; this.icon = icon; this.sprite_male = sprite_male; this.sprite_female = sprite_female; int[] tmp = new int[4]; tmp[0] = health; tmp[1] = resource; tmp[2] = damage; tmp[3] = value; this.attributes = tmp; this.min_rarity = min_rarity; this.max_rarity = max_rarity; //randomizeRarity(min_rarity, max_rarity); }
public game_item RandomItem(SpriteGender gender, item_rarity.rarity rarity) { item_type t = item_type.consumable; int chance = 0; foreach (item_type type in Enum.GetValues(typeof(item_type))) { try { if (Game_Items[gender][type].Count <= 0) { continue; } int temp = InGameData.random_int(0, 100); if (temp > chance) { chance = temp; t = type; } } catch { } } return(GetItemFrom(gender, t, rarity).CopyItem()); }
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 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 AddEmptyOrRemoveSprite(item_type type, int layer) { try { SpriteRect sr; if (type == item_type.wand || type == item_type.spears || type == item_type.bow) { sr = Wearable_items[item_type.melee_weapons]; } else { sr = Wearable_items[type]; } sr.color = new Color(1, 1, 1, 0); } catch { Transform child = Instantiate(SpriteContainer).transform; if (type == item_type.wand || type == item_type.melee_weapons || type == item_type.spears || type == item_type.bow) { child.name = "(weapon slot)"; } else { child.name = 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.color = new Color(1, 1, 1, 0); sr.in_layer = layer; if (type == item_type.wand || type == item_type.spears) { Wearable_items.Add(item_type.melee_weapons, sr); } else { Wearable_items.Add(type, sr); } } }
public Card(string name, card_type type, List <event_type> events, item_type it, item_type itemType) { this.itemType = itemType; this.name = name; this.itemType = it; this.logic_event = type; if (events == null || events.Count == 0) { this.events = null; return; } this.events = new event_type[events.Count]; for (int i = 0; i < events.Count; i++) { this.events[i] = events[i]; } }
public weapon_type CheckIfWeapon(item_type type) { switch (type) { case item_type.melee_weapons: return(weapon_type.sword); case item_type.spears: return(weapon_type.spear); case item_type.wand: return(weapon_type.wand); case item_type.bow: return(weapon_type.bow); default: return(weapon_type.none); } }
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); }
public void RemoveItem(item_type type) { try { SpriteRect sr; if (type == item_type.wand || type == item_type.spears || type == item_type.bow || type == item_type.melee_weapons) { weapon_anim.color = new Color(1, 1, 1, 0); sr = Wearable_items[item_type.melee_weapons]; } else { sr = Wearable_items[type]; } sr.color = new Color(1, 1, 1, 0); } catch { } }
public void Read(TReader reader) { reader.ReadStructBegin("item_table"); { if (reader.ReadFieldBegin("ID")) { reader.Read(out this._ID); } reader.ReadFieldEnd("ID"); } { if (reader.ReadFieldBegin("ItemName")) { reader.Read(out this._ItemName); } reader.ReadFieldEnd("ItemName"); } { if (reader.ReadFieldBegin("Metempsychosis")) { reader.Read(out this._Metempsychosis); } reader.ReadFieldEnd("Metempsychosis"); } { if (reader.ReadFieldBegin("UseTime")) { reader.Read(out this._UseTime); } reader.ReadFieldEnd("UseTime"); } { if (reader.ReadFieldBegin("Bill")) { reader.Read(out this._Bill); } reader.ReadFieldEnd("Bill"); } { if (reader.ReadFieldBegin("ReplaceItem")) { reader.Read(out this._ReplaceItem); } reader.ReadFieldEnd("ReplaceItem"); } { if (reader.ReadFieldBegin("Medals")) { reader.Read(out this._Medals); } reader.ReadFieldEnd("Medals"); } { if (reader.ReadFieldBegin("Value")) { reader.Read(out this._Value); } reader.ReadFieldEnd("Value"); } { if (reader.ReadFieldBegin("ReserveMoneyFlag")) { reader.Read(out this._ReserveMoneyFlag); } reader.ReadFieldEnd("ReserveMoneyFlag"); } { if (reader.ReadFieldBegin("Quality")) { reader.Read(out this._Quality); } reader.ReadFieldEnd("Quality"); } { if (reader.ReadFieldBegin("ItemType")) { int e; reader.Read(out e); this._ItemType = (item_type)e; } else { string es; reader.Read(out es); this._ItemType = (item_type)Enum.Parse(typeof(item_type), es); } reader.ReadFieldEnd("ItemType"); } { if (reader.ReadFieldBegin("UseSingTime")) { reader.Read(out this._UseSingTime); } reader.ReadFieldEnd("UseSingTime"); } { if (reader.ReadFieldBegin("UserTarget")) { reader.Read(out this._UserTarget); } reader.ReadFieldEnd("UserTarget"); } { if (reader.ReadFieldBegin("CanMoved")) { reader.Read(out this._CanMoved); } reader.ReadFieldEnd("CanMoved"); } { if (reader.ReadFieldBegin("CanDeleted")) { reader.Read(out this._CanDeleted); } reader.ReadFieldEnd("CanDeleted"); } { if (reader.ReadFieldBegin("CanTrade")) { reader.Read(out this._CanTrade); } reader.ReadFieldEnd("CanTrade"); } { if (reader.ReadFieldBegin("CanSold")) { reader.Read(out this._CanSold); } reader.ReadFieldEnd("CanSold"); } { if (reader.ReadFieldBegin("CanStored")) { reader.Read(out this._CanStored); } reader.ReadFieldEnd("CanStored"); } { if (reader.ReadFieldBegin("CanLocked")) { reader.Read(out this._CanLocked); } reader.ReadFieldEnd("CanLocked"); } { if (reader.ReadFieldBegin("CanBound")) { reader.Read(out this._CanBound); } reader.ReadFieldEnd("CanBound"); } { if (reader.ReadFieldBegin("IsExclusive")) { reader.Read(out this._IsExclusive); } reader.ReadFieldEnd("IsExclusive"); } { if (reader.ReadFieldBegin("IsExpendable")) { reader.Read(out this._IsExpendable); } reader.ReadFieldEnd("IsExpendable"); } { if (reader.ReadFieldBegin("ColdDownType")) { reader.Read(out this._ColdDownType); } reader.ReadFieldEnd("ColdDownType"); } { if (reader.ReadFieldBegin("ColdDownTime")) { reader.Read(out this._ColdDownTime); } reader.ReadFieldEnd("ColdDownTime"); } { if (reader.ReadFieldBegin("CanDrop")) { reader.Read(out this._CanDrop); } reader.ReadFieldEnd("CanDrop"); } { if (reader.ReadFieldBegin("DecomposePackID")) { reader.Read(out this._DecomposePackID); } reader.ReadFieldEnd("DecomposePackID"); } { if (reader.ReadFieldBegin("IsMerge")) { reader.Read(out this._IsMerge); } reader.ReadFieldEnd("IsMerge"); } { reader.ReadVectorBegin(); if (reader.ReadFieldBegin("vec_num")) { reader.Read(out this._vec_num); this._vec = new string[this._vec_num]; } reader.ReadFieldEnd("vec_num"); for (uint i = 0; i < Constants.ITEM_VEC_NUM; ++i) { if (i == this._vec_num) { break; } if (reader.ReadVectorElementBegin("vec", i)) { reader.Read(out this._vec[i]); } reader.ReadVectorElementEnd("vec", i); } reader.ReadVectorEnd(); } reader.ReadStructEnd("item_table"); }
public List <game_item> GetRandomGear(SpriteGender gender) { 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; } int temp = Game_Items[gender][type].Count; int rand = InGameData.random_int(0, (int)(temp * 1.5f)); if (rand > temp) { continue; } ret.Add(Game_Items[gender][type][rand].CopyItem()); } catch { } } int temp2 = Game_Items[gender][weap].Count; int rand2 = InGameData.random_int(0, temp2); ret.Add(Game_Items[gender][weap][rand2].CopyItem()); if (weap == item_type.bow) { ret.Add(Game_Items[gender][item_type.arrows][0].CopyItem()); } else if (weap == item_type.melee_weapons || weap == item_type.spears) { temp2 = Game_Items[gender][item_type.shilds].Count; rand2 = InGameData.random_int(0, temp2 * 2); if (rand2 > temp2) { return(ret); } ret.Add(Game_Items[gender][weap][rand2].CopyItem()); } return(ret); }
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 loadFromFileAndParse() { String[] loaded = File.ReadAllLines("./Assets/Resources/deck_cards.txt"); foreach (string s in loaded) { if (s.StartsWith("#")) { continue; } Card newCard; string[] parsedRow = s.Split(':'); int theseInDeck = int.Parse(parsedRow[0]); string cardname = parsedRow[2]; List <event_type> readEvents = new List <event_type>(); // Add actions if (parsedRow[1].Equals("enm")) { newCard = new Card(cardname, translateToType(parsedRow[1]), new event_type[] { event_type.ENEMY }, item_type.ENEMY); for (int fields = 3; fields < parsedRow.Length; fields++) { if (parsedRow[fields].Equals("nospecial")) { break; } // Debug.Log("Enemy card attrs:" + parsedRow[fields]); string[] attrs = parsedRow[fields].Split('@'); switch (attrs[0]) { case "powr": newCard.power = int.Parse(attrs[1]); break; case "strn": newCard.strength = int.Parse(attrs[1]); break; } } fullDeck.Add(newCard); } else { int begin = 3; item_type type = item_type.CONSUMABLE; if (parsedRow[1].Equals("itm")) { type = translateToItemType(parsedRow[3]); begin = 4; } for (int fields = begin; fields < parsedRow.Length; fields++) { // Check what actions does the card have if (possibleEvents.Contains(parsedRow[fields])) { readEvents.Add(translateToEvent(parsedRow[fields])); } // If field is not special finish building if (parsedRow[fields].Equals("nospecial")) { if (parsedRow[1].Equals("itm")) { newCard = new Card(cardname, translateToType(parsedRow[1]), readEvents, type); } else { newCard = new Card(cardname, translateToType(parsedRow[1]), readEvents); } for (int times = 0; times < theseInDeck; times++) { fullDeck.Add(newCard); } } else if (parsedRow[fields].Equals("special")) { int current = fields + 1; if (parsedRow[1].Equals("itm")) { newCard = new Card(cardname, translateToType(parsedRow[1]), readEvents, type); } else { newCard = new Card(cardname, translateToType(parsedRow[1]), readEvents); } for (; current < parsedRow.Length; current++) { string[] ev_roll = parsedRow[current].Split('@'); newCard.AssignSpecial(new int[] { int.Parse(ev_roll[1]) }, translateToEvent(ev_roll[0])); } for (int times = 0; times < theseInDeck; times++) { fullDeck.Add(newCard); } } } } } listCards(); }