public FArpgNode Play(float time, List <string> state, out bool isChange) { isChange = false; this.curTimes += time; this.totalTimes += time; PlayStateCallBack(time, 1); for (int i = 0; i < mNextData.Count; i++) { FArpgNode fad = mNextData[i]; if (fad.mFArgpBaseData.conditionState == "" || state.Contains(fad.mFArgpBaseData.conditionState)) { if (ConditonCall(fad)) { Reset(); fad.Reset(); fad.PlayStateCallBack(0, -1); fad = fad.GetRealArpg(); fad.Reset(); fad.PlayStateCallBack(0, 0); if (mMian.mMainCallBack != null) { mMian.mMainCallBack(fad); } isChange = true; return(fad); } } } return(this); }
public bool PlayUpdate(float dp) { if (mIsPause) { return(false); } List <StateTimeEvent.STimeData> stds = mStateTimeEvent.GetStimeDataList(""); List <string> tempStates = new List <string>(); for (int i = 0; i < stds.Count; i++) { tempStates.Add(stds[i].Group); } mStateTimeEvent.PlayLogic(dp); bool isChange = false; if (mCurFArpgData != null && !mIsLock) { mIsLock = true; mCurFArpgData = mCurFArpgData.Play(dp, tempStates, out isChange); mIsLock = false; } return(isChange); }
public FArpgNode RemoveNode(FArpgNode node) { FArpgNode root = GetRoots(); if (root.mMainBuffs.ContainsKey(node.mFArgpBaseData.nodeName)) { root.mMainBuffs.Remove(node.mFArgpBaseData.nodeName); } if (root.mNextData.Contains(node)) { root.mNextData.Remove(node); } foreach (var k in root.mMainBuffs) { if (k.Value.mSkipNode == node) { k.Value.mSkipNode = null; } for (int i = 0; i < k.Value.mNextData.Count; i++) { FArpgNode temp = k.Value.mNextData[i]; if (temp == node) { k.Value.mNextData.Remove(temp); break; } } } return(node); }
public FArpgNode Regs(FArpgNode node, bool sameRemove = false) { if (node == null) { return(null); } node.mFArgpBaseData.SetNode(node); int index = 0; for (int i = 0; i < mNextData.Count; i++) { if (mNextData[i].mFArgpBaseData.conditionTimes > node.mFArgpBaseData.conditionTimes) { index = i; break; } } if (!mNextData.Contains(node)) { mNextData.Insert(index, node); return(node); } else if (sameRemove) { mNextData.Remove(node); } return(null); }
private void CallBackStateChange(FArpgNode fad) { if (StateCallBack != null) { StateCallBack(fad); } }
public static bool BaseLess(FArpgNode fad, FArpgNode next) { if (fad.curTimes <= next.mFArgpBaseData.conditionTimes) { return(true); } return(false); }
public bool Greater(FArpgNode fad, FArpgNode next) { if (fad.curTimes >= next.mFArgpBaseData.conditionTimes) { return(true); } return(false); }
public bool BaseTotalLess(FArpgNode fad, FArpgNode next) { if (fad.totalTimes <= next.mFArgpBaseData.conditionTimes) { return(true); } return(false); }
public FArpgNode(Action <FArpgNode> CallBack, FArpgMachine mach) { mMian = this; mMian.mMainCallBack = CallBack; mConditionCall = Greater; mArpgMachine = mach; mMainBuffs = new Dictionary <string, FArpgNode>(); }
public void SetStartNode(string node) { if (node != "") { var root = GetRoots(); if (root.mMainBuffs.ContainsKey(node)) { mCurFArpgData = root.mMainBuffs[node]; } } }
public FArpgNode(FArpgNode fad, FArgpBaseData abd, bool isCreate = true, Func <FArpgNode, FArpgNode, bool> ConditionCall = null) { mMian = fad.mMian; mFArgpBaseData = abd; if (ConditionCall == null) { if (mFArgpBaseData.ConditionCallBack == null || mFArgpBaseData.ConditionCallBack.Length == 0) { mConditionCall = TotalGreater; } } else { mConditionCall = ConditionCall; } if (isCreate) { mMian.mMainBuffs[mFArgpBaseData.nodeName] = this; } }
private bool ConditonCall(FArpgNode node) { if (node.mConditionCall != null) { if (!node.mConditionCall(this, node)) { return(false); } } if (node.mFArgpBaseData.ConditionCallBack != null) { for (int i = 0; i < node.mFArgpBaseData.ConditionCallBack.Length; i++) { var callBack = node.mFArgpBaseData.ConditionCallBack[i]; if (!callBack(this, node)) { return(false); } } } return(true); }
public void SaveFile(string fileName, Type type) { //保存配置 FArpgNode roots = GetRoots(); Dictionary <string, FArpgNode> nodes = roots.mMainBuffs; FSaveHandle sd = FSaveHandle.Create(fileName, FFilePath.FP_Abs, FOpenType.OT_Write); ArpgFileData arpgFileData = new ArpgFileData(); arpgFileData.typeName = type.FullName; arpgFileData.headHodeName = mStartNodeName; ArpgFileData.Data[] datas = new ArpgFileData.Data[nodes.Count]; arpgFileData.data = datas; IList paramList = Array.CreateInstance(type, nodes.Count); int index = 0; foreach (var k in nodes) { var afd = new ArpgFileData.Data(); datas[index] = afd; afd.rect = new Unit_Rect(); afd.rect.SetRect(k.Value.mRect); //条件判断事件 var conditions = k.Value.mFArgpBaseData.ConditionCallBack; if (conditions != null && conditions.Length != 0) { afd.conditionMothods = new string[conditions.Length]; for (int i = 0; i < conditions.Length; i++) { afd.conditionMothods[i] = conditions[i].Method.Name; } } //状态执行事件 var states = k.Value.mFArgpBaseData.PlayStateCallBacks; if (states != null && states.Length != 0) { afd.playMothods = new string[states.Length]; for (int i = 0; i < states.Length; i++) { afd.playMothods[i] = states[i].Method.Name; } } if (k.Value.mSkipNode != null) { afd.skipNode = k.Value.mSkipNode.mFArgpBaseData.nodeName; } afd.nextData = new string[k.Value.mNextData.Count]; for (int i = 0; i < k.Value.mNextData.Count; i++) { afd.nextData[i] = k.Value.mNextData[i].mFArgpBaseData.nodeName; } paramList[index++] = k.Value.mFArgpBaseData; } arpgFileData.param = StringSerialize.Serialize(paramList); sd.PushObject(arpgFileData); sd.Save(); }
public string LoadFile(string name, FFilePath pathType = FFilePath.FP_Relative) { string tempPath = "." + ResConfig.ARPGEX; if (!name.EndsWith(tempPath)) { name += tempPath; } NewRoot(); //加载配置 FSaveHandle sd = FSaveHandle.Create(name, pathType); ArpgFileData afd = new ArpgFileData(); sd.FromObject(afd); mStartNodeName = afd.headHodeName; IList baseData = (IList)StringSerialize.Deserialize(afd.param, typeof(List <>).MakeGenericType(Assembly.Load("Assembly-CSharp").GetType(afd.typeName))); if (afd != null) { FArpgNode roots = GetRoots(); for (int i = 0; i < afd.data.Length; i++) { var d = afd.data[i]; FArgpBaseData farpgData = (FArgpBaseData)baseData[i]; if (d.conditionMothods != null) { farpgData.ConditionCallBack = new Func <FArpgNode, FArpgNode, bool> [d.conditionMothods.Length]; for (int c = 0; c < d.conditionMothods.Length; c++) { farpgData.ConditionCallBack[c] = (System.Func <FArpgMachine.FArpgNode, FArpgMachine.FArpgNode, bool>)System.Delegate.CreateDelegate(typeof(System.Func <FArpgMachine.FArpgNode, FArpgMachine.FArpgNode, bool>), farpgData, d.conditionMothods[c]); } } if (d.playMothods != null) { farpgData.PlayStateCallBacks = new Action <FArpgNode, float, int> [d.playMothods.Length]; for (int c = 0; c < d.playMothods.Length; c++) { farpgData.PlayStateCallBacks[c] = (System.Action <FArpgNode, float, int>)System.Delegate.CreateDelegate(typeof(System.Action <FArpgNode, float, int>), farpgData, d.playMothods[c]); } } FArpgNode node = roots.Regs(farpgData, true, null); node.mRect = d.rect.GetRect(); } for (int i = 0; i < afd.data.Length; i++) { var d = afd.data[i]; FArgpBaseData farpgData = (FArgpBaseData)baseData[i]; FArpgNode node = roots.mMainBuffs[farpgData.nodeName]; if (d.skipNode != "") { node.mSkipNode = roots.mMainBuffs[d.skipNode]; } if (d.nextData != null) { for (int j = 0; j < d.nextData.Length; j++) { var nextNode = roots.mMainBuffs[d.nextData[j]]; node.Regs(nextNode); } } } } SetStartNode(mStartNodeName); return(afd.typeName); }
public void TestPlay(FArpgNode fad, float timedp, int type) { }
//节点名字,状态控制,几秒转换,是否创建, public FArpgNode Regs(FArgpBaseData abd, bool isCreate = true, Func <FArpgNode, FArpgNode, bool> ConditionCall = null) { FArpgNode fad = new FArpgNode(this, abd, isCreate, ConditionCall); return(Regs(fad)); }
public bool SetNode(FArpgNode node) { mNode = node; return(true); }
private void NewRoot() { mStateTimeEvent = new StateTimeEvent(UpdateTimeState); mCurFArpgData = new FArpgNode(CallBackStateChange, this); }