public override void createUIDescription(CutScene cutScene, SerializedObject serializedObject) { //display GUILayout.Label("<<Decision OnSwitch Node>>"); //switch system here: listOfSwitches.Clear(); listOfSwitches.Add("None"); foreach (GameSwitch gameSwitch in cutScene.css.SwitchVariables) { listOfSwitches.Add(gameSwitch.name); } indexOfSwitch = EditorGUILayout.Popup("Switch to check: ", indexOfSwitch, listOfSwitches.ToArray()); if (cutScene.css.SwitchVariables.Count > 0 && (indexOfSwitch - 1) >= 0) { decisionSwitch = cutScene.css.SwitchVariables [indexOfSwitch - 1]; } else { decisionSwitch = null; } //Now, for the inpector variables cutSceneToGo = (CutScene)EditorGUILayout.ObjectField("Cut Scene To Jump if switch's true: ", cutSceneToGo, typeof(CutScene), true); if (cutSceneToGo == null) { EditorGUILayout.HelpBox("if the switch is false the cutscene will stop in this node and will not execute the next nodes. If true, continues normally executing.", MessageType.Info); } else { EditorGUILayout.HelpBox("If the switch is false, the execution of the cutscene continues normally. If the switch is true, then the target cutscene is going to be played next.", MessageType.Info); } }
/// <summary> /// el: selfswitch /// switch [map:"integer"] [id:"integer"] local:"A-Z" /// [set "true|false"] /// </summary> /// <returns></returns> static void SelfSwitch() { MakeCommand.Category("switch"); int mapId = MakeCommand.MapId; int id = MakeCommand.EventId; if (MakeCommand.Optional("map")) { mapId = MakeCommand.Parameter("map").ToInteger(); } if (MakeCommand.Optional("id")) { id = MakeCommand.Parameter("id").ToInteger(); } string local = MakeCommand.Parameter("local").ToString(); GameSwitch s = new GameSwitch(mapId, id, local); if (MakeCommand.Optional("set")) { InGame.System.GameSelfSwitches[s] = MakeCommand.Command("set").ToBoolean(); if (mapId == InGame.Map.MapId) { InGame.Map.IsNeedRefresh = true; } } else { LastCondition = InGame.System.GameSelfSwitches[s]; } }
public override void createUIDescription(CutScene cutScene, SerializedObject serializedObject) { int i = 0; //display GUILayout.Label("<<Change Switch Value>>"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Set "); switchNames.Clear(); foreach (GameSwitch gameSwitch in cutScene.css.SwitchVariables) { switchNames.Add(gameSwitch.name); } selectedIndex = (int)EditorGUILayout.Popup(selectedIndex, switchNames.ToArray()); if (cutScene.css.SwitchVariables.Count > 0) { targetSwitch = cutScene.css.SwitchVariables[selectedIndex]; } GUILayout.Label(" to "); state = (SwitchState)EditorGUILayout.EnumPopup("", state); EditorGUILayout.EndHorizontal(); //eventCallee = (MonoBehaviour)EditorGUILayout.ObjectField ("Object: ",eventCallee, typeof(MonoBehaviour),true); //functionName = EditorGUILayout.TextField ("FuncitonName: ",functionName); }
/// <summary> /// Control Self Switch /// </summary> bool Command123() { // If event ID is valid if (eventId > 0) { // Make a self switch key GameSwitch key = new GameSwitch(InGame.Map.MapId, eventId, stringParams[0]); // Change self switches InGame.System.GameSelfSwitches[key] = (intParams[0] == 0); // Refresh map InGame.Map.IsNeedRefresh = true; } return(true); }
/// <summary> /// Control Self Switch /// </summary> bool Command123() { // If event ID is valid if (eventId > 0) { // Make a self switch key GameSwitch key = new GameSwitch(InGame.Map.MapId, eventId, stringParams[0]); // Change self switches InGame.System.GameSelfSwitches[key] = (intParams[0] == 0); // Refresh map InGame.Map.IsNeedRefresh = true; } return true; }
public override void OnInspectorGUI() { DrawDefaultInspector(); CutSceneSystem css = (CutSceneSystem)target; EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("New Switch:"); switchNameField = EditorGUILayout.TextField(switchNameField); if (GUILayout.Button("Add Switch", GUILayout.Width(100)) && switchNameField != "") { if (css.SwitchVariables == null) { css.SwitchVariables = new List <GameSwitch>(); } if (!checkNameInSwitchList(switchNameField, css)) { GameSwitch gs = GameSwitch.CreateInstance <GameSwitch>(); gs.name = switchNameField; gs.value = false; css.SwitchVariables.Add(gs); switchNameField = ""; } else { Debug.Log("Switch with name " + switchNameField + " already exists!"); } } EditorGUILayout.EndHorizontal(); foreach (GameSwitch gameSwitch in css.SwitchVariables) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(25))) { css.SwitchVariables.Remove(gameSwitch); } EditorGUILayout.LabelField(gameSwitch.name + " , " + gameSwitch.value); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
public void ResetText() { if (this.GroupID == -1 || this.SwitchID == -1) { SetInitialText(""); } else { if (this.GroupID > Editor.ProjectSettings.Switches.Count) { SetInitialText(""); } else if (this.SwitchID > Editor.ProjectSettings.Switches[this.GroupID - 1].Switches.Count) { SetInitialText(""); } else { GameSwitch sw = Editor.ProjectSettings.Switches[this.GroupID - 1].Switches[this.SwitchID - 1]; SetInitialText($"{Utilities.Digits(this.SwitchID, 3)}: {sw.Name}"); } } }
/// <summary> /// Conditional Branch /// </summary> bool Command111() { // Initialize local variable: result bool result = false; switch (intParams[0]) { #region if switch case 0: // switch result = (InGame.Switches.Arr[intParams[1]] == (intParams[2] == 0)); break; #endregion #region if variable case 1: // variable int value1 = InGame.Variables.Arr[intParams[1]]; int value2; if (intParams[2] == 0) { value2 = intParams[3]; } else { value2 = InGame.Variables.Arr[intParams[3]]; } switch (intParams[4]) { case 0: // value1 is equal to value2 result = (value1 == value2); break; case 1: // value1 is greater than or equal to value2 result = (value1 >= value2); break; case 2: // value1 is less than or equal to value2 result = (value1 <= value2); break; case 3: // value1 is greater than value2 result = (value1 > value2); break; case 4: // value1 is less than value2 result = (value1 < value2); break; case 5: // value1 is not equal to value2 result = (value1 != value2); break; } break; #endregion #region if self switch case 2: // self switch if (eventId > 0) { GameSwitch key = new GameSwitch(InGame.Map.MapId, eventId, stringParams[0]); if (intParams[1] == 0) { result = (InGame.System.GameSelfSwitches[key] == true); } else { result = (InGame.System.GameSelfSwitches[key] != true); } } break; #endregion #region if Timer case 3: // Timer if (InGame.System.IsTimerWorking) { int sec = InGame.System.Timer / Graphics.FrameRate; if (intParams[2] == 0) { result = (sec >= intParams[1]); } else { result = (sec <= intParams[1]); } } break; #endregion #region if actor case 4: // actor GameActor actor = InGame.Actors[intParams[1] - 1]; if (actor != null) { switch (intParams[2]) { case 0: // in party result = InGame.Party.Actors.Contains(actor); break; case 1: // Name result = (actor.Name == stringParams[0]); break; case 2: // skill result = (actor.IsSkillLearn(intParams[3])); break; case 3: // weapon result = (actor.WeaponId == intParams[3]); break; case 4: // armor int test = intParams[3]; result = (actor.ArmorShield == test || actor.ArmorHelmet == test || actor.ArmorBody == test || actor.ArmorAccessory == test); break; case 5: // state result = (actor.IsState(intParams[3])); break; } } break; #endregion #region if enemy case 5: // enemy GameNpc enemy = InGame.Troops.Npcs[intParams[1]]; if (enemy != null) { switch (intParams[2]) { case 0: // appear result = (enemy.IsExist); break; case 1: // state result = (enemy.IsState(intParams[3])); break; } } break; #endregion #region if Character case 6: // Character GameCharacter character = GetCharacter(intParams[1]); if (character != null) { result = (character.Dir == intParams[2]); } break; #endregion #region if gold case 7: // gold if (intParams[2] == 0) { result = (InGame.Party.Gold >= intParams[1]); } else { result = (InGame.Party.Gold <= intParams[1]); } break; #endregion #region if item case 8: // item result = (InGame.Party.ItemNumber(intParams[1]) > 0); break; #endregion #region if weapon case 9: // weapon result = (InGame.Party.WeaponNumber(intParams[1]) > 0); break; #endregion #region if armor case 10: // armor result = (InGame.Party.ArmorNumber(intParams[1]) > 0); break; #endregion #region if button case 11: // button result = (Input.IsPressed(intParams[1])); break; #endregion #region if EL case 12: // script // no scripting - result = eval(parameters[1]); result = MakeCommand.LastCondition; break; #endregion } // Store determinant results in hash branch[list[index].Indent].Result = result; // If determinant results are true if (result == true) { return(true); } // If it doesn't meet the conditions: command skip return(CommandSkip()); }
/// <summary> /// el: selfswitch /// switch [map:"integer"] [id:"integer"] local:"A-Z" /// [set "true|false"] /// </summary> /// <returns></returns> static void SelfSwitch() { MakeCommand.Category("switch"); int mapId = MakeCommand.MapId; int id = MakeCommand.EventId; if (MakeCommand.Optional("map")) mapId = MakeCommand.Parameter("map").ToInteger(); if (MakeCommand.Optional("id")) id = MakeCommand.Parameter("id").ToInteger(); string local = MakeCommand.Parameter("local").ToString(); GameSwitch s = new GameSwitch(mapId, id, local); if (MakeCommand.Optional("set")) { InGame.System.GameSelfSwitches[s] = MakeCommand.Command("set").ToBoolean(); if (mapId == InGame.Map.MapId) InGame.Map.IsNeedRefresh = true; } else { LastCondition = InGame.System.GameSelfSwitches[s]; } }
void Start() { if (PlayerObject == null) { PlayerObject = GameObject.Find("Faylisa"); if (PlayerObject == null) { PlayerObject = GameObject.Find("BlueHat"); } } RecordingTime = true; IsPause = false; InputMgr = gameObject.AddComponent <GameInput>(); PlayerLogic = PlayerObject.AddMissingComponent <Player>(); LineMgr = gameObject.AddMissingComponent <LineMgr>(); UiManager = gameObject.AddMissingComponent <UIManager>(); UiManager.OpenUI(0); Config = new GameConfig(); Config.Load(); // 查找开关 var s = GameObject.Find("GameSwitch"); if (s != null) { WorldSwith = s.GetComponent <GameSwitch>(); } if (WorldSwith == null) { WorldSwith = new GameSwitch(); WorldSwith.ForbidDrawLine = false; WorldSwith.ForbidTimeOperation = false; } if (Camera.main.GetComponent <ProCamera2D>().CameraTargets.Count == 0) { Camera.main.GetComponent <ProCamera2D>().AddCameraTarget(PlayerObject.transform); } Camera.main.GetComponent <ProCamera2DTransitionsFX>().TransitionEnter(); GameObject bgm = GameObject.Find("BGManager"); if (bgm == null) { Instantiate(Resources.Load("prefabs/Utilities/BGManager")); } // 首先从gamedata中得到当前level的保存信息 // 如果没有保存内容,那么就创建一个 if (GameData.Instance != null) { SaveBlack data = GameData.Instance.GetLevelData(LevelName); if (data == null) { GameData.Instance.AddNewLevel(LevelName, LevelName, PlayerLogic.Position); } else { GameData.Instance.ChangeCurrentLevel(LevelName); // 重置玩家坐标 PlayerLogic.SetRevivePoint(data.BornPos); PlayerLogic.Position = data.BornPos; } } CreateLevelItem(); PlayerLogic.OnPickUpAction += GameData.Instance.SaveCollectPickup; }