Slot.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class Slot : Regist
  6. {
  7. #region 变量
  8. public int ID
  9. {
  10. get { return FlowerInfo.ID_; }
  11. }
  12. public bool Lock
  13. {
  14. get { return Lock_; }
  15. set
  16. {
  17. Lock_ = value;
  18. if (Lock_)
  19. {
  20. Icon.SetActive(false);
  21. }
  22. else
  23. {
  24. Icon.SetActive(true);
  25. }
  26. }
  27. }
  28. public bool Available
  29. {
  30. get { return Available_; }
  31. set
  32. {
  33. if (value)
  34. {
  35. if (Flower == null)
  36. {
  37. Available_ = value;
  38. }
  39. }
  40. else
  41. {
  42. Available_ = value;
  43. }
  44. }
  45. }
  46. public bool Lock_;
  47. public bool Available_;
  48. public int Index;
  49. public Flower Flower;
  50. public TextMesh TextMesh;
  51. public FlowerInfo FlowerInfo;
  52. public GameObject Icon;
  53. public BoxCollider2D Collider;
  54. #endregion
  55. public override bool RegistImmed()
  56. {
  57. if (base.RegistImmed())
  58. {
  59. return true;
  60. }
  61. enabled = true;
  62. Icon = transform.GetChild(0).gameObject;
  63. Collider = GetComponent<BoxCollider2D>();
  64. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  65. ManaLan.Add(TextMesh, new LanStr("Object", "SlotSign"));
  66. return false;
  67. }
  68. public void Plant(FlowerInfo flowerInfo, bool anim)
  69. {
  70. FlowerInfo = flowerInfo;
  71. Collider.enabled = false;
  72. Available = false;
  73. FlowerInfo.Slot = this;
  74. FlowerInfo.Plant = true;
  75. Flower = ManaReso.GetFlower(flowerInfo, this, true);
  76. if (anim)
  77. {
  78. Flower.PlayParticle();
  79. }
  80. ManaGarden.PlantList.Add(this);
  81. }
  82. public void Retrieve()
  83. {
  84. Collider.enabled = true;
  85. Available_ = true;
  86. FlowerInfo.Plant = false;
  87. ManaGarden.PlantList.Remove(this);
  88. Flower.Retrieve();
  89. }
  90. }