public static void Load(Save save) { Game.Player = save.Player; ScreenManager.AddScreen(new WorldScreen()); Game.World = save.Map; Globals.CurrentMap = save.CurMap; Game.worldscreen.ShowMapName(5000); Globals.Money = save.Money; Globals.Mode = save.Mode; Globals.Flags = save.Flags; Game.SkillButtons = save.SkillButtons; Game.ItemButtons = save.ItemButtons; if (save.CurBGM.Length > 0) { BGM.PlayByFileName(save.CurBGM); } BGM.BGMPlayer.settings.setMode("loop", save.BGMLoop); save.BGMLoop = BGM.BGMPlayer.settings.getMode("loop"); Settings.SoundVolume = save.SoundVolume; Settings.MusicVolume = save.MusicVolume; Settings.ShowInfo = save.ShowInfo; Settings.ShowHPBars = save.ShowHPBars; Game.InGame = true; }
public TrollScreen() { Name = "Troll Screen"; if (Game.worldscreen != null) { Game.worldscreen.Active = false; } BGM.PlayByFileName("RPS"); if (Game.Player.charType.Index == 5) { Char = Image.FromFile(Globals.GameDir + @"\Content\Textures\Scenes\Characters\HHung.png"); } else if (Game.Player.charType.Index == 3) { Char = Image.FromFile(Globals.GameDir + @"\Content\Textures\Scenes\Characters\Dat.png"); } else if (Game.Player.charType.Index == 4) { Char = Image.FromFile(Globals.GameDir + @"\Content\Textures\Scenes\Characters\QHung.png"); } else if (Game.Player.charType.Index == 6) { Char = Image.FromFile(Globals.GameDir + @"\Content\Textures\Scenes\Characters\Khai.png"); } RPS.Add(Image.FromFile(Globals.GameDir + @"\Content\Textures\Arts\Rock.png")); RPS.Add(Image.FromFile(Globals.GameDir + @"\Content\Textures\Arts\Paper.png")); RPS.Add(Image.FromFile(Globals.GameDir + @"\Content\Textures\Arts\Scissors.png")); }
public static void Update() { for (int i = 0; i < SoundList.Count; i += 1) { //Lặp trong list Sound xem những sound nào đã chạy xong if (SoundList[i].Player.NaturalDuration.HasTimeSpan && SoundList[i].Player.Position.TotalMilliseconds >= SoundList[i].Player.NaturalDuration.TimeSpan.TotalMilliseconds) { if (SoundList[i].Loop) { //Chạy xong mà loop = true thì chạy lại SoundList[i].Player.Position = new TimeSpan(0, 0, 0); SoundList[i].Player.Play(); } else { //Chạy xong mà loop = false thì close + xóa khỏi list if (SoundList[i].FileName == "MapCleared") { BGM.PlayByFileName(Globals.CurrentMap); } SoundList[i].Player.Close(); SoundList.RemoveAt(i); i -= 1; } } } }
public static void LoadMap(string name) { string path = Globals.GameDir + "\\Map\\" + name + ".map"; if (File.Exists(path) == true) { Globals.CurrentMap = name; FileStream fs = new FileStream(path, FileMode.Open); GZipStream zipStream = new GZipStream(fs, CompressionMode.Decompress); BinaryReader reader = new BinaryReader(zipStream); Game.World = new Map(reader.ReadString(), reader.ReadInt32(), reader.ReadInt32()); foreach (Tile t in Game.World.TileList) { t.Location.X = reader.ReadInt32(); t.Location.Y = reader.ReadInt32(); foreach (TileLayer tl in t.Layers) { tl.srcImg = reader.ReadString(); tl.srcPos.X = reader.ReadInt32(); tl.srcPos.Y = reader.ReadInt32(); } t.IsBlocked = reader.ReadBoolean(); t.TouchTrigger = reader.ReadBoolean(); t.StepTrigger = reader.ReadBoolean(); t.Script = reader.ReadString(); } int count = reader.ReadInt32() - 1; for (int i = 0; i <= count; i += 1) { Character newChar = new Character(reader.ReadInt32()); newChar.team = (Team)reader.ReadInt32(); newChar.team = Team.Enemy; CharType.SetSkill(newChar); newChar.Level = reader.ReadInt32(); newChar.LastDir = (Dir)reader.ReadInt32(); newChar.CurPos = new Point(reader.ReadInt32(), reader.ReadInt32()); Game.World.MapChar.Add(newChar); } reader.Close(); reader.Dispose(); zipStream.Close(); zipStream.Dispose(); fs.Close(); fs.Dispose(); if (Game.EditorMode) { Globals.Editor.CurrentMap = path; } Game.worldscreen.ShowMapName(5000); if (name == "C1") { BGM.PlayByFileName("C1"); } } }
public CharacterSelectScreen() { Name = "Character Select Screen"; BGM.PlayByFileName("CharacterSelect"); Game.Frame.Visible = true; }
public static void OnCharacterDies(CharacterDies e) { if (e.Target == Game.Player) { //chạy code thua và trở về Title BGM.StopBGM(); Game.InGame = false; Game.worldscreen.Unload(); Globals.Main.videoPlayer.Visible = true; Globals.Main.videoPlayer.URL = Globals.GameDir + "\\Title\\GameOver.mp4"; Globals.Main.videoPlayer.Ctlcontrols.play(); return; } else if (e.Target.team == Team.Enemy) { //Drop Item int random = Globals.gen.Next(0, 101); if (random <= Globals.ITEM_DROP_PERCENTAGE) { Item item; int ran = Globals.gen.Next(0, 101); if (ran <= 70) { item = new iRestoreHP(Game.Player); } else if (random <= 100) { item = new iRestoreMP(Game.Player); } else { item = new iMoney(Game.Player); } item.LocInMap = new Rectangle(e.Target.CurRawPos.X, e.Target.CurRawPos.Y, Globals.TileSize, Globals.TileSize); Game.World.ItemList.Add(item); } } Game.World.DiedChar.Add(e.Target); if (e.Attacker == Game.Player) { Game.Player.curEXP += (int)((e.Target.Level / 3 + 1.0) * Globals.gen.Next(100, 201)); while (Game.Player.curEXP >= Game.Player.nextEXP) { Game.Player.Level += 1; Game.Player.previousEXP = Game.Player.nextEXP; Game.Player.nextEXP += (int)((10 + (Game.Player.Level * 3)) * 150 * (Game.Player.Level / 3 + 1.0)); Game.Player.HPMax += Game.Player.charType.luHP; Game.Player.MPMax += Game.Player.charType.luMP; Game.Player.ATK += Game.Player.charType.luAtk; Game.Player.DEF += Game.Player.charType.luDef; Game.Player.SATK += Game.Player.charType.luSAtk; Game.Player.SDEF += Game.Player.charType.luSDef; Game.Player.Speed += Game.Player.charType.luSpeed; //Thêm các thứ muốn cho khi người chơi lên level } } //Check Flags if (CheckMapEnemy() && e.Target.charType.Index != 10 && e.Target.charType.Index != 7) { //Set flag cho map đã clear if (Globals.Flags.ContainsKey(Globals.CurrentMap) && Globals.Flags[Globals.CurrentMap] == "Uncleared") { //Tạo boss của map Character subBoss = new Character(10); subBoss.team = Team.Enemy; CharType.SetSkill(subBoss); if (Globals.CurrentMap == "C9") { subBoss.CurPos = new Point(20, 11); } else if (Globals.CurrentMap == "D3") { subBoss.CurPos = new Point(17, 13); } else if (Globals.CurrentMap == "TQB") { subBoss.CurPos = new Point(21, 15); } else if (Globals.CurrentMap == "C1") { subBoss.CurPos = new Point(19, 11); } else { Globals.Flags[Globals.CurrentMap] = "Cleared"; } subBoss.ResetPos(); Game.World.NewChar.Add(subBoss); BGM.PlayByFileName("SubBoss"); } } if (e.Target.charType.Index == 10) { if (Globals.Flags.ContainsKey(Globals.CurrentMap)) { //Đánh xong boss phụ các map khác --> clear map đó if (Globals.CurrentMap == "C1" && Globals.Flags[Globals.CurrentMap] != "Cleared") { //Đánh xong boss phụ map C1 --> Tạo boss cuối Globals.Flags[Globals.CurrentMap] = "Cleared"; Character Boss = new Character(7); Boss.team = Team.Enemy; CharType.SetSkill(Boss); Boss.CurPos = new Point(19, 11); Game.World.NewChar.Add(Boss); ScreenManager.AddScreen(new SceneScreen(DataHandler.LoadScreneByName("FinalBoss"))); } else { Globals.Flags[Globals.CurrentMap] = "Cleared"; BGM.StopBGM(); SoundManager.PlayByFileName("MapCleared"); ScreenManager.AddScreen(new DummyScreen(8500)); } if (Globals.Flags["SubCleared"] == "false" && Globals.Flags["C9"] == "Cleared" && Globals.Flags["D3"] == "Cleared" && Globals.Flags["TQB"] == "Cleared") { Globals.Flags["SubCleared"] = "true"; } } } else if (e.Target.charType.Index == 7) { BGM.StopBGM(); SoundManager.PlayByFileName("BossDies"); ScreenManager.AddScreen(new DummyScreen(5000)); Game.Ending = true; } else if (e.Target.charType.Index == 8 || e.Target.charType.Index == 9) { SoundManager.PlayByFileName("GirlShout" + (e.Target.charType.Index - 7).ToString()); } }
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; } } }