public static List <PokeMove> Load() { XDocument doc = XMLTools.GetXMLDocument(path); XElement root = doc.Root; List <PokeMove> moves = new List <PokeMove>(); if (doc != null) { int i = 0; foreach (XElement e in root.Elements("move")) { i++; try { PokeMove newMove = LoadDataInMove(e); moves.Add(newMove); } catch (Exception) { Console.WriteLine("Movement in the position {0} could not be read", i); } } } return(moves); }
private static PokeMove LoadDataInMove(XElement e) { PokeMove p = new PokeMove(); p.Id = Convert.ToInt32(e.Attribute("id").Value); p.Name = e.Element("name").Value; p.Description = e.Element("description").Value; p.Type = Convert.ToByte(e.Element("type").Value); p.Category = Convert.ToByte(e.Element("category").Value); p.Accuracy = Convert.ToByte(e.Element("accuarcy").Value); p.Power = Convert.ToSByte(e.Element("power").Value); p.Recover = Convert.ToSByte(e.Element("recover").Value); p.Target = Convert.ToByte(e.Element("target").Value); p.PP = Convert.ToByte(e.Element("pp").Value); p.Contact = e.Element("contact").Value.Equals("true") ? true : false; p.Priority = Convert.ToByte(e.Element("priority").Value); p.EffectCode = e.Element("effectCode").Value; p.EffectProbability = Convert.ToByte(e.Element("effectProbability").Value); return(p); }
private static XElement AddDataMoveElement(PokeMove m) { XElement move = new XElement("move"); move.Add(new XAttribute("id", GenerateId())); move.Add(new XElement("name", m.Name)); move.Add(new XElement("description", m.Description)); move.Add(new XElement("type", m.Type)); move.Add(new XElement("category", m.Category)); move.Add(new XElement("accuarcy", m.Accuracy)); move.Add(new XElement("damage", m.Power)); move.Add(new XElement("recover", m.Recover)); move.Add(new XElement("repetitions", m.Repetitions)); move.Add(new XElement("repetitionsInTurn", m.RepetitionsInTurn)); move.Add(new XElement("target", m.Target)); move.Add(new XElement("pp", m.PP)); move.Add(new XElement("contact", m.Contact ? "true" : "false")); move.Add(new XElement("priority", m.Priority)); move.Add(new XElement("effectCode", m.EffectCode)); move.Add(new XElement("effectProbability", m.EffectProbability)); return(move); }
IEnumerator SetYield(PokeInfo pokeInfo) { _curPokeInfo = pokeInfo; foreach (var o in _curQuickMovesObj) { Destroy(o); } foreach (var o in _curChargeMovesObj) { Destroy(o); } float nextPanelPosY = 0; #region Set labels (0 PANEL) _idText.text = "#" + pokeInfo.Id; _baseImageLabel.Set(pokeInfo.Image, pokeInfo.Name); if (pokeInfo.EvoFromId > -1) { PokeInfo evoFrom = AppManager.Instance.PokeData.PokeInfos[pokeInfo.EvoFromId]; _prevImageLabel.Set(evoFrom.Image, evoFrom.Name, evoFrom.CandyToEvolve); _prevImageLabel.EnableObj(); } else { _prevImageLabel.DisableObj(); } if (pokeInfo.EvoToId > -1) { PokeInfo evoTo = AppManager.Instance.PokeData.PokeInfos[pokeInfo.EvoToId]; _nextImageLabel.Set(evoTo.Image, evoTo.Name, pokeInfo.CandyToEvolve); _nextImageLabel.EnableObj(); } else { _nextImageLabel.DisableObj(); } if (AppManager.Instance.UserData.FavoritePokemons.Contains(pokeInfo.Id)) { _favoriteButton.Selected = true; } else { _favoriteButton.Selected = false; } nextPanelPosY -= _allPanels[0].sizeDelta.y + PanelSpace; #endregion #region Set info (1 PANEL) foreach (var pokeTypeLabel in _pokeTypeLabels) { pokeTypeLabel.DisableObj(); } for (int i = 0; i < pokeInfo.Type.Length; i++) { _pokeTypeLabels[i].SetType(pokeInfo.Type[i]); _pokeTypeLabels[i].EnableObj(); } if (pokeInfo.Class == PokeClass.Legendary) { _classText.text = pokeInfo.Class.ToString().ToUpper(); } else { _classText.text = ""; } _maxCpWHText.text = TextManager.GetText(TextType.Element, 0) + UIManager.NewLine(1) + UIManager.GetFormattedText(TextManager.GetNumericFormat((int)pokeInfo.MaxCp), TextColorType.GreenSmooth, true, 30) + UIManager.NewLine(1) + TextManager.GetText(TextType.Element, 2) + ": " + UIManager.GetFormattedText(pokeInfo.Weight.ToString(), TextColorType.BlackLight, true, 16) + " " + UIManager.GetFormattedText(TextManager.GetText(TextType.Element, 17), TextColorType.GreyLight, true, 12) + UIManager.NewLine(1) + TextManager.GetText(TextType.Element, 3) + ": " + UIManager.GetFormattedText(pokeInfo.Height.ToString(), TextColorType.BlackLight, true, 16) + " " + UIManager.GetFormattedText(TextManager.GetText(TextType.Element, 18), TextColorType.GreyLight, true, 12); _pokeStats.SetStats(pokeInfo.AttackRate, pokeInfo.DefenseRate, pokeInfo.StaminaRate); _statsText.text = pokeInfo.BaseAttack + UIManager.NewLine(1) + pokeInfo.BaseDefense + UIManager.NewLine(1) + pokeInfo.BaseStamina; if (pokeInfo.EggDistanceType != EggType.None) { _eggDistanceText.text = ((int)pokeInfo.EggDistanceType) + TextManager.GetText(TextType.Element, 23); _eggDistanceText.color = UIManager.TextColorsList[TextColorType.GreenSmooth]; _eggImage.sprite = UIManager.Instance.UIRes.EggSprites[0]; } else { _eggDistanceText.text = TextManager.GetText(TextType.Element, 24); _eggDistanceText.color = UIManager.TextColorsList[TextColorType.GreyLight]; _eggImage.sprite = UIManager.Instance.UIRes.EggSprites[1]; } nextPanelPosY -= _allPanels[1].sizeDelta.y + (PanelSpace * 2); #endregion #region Set Resistance & Weaknesses (4 PANEL) _typeChart.Set(TypeChartPanelType.Pokemon, _curPokeInfo.Resistance, _curPokeInfo.Weaknesses); yield return(new WaitForEndOfFrame()); _allPanels[4].anchoredPosition = new Vector2(_allPanels[4].anchoredPosition.x, nextPanelPosY); nextPanelPosY -= _allPanels[4].sizeDelta.y + PanelSpace; #endregion #region Set moves (2 PANEL) int movesCount = Mathf.Max(pokeInfo.PrimaryMovesIds.Length, pokeInfo.SecondaryMovesIds.Length); float movePanelHeight = movesCount * (PokeMove.PanelHeight + (PanelSpace)); _allPanels[2].sizeDelta = new Vector2(_allPanels[2].sizeDelta.x, movePanelHeight + MoveStartHeightPos); _allPanels[2].anchoredPosition = new Vector2(_allPanels[2].anchoredPosition.x, nextPanelPosY); _curQuickMovesObj = new GameObject[pokeInfo.PrimaryMovesIds.Length]; for (int i = 0; i < pokeInfo.PrimaryMovesIds.Length; i++) { _curQuickMovesObj[i] = Instantiate(QuickMoveTemplate); PokeMove move = _curQuickMovesObj[i].GetComponent <PokeMove>(); move.RectTransform.SetParent(_allPanels[2]); move.RectTransform.anchoredPosition = new Vector2(0, -(MoveStartHeightPos + PokeMove.PanelHeight * i) - (PanelSpace * i)); move.RectTransform.sizeDelta = new Vector2(0, move.RectTransform.sizeDelta.y); move.RectTransform.localScale = Vector3.one; move.Set(AppManager.Instance.PokeData.PrimaryMoves[pokeInfo.PrimaryMovesIds[i]]); } _curChargeMovesObj = new GameObject[pokeInfo.SecondaryMovesIds.Length]; for (int i = 0; i < pokeInfo.SecondaryMovesIds.Length; i++) { _curChargeMovesObj[i] = Instantiate(ChargeMoveTemplate); PokeMove move = _curChargeMovesObj[i].GetComponent <PokeMove>(); move.RectTransform.SetParent(_allPanels[2]); move.RectTransform.anchoredPosition = new Vector2(0, -(MoveStartHeightPos + PokeMove.PanelHeight * i) - (PanelSpace * i)); move.RectTransform.sizeDelta = new Vector2(0, move.RectTransform.sizeDelta.y); move.RectTransform.localScale = Vector3.one; move.Set(AppManager.Instance.PokeData.SecondaryMoves[pokeInfo.SecondaryMovesIds[i]]); } nextPanelPosY -= _allPanels[2].sizeDelta.y + PanelSpace; #endregion #region Set Additional Info (3 PANEL) //Fill INFO string percentFormatted = UIManager.GetFormattedText(" %", TextColorType.GreyLight, false, 12); _addInfoText.text = TextManager.GetText(TextType.Element, 33) + ":" + UIManager.NewLine(1); if (_curPokeInfo.CpMultiFromEvo > 0) { _addInfoText.text += TextManager.GetText(TextType.Element, 34) + ":" + UIManager.NewLine(1); } _addInfoText.text += TextManager.GetText(TextType.Element, 35) + ":" + UIManager.NewLine(1) + TextManager.GetText(TextType.Element, 36) + ":" + UIManager.NewLine(1) + TextManager.GetText(TextType.Element, 37) + ":"; //Fill INFO COUNT _addInfoCountText.text = _curPokeInfo.BaseHp + UIManager.NewLine(1); if (_curPokeInfo.CpMultiFromEvo > 0) { _addInfoCountText.text += _curPokeInfo.CpMultiFromEvo + UIManager.GetFormattedText("x", TextColorType.GreyLight, false, 12) + UIManager.NewLine(1); } _addInfoCountText.text += _curPokeInfo.CaptureRate + percentFormatted + UIManager.NewLine(1) + _curPokeInfo.FleeRate + percentFormatted + UIManager.NewLine(1) + _curPokeInfo.Rarity.ToString("F") + percentFormatted; yield return(new WaitForEndOfFrame()); _allPanels[3].anchoredPosition = new Vector2(_allPanels[3].anchoredPosition.x, nextPanelPosY); _allPanels[3].sizeDelta = new Vector2(_allPanels[3].sizeDelta.x, _addInfoText.GetComponent <RectTransform>().sizeDelta.y + (PanelSpace * 2)); nextPanelPosY -= _allPanels[3].sizeDelta.y + PanelSpace; #endregion _content.sizeDelta = new Vector2(0, Mathf.Abs(nextPanelPosY) + UIManager.PanelBottomOffset); }