46 lines
1006 B
C#
46 lines
1006 B
C#
![]() |
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ThunderController : MonoBehaviour
|
||
|
{
|
||
|
public ThunderAtk thunderAtk;
|
||
|
Player player;
|
||
|
public float frequency = 2f;
|
||
|
bool ifStart = false;
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
player = (Player)GameObject.FindObjectOfType(typeof(Player));
|
||
|
//InitThunder();
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public void NextLightAtk() {
|
||
|
Invoke(nameof(InitThunder),frequency);
|
||
|
}
|
||
|
|
||
|
void InitThunder() {
|
||
|
if (ifStart) {
|
||
|
ThunderAtk atk;
|
||
|
atk = Instantiate(thunderAtk,new Vector3(player.transform.position.x,0,0), Quaternion.identity);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OnTriggerEnter2D(Collider2D collision)
|
||
|
{
|
||
|
if (collision.gameObject.tag=="Player" && ifStart == false)
|
||
|
{
|
||
|
ifStart = true;
|
||
|
InitThunder();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|