54 lines
1.3 KiB
Plaintext
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);
|
|
}
|
|
}
|