Slot.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 int Index;
  27. public bool Available;
  28. public Flower Flower;
  29. public TextMesh TextMesh;
  30. public FlowerInfo FlowerInfo;
  31. public GameObject Icon;
  32. public BoxCollider2D Collider;
  33. #endregion
  34. public override void RegistImmed()
  35. {
  36. enabled = true;
  37. Icon = transform.GetChild(0).gameObject;
  38. Collider = GetComponent<BoxCollider2D>();
  39. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  40. ManaLan.Add(TextMesh, new LanStr("Object", "SlotSign"));
  41. }
  42. public void Plant(FlowerInfo flowerInfo, bool anim)
  43. {
  44. FlowerInfo = flowerInfo;
  45. ID = flowerInfo.ID_;
  46. Collider.enabled = false;
  47. Available = false;
  48. FlowerInfo.Slot = this;
  49. FlowerInfo.Plant = true;
  50. Flower = ManaReso.GetFlower(flowerInfo, this, true);
  51. if (anim)
  52. {
  53. Flower.PlayParticle();
  54. }
  55. ManaGarden.PlantList.Add(this);
  56. }
  57. public void Retrieve()
  58. {
  59. Collider.enabled = true;
  60. Available = true;
  61. FlowerInfo.Plant = false;
  62. ManaReso.Save(Flower);
  63. ManaGarden.PlantList.Remove(this);
  64. for (int i = 0; i < Flower.ElfList.Count; i++)
  65. {
  66. ManaReso.Save(Flower.ElfList[i]);
  67. }
  68. Flower.ElfList = new List<Transform>();
  69. Flower.Award_ = false;
  70. Flower.GoldBk.SetActive(false);
  71. Flower.GoldBk.GetTweenSr().Pause();
  72. Flower.GoldIcon.GetTweenSr().Pause();
  73. Flower.GoldBk.GetTweenSr().InOrigin = true;
  74. Flower.GoldIcon.GetTweenSr().InOrigin = true;
  75. }
  76. }