You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

73 regels
1.5 KiB

  1. using System;
  2. using CIG;
  3. using CIGEnums;
  4. using SUISS.Core;
  5. public class CityAdvisorBalloonFactory : BalloonFactory
  6. {
  7. public CityAdvisorBalloonFactory()
  8. {
  9. }
  10. public CityAdvisorBalloonFactory(StorageDictionary storage) : base(storage)
  11. {
  12. this._lastAdvice = (AdviceType)storage.Get<int>("LastAdviceType", 0);
  13. }
  14. public override bool CanProduce()
  15. {
  16. if (!base.CanProduce())
  17. {
  18. return false;
  19. }
  20. SingletonMonobehaviour<CIGCityAdvisor>.Instance.UpdateAdvise();
  21. if (this._lastAdvice == SingletonMonobehaviour<CIGCityAdvisor>.Instance.AdviceType)
  22. {
  23. this._sameAdviceCount++;
  24. return this._sameAdviceCount < 2;
  25. }
  26. this._sameAdviceCount = 0;
  27. return true;
  28. }
  29. public override int CoolDownAfterCollectInMinutes
  30. {
  31. get
  32. {
  33. return 3;
  34. }
  35. }
  36. public override int CoolDownAfterShowInMinutes
  37. {
  38. get
  39. {
  40. return 2;
  41. }
  42. }
  43. protected override Balloon CreateBalloonInstance()
  44. {
  45. return new CityAdvisorBalloon();
  46. }
  47. protected override void OnBalloonCollected(Balloon balloon)
  48. {
  49. this._lastAdvice = ((CityAdvisorBalloon)balloon).ShownAdvice;
  50. base.OnBalloonCollected(balloon);
  51. }
  52. public override StorageDictionary Serialize()
  53. {
  54. StorageDictionary storageDictionary = base.Serialize();
  55. storageDictionary.Set("LastAdviceType", (int)this._lastAdvice);
  56. return storageDictionary;
  57. }
  58. private AdviceType _lastAdvice;
  59. private int _sameAdviceCount;
  60. private const string LastAdviceTypeKey = "LastAdviceType";
  61. }