/// <summary> /// Highligh monkey item slot associated with selected item /// </summary> /// <param name="sT"></param> private void HighlightMonkeySlot(EquipmentItem.SLOT_TYPE sT) { for (int i = 0; i < _monkeysSlotist.Count; ++i) { _monkeysSlotist[i].transform.GetChild(3).gameObject.SetActive(i == (int)sT); } /*int slotIndex = -1; * switch (sT) * { * case EquipmentItem.SLOT_TYPE.SHAKER_A: * slotIndex = 0; * break; * * case EquipmentItem.SLOT_TYPE.SHAKER_B: * slotIndex = 1; * break; * * case EquipmentItem.SLOT_TYPE.COLLECTOR_A: * slotIndex = 2; * break; * * case EquipmentItem.SLOT_TYPE.COLLECTOR_B: * slotIndex = 3; * break; * * case EquipmentItem.SLOT_TYPE.STRIKER_A: * slotIndex = 4; * break; * * case EquipmentItem.SLOT_TYPE.STRIKER_B: * slotIndex = 5; * break; * }*/ /*for (int i = 0; i < _monkeysSlotist.Count; ++i) * _monkeysSlotist[i].GetComponent<Outline>().enabled = (i == (int)sT);*/ }
/// <summary> /// /// </summary> /// <param name="mT"></param> private void ClearSlotText(EquipmentItem.SLOT_TYPE sT) { _monkeysSlotist[(int)sT].GetComponentInChildren <Text>().text = ""; }
/// <summary> /// /// </summary> public void LoadItemData() { string slotTypeS, modTypeS; string auxId, auxSpriteId; int auxValue = -1, auxCount = -1; GoldItem auxGoldItm = null; EquipmentItem auxEquipItm = null; List <EquipmentItem.MOD_TYPE> auxMtList = new List <EquipmentItem.MOD_TYPE>(); List <float> auxModValList = new List <float>(); EquipmentItem.SLOT_TYPE auxSt = EquipmentItem.SLOT_TYPE.COLLECTOR_A; XmlReader reader = XmlReader.Create(new StringReader(_itemDataTA.text)); //XmlDocument doc = new XmlDocument(); // doc.LoadXml(_textDoc.text); if (_gameItemList == null) { _gameItemList = new List <EquipmentItem>(); } else { _gameItemList.Clear(); } if (_goldItemList == null) { _goldItemList = new List <GoldItem>(); } else { _goldItemList.Clear(); } _readingGoldItem = false; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name.CompareTo("gold_item_type") == 0) { _readingGoldItem = true; } else if (reader.Name.CompareTo("equipment_item_data") == 0) { _readingGoldItem = false; } else { //Debug.Log("Value: " + reader.Name); if (reader.Name.CompareTo("item") == 0) { if (_readingGoldItem) { auxSpriteId = reader.GetAttribute("spriteId"); //auxGoldItm = new GoldItem(reader.GetAttribute("id"), auxSpriteId, XmlConvert.ToInt32(reader.GetAttribute("value"))); auxGoldItm = new GoldItem(reader.GetAttribute("id"), auxSpriteId, XmlConvert.ToInt32(reader.GetAttribute("value"))); auxGoldItm._Sprite = Resources.Load(auxSpriteId, typeof(Sprite)) as Sprite; _goldItemList.Add(auxGoldItm /*auxGoldItm*/); } else { auxId = reader.GetAttribute("id"); auxSpriteId = reader.GetAttribute("spriteId"); auxValue = XmlConvert.ToInt32(reader.GetAttribute("value")); Debug.Log("Adding item.... " + auxId); //auxCount = XmlConvert.ToInt32(reader.GetAttribute("count")); slotTypeS = reader.GetAttribute("slotType"); if (slotTypeS.CompareTo("COLLECTOR_A") == 0) { auxSt = EquipmentItem.SLOT_TYPE.COLLECTOR_A; } else if (slotTypeS.CompareTo("COLLECTOR_B") == 0) { auxSt = EquipmentItem.SLOT_TYPE.COLLECTOR_B; } else if (slotTypeS.CompareTo("STRIKER_A") == 0) { auxSt = EquipmentItem.SLOT_TYPE.STRIKER_A; } else if (slotTypeS.CompareTo("STRIKER_B") == 0) { auxSt = EquipmentItem.SLOT_TYPE.STRIKER_B; } else if (slotTypeS.CompareTo("SHAKER_A") == 0) { auxSt = EquipmentItem.SLOT_TYPE.SHAKER_A; } else if (slotTypeS.CompareTo("SHAKER_B") == 0) { auxSt = EquipmentItem.SLOT_TYPE.SHAKER_B; } else { Debug.LogError("Error parsing slotType " + auxSt); } //Read mod list auxMtList = new List <EquipmentItem.MOD_TYPE>(); auxModValList = new List <float>(); while (reader.Read()) { if (reader.IsStartElement() && reader.Name.CompareTo("mod") == 0) { modTypeS = reader.GetAttribute("modType"); //Debug.Log("R E A D I N G: " + modTypeS); if (modTypeS.CompareTo("RELOAD_SPEED") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.RELOAD_SPEED); } else if (modTypeS.CompareTo("SACK_SIZE") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.SACK_SIZE); } else if (modTypeS.CompareTo("COLLECTOR_SPEED") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.COLLECTOR_SPEED); } else if (modTypeS.CompareTo("STRIKER_HIT_SIZE") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.STRIKER_HIT_SIZE); } else if (modTypeS.CompareTo("STRIKER_SPEED") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.STRIKER_SPEED); } else if (modTypeS.CompareTo("ACCURACY") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.ACURRACY); } else if (modTypeS.CompareTo("FALL_SPEED") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.FALL_SPEED); } else if (modTypeS.CompareTo("GOLD_FIND_PROB") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.GOLD_FIND_PROB); } else if (modTypeS.CompareTo("ITEM_FIND_PROB") == 0) { auxMtList.Add(EquipmentItem.MOD_TYPE.ITEM_FIND_PROB); } else { Debug.LogError("Error parsing slotType " + modTypeS); } auxModValList.Add(float.Parse(reader.GetAttribute("modVal"))); } else if (!reader.IsStartElement() && reader.Name.CompareTo("item") == 0) { //Debug.Log("Item read ended, break reading mod List"); break; } } auxEquipItm = new EquipmentItem(auxId, auxSpriteId, auxValue, auxSt, auxMtList, auxModValList /*,auxCount*/); //auxSt, auxMt, float.Parse(reader.GetAttribute("modVal")), 0); //Load Sprite reference auxEquipItm._Sprite = Resources.Load(auxSpriteId, typeof(Sprite)) as Sprite; _gameItemList.Add(auxEquipItm); } } } break; case XmlNodeType.EndElement: Debug.Log("End element Value: " + reader.Name); break; } } Debug.Log("Current itemlist count:" + _gameItemList.Count); }