|
- using System;
- using System.Collections.Generic;
- using SUISS.Storage;
- using UnityEngine;
-
- public class FreeBuildingReward : IOngoingReward, IStorable
- {
- public FreeBuildingReward()
- {
- }
-
- public FreeBuildingReward(string buildingName, int amount)
- {
- this.BuildingName = buildingName;
- this.Amount = amount;
- }
-
- public string BuildingName { get; private set; }
-
- public int Amount { get; private set; }
-
- public bool IsActive
- {
- get
- {
- return this.Amount > 0;
- }
- }
-
- public void FromStorage(IDictionary<string, object> dict)
- {
- this.BuildingName = (string)dict["BuildingName"];
- this.Amount = (int)dict["Amount"];
- }
-
- public IDictionary<string, object> ToStorage()
- {
- IDictionary<string, object> dictionary = new Dictionary<string, object>();
- dictionary["BuildingName"] = this.BuildingName;
- dictionary["Amount"] = this.Amount;
- return dictionary;
- }
-
- public override string ToString()
- {
- return string.Format("[FreeBuildingReward] {0}x{1}", this.BuildingName, this.Amount);
- }
-
- public void Run()
- {
- }
-
- public void Claim()
- {
- if (this.Amount > 0)
- {
- this.Amount--;
- }
- else
- {
- UnityEngine.Debug.LogErrorFormat("Free building reward claimed, but Amount = {0}", new object[]
- {
- this.Amount
- });
- }
- }
-
- public bool Add(IOngoingReward reward)
- {
- if (reward is FreeBuildingReward)
- {
- FreeBuildingReward freeBuildingReward = reward as FreeBuildingReward;
- if (freeBuildingReward.BuildingName == this.BuildingName)
- {
- this.Amount += freeBuildingReward.Amount;
- return true;
- }
- }
- return false;
- }
-
- public const string BuildingNameKey = "BuildingName";
-
- public const string AmountKey = "Amount";
- }
|