using System.Collections; using System.Collections.Generic; using UnityEngine; public class ThunderAtk : MonoBehaviour { public Player player; public ThunderController controller; bool ifHit = false; bool ifFinal = false; void Start() { player = (Player)GameObject.FindObjectOfType(typeof(Player)); controller = (ThunderController)GameObject.FindObjectOfType(typeof(ThunderController)); } // Update is called once per frame void Update() { } public void LightAtk() { //Debug.Log("打雷咯"); } public void DesTroyThunder() { Destroy(gameObject); } public void Next() { if(ifFinal==false) controller.NextLightAtk(); } private void OnTriggerEnter2D(Collider2D collision) { if (collision.TryGetComponent(out HittenStone stone)) { Debug.Log("播放石头爆炸特效,停止打雷"); Destroy(stone.gameObject); controller.gameObject.SetActive(false); ifFinal = true; } if (collision.TryGetComponent(out player)&&ifHit == false) { ifHit = true; player.GetHurt(1,0.5f,transform.position.x); Debug.Log("被雷打"); } } }