public static void HandleTriggers(string script) { if (script.Length == 0) { return; } //Action1; Action2; Action3;...| (Value1, Value2),...; Values;... string[] Action = script.Split('|')[0].Split(';'); string[] Values = script.Split('|')[1].Split(';'); for (int i = 0; i <= Action.Length - 1; i += 1) { string[] Value = Values[i].Split(','); switch (Action[i]) { case "Load Map": //Tên map, vị trí X, vị trí Y. //Game.Player.CurPos = new Point(0, 0); MapHandler.LoadMap(Value[0]); Game.Player.CurPos.X = Convert.ToInt32(Value[1]); Game.Player.CurPos.Y = Convert.ToInt32(Value[2]); Game.Player.OffSet = new Point(0, 0); break; case "Show Dialog": //Text(s) List <string> s = new List <string>(); s.AddRange(Value[0].Split('\n')); ScreenManager.AddScreen(new DialogScreen(s)); break; case "Load Scene": //FileName ScreenManager.AddScreen(new SceneScreen(DataHandler.LoadScene(Globals.GameDir + "\\Data\\Scenes\\" + Values[0] + ".dat"))); break; default: break; } } }
private void Form1_KeyPress(object sender, KeyPressEventArgs e) { ScreenManager.HandleInput(e.KeyChar); if (e.KeyChar == 'j') { ScreenManager.AddScreen(new SceneScreen(DataHandler.LoadScene(Globals.GameDir + "\\Data\\Scenes\\1.dat"))); //Scene newScene = new Scene(); //SceneFrame newFrame = new SceneFrame(); //newFrame.BGFileName = "Meadow"; //newFrame.Characters.Add(new CharImage("Loli", new Rectangle(108, 50, 0, 0))); //newFrame.Characters.Add(new CharImage("Toad", new Rectangle(660, 50, 200, 200))); //newFrame.Name = "Chiyo"; //newFrame.Text = "Hello Toad"; //newScene.Frames.Add(newFrame); //newFrame = new SceneFrame(); //newFrame.BGFileName = "Meadow"; //newFrame.Characters.Add(new CharImage("Loli", new Rectangle(424, 50, 0, 0))); //newFrame.Name = "Chiyo"; //newFrame.Text = "Con cóc biến mất rồi!"; //newScene.Frames.Add(newFrame); //ScreenManager.AddScreen(new SceneScreen(newScene)); } }
public static void HandleTriggers(string script) { if (script.Length == 0) { return; } //Action|Value1, Value2, Values3,...|Conditions //Load Map|Map2, X, Y //Action1; Action2; Action3;...| Value1, Value2,...; Values;... string[] str = script.Split('|'); string[] Action = str[0].Split(';'); string[] Values = str[1].Split(';'); string[] Conditions = { "" }; if (str.Length > 2) { Conditions = script.Split('|')[2].Split(';'); } for (int i = 0; i <= Action.Length - 1; i += 1) { string[] Value = Values[i].Split(','); string[] Condition = Conditions[i].Split(','); if (CheckConditions(Condition) == false) { continue; } switch (Action[i].ToLower()) { case "load map": //Tên map, vị trí X, vị trí Y //Game.Player.CurPos = new Point(0, 0); MapHandler.LoadMap(Value[0]); Game.Player.CurPos.X = Convert.ToInt32(Value[1]); Game.Player.CurPos.Y = Convert.ToInt32(Value[2]); Game.Player.OffSet = new Point(0, 0); break; case "load scene": //FileName //Load Scene|1 ScreenManager.AddScreen(new SceneScreen(DataHandler.LoadScene(Globals.GameDir + "\\Data\\Scenes\\" + Value[0] + ".dat"))); break; case "play sound": //FileName SoundManager.PlayByFileName(Value[0]); break; case "play bgm": //FileName BGM.PlayByFileName(Value[0]); break; case "stop bgm": BGM.StopBGM(); break; case "Pause BGM": BGM.PauseBGM(); break; case "resume bgm": BGM.ResumeBGM(); break; case "tom": ScreenManager.AddScreen(new TrollScreen()); break; default: break; } } }