65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Stats : MonoBehaviour
|
|
{
|
|
[Header("--- 기본 능력치 ---")]
|
|
[SerializeField] private float baseMaxHealth = 100f;
|
|
[SerializeField] private float baseMoveSpeed = 5f;
|
|
[SerializeField] private float baseStrength = 10f;
|
|
[SerializeField] private float baseAttackDamage = 10f;
|
|
|
|
[Header("--- 보너스 능력치 ---")]
|
|
public float bonusMaxHealth;
|
|
public float bonusMoveSpeed;
|
|
public float bonusStrength;
|
|
public float bonusAttackDamage;
|
|
|
|
[Header("--- 밸런스 설정 ---")]
|
|
[SerializeField] private float weightToSpeedPenalty = 0.1f;
|
|
[SerializeField] private float runSpeedMultiplier = 1.5f;
|
|
private float _weightPenalty = 0f;
|
|
|
|
/* =========================
|
|
* 실제 게임 로직용 프로퍼티
|
|
* ========================= */
|
|
public float MaxHealth => baseMaxHealth + bonusMaxHealth;
|
|
public float Strength => baseStrength + bonusStrength;
|
|
public float BaseAttackDamage => baseAttackDamage + bonusAttackDamage;
|
|
|
|
// ⭐ [에러 해결] PlayerMovement.cs에서 사용하는 속도 프로퍼티
|
|
public float CurrentMoveSpeed => Mathf.Max(1f, baseMoveSpeed + bonusMoveSpeed - _weightPenalty);
|
|
public float CurrentRunSpeed => CurrentMoveSpeed * runSpeedMultiplier;
|
|
|
|
private void Update()
|
|
{
|
|
// 인스펙터 실시간 표시용 (Read Only)
|
|
finalMaxHealth = MaxHealth;
|
|
finalMoveSpeed = CurrentMoveSpeed;
|
|
finalStrength = Strength;
|
|
finalAttackDamage = BaseAttackDamage;
|
|
}
|
|
|
|
// ⭐ 레벨업 시 기초 능력치 영구 상승
|
|
public void AddBaseLevelUpStats(float hpAdd, float strAdd)
|
|
{
|
|
baseMaxHealth += hpAdd;
|
|
baseStrength += strAdd;
|
|
Debug.Log($"[Stats] 기초 스탯 상승 완료! 최대 체력: {MaxHealth}");
|
|
}
|
|
|
|
public void AddMaxHealth(float value) => bonusMaxHealth += value;
|
|
public void AddMoveSpeed(float value) => bonusMoveSpeed += value;
|
|
public void AddStrength(float value) => bonusStrength += value;
|
|
public void AddAttackDamage(float value) => bonusAttackDamage += value;
|
|
|
|
public void UpdateWeaponWeight(float requiredStrength) => _weightPenalty = requiredStrength * weightToSpeedPenalty;
|
|
public void ResetWeight() => _weightPenalty = 0f;
|
|
|
|
[Header("--- 최종 능력치 (Read Only) ---")]
|
|
[SerializeField] private float finalMaxHealth;
|
|
[SerializeField] private float finalMoveSpeed;
|
|
[SerializeField] private float finalStrength;
|
|
[SerializeField] private float finalAttackDamage;
|
|
} |