2022-03-21 19:49:15 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Thunder : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
Player player;
|
|
|
|
|
|
|
|
|
|
float interactTime = 2f;
|
|
|
|
|
|
|
|
|
|
bool haveInteracted = false;
|
|
|
|
|
|
2022-03-22 22:15:12 +08:00
|
|
|
|
Animator anim;
|
2022-03-21 19:49:15 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
2022-03-22 22:15:12 +08:00
|
|
|
|
anim = GetComponent<Animator>();
|
2022-03-21 19:49:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
|
{
|
|
|
|
|
if (collision.TryGetComponent<Player>(out player)&&haveInteracted == false) {
|
|
|
|
|
StopPlayerInput();
|
|
|
|
|
Debug.Log("播打雷动画");
|
2022-03-22 22:15:12 +08:00
|
|
|
|
anim.SetTrigger("Active");
|
2022-03-21 19:49:15 +08:00
|
|
|
|
Invoke(nameof(ResetPlayerInput),interactTime);
|
|
|
|
|
haveInteracted = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Debug.Log("未能监测到Player,请检查脑子是否有问题");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StopPlayerInput() {
|
|
|
|
|
player.ToMap("Null");
|
|
|
|
|
}
|
|
|
|
|
public void ResetPlayerInput() {
|
|
|
|
|
player.ToMap("Normal");
|
|
|
|
|
}
|
|
|
|
|
}
|