Roofen-Game
  • Welcome to Roofen Game
  • Frameworks
    • Common Stat
      • Demo
      • 🚀 Quick Start Guide
      • Runtime
      • Action
      • Formula
      • Examples
      • Debugger
      • FAQ
      • Version Update
      • FutureDirection
    • RToDo
  • Survivors Roguelike Kit
    • Quick Start
    • Core Concepts Overview
      • Scene Concepts
      • Stat Concepts
      • Skill Concepts
    • Adding a New Playable Character
    • Adding a New Enemy
    • Adding a New Stage Configuration
    • Adding a New Map Configuration
    • Adding a New Level
    • Adding a New Attack Skill
    • Adding a New Buff
    • Configuring the Exp System
    • Damage Numbers Display Guide
    • Upcoming Features Preview
    • Release Notes
  • RSOFramework
Powered by GitBook
On this page
  1. Frameworks
  2. Common Stat

Examples

The following is a simple use of the above.

See the demo scenario StatTest in the example for more usage.

namespace RGame
{
    public class BtnOneParmModify : MonoBehaviour
    {
        public CommonStatRuntimeSO ValueSO;

        public string ValueName;
        public bool IsModifyMaxValue;
        public int ModifyValue;
        
        public FormulaCalSO FormulaSO;
        public string ParameterName;
        
        private Button mButton;

        private Dictionary<string, double> ParameterDic = new Dictionary<string, double>();

        private void Start()
        {
            mButton = GetComponent<Button>();
            
            mButton.onClick.AddListener(() =>
            {
                ParameterDic[ParameterName] = ModifyValue;
                ValueSO.ModifyValue(ValueName,FormulaSO.Evaluate(ValueSO,ParameterDic),IsModifyMaxValue);
            });
        }
    }
}

Mount the script and use it!

PreviousFormulaNextDebugger

Last updated 4 months ago