Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

86 righe
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using SUISS.Storage;
  4. using UnityEngine;
  5. public class FreeBuildingReward : IOngoingReward, IStorable
  6. {
  7. public FreeBuildingReward()
  8. {
  9. }
  10. public FreeBuildingReward(string buildingName, int amount)
  11. {
  12. this.BuildingName = buildingName;
  13. this.Amount = amount;
  14. }
  15. public string BuildingName { get; private set; }
  16. public int Amount { get; private set; }
  17. public bool IsActive
  18. {
  19. get
  20. {
  21. return this.Amount > 0;
  22. }
  23. }
  24. public void FromStorage(IDictionary<string, object> dict)
  25. {
  26. this.BuildingName = (string)dict["BuildingName"];
  27. this.Amount = (int)dict["Amount"];
  28. }
  29. public IDictionary<string, object> ToStorage()
  30. {
  31. IDictionary<string, object> dictionary = new Dictionary<string, object>();
  32. dictionary["BuildingName"] = this.BuildingName;
  33. dictionary["Amount"] = this.Amount;
  34. return dictionary;
  35. }
  36. public override string ToString()
  37. {
  38. return string.Format("[FreeBuildingReward] {0}x{1}", this.BuildingName, this.Amount);
  39. }
  40. public void Run()
  41. {
  42. }
  43. public void Claim()
  44. {
  45. if (this.Amount > 0)
  46. {
  47. this.Amount--;
  48. }
  49. else
  50. {
  51. UnityEngine.Debug.LogErrorFormat("Free building reward claimed, but Amount = {0}", new object[]
  52. {
  53. this.Amount
  54. });
  55. }
  56. }
  57. public bool Add(IOngoingReward reward)
  58. {
  59. if (reward is FreeBuildingReward)
  60. {
  61. FreeBuildingReward freeBuildingReward = reward as FreeBuildingReward;
  62. if (freeBuildingReward.BuildingName == this.BuildingName)
  63. {
  64. this.Amount += freeBuildingReward.Amount;
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. public const string BuildingNameKey = "BuildingName";
  71. public const string AmountKey = "Amount";
  72. }