public override void OnInspectorGUI() { ViNoSaveInfo info = target as ViNoSaveInfo; m_Edit = EditorGUILayout.BeginToggleGroup("", m_Edit); info.data.m_LoadedLevelIndex = EditorGUILayout.IntField("LevelIndex", info.data.m_LoadedLevelIndex); info.data.m_LoadedLevelName = EditorGUILayout.TextField("LevelName", info.data.m_LoadedLevelName); // string[] pop = { info.data.m_CurrentScenarioName }; // int sel = 0; // sel =EditorGUILayout.Popup( "ScenarioName" , sel , pop ); info.data.m_CurrentScenarioName = EditorGUILayout.TextField("ScenarioName", info.data.m_CurrentScenarioName); // string[] pop2 = { info.data.m_NodeName }; // int sel2 = 0; // sel2 =EditorGUILayout.Popup( "CurrentNode" , sel2 , pop2 ); info.data.m_NodeName = EditorGUILayout.TextField("CurrentNode", info.data.m_NodeName); info.data.m_BgmName = EditorGUILayout.TextField("BGM", info.data.m_BgmName); info.data.m_ScenarioResourceFilePath = EditorGUILayout.TextField("ScenarioFilePath", info.data.m_ScenarioResourceFilePath); EditorGUILayout.LabelField("SceneXml"); info.data.m_SceneXmlData = EditorGUILayout.TextArea(info.data.m_SceneXmlData); EditorGUILayout.LabelField("Saved Date"); EditorGUILayout.SelectableLabel(info.data.m_Date); EditorGUILayout.LabelField("Desc"); EditorGUILayout.SelectableLabel(info.data.m_ScenarioDescription); scenarioNode = EditorGUILayout.ObjectField(scenarioNode, typeof(ScenarioNode), true) as ScenarioNode; if (scenarioNode != null) { List <string> tagList = scenarioNode.GetNodeTagsUnderMe(); m_SelectedID = EditorGUILayout.Popup("NodeTagList", m_SelectedID, tagList.ToArray()); } if (GUILayout.Button("Clear Data")) { bool yes = EditorUtility.DisplayDialog(" ! ", "Are you sure you want to Clear Data", "yes", "no"); if (yes) { info.ClearData(); } } EditorGUILayout.EndToggleGroup(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
public void OnButtonComplete() { int selectedElementData = this.m_List.GetSelectedElementData(); if (selectedElementData >= 0 && selectedElementData < Scenario.Get().m_Nodes.Count) { ScenarioNode scenarioNode = Scenario.Get().m_Nodes[selectedElementData]; scenarioNode.Complete(); this.Setup(); } }
public void ExecuteNode(string node_name) { ScenarioNode node = this.GetNode(node_name); if (node != null) { node.Reset(); node.Activate(); node.Update(); } }
private void Update(WorldForm wf, ref MapSelection sel, Vector3 p) { ScenarioNode?.SetPosition(p); if (ScenarioNode != sel.ScenarioNode) { wf.SelectScenarioNode(ScenarioNode); } wf.SetWidgetPosition(p); UpdateGraphics(wf); }
private void Update(WorldForm wf, ref MapSelection sel, Quaternion q) { ScenarioNode?.SetOrientation(q); if (ScenarioNode != sel.ScenarioNode) { wf.SelectScenarioNode(ScenarioNode); } wf.SetWidgetRotation(q); //UpdateGraphics(wf); }
public override void Load(ScenarioNode node, int index) { base.Load(node, index); if (this.m_HasNullObject) { return; } if ((this.m_IsGO1 && this.m_ParamO1 == null) || (this.m_IsGO2 && this.m_ParamO2 == null)) { this.m_HasNullObject = true; } }
public override void Load(ScenarioNode node, int index) { base.Load(node, index); if (ScenarioCndTF.s_NullObjects.Contains(this)) { return; } if (this.m_ParamO1 == null || this.m_ParamO2 == null) { ScenarioCndTF.s_NullObjects.Add(this); } }
public void TrySelectScenarioNodeTreeNode(ScenarioNode node) { TreeNode tnode = FindScenarioNodeTreeNode(node); if (tnode == null) { tnode = FindScenarioTreeNode(node?.Ymt); } if (tnode != null) { ProjectTreeView.SelectedNode = tnode; } }
public override void OnInspectorGUI() { ViNoSaveInfo info = target as ViNoSaveInfo; m_Edit = EditorGUILayout.BeginToggleGroup( "" , m_Edit ); info.data.m_LoadedLevelIndex = EditorGUILayout.IntField( "LevelIndex" , info.data.m_LoadedLevelIndex ); info.data.m_LoadedLevelName = EditorGUILayout.TextField( "LevelName" , info.data.m_LoadedLevelName ); // string[] pop = { info.data.m_CurrentScenarioName }; // int sel = 0; // sel =EditorGUILayout.Popup( "ScenarioName" , sel , pop ); info.data.m_CurrentScenarioName = EditorGUILayout.TextField( "ScenarioName" , info.data.m_CurrentScenarioName ); // string[] pop2 = { info.data.m_NodeName }; // int sel2 = 0; // sel2 =EditorGUILayout.Popup( "CurrentNode" , sel2 , pop2 ); info.data.m_NodeName = EditorGUILayout.TextField( "CurrentNode" , info.data.m_NodeName ); info.data.m_BgmName = EditorGUILayout.TextField( "BGM" , info.data.m_BgmName ); info.data.m_ScenarioResourceFilePath = EditorGUILayout.TextField( "ScenarioFilePath" , info.data.m_ScenarioResourceFilePath ); EditorGUILayout.LabelField( "SceneXml" ); info.data.m_SceneXmlData = EditorGUILayout.TextArea( info.data.m_SceneXmlData ); EditorGUILayout.LabelField( "Saved Date" ); EditorGUILayout.SelectableLabel( info.data.m_Date ); EditorGUILayout.LabelField( "Desc" ); EditorGUILayout.SelectableLabel( info.data.m_ScenarioDescription ); scenarioNode = EditorGUILayout.ObjectField( scenarioNode , typeof( ScenarioNode ) , true ) as ScenarioNode; if( scenarioNode != null ){ List<string> tagList = scenarioNode.GetNodeTagsUnderMe(); m_SelectedID =EditorGUILayout.Popup( "NodeTagList" , m_SelectedID , tagList.ToArray() ); } if( GUILayout.Button ( "Clear Data" ) ){ bool yes = EditorUtility.DisplayDialog( " ! " , "Are you sure you want to Clear Data" , "yes" , "no" ); if( yes) { info.ClearData(); } } EditorGUILayout.EndToggleGroup(); if( GUI.changed ){ EditorUtility.SetDirty( target ); } }
public Transform SpawnActionElement(Vector3 position, ScenarioNode config, SpawnableVersion version) { Transform result = null; foreach (SpawnablePrefabs prefab in this.actionPrefabs) { if (prefab.version == version) { result = Instantiate(prefab.prefab, position, Quaternion.identity, cardContainer); result.GetComponent <ActionConfigSpawnable>().scenarioNode = config; } } return(result); }
public virtual void Load(ScenarioNode node, int index) { if (node.m_State == ScenarioNode.State.Completed) { this.m_State = ScenarioElement.State.Completed; return; } if (SaveGame.m_SaveGameVersion >= GreenHellGame.s_GameVersionEarlyAccessUpdate9 && this.m_ID >= 0) { this.m_State = (ScenarioElement.State)SaveGame.LoadIVal(node.m_Name + "_" + this.m_ID); return; } this.m_State = (ScenarioElement.State)SaveGame.LoadIVal(node.m_Name + "_" + index); }
public void SetPosition(Vector3 newpos, Vector3 oldpos, bool editPivot) { if (MultipleSelection) { //don't do anything here for multiselection } else if (EntityDef != null) { if (editPivot) { EntityDef.SetPivotPositionFromWidget(newpos); } else { EntityDef.SetPositionFromWidget(newpos); } } else if (CarGenerator != null) { CarGenerator.SetPosition(newpos); } else if (PathNode != null) { PathNode.SetPosition(newpos); } else if (NavPoly != null) { //NavPoly.SetPosition(newpos); //if (projectForm != null) //{ // projectForm.OnWorldNavPolyModified(NavPoly); //} } else if (TrainTrackNode != null) { TrainTrackNode.SetPosition(newpos); } else if (ScenarioNode != null) { ScenarioNode.SetPosition(newpos); } else if (Audio != null) { Audio.SetPosition(newpos); } }
/// <summary> /// OnEnter and SetFlag the Node. /// </summary> /// <param name='vm'> /// Vm. /// </param> public override void OnEnterNode(VirtualMachine vm) { ScenarioNode scenario = ScenarioNode.Instance; if (scenario.flagTable != null) { VirtualMachine._ALREADY_PASS_THE_NODE = scenario.flagTable.CheckFlagBy(vm.currNodeName); scenario.flagTable.SetFlagBy(vm.currNodeName, true); } if (ViNoEventManager.Instance != null) { nodeEvtData.eventType = "NODE_ENTER"; nodeEvtData.nodeName = vm.currNodeName; nodeEvtData.nodeObject = IScriptEngine.Instance.CURRENT; ViNoEventManager.Instance.TriggerEvent("OnEnterViNode", nodeEvtData); } }
static public void PlayScenario(string levelName, string scenarioName) { if (levelName != Application.loadedLevelName) // currentlyLoadedLevelName ){ { Debug.LogWarning("ScenarioCtrl couldn't play because LoadLevelName not match."); return; } // Get ScenarioObject. GameObject scenarioObj = GameObject.Find(scenarioName); bool isFromResource = false; if (scenarioObj == null) { Debug.LogWarning("ScenarioNode object NOT FOUND in scene. now Find in Resources."); scenarioObj = ViNoGOExtensions.InstantiateFromResource(scenarioName, null); if (scenarioObj == null) { Debug.LogError("ScenarioNode :" + scenarioName + " also Not Found in Resources."); } else { isFromResource = true; ViNoGOExtensions.StripGameObjectName(scenarioObj, "(Clone)", ""); } } ScenarioNode scenario = scenarioObj.GetComponent <ScenarioNode>(); if (scenario != null) { if (m_LoadLevelAndStartScenario) { scenario.startFromSave = true; } if (!isFromResource) { scenario.Play(); } } else { Debug.LogError("Scenario :" + scenarioName + "object not attached a ScenarioNode."); } m_LoadLevelAndStartScenario = false; m_LoadLevelAndNewGame = false; }
public override void Save(ScenarioNode node) { base.Save(node); if (this.m_ParamO1 && !Scenario.Get().m_ActionObjectsToSave.Contains(this.m_ParamO1)) { Scenario.Get().m_ActionObjectsToSave.Add(this.m_ParamO1); } if (this.m_ParamO2 && !Scenario.Get().m_ActionObjectsToSave.Contains(this.m_ParamO2)) { Scenario.Get().m_ActionObjectsToSave.Add(this.m_ParamO2); } string empty = string.Empty; if (this.m_ParamO1 && this.m_ComponentName != string.Empty && !Scenario.Get().m_ActionComponentToSave.TryGetValue(this.m_ParamO1, out empty)) { Scenario.Get().m_ActionComponentToSave.Add(this.m_ParamO1, this.m_ComponentName); } }
public void LoadScript(string script_name) { if (MainLevel.Instance.m_GameMode == GameMode.Debug) { return; } TextAssetParser textAssetParser = new TextAssetParser(Resources.Load(Scenario.s_ScriptPath + script_name) as TextAsset); for (int i = 0; i < textAssetParser.GetKeysCount(); i++) { Key key = textAssetParser.GetKey(i); if (key.GetName() == "Node") { ScenarioNode scenarioNode = new ScenarioNode(); scenarioNode.Load(key); this.AddNode(scenarioNode); } } }
/// <summary> /// Loads the data. /// </summary> static public bool LoadData(string fileName, ref ViNoSaveInfo info) { // IScriptEngine vino = IScriptEngine.Instance; ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null) { // if( vino.saveToExternalFile ){ // Load Flag Data from Storage. // FlagTable.FlagUnit[] flags = LoadFlagTable( fileName ); FlagTableData flagData = LoadFlagTable(fileName); if (scenario.flagTable != null) { #if false // scenario.flagTable.flags = flags; #else scenario.flagTable.flags = flagData.flags; scenario.flagTable.stringValues = flagData.stringValues; #endif } else { Debug.LogWarning("ScenarioNode.Instance " + scenario.name + " flagTable Not attached."); } // Load SaveData from Storage. LoadDataFromStorage(fileName, ref info); return(ViNo.Load(info)); // } /* else{ * return ViNo.Load( info ); * } * //*/ } else { Debug.LogWarning("ScenarioNode instance NOT FOUND."); return(false); } }
public override void Save(ScenarioNode node, int index) { base.Save(node, index); if (this.m_State == ScenarioElement.State.None) { return; } if (this.m_StartParamO1 && !Scenario.Get().m_ActionObjectsToSave.Contains(this.m_StartParamO1)) { Scenario.Get().m_ActionObjectsToSave.Add(this.m_StartParamO1); } if (this.m_StartParamO2 && !Scenario.Get().m_ActionObjectsToSave.Contains(this.m_StartParamO2)) { Scenario.Get().m_ActionObjectsToSave.Add(this.m_StartParamO2); } string empty = string.Empty; if (this.m_StartParamO1 && this.m_ComponentName != string.Empty && !Scenario.Get().m_ActionComponentToSave.TryGetValue(this.m_StartParamO1, out empty)) { Scenario.Get().m_ActionComponentToSave.Add(this.m_StartParamO1, this.m_ComponentName); } }
/// <summary> /// Checks the instance. /// if Played , the Played Scenario is the instance. /// if Awaken , the Awaken Scenairo is the instance. /// </summary> private void CheckInstance() { // DialogPartNode OnEnable is off. // SOUND DATA IS NOT USED CURRENTLY. #if false if (soundData != null) { ViNoSoundPlayer pl = ISoundPlayer.Instance as ViNoSoundPlayer; pl.SetSoundData(soundData); } #endif // Debug.Log( "ScenarioNode Check Instance."); /* if( saveInfo == null ){ * Debug.LogWarning( "SaveInfo not Attached to " + name + "ScenarioNode. The GameState of this ScenarioNode is NOT Saved." ) ; * } * //*/ if (flagTable == null) { Debug.LogWarning("FlagTable not Attached to " + name + "ScenarioNode. Flag Information is NOT to be Saved."); } if (ScenarioCtrl.Instance != null && ScenarioCtrl.Instance.destroyPrevScenario) { if (instance != null && instance.gameObject != this.gameObject) { // instance.gameObject.SetActive( false) ; Destroy(instance.gameObject); } } // Debug.Log( "ScenarioNode Instance is now :" + this.name ); instance = this; // Play a Scenario and Active. Currently false. // instance.gameObject.SetActive( true ); }
void eval(Hashtable param) { string exp = param["exp"] as string; Debug.Log("exp:" + exp); #if false exp = exp.Replace("\"", ""); string varName1 = string.Empty; string varName2 = string.Empty; string[] strs = exp.Split("=="[0]); bool processed = false; // == or !=. if (strs.Length >= 2) { processed = true; varName1 = strs[0]; varName2 = strs[1]; } else { strs = exp.Split("!="[0]); if (strs.Length >= 2) { processed = true; } } if (!processed) { } ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null && scenario.flagTable != null) { // scenario.flagTable.SetStringValue( ); } #endif }
/// <summary> /// Saves the data. if a Scenario is Played. /// </summary> static public bool SaveData(string fileName, ViNoSaveInfo info) { ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null) { // if( vino.saveToExternalFile ){ // ScenarioNode has a ViNoSaveInfo. saveInfo is a ScriptableObject Data. ViNo.SaveToExternalFile(fileName, info, scenario.flagTable); /* } * else{ * ViNo.Save( info ); * } * //*/ return(true); } else { Debug.LogWarning("ScenarioNode instance NOT FOUND."); return(false); } }
public TreeNode FindScenarioNodeTreeNode(ScenarioNode p) { if (p == null) { return(null); } TreeNode ymtnode = FindScenarioTreeNode(p.Ymt); var pointsnode = GetChildTreeNode(ymtnode, "Points"); if (pointsnode == null) { return(null); } for (int i = 0; i < pointsnode.Nodes.Count; i++) { TreeNode pnode = pointsnode.Nodes[i]; if (pnode.Tag == p) { return(pnode); } } return(null); }
public void RemoveNode(ScenarioNode node) { this.m_Nodes.Remove(node); }
public void AddNode(ScenarioNode node) { this.m_Nodes.Add(node); }
public bool IsNodeCompleted(string node_name) { ScenarioNode node = this.GetNode(node_name); return(node != null && node.m_State == ScenarioNode.State.Completed); }
public override string ToString() { return(ScenarioNode.ToString() + ": Rotation"); }
static public void CreateConvScene(string templScenePath) { GameObject sceneRoot = CreateTemplScene(templScenePath); sceneRoot.name = "A Conversation Scene"; string scenarioName = "A_Conversation"; if (!System.IO.Directory.Exists("Assets/" + scenarioName)) { AssetDatabase.CreateFolder("Assets", scenarioName); } GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(scenarioName, true); GameObject startObj = scenarioObj.transform.FindChild("START").gameObject; // scenarioObj.transform.parent.transform.parent = sceneRoot.transform; GameObject node0 = new GameObject("0_Scene"); LoadSceneNode loadSceneNode = node0.AddComponent <LoadSceneNode>(); loadSceneNode.sceneName = "Scene1"; loadSceneNode.method = LoadSceneNode.Methods.DESTROY_AND_LOAD; loadSceneNode.withFadeIn = true; loadSceneNode.transform.parent = startObj.transform; DialogPartNode dlgNode = ViNoToolUtil.AddDialogPartNode(startObj.transform); dlgNode.name = "1_Dialog"; DialogPartData data0 = dlgNode.AddData("", ""); DialogPartData data1 = dlgNode.AddData("Sachi", "Hello. I am Sachi."); DialogPartData data2 = dlgNode.AddData("", ""); DialogPartData data3 = dlgNode.AddData("Maiko", "Hi. Sachi."); DialogPartData data4 = dlgNode.AddData("Sachi", "Bye Bye !"); DialogPartData data5 = dlgNode.AddData("Maiko", "Bye Bye !"); DialogPartData data6 = dlgNode.AddData("", ""); data0.enterActorEntries = new DialogPartData.ActorEntry[1]; data0.enterActorEntries[0] = new DialogPartData.ActorEntry(); data0.enterActorEntries[0].actorName = "Sachi"; data0.actionID = DialogPartNodeActionType.EnterActor; data0.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_left; data1.isName = true; data2.enterActorEntries = new DialogPartData.ActorEntry[1]; data2.enterActorEntries[0] = new DialogPartData.ActorEntry(); data2.enterActorEntries[0].actorName = "Maiko"; data2.actionID = DialogPartNodeActionType.EnterActor; data2.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_right; data3.isName = true; data4.isName = true; data5.isName = true; data6.actionID = DialogPartNodeActionType.ExitActor; data6.exitActorEntries = new DialogPartData.ActorEntry[2]; data6.exitActorEntries[0] = new DialogPartData.ActorEntry(); data6.exitActorEntries[1] = new DialogPartData.ActorEntry(); data6.exitActorEntries[0].actorName = "Sachi"; data6.exitActorEntries[1].actorName = "Maiko"; #if false GameObject parentObj = GameObject.Find("Panels"); DrawObjectsTab.CreateBG("BG", parentObj); GameObject ch1 = DrawObjectsTab.Create2Layer("Ch1", parentObj); GameObject ch2 = DrawObjectsTab.Create2Layer("Ch2", parentObj); ch1.transform.localPosition = new Vector3(-120f, 0f, 0f); ch2.transform.localPosition = new Vector3(120f, 0f, 0f); AssetDatabase.MoveAsset("Assets/BG", "Assets/" + scenarioName + "/BG"); AssetDatabase.MoveAsset("Assets/Ch1", "Assets/" + scenarioName + "/Ch1"); AssetDatabase.MoveAsset("Assets/Ch2", "Assets/" + scenarioName + "/Ch2"); #endif string scenarioFlagDataPath = "Assets/" + scenarioName + "/" + scenarioName + "Flags.asset"; string scenarioSaveDataPath = "Assets/" + scenarioName + "/" + scenarioName + "SaveData.asset"; FlagTable flagTable = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable; ViNoSaveInfo saveInfo = ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath) as ViNoSaveInfo; ScenarioNode scenarioNode = scenarioObj.GetComponent <ScenarioNode>(); scenarioNode.m_PlayAtStart = true; scenarioNode.flagTable = flagTable; // scenarioNode.saveInfo = saveInfo; ScenarioCtrl scenarioCtrl = GameObject.FindObjectOfType(typeof(ScenarioCtrl)) as ScenarioCtrl; scenarioCtrl.quickSaveSlot = saveInfo; scenarioCtrl.saveInfo = saveInfo; // Create an ActorLibrary and a SceneLibrary. string actorLibPrefabPath = "Assets/" + scenarioName + "/ActorLibrary.prefab"; string sceneLibPrefabPath = "Assets/" + scenarioName + "/SceneLibrary.prefab"; ViNoScenarioDataUtil.CreateActorLibrary(actorLibPrefabPath); ViNoScenarioDataUtil.CreateSceneLibrary(sceneLibPrefabPath); GameObject.DestroyImmediate(GameObject.Find("ActorLibrary")); GameObject.DestroyImmediate(GameObject.Find("SceneLibrary")); // ViNoToolkit.ActorInfo actor1 = ViNoScenarioDataUtil.CreateActorInfo() as ViNoToolkit.ActorInfo; ViNoToolkit.SceneEvent sceneEvt = GameObject.FindObjectOfType(typeof(ViNoToolkit.SceneEvent)) as ViNoToolkit.SceneEvent; ViNoToolkit.ActorLibrary actorLib = AssetDatabase.LoadAssetAtPath(actorLibPrefabPath, typeof(ViNoToolkit.ActorLibrary)) as ViNoToolkit.ActorLibrary; ViNoToolkit.SceneLibrary sceneLib = AssetDatabase.LoadAssetAtPath(sceneLibPrefabPath, typeof(ViNoToolkit.SceneLibrary)) as ViNoToolkit.SceneLibrary; /* actorLib.actorEntries = new ViNoToolkit.ActorInfo[ 1 ]; * actorLib.actorEntries[ 0 ] = actor1; * //*/ sceneEvt.actorLib = actorLib; sceneEvt.sceneLib = sceneLib; }
public void SetRotation(Quaternion newrot, bool editPivot) { if (MultipleSelectionItems != null) { if (editPivot) { } else { var cen = MultipleSelectionCenter; var orinv = Quaternion.Invert(MultipleSelectionRotation); var trans = newrot * orinv; for (int i = 0; i < MultipleSelectionItems.Length; i++) { if (MultipleSelectionItems[i].CollisionPoly == null)//skip polys, they use gathered verts { var refpos = MultipleSelectionItems[i].WidgetPosition; var relpos = refpos - cen; var newpos = trans.Multiply(relpos) + cen; var refori = MultipleSelectionItems[i].WidgetRotation; var newori = trans * refori; MultipleSelectionItems[i].SetPosition(newpos, false); MultipleSelectionItems[i].SetRotation(newori, false); } } if (GatheredCollisionVerts != null) { for (int i = 0; i < GatheredCollisionVerts.Length; i++) { var refpos = GatheredCollisionVerts[i].Position; var relpos = refpos - cen; var newpos = trans.Multiply(relpos) + cen; GatheredCollisionVerts[i].Position = newpos; } } MultipleSelectionRotation = newrot; } } else if (EntityDef != null) { if (editPivot) { EntityDef.SetPivotOrientationFromWidget(newrot); } else { EntityDef.SetOrientationFromWidget(newrot); } } else if (CarGenerator != null) { CarGenerator.SetOrientation(newrot); } else if (CollisionVertex != null) { //do nothing, but stop any poly from being rotated also } else if (CollisionPoly != null) { CollisionPoly.Orientation = newrot; } else if (CollisionBounds != null) { CollisionBounds.Orientation = newrot; } else if (ScenarioNode != null) { ScenarioNode.SetOrientation(newrot); } else if (NavPoint != null) { NavPoint.SetOrientation(newrot); } else if (NavPortal != null) { NavPortal.SetOrientation(newrot); } else if (Audio != null) { Audio.SetOrientation(newrot); } }
public static void CreateStepNode( ReportLogs report, List <string> logs, FeatureContext featureContext, TestContext testContext, ScenarioContext scenarioContext, Contexts contexts) { if (report.Features == null) { report.Features = new List <FeatureNode>(); } var feature = report.Features.Find(f => f.Name == featureContext.FeatureInfo.Title); if (feature == null) { feature = new FeatureNode { Name = featureContext.FeatureInfo.Title }; report.Features.Add(feature); } if (feature.Scenarios == null) { feature.Scenarios = new List <ScenarioNode>(); } var scenario = feature.Scenarios.Find(s => s.Name == testContext.TestName); if (scenario == null) { scenario = new ScenarioNode { Name = testContext.TestName, Tags = scenarioContext.ScenarioInfo.Tags }; feature.Scenarios.Add(scenario); } var keyword = scenarioContext.StepContext.StepInfo.StepInstance.Keyword; var step = scenarioContext.StepContext.StepInfo.StepInstance.Text; if (string.IsNullOrEmpty(keyword)) { keyword = scenarioContext.StepContext.StepInfo.StepInstance.StepDefinitionKeyword.ToString(); logs.Add($"{keyword} {step}"); logs.AddRange(contexts.Logs); } else { logs = logs?.Select(x => " " + x.Replace("<br />", "<br /> ")).ToList(); logs.AddRange(contexts.Logs); if (scenario.Steps == null) { scenario.Steps = new List <StepNode>(); } if (scenarioContext.TestError == null) { scenario.Steps.Add(new StepNode { Keyword = keyword, Name = step, Pass = true, Logs = new List <string>(logs), ErrorMessage = string.Empty, Screenshot = string.Empty }); } else { scenario.Steps.Add(new StepNode { Keyword = keyword, Name = step, Pass = scenarioContext.TestError == null, Logs = new List <string>(logs), ErrorMessage = scenarioContext.TestError.Message, Screenshot = report.Name.Contains("API")? string.Empty : contexts.Screenshot }); } } }
public static EvaluationPocket Evaluate(string[][] pocketCardsStr, string[] boardStr, string[] deadStr) { int pocketsCount = pocketCardsStr.GetLength(0); int totalBoards = Eval(pocketCardsStr, boardStr, deadStr); ScenarioNode root = new ScenarioNode(); int[] values = new int[pocketsCount]; for (int i = 0; i < totalBoards; i++) { for (int p = 0; p < pocketsCount; p++) { values[p] = _boardsBuffer[i * pocketsCount + p]; } root.Add(ScenarioNode.Normalize(values), 1); } return new EvaluationPocket(pocketCardsStr, boardStr, deadStr, root.CollectScenarios()); }
/// <summary> /// Checks the instance. /// if Played , the Played Scenario is the instance. /// if Awaken , the Awaken Scenairo is the instance. /// </summary> private void CheckInstance() { // DialogPartNode OnEnable is off. // SOUND DATA IS NOT USED CURRENTLY. #if false if( soundData != null ){ ViNoSoundPlayer pl = ISoundPlayer.Instance as ViNoSoundPlayer; pl.SetSoundData( soundData ); } #endif // Debug.Log( "ScenarioNode Check Instance."); /* if( saveInfo == null ){ Debug.LogWarning( "SaveInfo not Attached to " + name + "ScenarioNode. The GameState of this ScenarioNode is NOT Saved." ) ; } //*/ if( flagTable == null ){ Debug.LogWarning( "FlagTable not Attached to " + name + "ScenarioNode. Flag Information is NOT to be Saved." ) ; } if( ScenarioCtrl.Instance != null && ScenarioCtrl.Instance.destroyPrevScenario ){ if( instance != null && instance.gameObject != this.gameObject ){ // instance.gameObject.SetActive( false) ; Destroy( instance.gameObject ); } } // Debug.Log( "ScenarioNode Instance is now :" + this.name ); instance = this; // Play a Scenario and Active. Currently false. // instance.gameObject.SetActive( true ); }
// ------------- Override --------------------. /// <summary> /// Handles the opcode. /// </summary> public override void OnUpdate() { if (IsFinish()) { return; } // Pomp Message to MessagingHandler. if (m_MessagePompToMsghandler) { if (m_MessagingHandler != null) { bool handled = m_MessagingHandler.HandleOpcode(this); m_MessagePompToMsghandler = !handled; } return; } m_CanTextProgress = false; switch (code[pc]) { case Opcode.STRING: pc = ByteCodeReader.readString(code, pc + 1); m_TextBuilder.Append(loadedString); break; case Opcode.TEXT: pc = ReadText(pc); break; case Opcode.VAR: pc = ByteCodeReader.readVar(code, pc, ref paramHash, ref m_TextBuilder, stubIndent); break; case Opcode.TABLE: pc = ByteCodeReader.readTable(code, pc, ref paramHash); break; case Opcode.ASSIGN_STRING: // Debug.Log("OPCODE>ASSIGN_STRING"); pc = ByteCodeReader.readString(code, pc + 2); leftHand = loadedString; pc = ByteCodeReader.readString(code, pc + 1); rightHand = loadedString; // Debug.Log( "Opcode.ASSIGN key=" + leftHand + " value=\"" + rightHand + "\"" ); // Assign Value to Hashtable ?. #if false symbolTable[leftHand] = rightHand; // Assign Value to FlagTable. #else ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null && scenario.flagTable != null) { scenario.flagTable.SetStringValue(leftHand, rightHand); } #endif leftHand = ""; rightHand = ""; break; case Opcode.NULL: pc++; break; case Opcode.MESSAGING: pc = ByteCodeReader.readString(code, pc + 2); messagingTargetName = loadedString; m_MessagePompToMsghandler = true; bool isIgnoreObj = loadedString.Equals("env"); if (!isIgnoreObj) { if (tweenDataCached.tweenTarget != null) { if (!tweenDataCached.tweenTarget.name.Equals(messagingTargetName)) { tweenDataCached.tweenTarget = GameObject.Find(messagingTargetName); } } else { tweenDataCached.tweenTarget = GameObject.Find(messagingTargetName); } } tweenDataCached.paramTable = paramHash; break; case Opcode.NODE: m_PrevNodeName = m_CurrNodeName; pc = ByteCodeReader.readString(code, pc + 2); ViNoDebugger.Log("NODE", loadedString); m_CurrNodeName = loadedString; m_NodePcMap[loadedString] = pc; SetCurrentNodeToScriptEngine(); // Callback to ScriptBinder. scriptBinder.OnEnterNode(this); break; case Opcode.LOAD_RESOURCE: m_LoadedResourcePath = VirtualMachine.loadedTextLiteralString; m_LoadedResource = UnityWrapper.LoadResource(m_LoadedResourcePath); pc++; break; // TODO : Need to Test . case Opcode.PLAY_AUDIO_FROM_RESOURCE: m_LoadedResourcePath = VirtualMachine.loadedTextLiteralString; ISoundPlayer.Instance.PlayAudioClip(m_LoadedResource as AudioClip, m_LoadedResourcePath, ViNoConfig.prefsBgmVolume, 0f); m_LoadedResource = null; Resources.UnloadUnusedAssets(); pc++; break; case Opcode.INSTANTIATE_AS_GAMEOBJECT: if (m_LoadedResource != null) { string parentName = VirtualMachine.loadedTextLiteralString; UnityWrapper.InstantiateAsGameObject(m_LoadedResource, parentName); m_LoadedResource = null; Resources.UnloadUnusedAssets(); } else { Debug.LogError("Resource not loaded."); } pc++; break; case Opcode.DESTROY_OBJECT: string goName = VirtualMachine.loadedTextLiteralString; GameObject go = GameObject.Find(goName); // TODO : GO.Find is Slow . GameObject.Destroy(go); pc++; break; case Opcode.JUMP: // Jump to loadedString Node . ByteCodeReader.readString(code, pc + 2); GoToLabel(loadedString); ViNoDebugger.Log("NODE", "jump to :" + loadedString); break; case Opcode.IF: pc = ByteCodeReader.readString(code, pc + 2); string flagName = VirtualMachine.loadedString; Debug.Log("flag name :" + flagName); bool isOnOrOff = (code[pc] == 1) ? true : false; pc++; pc = ByteCodeReader.readString(code, pc + 1); string ifTarget = VirtualMachine.loadedString; Debug.Log("IF =>" + ifTarget); pc = ByteCodeReader.readString(code, pc + 1); string elseTarget = VirtualMachine.loadedString; Debug.Log("ELSE =>" + elseTarget); bool isFlagOn = ScenarioNode.Instance.flagTable.CheckFlagBy(flagName); if (isFlagOn == isOnOrOff) { Debug.Log("IF"); GoToLabel(ifTarget); } else { Debug.Log("ELSE"); GoToLabel(elseTarget); } break; // ----- Layer -----. #if false case Opcode.LAYOPT: GOOptionNode.Do(paramHash); pc++; break; #endif case Opcode.BEGIN_TRANSITION: UnityWrapper.BeginTransition(); pc++; break; case Opcode.END_TRANSITION: UnityWrapper.EndTransition(); pc++; break; case Opcode.SCENE_NODE: SceneData.SceneNodeData data = SceneCreator.CreateNodeData(paramHash); SceneCreator.Create(data); pc++; break; case Opcode.LOAD_SCENE: // bool destroy = ( code[ pc + 1 ] == 0 ) ? true : false ; // UnityWrapper.LoadScene( m_LoadedResource , destroy ); LoadSceneNode.Do(m_LoadedResource, paramHash); m_LoadedResource = null; Resources.UnloadUnusedAssets(); pc++; break; case Opcode.CLEAR_SCENE: GameObject advSceneRoot = ViNoSceneManager.Instance.theSavedPanel; bool immediateDestroy = false; SceneCreator.DestroyScene(advSceneRoot, immediateDestroy); pc++; break; /* case Opcode.PLAY_ANIMATION: * byte animationID = code[ pc + 1 ]; * ViNoAnimationManager.Instance.PlayAnimation( (int)animationID ); * pc+= 2; * break; * //*/ // ----- Message -----. case Opcode.BR: // m_TextBuilder.Append( "\n" ); pc++; break; //scriptBinder.BR( this ); pc++; break; case Opcode.CM: ClearMessage(); pc++; break; case Opcode.ER: AddToBacklog(); ClearTextBuilder(); if (m_MsgTargetTextBox != null) { m_MsgTargetTextBox.ClearMessage(); } else { Debug.LogWarning("Current Message Target Not Set."); } pc++; break; case Opcode.PRINT: scriptBinder.PRINT(this); pc++; break; case Opcode.CURRENT: TriggerMessageEvent("OnMessageTargetChanged", code[pc + 1], "", true); break; case Opcode.SET_TEXT: TriggerMessageEvent("OnSetText", code[pc + 1], VirtualMachine.loadedTextLiteralString, true); m_CurrentText = m_MessageEventData.message; break; case Opcode.HIDE_MESSAGE: TriggerMessageEvent("OnHideMessage", code[pc + 1], "", false); break; // ------ System Opcode -----. case Opcode.START_WAIT: m_ElapsedSec = 0f; if (!string.IsNullOrEmpty(loadedTextLiteralString)) { m_WaitSec = float.Parse(loadedTextLiteralString); } else { m_WaitSec = kWaitSec; } pc++; break; case Opcode.UPDATE_WAIT: // ViNoDebugger.Log( "VM" , "waiting ..."); m_ElapsedSec += Time.deltaTime; if (m_ElapsedSec > m_WaitSec) { pc++; } break; case Opcode.STOP: // Wait Until Player choosing from options . or reached to the end of a leaf node . // Nothing to do... break; case Opcode.END: ViNoEventManager.Instance.TriggerEvent("OnFinishScenario"); update = false; break; case Opcode.PLAY_SCENARIO: pc = ByteCodeReader.readString(code, pc + 2); string scenarioName = loadedString; GameObject scenarioObj = GOCache.SetActive(scenarioName, true); if (scenarioObj != null) { ScenarioNode s = scenarioObj.GetComponent <ScenarioNode>(); s.Play(); } break; case Opcode.FLAG_ON: if (ScenarioNode.Instance != null && ScenarioNode.Instance.flagTable != null) { ScenarioNode.Instance.flagTable.SetFlagBy(VirtualMachine.loadedTextLiteralString, true); } pc++; break; case Opcode.FLAG_OFF: if (ScenarioNode.Instance != null && ScenarioNode.Instance.flagTable != null) { ScenarioNode.Instance.flagTable.SetFlagBy(VirtualMachine.loadedTextLiteralString, false); } pc++; break; case Opcode.SELECTIONS: ISelectionsCtrl selCtrl = ISelectionsCtrl.Instance; if (selCtrl != null) { if (!selCtrl.IsActive()) { string title = VirtualMachine.loadedTextLiteralString; selCtrl.SetTitle(title); ISelectionsCtrl.Instance.ChangeActive(true); } } else { Debug.LogError("ISelectionsCtrl instance not found."); } pc++; break; case Opcode.LINK: ISelectionsCtrl.Instance.AddSelection(ref paramHash); pc++; break; case Opcode.WAIT_TOUCH: if (IScriptEngine.skip) { if (IScriptEngine.skipAlreadyPass && !VirtualMachine._ALREADY_PASS_THE_NODE) { return; } _SkipText( ); ISoundPlayer pl = ISoundPlayer.Instance; if (pl != null) { if (pl.IsPlayingVoice()) { pl.StopVoice(); } } m_CanTextProgress = true; return; } if (autoMode) { float dt = Time.deltaTime; m_TimeElapsed += dt; if (m_TimeElapsed > _AUTO_MODE_WAIT_TIME) { m_TimeElapsed = 0f; _SkipText(); } return; } m_CanTextProgress = true; break; // case Opcode.PLAY_BGM: // break; // -----Audio -----. case Opcode.PLAY_SOUND: byte soundCategory = code[pc + 1]; // 0: BGM 1:SE 2: VOICE. byte soundID = code[pc + 2]; UnityWrapper.PlaySound(soundCategory, soundID); if (soundCategory == 2) { SET_CURRENT_VOICE_ID(true, soundID); } pc += 3; break; case Opcode.STOP_SOUND: //TODO : pc++; break; case Opcode.STOP_VOICE: SET_CURRENT_VOICE_ID(false, 0); if (ISoundPlayer.Instance != null) { ISoundPlayer.Instance.StopVoice(); } pc++; break; default: ViNoDebugger.LogError("VM", "PC : " + pc); break; } }
private string vpathEvaluator(Match match) { if (Scenario == null) return ""; var vpath = match.Groups[1].Value; var branch = Scenario.Vault.GetBranch(vpath); if (branch == null) return "<span style='background-color:red'>Узел не существует</span>"; var value = branch.GetValue("declarationType"); if (value != null) { var type = value.ContentString; if (type == "formula") { string eval = null; var conditions = branch.Parent.Parent.GetBranch("_conditions"); var isConditional = conditions != null && conditions.GetBranches().Length > 0; TreeNode treeNode; var index = branch.GetValue("elfCode").ContentString.IndexOf('='); if (isConditional && _map.TryGetValue(branch.Parent.Parent.Id, out treeNode) && index > 0) { treeNode = treeNode.Nodes.Cast<TreeNode>().Where(x => x.Checked).FirstOrDefault(); if (treeNode != null) { var scenarioNode = new ScenarioNode(treeNode.Tag as IBranch); var varName = branch.GetValue("elfCode").ContentString.Substring(0, index); var realCode = scenarioNode.FormulaDeclarations.Where(x => x.ElfCode.IndexOf(varName) > 0).FirstOrDefault(); if (realCode != null) { var lines = realCode.ElfCode.Split('\n'); lines[lines.Length - 1] = "ret " + lines[lines.Length - 1]; eval = string.Join(Environment.NewLine, lines); } } } try { eval = _evalSession2.Eval(branch, eval).ToString(); } catch (Exception) { eval = string.Format("<div style='background-color:red'>Ошибка вычисления формулы</div>"); } return eval; } } var selfValue = branch.GetValue("valueForTesting").ContentString; if (string.IsNullOrEmpty(selfValue)) { var repositoryVPath = branch.GetValue("repositoryValue").ContentString; if (!string.IsNullOrEmpty(repositoryVPath)) { using (var repo = RepositoryEditor.Repository()) { var v = repo.GetValue(repositoryVPath); if (v == null) return ""; return v.ContentString ?? ""; } } } return selfValue; }
public string GetFullNameString(string defval) { string name = defval; if (MultipleSelection) { name = "Multiple items"; } else if (EntityDef != null) { name = EntityDef._CEntityDef.archetypeName.ToString(); } else if (Archetype != null) { name = Archetype.Hash.ToString(); } else if (CollisionBounds != null) { name = CollisionBounds.GetName(); } if (Geometry != null) { name += " (" + GeometryIndex.ToString() + ")"; } if (TimeCycleModifier != null) { name = TimeCycleModifier.CTimeCycleModifier.name.ToString(); } if (BoxOccluder != null) { name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString(); } if (OccludeModel != null) { name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString(); } if (CarGenerator != null) { name = CarGenerator.NameString(); } if (EntityExtension != null) { name += ": " + EntityExtension.Name; } if (ArchetypeExtension != null) { name += ": " + ArchetypeExtension.Name; } if (WaterQuad != null) { name = "WaterQuad " + WaterQuad.ToString(); } if (NavPoly != null) { name = "NavPoly " + NavPoly.ToString(); } if (NavPoint != null) { name = "NavPoint " + NavPoint.ToString(); } if (NavPortal != null) { name = "NavPortal " + NavPortal.ToString(); } if (PathNode != null) { name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position); } if (TrainTrackNode != null) { name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position); } if (ScenarioNode != null) { name = ScenarioNode.ToString(); } if (Audio != null) { name = Audio.ShortTypeName + " " + Audio.GetNameString();// + FloatUtil.GetVector3String(Audio.InnerPos); } if (MloRoomDef != null) { name = "MloRoomDef " + MloRoomDef.RoomName; } return(name); }
// private SerializedProperty soundDataProp = null; private static void CompileAndSaveAsBinaryFile( string fileName , ScenarioNode scenario ) { ByteCodes btcodes = scenario.Compile(); ViNode.SaveByteCodesToFile( fileName , btcodes.GetCode() ); }