25 lines
896 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 锤子类,主要判定下攻击
/// </summary>
public class Hammer : MonoBehaviour
{
//当有东西进入触发器
public void OnTriggerEnter2D(Collider2D other){
//看看是不是敌人,再看下它此时能不能被打
if (other.TryGetComponent<Enemy>(out Enemy enemy) && enemy.canBeHit && !other.isTrigger){
enemy.OnBeHit(MyPlayer.AtkMethod.,
(enemy.transform.position.x -
transform.position.x > 0) ? -1 : 1);
//击中成功后中幅度震动一下手柄
StartCoroutine(FindObjectOfType<VibrationManager>().ShakePad(0.5f,0.3f,0.2f,VibrationManager.PadShakeitem.));
//再触发一下子弹时间
FindObjectOfType<VibrationManager>().TimeSlow();
}
}
}