ESpirits_Cook.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using System;
  6. using Random = UnityEngine.Random;
  7. public class ESpirits_Cook : MonoBehaviour
  8. {/*
  9. public TextMeshProUGUI text; //剩余串的数量文本
  10. private GameObject dia; //文本框
  11. private Transform cook; //厨子
  12. private Animator ani; //厨子动画
  13. public int chuan; //厨子拥有多少串
  14. //public bool isGood; //厨子是否是好厨子
  15. private float intervalTimePast;
  16. public float intervalTimeSell; //卖串的间隔时间
  17. private bool isInterval = false; //开始计算间隔时间
  18. public float minX; //厨子卖串的最小地址站
  19. public float maxX; //厨子卖串的最大地址站
  20. public float value; //加血程度百分比
  21. public GameObject effect; //加血效果
  22. private Enemy ene; //厨子的enemy脚本
  23. private float activeTime; //厨子已出现的时长
  24. public float activeAniTime; //厨子出现动画的时长
  25. private bool isAct = false; //厨子已经完整出现
  26. public float larger; //顾客变大的程度
  27. public List<Character> customers; //所有顾客
  28. public Character target;
  29. public SearchTrigger searchtrigger;
  30. private float destX;
  31. private void Start()
  32. {
  33. cook = transform.parent;
  34. ene = cook.GetComponent<Enemy>();
  35. ani = ene.ani;
  36. dia = text.transform.parent.gameObject;
  37. destX = DestinationX();
  38. text.text = chuan.ToString();
  39. dia.SetActive(false);
  40. }
  41. private float DestinationX()
  42. {
  43. float x = Random.Range(minX, maxX);
  44. return x;
  45. }
  46. private void TargetInteract()
  47. {
  48. target = searchtrigger.GetMinDisTarget(ene.targetTypes, ene.canHitFly);
  49. if (target != null)
  50. {
  51. if (target.gameObject.layer == 7 || target.gameObject.layer == 8 || target.gameObject.layer == 6)
  52. {
  53. if (!isInterval && chuan > 0)
  54. {
  55. if (!customers.Exists(T => T == target))
  56. {
  57. isInterval = true;
  58. chuan -= 1;
  59. text.text = chuan.ToString();
  60. ani.Play("Attack_march", 0, 0);
  61. if (target.cookEffect == null)
  62. {
  63. target.cookEffect = Instantiate(effect, target.transform.position, new Quaternion(0, 0, 0, 0), target.transform);
  64. }
  65. target.HpUp(value, larger);
  66. customers.Add(target);
  67. //count += 1;
  68. //Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform);
  69. if (chuan == 0)
  70. {
  71. ene.ChangeState(CharacterState.Die);
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. private bool isMove = false;
  79. private void Update()
  80. {
  81. if (!isAct)
  82. {
  83. if (!isMove)
  84. {
  85. activeTime += Time.deltaTime;
  86. if (activeTime >= activeAniTime)
  87. {
  88. dia.SetActive(true);
  89. isMove = true;
  90. ene.canMove = true;
  91. }
  92. }
  93. else
  94. {
  95. if (transform.position.x >= destX)
  96. {
  97. dia.SetActive(true);
  98. ene.canMove = false;
  99. isMove = false;
  100. isAct = true;
  101. }
  102. }
  103. }
  104. if (isInterval)
  105. {
  106. intervalTimePast += Time.deltaTime;
  107. if (intervalTimePast >= intervalTimeSell)
  108. {
  109. intervalTimePast = 0;
  110. isInterval = false;
  111. }
  112. }
  113. }
  114. private void FixedUpdate()
  115. {
  116. if (isAct)
  117. {
  118. TargetInteract();
  119. }
  120. }*/
  121. }