SpiritOutDoor.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SpiritOutDoor : MonoBehaviour
  5. {
  6. public enum spiritQuality
  7. {
  8. blue = 0,
  9. purple = 1,
  10. gold = 2,
  11. }
  12. public enum spiritType
  13. {
  14. spiritFloat = 0,
  15. spiritAssassin = 1,
  16. spiritCook = 2,
  17. spiritInvisible = 3,
  18. }
  19. [System.Serializable]
  20. public struct SpiritInfo
  21. {
  22. public GameObject spiritPrefab;
  23. public spiritType type;
  24. public spiritQuality quality;
  25. public int corpse;
  26. public Sprite introduction;
  27. public int ultimateTimes;
  28. }
  29. public BackDoor doorController;
  30. public List<SpiritInfo> spirits;
  31. public int times = 1;
  32. public GameObject[] qualityBackgrounds;
  33. //public GameObject isLooking1;
  34. //public GameObject isLooking2;
  35. public List<GameObject> outSpirits;
  36. public GameObject poses;
  37. public int maxPos = 6;
  38. static public int curPos;
  39. private void RandomSpirit()
  40. {
  41. int num = spirits.Count;
  42. int r = Random.Range(0, num);
  43. OutSpirit(r);
  44. }
  45. private void OutSpirit(int id)
  46. {
  47. GameObject g = Instantiate(spirits[id].spiritPrefab, poses.transform.GetChild(curPos++).transform.position, new Quaternion(0, 0, 0, 0), null);
  48. if (curPos == maxPos)
  49. {
  50. doorController.canCount = false;
  51. }
  52. outSpirits.Add(g);
  53. Base_Spirits bs = g.GetComponentInChildren<Base_Spirits>();
  54. bs.needCorpse = spirits[id].corpse;
  55. bs.type = (int)spirits[id].type;
  56. bs.ultimateTimes = spirits[id].ultimateTimes;
  57. }
  58. private void OnTriggerEnter(Collider other)
  59. {
  60. if (other.gameObject.layer == 6)
  61. {
  62. times -= 1;
  63. if (times >= 0)
  64. {
  65. doorController.LionDark(times);
  66. RandomSpirit();
  67. if (times == doorController.maxSpirits - 1 && curPos < maxPos)
  68. {
  69. doorController.canCount = true;
  70. }
  71. }
  72. else
  73. {
  74. times = 0;
  75. doorController.col.enabled = false;
  76. }
  77. }
  78. }
  79. }