コード例 #1
0
 public override void Unload()
 {
     Tom.Dispose();
     Tom = null;
     Char.Dispose();
     Char = null;
     foreach (Image i in RPS)
     {
         i.Dispose();
     }
     RPS.Clear();
     if (Game.worldscreen != null)
     {
         Game.worldscreen.Active = true;
     }
     BGM.StopBGM();
     base.Unload();
 }
コード例 #2
0
 private void Mode_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Y <= Mode.Height / 3)
     {
         Globals.Mode = HardMode.Easy;
     }
     else if (e.Y <= Mode.Height * 2 / 3)
     {
         Globals.Mode = HardMode.Normal;
     }
     else
     {
         Globals.Mode = HardMode.Hard;
     }
     Unload();
     Game.Player = new Character(SelectedCharacterIndex);
     BGM.StopBGM();
     Game.StartGame();
 }
コード例 #3
0
 public override void KeyUp(Keys key)
 {
     if (key == Keys.Up)
     {
         SelectedIndex -= 1;
         SoundManager.PlayByFileName("Select1");
         //Cursor.Position = new Point(Globals.Main.Location.X + Mode.Width / 2, Globals.Main.Location.Y + 20 + Mode.Height / 3 * SelectedIndex + Mode.Height / 6);
     }
     else if (key == Keys.Down)
     {
         SelectedIndex += 1;
         SoundManager.PlayByFileName("Select1");
         //Cursor.Position = new Point(Globals.Main.Location.X + Mode.Width / 2, Globals.Main.Location.Y + 20 + Mode.Height / 3 * SelectedIndex + Mode.Height / 6);
     }
     else if (key == Keys.Enter || key == Keys.Space)
     {
         BGM.StopBGM();
         SoundManager.PlayByFileName("Select2");
         //Mode_MouseClick(null, new MouseEventArgs(MouseButtons.Left, 1, Mode.PointToClient(Cursor.Position).X, Mode.PointToClient(Cursor.Position).Y, 0));
         Mode_MouseClick(null, new MouseEventArgs(MouseButtons.Left, 1, Mode.PointToClient(Cursor.Position).X, SelectedIndex * Mode.Height / 3 + 20, 0));
     }
 }
コード例 #4
0
 public override void Update()
 {
     if (Selected)
     {
         SelectedTimer += Game.ElapsedGameTime;
         if (SelectedTimer >= SelectedInterval)
         {
             SelectedTimer = 0;
             Selected      = false;
             if (Round >= 10)
             {
                 Unload();
                 BGM.StopBGM();
                 Game.InGame = false;
                 Game.worldscreen.Unload();
                 Game.Tomming = 10;
                 Globals.Main.videoPlayer.Visible = true;
                 Globals.Main.videoPlayer.URL     = Globals.GameDir + @"\Content\Video\Tom.mp4";
                 Globals.Main.videoPlayer.Ctlcontrols.play();
             }
         }
     }
 }
コード例 #5
0
        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());
            }
        }
コード例 #6
0
        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;
                }
            }
        }