Projext/Assets/5.TestScript/Stats.cs
hydrozen1178 620b0e47e9 수정본
카드 ui, 대쉬 , 플레이어 공격 범위 .
2026-02-02 00:49:12 +09:00

63 lines
2.6 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("--- 장착 장비 ---")]
public float weaponDamage; // ⭐ 추가: 무기의 순수 공격력
[Header("--- 밸런스 설정 ---")]
[SerializeField] private float weightToSpeedPenalty = 0.1f;
[SerializeField] private float runSpeedMultiplier = 1.5f;
private float _weightPenalty = 0f;
// ⭐ [추가] 현재 적용 중인 무게 페널티 수치를 외부(UI)에 공개합니다.
public float WeightPenalty => _weightPenalty;
/* =========================
* 실제 게임 로직용 프로퍼티
* ========================= */
public float MaxHealth => baseMaxHealth + bonusMaxHealth;
public float Strength => baseStrength + bonusStrength;
public float BaseAttackDamage => baseAttackDamage + bonusAttackDamage;
public float TotalAttackDamage => BaseAttackDamage + weaponDamage;
public float CurrentMoveSpeed => Mathf.Max(1f, baseMoveSpeed + bonusMoveSpeed - _weightPenalty);
public float CurrentRunSpeed => CurrentMoveSpeed * runSpeedMultiplier;
private void Update()
{
finalMaxHealth = MaxHealth;
finalMoveSpeed = CurrentMoveSpeed;
finalStrength = Strength;
finalAttackDamage = TotalAttackDamage;
}
public void AddBaseLevelUpStats(float hpAdd, float strAdd) { baseMaxHealth += hpAdd; baseStrength += strAdd; }
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;
}