Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

96 linhas
3.0 KiB

  1. using System;
  2. using Engine.DependencyTree;
  3. using SUISS.Core;
  4. using UnityEngine;
  5. public class CIGChangeWatcher : MonoBehaviour
  6. {
  7. protected void Start()
  8. {
  9. this.StartWatching();
  10. }
  11. protected void OnDestroy()
  12. {
  13. this.EndWatching();
  14. }
  15. protected void StartWatching()
  16. {
  17. if (!this._watchingGameState && SingletonMonobehaviour<CIGGameState>.IsAvailable)
  18. {
  19. SingletonMonobehaviour<CIGGameState>.Instance.ValueChangedEvent += this.GameStateValueChanged;
  20. this._watchingGameState = true;
  21. }
  22. if (!this._watchingGameStats && SingletonMonobehaviour<CIGGameStats>.IsAvailable)
  23. {
  24. SingletonMonobehaviour<CIGGameStats>.Instance.ValueChangedEvent += this.GameStatsValueChanged;
  25. this._watchingGameStats = true;
  26. }
  27. if (!this._watchingDependencyTree && SingletonMonobehaviour<DependencyTree>.IsAvailable)
  28. {
  29. SingletonMonobehaviour<DependencyTree>.Instance.DependencyAchievedChangedEvent += this.DependencyAchievedChanged;
  30. this._watchingDependencyTree = true;
  31. }
  32. }
  33. protected void EndWatching()
  34. {
  35. if (this._watchingGameState && SingletonMonobehaviour<CIGGameState>.IsAvailable)
  36. {
  37. SingletonMonobehaviour<CIGGameState>.Instance.ValueChangedEvent -= this.GameStateValueChanged;
  38. this._watchingGameState = false;
  39. }
  40. if (this._watchingGameStats && SingletonMonobehaviour<CIGGameStats>.IsAvailable)
  41. {
  42. SingletonMonobehaviour<CIGGameStats>.Instance.ValueChangedEvent -= this.GameStatsValueChanged;
  43. this._watchingGameStats = false;
  44. }
  45. if (this._watchingDependencyTree && SingletonMonobehaviour<DependencyTree>.IsAvailable)
  46. {
  47. SingletonMonobehaviour<DependencyTree>.Instance.DependencyAchievedChangedEvent -= this.DependencyAchievedChanged;
  48. this._watchingDependencyTree = false;
  49. }
  50. }
  51. protected void GameStateValueChanged(string key, object oldValue, object newValue)
  52. {
  53. if (key != null)
  54. {
  55. if (key == "TotalMinutesPlayed" || key == "TotalFiveMinuteSessions" || key == "currentRetentionReward" || key == "retentionRewardTimestamp")
  56. {
  57. return;
  58. }
  59. }
  60. UnityEngine.Debug.LogError(string.Format("GameStateValueChanged(string key '{0}', object oldValue '{1}', object newValue '{2}')", key, oldValue, newValue));
  61. }
  62. protected void GameStatsValueChanged(string key, object oldValue, object newValue)
  63. {
  64. if (key != null)
  65. {
  66. if (key == "InterstitialsWatched" || key == "InterstitialsClicked" || key == "NumberOfScreenViews")
  67. {
  68. return;
  69. }
  70. }
  71. UnityEngine.Debug.LogErrorFormat("GameStatsValueChanged(string key '{0}', object oldValue '{1}', object newValue '{2}')", new object[]
  72. {
  73. key,
  74. oldValue,
  75. newValue
  76. });
  77. }
  78. protected void DependencyAchievedChanged(Dependency dependency, bool achieved)
  79. {
  80. UnityEngine.Debug.LogError(string.Format("DependencyAchievedChanged(Dependency dependency '{0}', bool achieved '{1}')", dependency.Title ?? dependency.ToString(), achieved));
  81. }
  82. private bool _watchingGameState;
  83. private bool _watchingGameStats;
  84. private bool _watchingDependencyTree;
  85. }