项目作者: derived-studio

项目描述 :
Data-driven game stat modeling framework for .Net
高级语言: C#
项目地址: git://github.com/derived-studio/DrapeDotNet.git
创建时间: 2017-06-03T02:56:28Z
项目社区:https://github.com/derived-studio/DrapeDotNet

开源协议:

下载


Drape

Drape is C# data-driven modeling framework for game stats/attributes.
It is being developed for Unity but is not Unity dependent, thus can be used without it.

Important
It is work in progress and current API is subject to change.

Motivation

Drape has been started as a side project facilitating management of numeric game stats.
Main requirement was ability to create and register stats that then could be dynamically modified with stat modifier objects.

Goals

  • Flexibility
  • Extendability
  • Small footprint
  • Performance

Features

  • Creating stats from code
  • Stat registration and retrieval
  • Dynamically calculated stat values
  • Modifying stats with stat modifiers
  • Local stat
  • Creating stats using data files
    • JSON support
    • YAML support

Stat types

  • Stat (simple stat)
  • Modifier
  • Resource
  • Multistat

Stat formulas

Stat and modifiers

  1. Stat components
  2. ---------------
  3. B - base value
  4. R - raw modifier
  5. F - final modifier
  6. Modifier types
  7. ---------------
  8. f - flat
  9. m - multiplier
  10. Raw value formula
  11. -----------------
  12. R = (B + Rf) * Rm
  13. Rf = Rf(a) + Rf(l) + Rf(g) + + Rf(x)
  14. Rm = Rm(a) + Rm(l) + Rm(g) + + Rm(y)
  15. Final value formula
  16. -------------------
  17. F = (R + Ff) * Fm
  18. Ff = Ff(a) + Ff(l) + Ff(g) + …. + Ff(x)
  19. Fm = 1 + Fm(a) + Ff(l) + Ff(g) + + Ff(x)

Serialization

Json

JSON serialization supported with SaladLab fork of Newtonsoft Json.NET. You can get latest DLL file from here.

Private setter serialization supported with custom contract resolver method as described in Daniel’s blog.

Yaml

Yaml serialization supported with YamlDotNet. Get latest release dll from here.

Consideration

  • What is the reason of using final stat modifier (F)? Is it needed at all?
  • BaseStatData.ToJSON() method only serializes public properties and doesn’t allow to serialize members.
  • Is BaseStatData needed? Can Stat be serialized directly?
  • Applying global modifier to multiple stats of same type not supported. Eg. improved melee damage should apply to all melee damage type stats: sword damage, axe damage, etc.

Project setup

  1. Clone repository
  2. Open it from unity
    • Ignore console errors. You need to build it .dll.
    • Let unity create .sln solution file and open it from Visual Studio
  3. Add ./Drape.Source/Drape.Source.csproj (existing project) to the solution
  4. Build added Drape.Source project.