private void TryUpdateValue() { bool canCalc = true; for (int i = 0; i < m_Args.Count; i++) { if (!m_Args[i].HaveValue) { canCalc = false; break; } } if (canCalc) { m_HaveValue = true; var dict = new Hashtable(); for (int i = 0; i < m_Args.Count; i++) { Pair pair = m_Args[i]; var key = pair.m_Key.Value.ToString(); if (null != key) { dict.Add(key, pair.m_Value.Value.Get <object>()); } } m_Value = BoxedValue.From(dict); } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params) { var args = _params.Values; int objId = args[0]; EntityInfo npc = PluginFramework.Instance.GetEntityById(objId); if (null != npc) { int targetId = npc.GetAiStateInfo().Target; if (targetId > 0) { EntityInfo entity = PluginFramework.Instance.GetEntityById(targetId); if (null != entity && !entity.IsDead()) { m_Proxy.Value = BoxedValue.From(entity); } else { m_Proxy.Value = BoxedValue.NullObject; } } else { m_Proxy.Value = BoxedValue.NullObject; } } }
private void TryUpdateValue(StoryInstance instance) { Scene scene = instance.Context as Scene; if (null != scene) { if (m_CampId.HaveValue && m_Index.HaveValue) { m_HaveValue = true; int sceneId = scene.SceneResId; int campId = m_CampId.Value; int index = m_Index.Value; int monstersId = TableConfigUtility.GenLevelMonstersId(sceneId, campId); List <TableConfig.LevelMonster> monsterList; if (TableConfig.LevelMonsterProvider.Instance.TryGetValue(monstersId, out monsterList)) { if (index >= 0 && index < monsterList.Count) { m_Value = BoxedValue.From(monsterList[index]); } else { m_Value = BoxedValue.NullObject; } } else { m_Value = BoxedValue.NullObject; } } } }
private void TryUpdateValue(StoryInstance instance) { Scene scene = instance.Context as Scene; if (null != scene) { if (m_AttrName.HaveValue) { string name = m_AttrName.Value; m_HaveValue = true; object v; if (scene.SceneContext.BlackBoard.TryGetVariable(name, out v)) { m_Value = BoxedValue.From(v); } else { if (m_ParamNum > 1) { m_Value = m_DefaultValue.Value; } } } } }
private void TryUpdateValue() { if (m_Var.HaveValue && m_Key.HaveValue && (m_ParamNum <= 2 || m_DefValue.HaveValue)) { object obj = m_Var.Value.Get <object>(); var dict = obj as IDictionary; object key = m_Key.Value.Get <object>(); BoxedValue defVal = BoxedValue.NullObject; if (m_ParamNum > 2) { defVal = m_DefValue.Value; } m_HaveValue = true; if (null != dict && null != key) { try { if (dict.Contains(key)) { m_Value = BoxedValue.From(dict[key]); } else { m_Value = defVal; } } catch { m_Value = defVal; } } else { m_Value = defVal; } } }
private void TryUpdateValue(StoryInstance instance) { UserThread userThread = instance.Context as UserThread; if (null != userThread) { if (m_UserGuid.HaveValue && m_Index.HaveValue) { ulong userGuid = m_UserGuid.Value; var id = m_Index.Value; m_HaveValue = true; UserInfo ui = userThread.GetUserInfo(userGuid); if (null != ui) { if (id.Type == BoxedValue.c_ULongType) { ulong guid = id.Get <ulong>(); m_Value = BoxedValue.From(ui.ItemBag.GetItemData(guid)); } else { try { int itemId = id.Get <int>(); m_Value = BoxedValue.From(ui.ItemBag.GetItemData(itemId)); } catch { m_Value = BoxedValue.NullObject; } } } } } }
private void TryUpdateValue(StoryInstance instance) { UserThread userThread = instance.Context as UserThread; if (null != userThread) { if (m_UserGuid.HaveValue && m_Index.HaveValue) { ulong userGuid = m_UserGuid.Value; int index = m_Index.Value; m_HaveValue = true; UserInfo ui = userThread.GetUserInfo(userGuid); if (null != ui) { if (index >= 0 && index < ui.MemberInfos.Count) { m_Value = BoxedValue.From(ui.MemberInfos[index]); } else { m_Value = BoxedValue.NullObject; } } } } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params) { var args = _params.Values; int objId = args[0].Get <int>(); float dist = args[1].Get <float>(); EntityInfo npc = PluginFramework.Instance.GetEntityById(objId); if (null != npc) { EntityInfo entity; if (dist < Geometry.c_FloatPrecision) { entity = AiLogicUtility.GetNearstTargetHelper(npc, CharacterRelation.RELATION_ENEMY); if (null != entity) { npc.GetAiStateInfo().Target = entity.GetId(); } } else { entity = AiLogicUtility.GetNearstTargetHelper(npc, dist, CharacterRelation.RELATION_ENEMY); if (null != entity) { npc.GetAiStateInfo().Target = entity.GetId(); } } m_Proxy.Value = BoxedValue.From(entity); } }
private void TryUpdateValue() { if (m_Type.HaveValue && m_Val.HaveValue) { m_HaveValue = true; var objType = m_Type.Value; string val = m_Val.Value; try { var t = objType.IsObject ? objType.ObjectVal as Type : null; string type = objType.IsString ? objType.StringVal : null; if (null == t && null != type) { t = Type.GetType(type); } if (null != t) { m_Value = BoxedValue.From(Enum.Parse(t, val, true)); } else { GameFramework.LogSystem.Warn("null == Type.GetType({0})", type); } } catch (Exception ex) { GameFramework.LogSystem.Warn("Exception:{0}\n{1}", ex.Message, ex.StackTrace); m_Value = BoxedValue.NullObject; } } }
private void BuildInputArgs(BoxedValueList args) { string[] strVals = null; int[] boolVals = null; float[] floatVals = null; int[] dropdownVals = null; if (null != InputLabels) { int strCt = InputLabels.Count; strVals = new string[strCt]; for (int i = 0; i < strCt; ++i) { strVals[i] = InputLabels[i].text; } if (strCt > 0) { args.Add(BoxedValue.From(strVals)); } } if (null != InputToggles) { int boolCt = InputToggles.Count; boolVals = new int[boolCt]; for (int i = 0; i < boolCt; ++i) { boolVals[i] = InputToggles[i].isOn ? 1 : 0; } if (boolCt > 0) { args.Add(BoxedValue.From(boolVals)); } } if (null != InputSliders) { int floatCt = InputSliders.Count; floatVals = new float[floatCt]; for (int i = 0; i < floatCt; ++i) { floatVals[i] = InputSliders[i].value; } if (floatCt > 0) { args.Add(BoxedValue.From(floatVals)); } } if (null != InputDropdowns) { int dropdownCt = InputDropdowns.Count; dropdownVals = new int[dropdownCt]; for (int i = 0; i < dropdownCt; ++i) { dropdownVals[i] = InputDropdowns[i].value; } if (dropdownCt > 0) { args.Add(BoxedValue.From(dropdownVals)); } } }
protected override bool ExecCommand(StoryInstance instance, StoryMessageHandler handler, long delta, BoxedValue iterator, BoxedValueList args) { var runtime = handler.PeekRuntime(); if (runtime.TryBreakLoop()) { return(false); } var localInfos = handler.LocalInfoStack.Peek(); var localInfo = localInfos.GetLocalInfo(m_LocalInfoIndex) as LocalInfo; if (null == localInfo) { localInfo = new LocalInfo { List = m_LoadedList.Clone() }; localInfos.SetLocalInfo(m_LocalInfoIndex, localInfo); } if (!handler.PeekRuntime().CompositeReentry) { Evaluate(instance, handler, iterator, args); } bool ret = true; while (ret) { if (localInfo.Iterators.Count > 0) { Prepare(handler); runtime = handler.PeekRuntime(); runtime.Iterator = BoxedValue.From(localInfo.Iterators.Dequeue()); runtime.Arguments = args; ret = true; //没有wait之类命令直接执行 runtime.Tick(instance, handler, delta); if (runtime.CommandQueue.Count == 0) { handler.PopRuntime(instance); if (runtime.TryBreakLoop()) { ret = false; break; } } else { //遇到wait命令,跳出执行,之后直接在StoryMessageHandler里执行栈顶的命令队列(降低开销) break; } } else { ret = false; } } return(ret); }
private void HandleRequestNicknameResult(NodeMessage lobbyMsg) { GameFrameworkMessage.RequestNicknameResult protoMsg = lobbyMsg.m_ProtoData as GameFrameworkMessage.RequestNicknameResult; if (null == protoMsg) { return; } GfxStorySystem.Instance.SendMessage("show_nickname", BoxedValue.From(protoMsg.m_Nicknames)); }
private void TryUpdateValue() { bool canCalc = true; if (!m_Object.HaveValue || !m_Method.HaveValue) { canCalc = false; } else { for (int i = 0; i < m_Args.Count; i++) { if (!m_Args[i].HaveValue) { canCalc = false; break; } } } if (canCalc) { m_HaveValue = true; m_Value = BoxedValue.NullObject; object obj = m_Object.Value.Get <object>(); var methodObj = m_Method.Value; ArrayList arglist = new ArrayList(); for (int i = 0; i < m_Args.Count; i++) { arglist.Add(m_Args[i].Value.Get <object>()); } object[] args = arglist.ToArray(); if (null != obj) { IDictionary dict = obj as IDictionary; var mobj = methodObj.Get <object>(); if (null != dict && dict.Contains(mobj)) { m_Value = BoxedValue.From(dict[mobj]); } else { IEnumerable enumer = obj as IEnumerable; if (null != enumer && methodObj.IsInteger) { int index = methodObj.Get <int>(); var e = enumer.GetEnumerator(); for (int i = 0; i <= index; ++i) { e.MoveNext(); } m_Value = BoxedValue.From(e.Current); } } } } }
private void TryUpdateValue() { if (m_String.HaveValue) { string str = m_String.Value; m_HaveValue = true; var json = JsonMapper.ToObject(str); m_Value = BoxedValue.From(ToValue(json, null)); } }
private void TryUpdateValue(StoryInstance instance) { List <object> npcs = new List <object>(); PluginFramework.Instance.EntityManager.Entities.VisitValues((EntityInfo npcInfo) => { npcs.Add(npcInfo.GetId()); }); m_HaveValue = true; m_Value = BoxedValue.From(npcs); }
private void TryUpdateValue(StoryInstance instance) { if (m_ObjId.HaveValue) { m_HaveValue = true; m_Value = BoxedValue.NullObject; int objId = m_ObjId.Value; m_Value = BoxedValue.From((object)EntityController.Instance.GetGameObject(objId)); } }
public void Init() { StoryInstance instance = GfxStorySystem.Instance.GetStory("main", WindowName); if (null != instance) { instance.LocalVariables.Clear(); instance.LocalVariables.Add("@window", BoxedValue.From((object)gameObject)); GfxStorySystem.Instance.StartStory("main", WindowName); } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params) { var args = _params.Values; int objId = args[0].Get <int>(); EntityInfo npc = PluginFramework.Instance.GetEntityById(objId); if (null != npc) { m_Proxy.Value = BoxedValue.From(npc.GetSkillStateInfo().GetAllSkill()); } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params) { var args = _params.Values; int objId = args[0]; EntityInfo npc = PluginFramework.Instance.GetEntityById(objId); if (null != npc) { SkillInfo skillInfo = AiLogicUtility.NpcFindCanUseSkill(npc); m_Proxy.Value = BoxedValue.From(skillInfo); } }
private void TryUpdateValue() { if (m_TypeName.HaveValue) { m_HaveValue = true; string typeName = m_TypeName.Value; m_Value = BoxedValue.From(Type.GetType(typeName)); if (null == m_Value.ObjectVal) { GameFramework.LogSystem.Warn("null == Type.GetType({0})", typeName); } } }
private void TryUpdateValue() { if (m_String.HaveValue) { string str = m_String.Value; m_HaveValue = true; m_Value = BoxedValue.NullObject; if (File.Exists(str)) { m_Value = BoxedValue.From(File.ReadAllLines(str)); } } }
private void TryUpdateValue(StoryInstance instance) { Scene scene = instance.Context as Scene; if (null != scene) { if (m_ObjId.HaveValue) { int objId = m_ObjId.Value; m_HaveValue = true; m_Value = BoxedValue.From(scene.SceneContext.GetEntityById(objId)); } } }
private void TryUpdateValue(StoryInstance instance) { UserThread userThread = instance.Context as UserThread; if (null != userThread) { if (m_UserGuid.HaveValue) { ulong userGuid = m_UserGuid.Value; m_HaveValue = true; m_Value = BoxedValue.From(UserServer.Instance.UserProcessScheduler.GetUserInfo(userGuid)); } } }
private void TryUpdateValue(StoryInstance instance) { Scene scene = instance.Context as Scene; if (null != scene) { List <object> npcs = new List <object>(); scene.EntityManager.Entities.VisitValues((EntityInfo npcInfo) => { npcs.Add(npcInfo.GetId()); }); m_HaveValue = true; m_Value = BoxedValue.From(npcs); } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, BoxedValue iterator, BoxedValueList args) { if (null != m_Select && null != m_From) { m_From.Evaluate(instance, handler, iterator, args); ArrayList coll = new ArrayList(); //筛选 IEnumerable enumer = m_From.Value.ObjectVal as IEnumerable; if (null != enumer) { var enumerator = enumer.GetEnumerator(); while (enumerator.MoveNext()) { var v = enumerator.Current; var bv = BoxedValue.From(v); if (null != m_Where) { m_Where.Evaluate(instance, handler, bv, args); object wvObj = m_Where.Value; int wv = (int)System.Convert.ChangeType(wvObj, typeof(int)); if (wv != 0) { AddRow(coll, bv, instance, handler, args); } } else { AddRow(coll, bv, instance, handler, args); } } } //排序 int ct = m_OrderBy.Count; if (ct > 0) { coll.Sort(new AiQueryComparer(m_Desc, ct)); } //收集结果 ArrayList result = new ArrayList(); for (int i = 0; i < coll.Count; ++i) { var ao = coll[i] as ArrayList; result.Add(ao[0]); } m_Proxy.Value = result; } }
public void Evaluate(StoryInstance instance, StoryMessageHandler handler, StoryValueParams _params) { var args = _params.Values; int objId = args[0]; EntityInfo npc = PluginFramework.Instance.GetEntityById(objId); if (null != npc) { int targetId = npc.GetAiStateInfo().Target; if (targetId > 0) { EntityInfo target = PluginFramework.Instance.GetEntityById(targetId); if (null != target) { float distToTarget = Geometry.Distance(npc.GetMovementStateInfo().GetPosition3D(), target.GetMovementStateInfo().GetPosition3D()); SkillInfo maxSkillInfo = null; float diffDist = float.MaxValue; SkillInfo targetSkillInfo = null; for (int i = 0; i < npc.AutoSkillIds.Count; ++i) { int skillId = npc.AutoSkillIds[i]; SkillInfo temp = npc.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != temp) { float dist = temp.Distance; float absDist = Mathf.Abs(distToTarget - dist); if (diffDist > absDist) { diffDist = absDist; targetSkillInfo = temp; } } } if (null != targetSkillInfo) { m_Proxy.Value = BoxedValue.From(targetSkillInfo); } else { m_Proxy.Value = BoxedValue.From(maxSkillInfo); } return; } } } m_Proxy.Value = BoxedValue.NullObject; }
private void TryUpdateValue(StoryInstance instance) { if (m_Index.HaveValue) { m_HaveValue = true; int index = m_Index.Value; UnityEngine.Sprite obj = SpriteManager.GetActorIcon(index); if (null != obj) { m_Value = BoxedValue.From((object)obj); } else { m_Value = BoxedValue.NullObject; } } }
private void TryUpdateValue() { if (m_Var.HaveValue) { object obj = m_Var.Value.Get <object>(); var dict = obj as IDictionary; m_HaveValue = true; if (null != dict) { ArrayList list = new ArrayList(); list.AddRange(dict.Values); m_Value = BoxedValue.From(list); } else { m_Value.SetNullObject(); } } }
private void TryUpdateValue(StoryInstance instance) { if (m_DlgId.HaveValue && m_Index.HaveValue) { m_HaveValue = true; int dlgId = m_DlgId.Value; int index = m_Index.Value; int dlgItemId = TableConfigUtility.GenStoryDlgItemId(dlgId, index); TableConfig.StoryDlg cfg = TableConfig.StoryDlgProvider.Instance.GetStoryDlg(dlgItemId); if (null != cfg) { m_Value = BoxedValue.From(cfg); } else { m_Value = BoxedValue.NullObject; } } }
private void TryUpdateValue(StoryInstance instance) { if (m_AttrName.HaveValue) { string name = m_AttrName.Value; m_HaveValue = true; object v; if (PluginFramework.Instance.BlackBoard.TryGetVariable(name, out v)) { m_Value = BoxedValue.From(v); } else { if (m_ParamNum > 1) { m_Value = m_DefaultValue.Value; } } } }