CangJie/Assets/Scripts//Thunder.cs
lspdC 2a2a11e851 3.22
完成了跟踪雷击与玩家的碰撞判定,玩家的受击反馈
击碎石头那边还有bug,明天再改
2022-03-22 22:15:12 +08:00

44 lines
947 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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