Files
XMen/Assets/Scripts/Weapons/Bullets/RobotMeshBullet.cs
2025-07-10 14:49:53 +08:00

50 lines
1.5 KiB
C#

using DragonLi.Core;
using DragonLi.Frame;
using Mirror;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RobotMeshBullet : Bullet
{
public override void OnApplyDamage(IDamagable damagable)
{
int id = (int)BulletType.RobotMesh;
int damage = GameManager.Ins.BulletDescInfos[id].Damage[0];
damagable.ApplyDamage(damage, null, transform);
if (ownerIndex != -1)
{
StatisticManager.Ins.AddScore(ownerIndex, damage);
StatisticManager.Ins.AddHitRate(ownerIndex);
}
}
public override void SpawnImpact()
{
// if()
GameObject impactPre = (GameObject)Data["impact_prefab"].ObjectValue;
if (impactPre != null)
{
GameObject impact = Instantiate(impactPre);
impact.transform.position = handlingHit.point;
//impact.transform.localEulerAngles
NetworkServer.Spawn(impact);
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
{
NetworkServer.Destroy(impact);
}, Data["impact_despawn_time"].FloatValue);
// 碰撞点的法线方向
Vector3 normal = handlingHit.normal;
// 在这里处理特效的生成和方向
// 计算特效的旋转方向,使用法线信息
Quaternion rotation = Quaternion.LookRotation(normal);
// 将特效的旋转方向设置为法线方向
impact.transform.rotation = rotation;
}
}
}