Slot.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. if (RegistFlag)
  37. {
  38. return;
  39. }
  40. else
  41. {
  42. RegistFlag = true;
  43. }
  44. enabled = true;
  45. Icon = transform.GetChild(0).gameObject;
  46. Collider = GetComponent<BoxCollider2D>();
  47. TextMesh = transform.GetChild(0).GetChild(0).GetComponent<TextMesh>();
  48. ManaLan.Add(TextMesh, new LanStr("Object", "SlotSign"));
  49. }
  50. public void Plant(FlowerInfo flowerInfo, bool anim)
  51. {
  52. FlowerInfo = flowerInfo;
  53. ID = flowerInfo.ID_;
  54. Collider.enabled = false;
  55. Available = false;
  56. FlowerInfo.Slot = this;
  57. FlowerInfo.Plant = true;
  58. Flower = ManaReso.GetFlower(flowerInfo, this, true);
  59. if (anim)
  60. {
  61. Flower.PlayParticle();
  62. }
  63. ManaGarden.PlantList.Add(this);
  64. }
  65. public void Retrieve()
  66. {
  67. Collider.enabled = true;
  68. Available = true;
  69. FlowerInfo.Plant = false;
  70. ManaReso.Save(Flower);
  71. ManaGarden.PlantList.Remove(this);
  72. for (int i = 0; i < Flower.ElfList.Count; i++)
  73. {
  74. ManaReso.Save(Flower.ElfList[i]);
  75. }
  76. Flower.ElfList = new List<Transform>();
  77. Flower.Award_ = false;
  78. Flower.GoldBk.SetActive(false);
  79. Flower.GoldBk.GetTweenSr().Pause();
  80. Flower.GoldIcon.GetTweenSr().Pause();
  81. Flower.GoldBk.GetTweenSr().InOrigin = true;
  82. Flower.GoldIcon.GetTweenSr().InOrigin = true;
  83. }
  84. }