Slot.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 = "SlotArrorw";
  9. }
  10. public class Slot : Regist
  11. {
  12. #region Config
  13. public int ID
  14. {
  15. get { return FlowerInfo.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 Available
  34. {
  35. get { return Available_; }
  36. set
  37. {
  38. if (value)
  39. {
  40. if (Flower == null)
  41. {
  42. Available_ = value;
  43. }
  44. }
  45. else
  46. {
  47. Available_ = value;
  48. }
  49. }
  50. }
  51. public bool Lock_;
  52. public bool Available_;
  53. public int Index;
  54. public Flower Flower;
  55. public TextMesh TextMesh;
  56. public FlowerInfo FlowerInfo;
  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. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  70. LanguageManager.Add(TextMesh, new MulLanStr(LanguageLabel.Object__SlotSign));
  71. return false;
  72. }
  73. public void Plant(FlowerInfo flowerInfo, bool anim)
  74. {
  75. FlowerInfo = flowerInfo;
  76. Collider.enabled = false;
  77. Available = false;
  78. FlowerInfo.PlantAmt++;
  79. Flower = ResourceManager.GetFlower(flowerInfo, this, true);
  80. if (anim)
  81. {
  82. Flower.PlayFlashLight();
  83. }
  84. GardenManager.PlantList.Add(this);
  85. }
  86. public void Retrieve()
  87. {
  88. Collider.enabled = true;
  89. Available_ = true;
  90. FlowerInfo.PlantAmt--;
  91. GardenManager.PlantList.Remove(this);
  92. Flower.Retrieve();
  93. Flower = null;
  94. }
  95. }