@@ -4,11 +4,11 @@
namespace Egametang {
-bool AndNode::Run()
+bool AndNode::Run(LogicContex* contex)
{
foreach(LogicNodeIf* node, nodes)
- if (!node->Run())
+ if (!node->Run(contex))
return false;
}
@@ -11,7 +11,7 @@ private:
std::list<LogicNodeIf*> nodes;
public:
- virtual bool Run();
+ virtual bool Run(LogicContex* contex);
};
} // namespace Egametang
@@ -4,9 +4,14 @@
-bool ConditionNode::Run()
+bool BuffType::Run(LogicContex* contex)
- return condition();
+ Buff* buff = contex->buff;
+ if (buff->type == type)
+ {
+ return true;
+ }
+ return false;
@@ -5,15 +5,15 @@
-class ConditionNode: public LogicNodeIf
+// 条件节点还可以预绑定一些配置参数,例如下面的type字段由策划配置
+// 可配置成dot hot之类的
+class BuffType: public LogicNodeIf
-private:
- int world;
- int caster;
- int target;
+public:
+ int type;
@@ -3,10 +3,31 @@
+class Spell;
+class Buff;
+
+class Spell
+{
+};
+class Buff
+class LogicContex
+ Spell* spell;
+ Buff* buff;
class LogicNodeIf
- virtual bool Run() = 0;
+ virtual bool Run(LogicContex* contex) = 0;
@@ -4,9 +4,9 @@
-bool NotNode::Run()
+bool NotNode::Run(LogicContex* contex)
- return !node->Run();
+ return !node->Run(contex);
LogicNodeIf* node;
-bool OrNode::Run()
+bool OrNode::Run(LogicContex* contex)
- if (node->Run())
+ if (node->Run(contex))
return true;