2021-11-28 23:34:14 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2021-12-01 19:14:21 +08:00
|
|
|
/// <summary>
|
|
|
|
/// 锤子类,主要判定下攻击
|
|
|
|
/// </summary>
|
2021-11-28 23:34:14 +08:00
|
|
|
public class Hammer : MonoBehaviour
|
|
|
|
{
|
2021-12-01 19:14:21 +08:00
|
|
|
//当有东西进入触发器
|
|
|
|
public void OnTriggerEnter2D(Collider2D other){
|
2021-12-03 23:58:34 +08:00
|
|
|
//看看是不是敌人,再看下它此时能不能被打
|
|
|
|
if (other.TryGetComponent<Enemy>(out Enemy enemy) && enemy.canBeHit && !other.isTrigger){
|
|
|
|
enemy.OnBeHit(MyPlayer.AtkMethod.锤子,
|
|
|
|
(enemy.transform.position.x -
|
2021-12-01 19:14:21 +08:00
|
|
|
transform.position.x > 0) ? -1 : 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-28 23:34:14 +08:00
|
|
|
}
|