/// <summary> /// Loads the event types from a JSON file. /// </summary> /// <param name="filename">Filename.</param> void LoadFromJSON(string filename) { TextAsset jsonAsset = Resources.Load <TextAsset>(filename); if (jsonAsset != null) { string fileContents = jsonAsset.text; var N = JSON.Parse(fileContents); var finishArray = N["match_finishes"].AsArray; foreach (JSONNode finish in finishArray) { string name = finish["name"]; string description = finish["description"]; int phase = finish["phase"].AsInt; List <WrestlingMatchType> incompatibleMatchTypes = new List <WrestlingMatchType>(); var incompatibleMatchTypeNames = finish["incompatible_match_types"].AsArray; for (int i = 0; i < incompatibleMatchTypeNames.Count; ++i) { string typeName = incompatibleMatchTypeNames[i]; WrestlingMatchType type = WrestlingMatchTypeManager.Instance.GetMatchType(typeName); if (type != null) { incompatibleMatchTypes.Add(type); } } CreateWrestlingMatchFinish(name, description, phase, incompatibleMatchTypes); } } else { Debug.LogError("Unable to load event type data from JSON at '" + filename + "': There was an error opening the file."); } }
public WrestlingMatchType CreateWrestlingMatchType(string name, string description, int phase) { WrestlingMatchType matchType = new WrestlingMatchType(); matchType.Initialize(name, description, phase); matchTypes.Add(matchType); return(matchType); }
public void AddUsedMatchType(WrestlingMatchType type) { if (!HasUsedMatchType(type)) { usedMatchTypes.Add(type.typeName); Wrestler.Save(this, SavedGameManager.Instance.CurrentGameID); } }
public void AddSeenMatchType(WrestlingMatchType type) { if (!HasSeenMatchType(type)) { seenMatchTypes.Add(type.typeName); Venue.Save(this, SavedGameManager.Instance.CurrentGameID); } }
public override void Write(object obj, ES2Writer writer) { WrestlingMatchType data = (WrestlingMatchType)obj; // Add your writer.Write calls here. writer.Write(data.typeName); writer.Write(data.description); writer.Write(data.phase); }
public float GetMatchTypeAffinity(WrestlingMatchType matchType) { if (matchTypeAffinities.ContainsKey(matchType.typeName)) { return(matchTypeAffinities[matchType.typeName]); } else { return(0f); } }
public override object Read(ES2Reader reader) { WrestlingMatchType data = new WrestlingMatchType(); // Add your reader.Read calls here and return your object. data.typeName = reader.Read <System.String>(); data.description = reader.Read <System.String>(); data.phase = reader.Read <System.Int32>(); return(data); }
public float GetMatchTypePreference(WrestlingMatchType type) { if (matchTypePreferences.ContainsKey(type.typeName)) { return(matchTypePreferences[type.typeName]); } else { return(0.5f); } }
public void AttemptUnlockMatchTypeByVenue(Venue venue) { bool unlockNewMatchType = (Random.Range(0, 3) == 0); if (unlockNewMatchType) { WrestlingMatchType matchType = GameManager.Instance.GetMatchTypeManager().GetMatchType(venue.unlockableMatchType); if (matchType != null && matchType.phase <= phase && unlockedMatchTypes.Find(x => x.typeName == matchType.typeName) == null) { GameManager.Instance.GetGUIManager().AddNotification("Match type '" + matchType.typeName + "' unlocked"); unlockedMatchTypes.Add(matchType); Save(this, SavedGameManager.Instance.CurrentGameID); } } }
public bool IsCompatibleWithMatchType(WrestlingMatchType matchType) { return(incompatibleMatchTypes.Find(x => x.typeName == matchType.typeName) == null); }
public List <WrestlingMatchFinish> GetCompatibleMatchFinishes(int phase, WrestlingMatchType matchType) { return(matchFinishes.FindAll(x => (x.phase <= phase && x.IsCompatibleWithMatchType(matchType)))); }
public float rating = -1.0f; // Negative number == not yet rated. void Initialize(List <WrestlingTeam> teams, WrestlingMatchType type, WrestlingMatchFinish finish) { this.teams = teams; this.type = type; this.finish = finish; }
public bool HasUsedMatchType(WrestlingMatchType type) { return(null != usedMatchTypes.Find(x => x == type.typeName)); }