Giter VIP home page Giter VIP logo

numericsystem's Introduction

NumericSystem

A flexible, generalized numerical system for computing game values.

Install

使用方法

Numeric

basicValue

某一属性的基础值,可读,可写,用于写入永久数值变化

finalValue

某一属性的最终值,只可读,用于获取经过暂时数值变化修饰的数值的最终值

ModifierCollector

数值修饰器的链表,用于存贮暂时的数值变化

NumericModifier

name

string 数值修正器的名字

count

int 同一数值修正器的数量

tag

string[]

  • 对于加法修饰器,表示收那些乘法修正器影响
  • 对于乘法修正器,表示可以修饰哪些加法修正器(或 basicValue)basicValue 对应的 tag 是 “self”

其他

修正器的比较通过方法 WeakEquals 实现,比较的基准是 类型,值和名字

注意,对 tag 的修改会改变所有同名同值同类型的修饰器

情境和案例

基础用法展示

    public IntNumeric health = new();
    public FloatNumeric speed = new();

    [Button]
    public void AddHealthBuff()
    {
        health.AddModifier(new IntNumericModifier(10, "治疗术"));
        health += new IntNumericModifier(10);
        health = health + new IntNumericModifier(10, "治疗术");
        health += (10, "治疗术");
        health += 10;
        health += new IntNumericModifier(10);
    }

数值常见和初始化

    public void CreateAndInit()
    {
        IntNumeric intNumeric = new();
        IntNumeric intNumeric2 = new(100);
        var intNumeric3 = new IntNumeric(100);
        IntNumeric intNumeric4 = 100;
        // 这里传入的参数是 basicValue
    }

永久改变值

    public IntNumeric health = new();

    public void ChangeValueForever()
    {
        health.basicValue = 100;
        health.basicValue += 10;
        health.basicValue %= 10;
    }

暂时改变值/加减修正器

        IntNumeric health = new();
        health.AddModifier(new IntNumericModifier()); //无意义
        health.AddModifier(new IntNumericModifier(10));
        health.AddModifier(new IntNumericModifier(10, "圣光术"));
        health.AddModifier(new IntNumericModifier(10, "圣光术", "self"));
        health.AddModifier(new IntNumericModifier(10, "圣光术", "self", "装备"));
        health += 10;
        health += (10, "圣光术");
        health += (10, "圣光术", "self");

        health.RemoveModifier(new IntNumericModifier()); //无意义
        health.RemoveModifier(new IntNumericModifier(10));
        health.RemoveModifier(new IntNumericModifier(10, "圣光术"));
        health.RemoveModifier(new IntNumericModifier(10, "圣光术", "self"));
        health.RemoveModifier(new IntNumericModifier(10, "圣光术", "self", "装备"));
        health -= 10;
        health -= (10, "圣光术");
        health -= (10, "圣光术", "self");
    }

百分比增强

覆盖分数修正器的使用

覆盖分数修正器会计算目标加法修正器和基础值与本修正器的值的乘积,并覆盖原来的值。如 原本为 10,经过 1/2 覆盖修正后为 5

增量分数修正器的使用

增量分数修正器不会覆盖原本的值而是在其基础上增加新的值.如 原本为 10,经过 1/2 增量修正后为 15

使用办法
        health.AddModifier(new IncreaseFractionNumericModifier(1, 2, "修改圣光术", "圣光术"));
        health.RemoveModifier(new IncreaseFractionNumericModifier(1, 2, "修改圣光术", "圣光术"));
        health.AddModifier(new OverrideFractionNumericModifier(1, 2, "修改圣光术", "圣光术"));
        health.RemoveModifier(new OverrideFractionNumericModifier(1, 2, "修改圣光术", "圣光术"));
        health *= new IncreaseFractionNumericModifier(1, 2, "修改圣光术", "圣光术");
        health /= new IncreaseFractionNumericModifier(1, 2, "修改圣光术", "圣光术");
        health *= new OverrideFractionNumericModifier(1, 2, "修改圣光术", "圣光术");
        health /= new OverrideFractionNumericModifier(1, 2, "修改圣光术", "圣光术");

这里的 * 和 / 分别是 add 和 remove

numericsystem's People

Contributors

dlqw avatar

Stargazers

Serein avatar  avatar 空格空格感叹号 avatar ChenWei avatar Glucy2 avatar Sucial avatar whisper avatar Alice.wrt avatar  avatar  avatar Avidel avatar  avatar

Watchers

 avatar

Forkers

kaijiang1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.