71 lines
1.7 KiB
C#
71 lines
1.7 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEditor.U2D.Animation;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.PlayerLoop;
|
|||
|
|
|
|||
|
|
|
|||
|
|
[System.Serializable]
|
|||
|
|
public class PlayerStat
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
[SerializeField] private float baseValue;
|
|||
|
|
|
|||
|
|
private float _value;
|
|||
|
|
private bool _isChange = true;
|
|||
|
|
|
|||
|
|
private List<float> modifiers = new List<float>();
|
|||
|
|
|
|||
|
|
public PlayerStat(float baseValue)
|
|||
|
|
{
|
|||
|
|
this.baseValue = baseValue;
|
|||
|
|
}
|
|||
|
|
private float CalculStat()
|
|||
|
|
{
|
|||
|
|
float finalValue = baseValue;
|
|||
|
|
foreach(float m in modifiers)
|
|||
|
|
{
|
|||
|
|
_value += m;
|
|||
|
|
}
|
|||
|
|
return finalValue;
|
|||
|
|
}
|
|||
|
|
public float fvalue
|
|||
|
|
{
|
|||
|
|
get { return fvalue; }
|
|||
|
|
}
|
|||
|
|
public int ivalue
|
|||
|
|
{
|
|||
|
|
get { return ivalue; }
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public class PlayerBase : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
[Header("Character Data")]
|
|||
|
|
[SerializeField] private CharacterStat characterStat;
|
|||
|
|
public PlayerStat playerMaxSpeed;
|
|||
|
|
public PlayerStat playerJumpPower;
|
|||
|
|
public PlayerStat playerMaxJumpCount;
|
|||
|
|
public PlayerStat playerHp;
|
|||
|
|
public PlayerStat playerStamina;
|
|||
|
|
void Awake()
|
|||
|
|
{
|
|||
|
|
if (characterStat == null)
|
|||
|
|
{
|
|||
|
|
Debug.LogError("Character Data<74><61> <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
InitializeStat();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public void InitializeStat()
|
|||
|
|
{
|
|||
|
|
playerMaxSpeed = new PlayerStat(characterStat.playerMaxSpeed);
|
|||
|
|
playerJumpPower = new PlayerStat(characterStat.playerJumpPower);
|
|||
|
|
playerMaxJumpCount = new PlayerStat(characterStat.playerMaxJumpCount);
|
|||
|
|
playerHp = new PlayerStat(characterStat.playerHp);
|
|||
|
|
playerStamina = new PlayerStat(characterStat.playerStamina);
|
|||
|
|
}
|
|||
|
|
}
|