WXMC/.svn/pristine/e3/e33ec27d5ea8e90c405cdf8a9752d9744e3c4e5a.svn-base
2024-12-04 16:18:46 +08:00

54 lines
1.3 KiB
Plaintext

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PEffect_Collide_HurtUnit : PHomeProjectileCollideEventHandler
{
public float Damage;
public bool FriendlyDamage;
public float PushForce;
public bool OutForce;
public bool DestorySelf;
public override void HandleEvent(ProjectileCollideContext context)
{
if (context.OtherUnit == null)
{
return;
}
if (!FriendlyDamage && !PHomeGameMode.IsEnemy(context.Projectile.Instigator, context.OtherUnit))
{
return;
}
PHomeGameMode.main.DoProjectileAttack(context.Projectile.Instigator, context.OtherUnit, context.Projectile, Damage + context.Projectile.GetWeaponDamage());
AddEnemyForce(context.Projectile, context.OtherUnit);
if (DestorySelf)
{
Destroy(context.Projectile.gameObject);
}
}
private void AddEnemyForce(PHomeProjectileBase projectile, PHomeUnit unit)
{
if (PushForce <= 0)
{
return;
}
Vector3 dir;
if (OutForce)
{
dir = projectile.GetOutDir();
}
else
{
dir = projectile.Mover.Velocity;
}
unit.PhysicsBody.AddForce(dir.normalized * PushForce);
}
}