[Network] 스킬 시스템 네트워크 동기화 및 로그 정리
- 스킬 실행 RequestSkillExecutionRpc (Client -> Server) - 스킬 전파 BroadcastSkillExecutionRpc (Server -> All Clients) - 서버에서 마나/쿨타임 검증 - NormalizeTime 디버그 로그 제거
This commit is contained in:
@@ -97,26 +97,73 @@ namespace Colosseum.Player
|
||||
return;
|
||||
}
|
||||
|
||||
// 로컬 체크 (빠른 피드백용)
|
||||
if (skillController.IsExecutingSkill)
|
||||
{
|
||||
Debug.Log($"Already executing skill");
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillController.IsOnCooldown(skill))
|
||||
{
|
||||
Debug.Log($"Skill {skill.SkillName} is on cooldown");
|
||||
return;
|
||||
}
|
||||
|
||||
// 마나 비용 체크
|
||||
if (networkController != null && networkController.Mana < skill.ManaCost)
|
||||
{
|
||||
Debug.Log($"Not enough mana for skill: {skill.SkillName} (Required: {skill.ManaCost}, Current: {networkController.Mana})");
|
||||
Debug.Log($"Not enough mana for skill: {skill.SkillName}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 논타겟: 타겟 없이 스킬 시전
|
||||
bool success = skillController.ExecuteSkill(skill);
|
||||
if (!success)
|
||||
{
|
||||
Debug.Log($"Cannot execute skill: {skill.SkillName}");
|
||||
return;
|
||||
}
|
||||
// 서버에 스킬 실행 요청
|
||||
RequestSkillExecutionRpc(slotIndex);
|
||||
}
|
||||
|
||||
// 스킬 성공 시 마나 소모
|
||||
/// <summary>
|
||||
/// 서버에 스킬 실행 요청
|
||||
/// </summary>
|
||||
[Rpc(SendTo.Server)]
|
||||
private void RequestSkillExecutionRpc(int slotIndex)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= skillSlots.Length)
|
||||
return;
|
||||
|
||||
SkillData skill = skillSlots[slotIndex];
|
||||
if (skill == null) return;
|
||||
|
||||
// 서버에서 다시 검증
|
||||
if (skillController.IsExecutingSkill || skillController.IsOnCooldown(skill))
|
||||
return;
|
||||
|
||||
if (networkController != null && networkController.Mana < skill.ManaCost)
|
||||
return;
|
||||
|
||||
// 마나 소모
|
||||
if (networkController != null && skill.ManaCost > 0)
|
||||
{
|
||||
networkController.UseManaRpc(skill.ManaCost);
|
||||
}
|
||||
|
||||
// 모든 클라이언트에 스킬 실행 전파
|
||||
BroadcastSkillExecutionRpc(slotIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 모든 클라이언트에 스킬 실행 전파
|
||||
/// </summary>
|
||||
[Rpc(SendTo.ClientsAndHost)]
|
||||
private void BroadcastSkillExecutionRpc(int slotIndex)
|
||||
{
|
||||
if (slotIndex < 0 || slotIndex >= skillSlots.Length)
|
||||
return;
|
||||
|
||||
SkillData skill = skillSlots[slotIndex];
|
||||
if (skill == null) return;
|
||||
|
||||
// 모든 클라이언트에서 스킬 실행 (애니메이션 포함)
|
||||
skillController.ExecuteSkill(skill);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user