| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- public class CoreCharacter : Character
- {
- [Header("传送门核心")]
- public float totalTime = 10;
- [HideInInspector]
- public float time;
-
- [HideInInspector]
- public string Text;
- public TextMeshProUGUI[] countDown = new TextMeshProUGUI[2];
- public bool isCoutDown; //是否开始倒计时
- public GameObject[] portals = new GameObject[2];
- public GameObject enemyUI;
- private void Update()
- {
- if (isCoutDown)
- {
- time -= Time.deltaTime;
- Text = ((int)time + 1).ToString();
- foreach(TextMeshProUGUI text in countDown)
- {
- text.text = Text;
- }
- if (time < 0)
- {
-
- PortalsDisappear();
- }
- }
- }
- public override void BeHit(int damage)
- {
- hp -= damage;
- uiHp.Show(hp, totalHp);
- if (hp <= 0)
- {
- CoreBreak();
- return;
- }
- }
- //核心被打破
- public void CoreBreak()
- {
- bodyTrans.gameObject.SetActive(false);
- uiHp.gameObject.SetActive(false);
- enemyUI.SetActive(false);
- for (int i = 0; i < countDown.Length; i++)
- {
- if (portals[i].transform.localScale.x < 0)
- {
- Vector3 localScale = countDown[i].transform.localScale;
- localScale.x = -localScale.x;
- }
- countDown[i].gameObject.SetActive(true);
- }
-
- time = totalTime;
- isCoutDown = true;
- }
- public void PortalsDisappear()
- {
- foreach(GameObject portal in portals)
- {
- portal.SetActive(false);
- }
- }
- }
|