59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
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<HittenStone>(out HittenStone stone)) {
|
|
Debug.Log("播放石头爆炸特效,停止打雷");
|
|
Destroy(stone.gameObject);
|
|
controller.gameObject.SetActive(false);
|
|
ifFinal = true;
|
|
}
|
|
|
|
if (collision.TryGetComponent<Player>(out player)&&ifHit == false) {
|
|
ifHit = true;
|
|
|
|
player.GetHurt(1,0.5f,transform.position.x);
|
|
Debug.Log("被雷打");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|