Slot.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.UI;
  5. public class Slot : Regist
  6. {
  7. #region 变量
  8. public bool Valid
  9. {
  10. get { return _Valid; }
  11. set
  12. {
  13. _Valid = value;
  14. if (_Valid)
  15. {
  16. Icon.SetActive(false);
  17. }
  18. else
  19. {
  20. Icon.SetActive(true);
  21. }
  22. }
  23. }
  24. private bool _Valid;
  25. public int ID;
  26. public bool Available;
  27. public Flower Flower;
  28. public TextMesh TextMesh;
  29. public FlowerInfo FlowerInfo;
  30. public GameObject Icon;
  31. public BoxCollider2D Collider;
  32. #endregion
  33. public override void RegistImmed()
  34. {
  35. enabled = true;
  36. Icon = transform.GetChild(0).gameObject;
  37. Collider = GetComponent<BoxCollider2D>();
  38. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  39. ManaLan.Add(TextMesh, new LanStr("Object", "SlotSign"));
  40. }
  41. public void Plant(FlowerInfo flowerInfo, bool anim)
  42. {
  43. FlowerInfo = flowerInfo;
  44. ID = flowerInfo.ID_;
  45. Collider.enabled = false;
  46. Available = false;
  47. FlowerInfo.Slot = this;
  48. FlowerInfo.Plant = true;
  49. Flower = ManaReso.GetFlower(flowerInfo, this, true);
  50. if (anim)
  51. {
  52. Flower.PlayParticle();
  53. }
  54. ManaGarden.PlantList.Add(this);
  55. }
  56. public void Retrieve()
  57. {
  58. Collider.enabled = true;
  59. Available = true;
  60. FlowerInfo.Plant = false;
  61. ManaReso.Save(Flower);
  62. ManaGarden.PlantList.Remove(this);
  63. }
  64. }