-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BodyPart-Ability-Effect属性系统的模型与计算 #43
Comments
属性模型的表达和更新方式 1 (基本实现 #46 )通过 优点:
缺点:
例子 private void UpdateSpaceTimeMagicPower()
=> State.SpaceTimeMagicPower.Update(
Min(
State.ReconstructionAbility,
State.ControllingAbility,
State.PerceptionAbility,
State.ResolvingAbility));
private void UpdatePerceptionMagicPower() => State.PerceptionMagicPower.Update(State.PerceptionAbility);
private void UpdateMagicTransformEfficiency()
=> State.MagicTransformEfficiency.Update(Min(State.PerceptionAbility, State.ControllingAbility));
private void UpdateControllingMagicPower() => State.ControllingMagicPower.Update(State.ControllingAbility);
private void UpdateMagicHitRate() => State.MagicHitRate.Update(State.ControllingAbility);
private void UpdateMagicLearningRate() => State.MagicLearningRate.Update(State.ControllingAbility);
private void UpdateAimingAccuracy() => State.AimingAccuracy.Update(State.Vision);
private void UpdateSightRange() => State.SightRange.Update(State.Vision); |
属性模型的表达和更新方式 2通过给 优点:
缺点:
例子 [Update(state => Min(state.ReconstructionAbility, state.ControllingAbility)]
public UnitProperty SummonMagicPower
{
get => Effects[(int) EffectIndex.SummonMagicPower];
set => Effects[(int) EffectIndex.SummonMagicPower] = value;
} |
属性模型的表达和更新方式 3将模型算法抽象成一个更新表服务,并使用依赖注入获取 优点:
缺点:每次更新公式需要重新编译 例子class SimpleUnitStateUpdater : IUnitStateUpdater
{
public void Update(UnitState state) { ... }
private static Dictionary<AbilityIndex, Func<UnitState, float>> _model = new <AbilityIndex, Func<UnitState, float>>
{
[AbilityIndex.ReconstructionAbility] = state => Min(state.ReconstructionAbility, state.ControllingAbility),
....
}
} |
属性模型的表达和更新方式 4将模型算法抽象成一个更新表以xml或者json保存,并使用依赖注入获取 优点:
缺点:
例子{
"Effects" : {
"SummonMagicPower" : {
"func" : "min",
"input": ["ReconstructionAbility", "ControllingAbility"]
},
}
} ... or .. {
"Effects" : {
"SummonMagicPower" : "min($ReconstructionAbility, $ControllingAbility)"
}
} |
属性模型的表达和更新方式 5模型算法用Lua脚本实现,然后通过使用json、xml或excel的方式进行配置。 优点:
缺点:
例子C#Part: LuaTable luaTable = lua.DoFile(filePath)[0] as LuaTable;//检查出脚本更新时调用或者每次都重新dofile。
...
float ret = (float)(double)((luaTable[funcName] as LuaFunction).Call(arg1, arg2)[0]); LuaPart: local TestClass = {}
TestClass.TestFunc1 = function(arg1, arg2)
return arg1 + arg2
end
TestClass.TestFunc2 = function(arg1, arg2)
return arg1 - arg2
end
return TestClass JsonPart: {
"luaFilePath" : "x.lua",
"Effects" : [
{
"name" : "Power",
"func" : "TestFunc1",
"input": ["Ability1","Ability2"]
}
]
} |
属性模型的表达和更新方式 6(3+5)模型使用Json/xml etc. 配置,算法用Lua脚本实现,将模型编译为C#的data model, [并且更新相关数据表] 优点:
缺点:
例子
C#Part:
public partial class EffectState
{
private double _state1;
private double _state2;
private double _state3;
private double _state4;
public double State1 {
get
{
return _state1;
}
set
{
_state1 = value;
State3 = UpdateTable[nameof(State3)].Calculate(_state1, _state2);
// Evaluation tree can be optimized
}
}
public double State2
{
get
{
return _state2;
}
set
{
_state2 = value;
State3 = UpdateTable[nameof(State3)].Calculate(_state1, _state2);
State4 = UpdateTable[nameof(State4)].Calculate(_state2, _state3);
}
}
public double State3
{
get
{
return _state3;
}
private set
{
_state3 = value;
_state4 = UpdateTable[nameof(State4)].Calculate(_state2, _state3);
}
}
public double State4
{
get
{
return _state4;
}
private set
{
_state4 = value;
}
}
} LuaPart: Lua scirpt template can also be generated by Json JsonPart: {
"luaFilePath": "x.lua",
"Effects": [
{
"name": "State1",
"type": "double",
"summary": "The introduction of State1 is written here",
"input": []
},
{
"name": "State2",
"type": "double",
"summary": "The introduction of State2 is written here",
"input": []
},
{
"name": "State3",
"type": "double",
"summary": "The introduction of State3 is written here",
"input": [ "State1", "State2" ] // Dependency
},
{
"name": "State4",
"type": "double",
"summary": "The introduction of State4 is written here",
"input": [ "State2", "State3" ] // Dependency
}
]
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: