2
0
Fork 0

命中结算顺序

master
cd 2 years ago
parent c7610dd9cf
commit 89c34dd034

@ -1609,6 +1609,8 @@ PlayableDirector:
value: {fileID: 5972941309607553105} value: {fileID: 5972941309607553105}
- key: {fileID: -4750574827767443630, guid: 027ab2f5cd4c9d244bad141e093bf72d, type: 2} - key: {fileID: -4750574827767443630, guid: 027ab2f5cd4c9d244bad141e093bf72d, type: 2}
value: {fileID: 1645380337361164335} value: {fileID: 1645380337361164335}
- key: {fileID: 2359698281133013487, guid: cb6c8d06eac093640ad53452562b8da0, type: 2}
value: {fileID: 1645380337361164335}
m_ExposedReferences: m_ExposedReferences:
m_References: [] m_References: []
--- !u!212 &89448210413526911 --- !u!212 &89448210413526911

@ -36,7 +36,7 @@ namespace Game
{ {
entity.pause.PauseTime = pauseTime; entity.pause.PauseTime = pauseTime;
entity.pause.PausePreFrame = 1; entity.pause.PausePreFrame = 1;
Util.EntityStopMove(entity.ID()); EntityStopMove(entity.ID());
} }
} }
} }

@ -12,7 +12,7 @@ public class SkillComponent : IComponent
public Vector3 CastDir; //技能释放方向 public Vector3 CastDir; //技能释放方向
public HashSet<Tuple<int, int>> HitSet = new HashSet<Tuple<int, int>>(); //技能命中信息 生命周期为一次技能释放 public HashSet<Tuple<int, int>> HitSet = new HashSet<Tuple<int, int>>(); //技能命中信息 生命周期为一次技能释放
public List<SkillHitInfo> HitInfo = new List<SkillHitInfo>(); //受击命中信息 结算时清空 public Queue<SkillHitInfo> HitInfo = new Queue<SkillHitInfo>(); //技能命中结算队列
} }
namespace Game namespace Game
@ -63,6 +63,7 @@ namespace Game
{ {
var skill = entity.skill; var skill = entity.skill;
skill.HitSet.Clear(); skill.HitSet.Clear();
skill.HitInfo.Clear();
skill.IsRunning = false; skill.IsRunning = false;
skill.SkillId.Value = ""; skill.SkillId.Value = "";
} }

@ -34,21 +34,22 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
private static void SettleSkill(SkillComponent skill) private static void SettleSkill(SkillComponent skill)
{ {
foreach (var hitInfo in skill.HitInfo) while (skill.HitInfo.Count > 0)
{ {
SettleHit(hitInfo); if (SettleHit(skill.HitInfo.Dequeue()))
{
break;
}
} }
skill.HitInfo.Clear();
} }
private static void SettleHit(SkillHitInfo hitInfo) private static bool SettleHit(SkillHitInfo hitInfo)
{ {
var entity = Util.GetEntity(hitInfo.OwnerEntity); var entity = Util.GetEntity(hitInfo.OwnerEntity);
var target = Util.GetEntity(hitInfo.HitEntity); var target = Util.GetEntity(hitInfo.HitEntity);
if (entity == null || target == null) if (entity == null || target == null)
{ {
return; return false;
} }
var damageResult = SettleDamage(hitInfo, entity, target); //伤害结算 var damageResult = SettleDamage(hitInfo, entity, target); //伤害结算
@ -67,6 +68,8 @@ public class SettleSystem : IExecuteSystem, IInitializeSystem
SettleShake(hitLevel, entity, target); //抖动 SettleShake(hitLevel, entity, target); //抖动
SettleScale(flowSpeed, entity, target); //抖动 SettleScale(flowSpeed, entity, target); //抖动
SettleGlobalEffect(target, pauseTime); //全局特效 SettleGlobalEffect(target, pauseTime); //全局特效
return true;
} }
public struct SettleDamageResult public struct SettleDamageResult

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace Game namespace Game
@ -18,6 +19,7 @@ namespace Game
public class ClipAttack : TimelineClipBase public class ClipAttack : TimelineClipBase
{ {
private AttackClip _mRealAsset; private AttackClip _mRealAsset;
private List<GameEntity> _tempTargetList = new List<GameEntity>();
public override void OnEnter() public override void OnEnter()
{ {
@ -29,23 +31,33 @@ namespace Game
var param = _mRealAsset.template; var param = _mRealAsset.template;
var skill = Owner.skill; var skill = Owner.skill;
var castShape = param.Shape; var castShape = param.Shape;
var castDir = Owner.skill.CastDir; var castDir = skill.CastDir;
castDir = new Vector3(castDir.x, 0, castDir.z); //忽略y castDir = new Vector3(castDir.x, 0, castDir.z); //忽略y
var rot = Quaternion.FromToRotation(Vector3.right, castDir); var rot = Quaternion.FromToRotation(Vector3.right, castDir);
var castPos = rot * castShape.Offset + Owner.Pos(); var castPos = rot * castShape.Offset + Owner.Pos();
Util.DrawShape(castShape, castPos, castDir, Color.red); Util.DrawShape(castShape, castPos, castDir, Color.red);
_tempTargetList.Clear();
Util.ForeachEnemies(Owner.Team(), target => Util.ForeachEnemies(Owner.Team(), target =>
{ {
var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos()); var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos());
if (!isHit) return; if (!isHit) return;
var targetID = target.ID(); var hitKey = new Tuple<int, int>(target.ID(), param.hitId);
if (skill.HitSet.Contains(hitKey)) return;
var hitKey = new Tuple<int, int>(targetID, param.hitId); skill.HitSet.Add(hitKey);
if (Owner.skill.HitSet.Contains(hitKey)) return;
Owner.skill.HitSet.Add(hitKey);
_tempTargetList.Add(target);
});
_tempTargetList.Sort((l, r) =>
{
var lRank = GetRank(param.hitDirType, l, castPos, castDir);
var rRank = GetRank(param.hitDirType, r, castPos, castDir);
return lRank.CompareTo(rRank);
});
foreach (var target in _tempTargetList)
{
var targetID = target.ID();
var skillHitInfo = new SkillHitInfo var skillHitInfo = new SkillHitInfo
{ {
SkillParam = param, SkillParam = param,
@ -68,12 +80,41 @@ namespace Game
} }
} }
target.skill.HitInfo.Add(skillHitInfo); skill.HitInfo.Enqueue(skillHitInfo);
}); }
}
private float GetRank(EHitDirType hitDirType, GameEntity target, Vector3 castPos, Vector3 castDir)
{
//小在前
var targetPos = target.Pos();
var targetDir = targetPos - castPos;
switch (hitDirType)
{
case EHitDirType.Center:
//按距离
return Vector3.Distance(targetPos, castPos);
case EHitDirType.Backward:
//从前往后
return -Vector3.Dot(targetDir, castDir);
case EHitDirType.Forward:
//从后往前
return Vector3.Dot(targetDir, castDir);
case EHitDirType.Clockwise:
//顺时针
return -GetRankRot(castDir, targetDir);
case EHitDirType.CounterClockwise:
//逆时针
return GetRankRot(castDir, targetDir);
}
return 0;
} }
public override void OnLeave() private float GetRankRot(Vector3 castDir, Vector3 targetDir)
{ {
var rot = Quaternion.FromToRotation(-castDir, Vector3.right);
return Util.Vec3ToRot(rot * targetDir) * (Owner.move.IsRight ? 1 : -1);
} }
} }
} }

@ -34,7 +34,7 @@ namespace Game
var owner = buffData.Entity; var owner = buffData.Entity;
var target = buffData.Target; var target = buffData.Target;
target.skill.HitInfo.Add(new SkillHitInfo() owner.skill.HitInfo.Enqueue(new SkillHitInfo()
{ {
SkillParam = new AttackBehaviour() SkillParam = new AttackBehaviour()
{ {

@ -6,7 +6,7 @@ namespace Game
public static class GameSetting public static class GameSetting
{ {
public static Dictionary<EFunctionKey, KeyCode> KeyMap; public static Dictionary<EFunctionKey, KeyCode> KeyMap;
public static bool IsDebugDraw = false; public static bool IsDebugDraw = true;
public static bool IsMasterControllable = true; public static bool IsMasterControllable = true;
public static bool IsShowExtraHeadBar = true; public static bool IsShowExtraHeadBar = true;
public static void Load() public static void Load()

File diff suppressed because it is too large Load Diff

@ -721,12 +721,13 @@ MonoBehaviour:
pauseTime: 20 pauseTime: 20
hitId: 0 hitId: 0
hitType: 0 hitType: 0
Type: 2 hitDirType: 3
Type: 1
Offset: {x: 0, y: 0, z: 0} Offset: {x: 0, y: 0, z: 0}
Height: 2 Height: 2
SizeX: 10 SizeX: 2
SizeY: 2 SizeY: 2
Radius: 4 Radius: 50
Angle: 180 Angle: 180
--- !u!114 &5178577764301111608 --- !u!114 &5178577764301111608
MonoBehaviour: MonoBehaviour:

@ -15,6 +15,7 @@ public class AttackBehaviour : PlayableBehaviour
[Rename("卡帧时间(帧)")] public int pauseTime; [Rename("卡帧时间(帧)")] public int pauseTime;
[Rename("命中id")] public int hitId; //同一hitId视为一段伤害 [Rename("命中id")] public int hitId; //同一hitId视为一段伤害
[Rename("伤害类型")] public EHitType hitType; [Rename("伤害类型")] public EHitType hitType;
[Rename("攻击方向")] public EHitDirType hitDirType;
[Rename("命中形状")] public EShapeType Type; [Rename("命中形状")] public EShapeType Type;
[Rename("偏移(格)")] public Vector3 Offset; [Rename("偏移(格)")] public Vector3 Offset;
[Rename("高度(格)")] public float Height; [Rename("高度(格)")] public float Height;

Loading…
Cancel
Save