|
- using System;
- using CIG;
- using CIGEnums;
- using SUISS.Core;
-
- public class CityAdvisorBalloonFactory : BalloonFactory
- {
- public CityAdvisorBalloonFactory()
- {
- }
-
- public CityAdvisorBalloonFactory(StorageDictionary storage) : base(storage)
- {
- this._lastAdvice = (AdviceType)storage.Get<int>("LastAdviceType", 0);
- }
-
- public override bool CanProduce()
- {
- if (!base.CanProduce())
- {
- return false;
- }
- SingletonMonobehaviour<CIGCityAdvisor>.Instance.UpdateAdvise();
- if (this._lastAdvice == SingletonMonobehaviour<CIGCityAdvisor>.Instance.AdviceType)
- {
- this._sameAdviceCount++;
- return this._sameAdviceCount < 2;
- }
- this._sameAdviceCount = 0;
- return true;
- }
-
- public override int CoolDownAfterCollectInMinutes
- {
- get
- {
- return 3;
- }
- }
-
- public override int CoolDownAfterShowInMinutes
- {
- get
- {
- return 2;
- }
- }
-
- protected override Balloon CreateBalloonInstance()
- {
- return new CityAdvisorBalloon();
- }
-
- protected override void OnBalloonCollected(Balloon balloon)
- {
- this._lastAdvice = ((CityAdvisorBalloon)balloon).ShownAdvice;
- base.OnBalloonCollected(balloon);
- }
-
- public override StorageDictionary Serialize()
- {
- StorageDictionary storageDictionary = base.Serialize();
- storageDictionary.Set("LastAdviceType", (int)this._lastAdvice);
- return storageDictionary;
- }
-
- private AdviceType _lastAdvice;
-
- private int _sameAdviceCount;
-
- private const string LastAdviceTypeKey = "LastAdviceType";
- }
|