Slot.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 Lock_;
  29. public int Index;
  30. public bool Available;
  31. public Flower Flower;
  32. public TextMesh TextMesh;
  33. public FlowerInfo FlowerInfo;
  34. public GameObject Icon;
  35. public BoxCollider2D Collider;
  36. #endregion
  37. public override bool RegistImmed()
  38. {
  39. if (base.RegistImmed())
  40. {
  41. return true;
  42. }
  43. enabled = true;
  44. Icon = transform.GetChild(0).gameObject;
  45. Collider = GetComponent<BoxCollider2D>();
  46. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  47. ManaLan.Add(TextMesh, new LanStr("Object", "SlotSign"));
  48. return false;
  49. }
  50. public void Plant(FlowerInfo flowerInfo, bool anim)
  51. {
  52. FlowerInfo = flowerInfo;
  53. Collider.enabled = false;
  54. Available = false;
  55. FlowerInfo.Slot = this;
  56. FlowerInfo.Plant = true;
  57. Flower = ManaReso.GetFlower(flowerInfo, this, true);
  58. if (anim)
  59. {
  60. Flower.PlayParticle();
  61. }
  62. ManaGarden.PlantList.Add(this);
  63. }
  64. public void Retrieve()
  65. {
  66. Collider.enabled = true;
  67. Available = true;
  68. FlowerInfo.Plant = false;
  69. ManaGarden.PlantList.Remove(this);
  70. Flower.Retrieve();
  71. }
  72. }