public static void Initialize(Form Form) { Textures.Initialize(); GameWindow = Form; //g = Graphics.FromImage(bb); //bbg = GameWindow.CreateGraphics(); Scale(GameWindow); DataHandler.LoadCharType(); //World = new Map("World", 20, 20); worldscreen = new WorldScreen(); ScreenManager.AddScreen(worldscreen); MapHandler.LoadMap("1"); SkillButtons.Add(Keys.Space, null); SkillButtons.Add(Keys.S, null); SkillButtons.Add(Keys.D, null); Player = new Character(); //Test SkillButtons[Keys.Space] = new sAttack(); SkillButtons[Keys.Space].Owner = Player; //BGM.PlayBGM(Globals.GameDir + "\\Content\\BGM\\Departure.mp3"); GameTime.Start(); GameLoop(); }
public static void StartGame(bool StartAsEditor = false) { if (StartAsEditor) { Player = new Character(); } worldscreen = new WorldScreen(); ScreenManager.AddScreen(worldscreen); if (!StartAsEditor) { ScreenManager.AddScreen(new SceneScreen(DataHandler.LoadScreneByName("StartScene"))); } MapHandler.LoadMap("StartMap"); Player.CurPos.X = 14; Player.CurPos.Y = 35; Player.OffSet = new Point(0, 0); Game.SetScreenByPlayerPos(); CharType.SetSkill(Player); ItemButtons.Add(Key.Z, new iRestoreHP(Player)); ItemButtons.Add(Key.X, new iRestoreMP(Player)); ItemButtons.First().Value.Count = 10; ItemButtons.Last().Value.Count = 5; Globals.InitializeFlags(); Globals.Money = 50000; //BGM.PlayBGM(Globals.GameDir + "\\Content\\BGM\\Departure.mp3"); InGame = true; }
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; } } }
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; } } }