private void ExcuteEffectNode(BaseEffectNode parent) { var type = parent.NodeType; switch (type) { case EffectNodeType.YesNoCondition: { var yesNoNode = parent as YesNoNode; var methodNode = m_ConditionMethods [yesNoNode.EffectParam.Method](yesNoNode.EffectParam.Params); if (methodNode) { var yesMethods = yesNoNode.YesMethods; for (int i = 0; i < yesMethods.Count; i++) { ExcuteEffectNode (yesMethods [i]); } } else { var noMethods = yesNoNode.NoMethods; for (int i = 0; i < noMethods.Count; i++) { ExcuteEffectNode (noMethods [i]); } } } break; case EffectNodeType.ExcuteEffectNode: { var excuteNode = parent as ExcuteEffectNode; var playerMethods = excuteNode.ExcuteMethods; for (int i = 0; i < playerMethods.Count; i++) { m_ExcuteMethods [playerMethods[i].Method](playerMethods[i].Params); } } break; } }
private BaseEffectNode ReadNode(Dictionary<string, object> nodeData, bool firstNode = false) { var id = int.Parse (nodeData ["ID"].ToString ()); var type = (EffectNodeType) byte.Parse (nodeData ["Type"].ToString ()); switch (type) { case EffectNodeType.YesNoCondition: { YesNoNode yesNo = null; if (firstNode) { m_CurrentNode = new YesNoNode(); yesNo = m_CurrentNode as YesNoNode; } else { yesNo = new YesNoNode(); } yesNo.ID = id; yesNo.NodeType = type; var methodName = string.Empty; var pars = ParseStringToObjects(nodeData["Method"].ToString(), out methodName); yesNo.EffectParam.Method = methodName; yesNo.EffectParam.Params = pars; var yesMethods = nodeData["YesMethods"] as List<object>; var noMethods = nodeData["NoMethods"] as List<object>; for (int i = 0; i < yesMethods.Count; i++) { var yesData = yesMethods[i] as Dictionary<string, object>; yesNo.YesMethods.Add(ReadNode(yesData)); } for (int i = 0; i < noMethods.Count; i++) { var noData = noMethods[i] as Dictionary<string, object>; yesNo.NoMethods.Add(ReadNode(noData)); } return yesNo; } case EffectNodeType.ExcuteEffectNode: { ExcuteEffectNode excuteMethod = null; if (firstNode) { m_CurrentNode = new ExcuteEffectNode(); excuteMethod = m_CurrentNode as ExcuteEffectNode; } else { excuteMethod = new ExcuteEffectNode(); } excuteMethod.ID = id; excuteMethod.NodeType = type; var pars = nodeData["ExcuteMethods"] as List<object>; for (int i = 0; i < pars.Count; i++) { var methodName = string.Empty; var par = ParseStringToObjects(pars[i].ToString(), out methodName); excuteMethod.ExcuteMethods.Add(new EffectParam() { Method = methodName, Params = par }); } return excuteMethod; } } return null; }