CangJie/Assets/Scripts//ThunderController.cs
lspdC c9c9ab4121 3.24
完成除boss战以外交互,逐步整合美术素材
2022-03-24 22:11:29 +08:00

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();
}
}
}