private void OnStatChanged(EventData_Gameplay eventData) { if (eventData.TheStatType != trackedStat) { return; } //TODO: SetIndexesFromString is inefficient, refrain from using a lot textLine.theString.SetIndexesFromString(textLine.theAlphabet, eventData.NewStatValue.ToString()); textLine.UpdateText(); }
private void OnKillObject(EventData_Gameplay theData) { if (this.GOInstanceID != theData.AteGOInstanceID) { return; } if (theData.IsImmediate) { RequestKillImmediate(); } else { RequestKill(); } }
//TODO: Setup to be through events, that will make // it MUCH easier to do things like update text // displaying a given stat. #region ModStats public void ModStat(TrackedStatType statType, ModType modType, float value) { StatData theStat = GetStat(statType); if (theStat == null) { #if UNITY_EDITOR Debug.LogError("StatTracker.ModStat() could not find stat with given name: " + statType.ToString()); #endif return; } float oldStat = theStat.currentValue; switch (modType) { case ModType.Set: theStat.currentValue = value; break; case ModType.Add: theStat.currentValue += value; break; case ModType.Mult: theStat.currentValue *= value; break; } float newStat = theStat.currentValue; EventData_Gameplay eventData = new EventData_Gameplay(); eventData.TheStatType = statType; eventData.OldStatValue = oldStat; eventData.NewStatValue = newStat; GameManager.Events.Broadcast <EventType_Gameplay> ((int)EventType_Gameplay.StatTracker_StatModified, eventData); }
private void OnReloadCurrentScene(EventData_Gameplay theData) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); }
private void OnLoadScene(EventData_Gameplay theData) { SceneManager.LoadScene(theData.SceneIndex); }