public void Substitute() { var subbedPlayer = Team.Players.Single(p => p.Number == SelectedNumber); var substitutePlayer = SelectedSubstitute; SubstitutedPlayers.Add(subbedPlayer); substitutePlayer.Location.XamlX = subbedPlayer.Location.XamlX; substitutePlayer.Location.XamlY = subbedPlayer.Location.XamlY; TeamFormation[TeamFormation. Where(kvp => kvp.Value.Number == subbedPlayer.Number). Select(kvp => kvp.Key).Single()] = substitutePlayer; UpdatePlayerShirts(); PlayerNumbers.Remove(SelectedNumber); PlayerSubstitutes.Remove(substitutePlayer); NotifyOfPropertyChange(() => PlayerSubstitutes); NotifyOfPropertyChange(() => PlayerNumbers); SelectedNumber = 0; SelectedSubstitute = null; ++SubstitutesUsed; }
public void ReadXml() { FormationList.Clear(); Clean(); var persistentFile = string.Format("{0}/{1}.xml", Application.persistentDataPath, XmlName); var hasPersistentFile = File.Exists(persistentFile); var document = new XmlDocument(); if (hasPersistentFile) { document.Load(persistentFile); } else { document.LoadXml(FormationText.text); } var rootNode = document.SelectSingleNode("/Root"); var formationNodeList = rootNode.SelectNodes("TeamFormation"); foreach (XmlNode formationNode in formationNodeList) { var formation = new TeamFormation(); formation.ReadXmlNode(formationNode); FormationList.Add(formation); } if (Index < 0 || Index >= FormationList.Count) { Logger.LogWarning("Formation index should be in range (0 - " + FormationList.Count + "), which is: " + Index + ", we will get 0 as default."); Index = 0; } #if UNITY_EDITOR if (!Application.isPlaying) { RefreshView(); } #endif var path = (hasPersistentFile) ? persistentFile : string.Format("{0}/{1}.xml", RelatedPath, XmlName); Logger.Log("Load xml from file: " + path + " succeed."); }
public void InjectData() { var teamFormation = new TeamFormation { Description = Description, }; SpawnList.ForEach(item => { teamFormation.PositionList.Add(item.transform.position); }); FormationList.Add(teamFormation); }