using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using System; using Random = UnityEngine.Random; public class ESpirits_Cook : MonoBehaviour {/* public TextMeshProUGUI text; //剩余串的数量文本 private GameObject dia; //文本框 private Transform cook; //厨子 private Animator ani; //厨子动画 public int chuan; //厨子拥有多少串 //public bool isGood; //厨子是否是好厨子 private float intervalTimePast; public float intervalTimeSell; //卖串的间隔时间 private bool isInterval = false; //开始计算间隔时间 public float minX; //厨子卖串的最小地址站 public float maxX; //厨子卖串的最大地址站 public float value; //加血程度百分比 public GameObject effect; //加血效果 private Enemy ene; //厨子的enemy脚本 private float activeTime; //厨子已出现的时长 public float activeAniTime; //厨子出现动画的时长 private bool isAct = false; //厨子已经完整出现 public float larger; //顾客变大的程度 public List customers; //所有顾客 public Character target; public SearchTrigger searchtrigger; private float destX; private void Start() { cook = transform.parent; ene = cook.GetComponent(); ani = ene.ani; dia = text.transform.parent.gameObject; destX = DestinationX(); text.text = chuan.ToString(); dia.SetActive(false); } private float DestinationX() { float x = Random.Range(minX, maxX); return x; } private void TargetInteract() { target = searchtrigger.GetMinDisTarget(ene.targetTypes, ene.canHitFly); if (target != null) { if (target.gameObject.layer == 7 || target.gameObject.layer == 8 || target.gameObject.layer == 6) { if (!isInterval && chuan > 0) { if (!customers.Exists(T => T == target)) { isInterval = true; chuan -= 1; text.text = chuan.ToString(); ani.Play("Attack_march", 0, 0); if (target.cookEffect == null) { target.cookEffect = Instantiate(effect, target.transform.position, new Quaternion(0, 0, 0, 0), target.transform); } target.HpUp(value, larger); customers.Add(target); //count += 1; //Instantiate(effect, ga.transform.position, new Quaternion(0, 0, 0, 0), ga.transform); if (chuan == 0) { ene.ChangeState(CharacterState.Die); } } } } } } private bool isMove = false; private void Update() { if (!isAct) { if (!isMove) { activeTime += Time.deltaTime; if (activeTime >= activeAniTime) { dia.SetActive(true); isMove = true; ene.canMove = true; } } else { if (transform.position.x >= destX) { dia.SetActive(true); ene.canMove = false; isMove = false; isAct = true; } } } if (isInterval) { intervalTimePast += Time.deltaTime; if (intervalTimePast >= intervalTimeSell) { intervalTimePast = 0; isInterval = false; } } } private void FixedUpdate() { if (isAct) { TargetInteract(); } }*/ }