Slot.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class SlotLabel
  6. {
  7. public static string Slot = "Slot";
  8. public static string SlotArrow = "SlotArrow";
  9. }
  10. public class Slot : Regist
  11. {
  12. #region Config
  13. public int ID
  14. {
  15. get { return PlantFlowerInfo.ID; }
  16. }
  17. public bool Lock
  18. {
  19. get { return lock_; }
  20. set
  21. {
  22. lock_ = value;
  23. if (lock_)
  24. {
  25. Icon.SetActive(false);
  26. }
  27. else
  28. {
  29. Icon.SetActive(true);
  30. }
  31. }
  32. }
  33. public bool lock_;
  34. public bool Available
  35. {
  36. get { return available; }
  37. set
  38. {
  39. if (value)
  40. {
  41. if (PlantFlower == null)
  42. {
  43. available = value;
  44. }
  45. }
  46. else
  47. {
  48. available = value;
  49. }
  50. }
  51. }
  52. public bool available;
  53. public int Index;
  54. public Flower PlantFlower;
  55. public TextMesh StatusTextMesh;
  56. public FlowerInfo PlantFlowerInfo;
  57. public GameObject Icon;
  58. public BoxCollider2D Collider;
  59. #endregion
  60. public override bool InitAtOnce()
  61. {
  62. if (base.InitAtOnce())
  63. {
  64. return true;
  65. }
  66. enabled = true;
  67. Icon = transform.GetChild(0).gameObject;
  68. Collider = GetComponent<BoxCollider2D>();
  69. StatusTextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  70. LanguageManager.Add(StatusTextMesh, new MulLanStr(LanguageLabel.Object__SlotSign));
  71. return false;
  72. }
  73. public void Plant(FlowerInfo flowerInfo, bool anim)
  74. {
  75. PlantFlowerInfo = flowerInfo;
  76. Collider.enabled = false;
  77. Available = false;
  78. PlantFlowerInfo.PlantAmt++;
  79. PlantFlower = ResourceManager.GetFlower(flowerInfo, this, true);
  80. if (anim)
  81. {
  82. PlantFlower.PlayFlashLight();
  83. }
  84. GardenManager.PlantSlotList.Add(this);
  85. }
  86. public void Retrieve()
  87. {
  88. Collider.enabled = true;
  89. available = true;
  90. PlantFlowerInfo.PlantAmt--;
  91. GardenManager.PlantSlotList.Remove(this);
  92. PlantFlower.RetrieveFlower();
  93. PlantFlower = null;
  94. }
  95. }