Пример #1
0
 private void DrawMap(PaintEventArgs e)
 {
     if (!game.IsGameFinished && animationCycles <= 39)
     {
         e.Graphics.DrawImage(mapImage, coordinates.X, coordinates.Y, game.MapImage.Width, game.MapImage.Height);
         if (!pauseGame)
         {
             animationCycles++;
         }
         if (animationCycles % 10 == 0)
         {
             mapImage = GameMethods.GetImageByName($"{animationCycles / 10}_");
         }
     }
     else if (game.IsGameFinished && animationCycles > -1)
     {
         if (animationCycles > 0 && !pauseGame)
         {
             animationCycles--;
         }
         if (animationCycles % 10 == 9)
         {
             mapImage = GameMethods.GetImageByName($"{animationCycles / 10}_");
         }
         e.Graphics.DrawImage(mapImage, coordinates.X, coordinates.Y, game.MapImage.Width, game.MapImage.Height);
     }
     else
     {
         e.Graphics.DrawImage(game.MapImage, coordinates.X, coordinates.Y,
                              game.MapImage.Width, game.MapImage.Height);
     }
 }
Пример #2
0
        internal static void CheckGameUpload()
        {
            string game = AppData.gameData.ToString();

            AppData.lastGameJSON = JsonConvert.SerializeObject(JsonConvert.DeserializeObject <CompetitiveGame>(game), Formatting.Indented);
            if (!GameMethods.IsValidGame())
            {
                return;
            }
            CalculateStats();

            if (AppData.settings.outputStatsToTextFile)
            {
                try
                {
                    string outputStats = ScreenCaptureHandler.trayMenu.winratesForm.textBox1.Text
                                         .Replace("{win}", AppData.win.ToString())
                                         .Replace("{loss}", AppData.loss.ToString())
                                         .Replace("{draw}", AppData.draw.ToString())
                                         .Replace("{wr}", Math.Round((double)AppData.win / (double)(AppData.win + AppData.loss + AppData.draw) * 100, 2).ToString());
                    File.WriteAllText("stats.txt", outputStats);
                }
                catch { }
            }
            UploadGame(game);
        }
Пример #3
0
        public void StartGameHandler(int Game_Id)
        {
            var game = HttpContext.Application["Game-" + Game_Id] as GameModel;

            game = GameMethods.StartGame(game);
            HttpContext.Application["Game-" + game.Id] = game;

            BeginPhase1Handler(game.Id);
        }
Пример #4
0
 private void PausePress()
 {
     pauseGame = !pauseGame;
     if (pauseGame)
     {
         pauseButton.Image = GameMethods.GetImageByName("PAUSE_PRESSED_ACTIVE");
     }
     else
     {
         pauseButton.Image = GameMethods.GetImageByName("PAUSE");
     }
     menuButton.Enabled = !menuButton.Enabled;
     menuButton.Visible = !menuButton.Visible;
 }
    private void policeAskRAdius(int ind, int radius)
    {
        CheckPoints check     = gameClickHandler.allChecks[ind];
        Vector3     playerPos = check.transform.position;
        Vector3     myPos     = myThief.transform.position;
        float       dist2     = GameMethods.getSqrDist(playerPos, myPos);

        if (radius * radius < dist2 * dist2)
        {
            netView.RPC("thiefAskRadiusAnswer", RPCMode.OthersBuffered, new object[] { false });
        }
        else
        {
            netView.RPC("thiefAskRadiusAnswer", RPCMode.OthersBuffered, new object[] { true });
        }
    }
Пример #6
0
 private void OnFrameChanged(object sender, EventArgs e)
 {
     if (animationCycles < 12)
     {
         if (animationCycles % 3 == 0 && animationCycles != 0)
         {
             image = GameMethods.GetImageByName($"menu_{animationCycles / 3}");
         }
         animationCycles++;
     }
     else
     {
         animationCycles = 0;
         image           = GameMethods.GetImageByName($"menu_0");
     }
     Invalidate();
 }
Пример #7
0
        public GameModel CreateGameHandler(string Player_Name)
        {
            var game = GameMethods.CreateGame();

            var player = PlayerMethods.CreatePlayer(HttpContext.Session.SessionID, game.Id, Player_Name);

            // Add the player Id to the game
            game.Player_Ids = "," + player.Id;
            HttpContext.Application["Game-" + game.Id] = game;

            player.Game_Id = game.Id;
            HttpContext.Application["Player-" + player.Id] = player;

            Session["Game_Id"] = game.Id;
            // new Hubs.GameHub().JoinGroup(game.Id.ToString());

            return(game);
        }
Пример #8
0
    private IEnumerator moveToPlace(CheckPoints orig, CheckPoints next, TransportType type)
    {
        isMoving    = true;
        isClickable = false;
        Vector3 finalPos = next.transform.position;
        float   speed    = getSpeed(type);

        while (true)
        {
            //TODO Move at a given rate(tranport)
            Vector3 cur = GameMethods.getProjectionWithSpeed(finalPos, transform.position, speed, Time.deltaTime);
            transform.position = cur;
            if (cur == finalPos)
            {
                break;
            }
            yield return(new WaitForEndOfFrame());
        }
        isMoving = false;
        if (GameRunningScript.getInstance().selectedPlayer == this)
        {
            controller.showCooldownWindow();
        }
        currentTime = coolDownTime;
        while (currentTime > 0)
        {
            if (GameRunningScript.getInstance().selectedPlayer == this)
            {
                controller.setCooldownTime(currentTime);
            }
            yield return(new WaitForSeconds(1));

            currentTime--;
        }
        currentCheck = next;
        isClickable  = true;
        if (GameRunningScript.getInstance().selectedPlayer == this)
        {
            setSelected(false);
            setSelected(true);
        }
        yield break;
    }
Пример #9
0
 void Start()
 {
     //オブジェクトの格納
     scoreObject = GameObject.Find("ScoreObject");
     startObject = GameObject.Find("StartObject");
     billBoard   = GameObject.Find("BillBoard");
     //コンポーネントの格納
     sE = GameObject.Find("SE").GetComponent <SEController>();
     this.myAnimator             = GetComponent <Animator>();
     gameMethods                 = GameObject.Find("GameMethods").GetComponent <GameMethods>();
     opCounter                   = GameObject.Find("CountImage").GetComponent <OpCounter>();
     clearTimeText               = GameObject.Find("ClearTimeText").GetComponent <Text>();
     gameTitleTimeline           = GameObject.Find("GameTitleTimeline").GetComponent <PlayableController>();
     gameTitleTimelineChara      = GameObject.Find("GameTitleTimeline(Chara)").GetComponent <PlayableController>();
     gameSceneTimeline           = GameObject.Find("GameSceneTimeline").GetComponent <PlayableController>();
     gameTitleTimelineAfterScore = GameObject.Find("GameTitleTimeline(AfterScore)").GetComponent <PlayableController>();
     gameScoreTimeline           = GameObject.Find("GameScoreTimeline").GetComponent <PlayableController>();
     gameScoreTimelineChara      = GameObject.Find("GameScoreTimeline(Chara)").GetComponent <PlayableController>();
 }
Пример #10
0
 public async Task NewNumber()
 {
     await Clients.All.SendAsync("SentNewNumber", GameMethods.NewRandomNumber());
 }
Пример #11
0
        public void EndGameHandler(int Game_Id)
        {
            var game = HttpContext.Application["Game-" + Game_Id] as GameModel;

            GameMethods.EndGame(game, HttpContext);
        }
Пример #12
0
        public Menu()
        {
            SoundOn = true;
            var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            #region Sound Files Initialization
            var soundsFolder = Path.Combine(currentDirectory, @"sounds");
            if (!Directory.Exists(soundsFolder))
            {
                Directory.CreateDirectory(soundsFolder);
            }
            string musicFile = Path.Combine(currentDirectory, @"sounds\music.wav");
            FileInitialize(musicFile, Properties.Resources.music);
            string clickSoundFile = Path.Combine(currentDirectory, @"sounds\click.wav");
            FileInitialize(clickSoundFile, Properties.Resources.menu_select);
            FileInitialize(Path.Combine(currentDirectory, @"sounds\heal.wav"), Properties.Resources.heal);
            FileInitialize(Path.Combine(currentDirectory, @"sounds\heal_recharge.wav"), Properties.Resources.heal_recharge);
            FileInitialize(Path.Combine(currentDirectory, @"sounds\hit.wav"), Properties.Resources.hit);
            FileInitialize(Path.Combine(currentDirectory, @"sounds\game_over.wav"), Properties.Resources.game_over);
            //Music Player Creation
            music     = new WindowsMediaPlayer();
            music.URL = musicFile;
            music.controls.stop();
            music.settings.setMode("loop", true);
            music.settings.volume = 10;
            if (SoundOn)
            {
                music.controls.play();
            }
            //Click Sound Player Creation
            clickSound                 = new WindowsMediaPlayer();
            clickSound.URL             = clickSoundFile;
            clickSound.settings.volume = 10;
            clickSound.controls.stop();
            #endregion
            #region Font File Initialization
            string fontFile = Path.Combine(currentDirectory, @"fontFile.tmp");
            FileInitialize(fontFile, Properties.Resources.Main_Font);
            //Font Creation
            FontCollection = new PrivateFontCollection();
            FontCollection.AddFontFile(fontFile);
            #endregion
            //Form Initialization
            InitializeComponent();
            Icon            = Properties.Resources.logo;
            image           = GameMethods.GetImageByName("menu_0");
            FormBorderStyle = FormBorderStyle.None;
            AutoScaleMode   = AutoScaleMode.Dpi;
            AutoValidate    = AutoValidate.Disable;
            Name            = "KeyboardSaga";
            Text            = "eyboardSaga";
            WindowState     = FormWindowState.Maximized;
            DoubleBuffered  = true;
            ClientSize      = new Size(1280, 720);
            BackColor       = Color.FromArgb(47, 40, 58);
            coordinates     = new Point((ClientSize.Width - image.Width) / 2, (ClientSize.Height - image.Height) / 2);
            SizeChanged    += new EventHandler((sender, args) =>
            {
                coordinates         = new Point((ClientSize.Width - image.Width) / 2, (ClientSize.Height - image.Height) / 2);
                playButton.Location =
                    new Point((coordinates.X + image.Width / 2 - playButton.Image.Width / 2),
                              (ClientSize.Height / 2 - playButton.Image.Height));
                tutorialButton.Location =
                    new Point(playButton.Location.X, playButton.Location.Y + 15 + playButton.Image.Height);
                exitButton.Location =
                    new Point(tutorialButton.Location.X, tutorialButton.Location.Y + 15 + tutorialButton.Image.Height);
                soundToggleButton.Location =
                    new Point((coordinates.X + 41),
                              (coordinates.Y + image.Height - 41 - soundToggleButton.Image.Height));
                Invalidate();
            });
            Paint += new PaintEventHandler(OnPaint);
            //Timer
            timer = new Timer(components)
            {
                Enabled  = true,
                Interval = 100
            };
            timer.Tick     += new EventHandler(OnFrameChanged);
            animationCycles = 0;
            #region Play Button
            playButton          = new PictureBox();
            playButton.Image    = GameMethods.GetImageByName("MENU_PLAY");
            playButton.Size     = new Size(playButton.Image.Width, playButton.Image.Height);
            playButton.Location = new Point((coordinates.X + image.Width / 2 - playButton.Image.Width / 2),
                                            (ClientSize.Height / 2 - playButton.Image.Height));
            playButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                        playButton.Image = GameMethods.GetImageByName("MENU_PLAY_ACTIVE"));
            playButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                          playButton.Image = GameMethods.GetImageByName("MENU_PLAY_PRESSED"));
            playButton.MouseClick += new MouseEventHandler((sender, args) =>
            {
                PlayClickSound();
                gameForm = new KeyboardSaga(this);
                gameForm.Show();
            });
            playButton.MouseEnter += new EventHandler((sender, args) =>
                                                      playButton.Image = GameMethods.GetImageByName("MENU_PLAY_ACTIVE"));
            playButton.MouseLeave += new EventHandler((sender, args) =>
                                                      playButton.Image = GameMethods.GetImageByName("MENU_PLAY"));
            playButton.BackColor = Color.Transparent;
            #endregion
            Controls.Add(playButton);
            #region Tutorial Button
            tutorialButton          = new PictureBox();
            tutorialButton.Image    = GameMethods.GetImageByName("MENU_TUTORIAL");
            tutorialButton.Size     = new Size(tutorialButton.Image.Width, tutorialButton.Image.Height);
            tutorialButton.Location =
                new Point(playButton.Location.X, playButton.Location.Y + 15 + playButton.Image.Height);
            tutorialButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                            tutorialButton.Image = GameMethods.GetImageByName("MENU_TUTORIAL_ACTIVE"));
            tutorialButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                              tutorialButton.Image = GameMethods.GetImageByName("MENU_TUTORIAL_PRESSED"));
            tutorialButton.MouseClick += new MouseEventHandler((sender, args) =>
            {
                PlayClickSound();
                tutorialForm = new Tutorial(this);
                tutorialForm.Show();
            });
            tutorialButton.MouseEnter += new EventHandler((sender, args) =>
                                                          tutorialButton.Image = GameMethods.GetImageByName("MENU_TUTORIAL_ACTIVE"));
            tutorialButton.MouseLeave += new EventHandler((sender, args) =>
                                                          tutorialButton.Image = GameMethods.GetImageByName("MENU_TUTORIAL"));
            tutorialButton.BackColor = Color.Transparent;
            #endregion
            Controls.Add(tutorialButton);
            #region Exit Game Button
            exitButton          = new PictureBox();
            exitButton.Image    = GameMethods.GetImageByName("MENU_EXIT");
            exitButton.Size     = new Size(exitButton.Image.Width, exitButton.Image.Height);
            exitButton.Location =
                new Point(tutorialButton.Location.X, tutorialButton.Location.Y + 15 + tutorialButton.Image.Height);
            exitButton.MouseUp += new MouseEventHandler((sender, ars) =>
                                                        exitButton.Image = GameMethods.GetImageByName("MENU_EXIT_ACTIVE"));
            exitButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                          exitButton.Image = GameMethods.GetImageByName("MENU_EXIT_PRESSED"));
            exitButton.MouseClick += new MouseEventHandler((sender, args) =>
            {
                Application.Exit();
            });
            exitButton.MouseEnter += new EventHandler((sender, args) =>
                                                      exitButton.Image = GameMethods.GetImageByName("MENU_EXIT_ACTIVE"));
            exitButton.MouseLeave +=
                new EventHandler((sender, args) => exitButton.Image = GameMethods.GetImageByName("MENU_EXIT"));
            exitButton.BackColor = Color.Transparent;
            #endregion
            Controls.Add(exitButton);
            #region Sound Toggle Button
            soundToggleButton       = new PictureBox();
            soundToggleButton.Image = SoundOn ? GameMethods.GetImageByName("SOUND_ON")
                                        : GameMethods.GetImageByName("SOUND_OFF");
            soundToggleButton.Size     = new Size(soundToggleButton.Image.Width, soundToggleButton.Image.Height);
            soundToggleButton.Location = new Point((coordinates.X + 41),
                                                   (coordinates.Y + image.Height - 41 - soundToggleButton.Image.Height));
            soundToggleButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                               soundToggleButton.Image = SoundOn ? GameMethods.GetImageByName("SOUND_ON_ACTIVE")
                                            : GameMethods.GetImageByName("SOUND_OFF_ACTIVE"));
            soundToggleButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                                 soundToggleButton.Image = SoundOn ? GameMethods.GetImageByName("SOUND_ON_PRESSED")
                                            : GameMethods.GetImageByName("SOUND_OFF_PRESSED"));
            soundToggleButton.MouseClick += new MouseEventHandler((sender, args) =>
            {
                PlayClickSound();
                SoundOn = !SoundOn;
                if (SoundOn)
                {
                    music.controls.play();
                }
                else
                {
                    music.controls.pause();
                }
            });
            soundToggleButton.MouseEnter += new EventHandler((sender, args) =>
                                                             soundToggleButton.Image = SoundOn ? GameMethods.GetImageByName("SOUND_ON_ACTIVE")
                                            : GameMethods.GetImageByName("SOUND_OFF_ACTIVE"));
            soundToggleButton.MouseLeave += new EventHandler((sender, args) =>
                                                             soundToggleButton.Image = SoundOn ? GameMethods.GetImageByName("SOUND_ON")
                                            : GameMethods.GetImageByName("SOUND_OFF"));
            soundToggleButton.BackColor = Color.Transparent;
            #endregion
            Controls.Add(soundToggleButton);
            Invalidate();
        }
Пример #13
0
        public void MainMenu()
        {
            // Menu options
            GameMethods.ShowOptionSelector(
                new Vector2(-66, -70),
                new List <Option>()
            {
                new Option("newGame", "NEW GAME", new Vector2(0, 0)),
                new Option("loadGame", "LOAD GAME", new Vector2(0, 16)),
                new Option("options", "OPTIONS", new Vector2(0, 32)),
                new Option("quit", "QUIT", new Vector2(0, 48)),

                new Option("debug", "DEBUG", new Vector2(80, 0)),
            },
                result =>
            {
                if (result == "newGame")
                {
                    GameData.Reset();

                    // Initiate game data here
                    GameData.Set("Level", "TheTree");

                    GameGlobal.Fader.RunFunction("FadeOut", e =>
                    {
                        Global.SceneManager.LoadScene("Level");
                    });
                }
                else if (result == "loadGame")
                {
                    GameData.Load();

                    GameGlobal.Fader.RunFunction("FadeOut", e =>
                    {
                        Global.SceneManager.LoadScene("Level");
                    });
                }
                else if (result == "quit")
                {
                    MonoXEngineGame.Instance.Exit();
                }
                else if (result == "debug")
                {
                    GameData.Reset();
                    foreach (var item in DebugData)
                    {
                        GameData.Set(item.Key, item.Value);
                    }

                    GameGlobal.Fader.RunFunction("FadeOut", e =>
                    {
                        Global.SceneManager.LoadScene("Level");
                    });
                }
                else if (result == "options")
                {
                    Option fullscreenOption = new Option("fullscreen", "FULL SCREEN: " + ((MonoXEngineGame.Instance.Graphics.IsFullScreen) ? "YES" : "NO "), new Vector2(0, 0));
                    Option muteOption       = new Option("mute", "MUTE: " + ((Global.AudioController.MasterVolume == 0) ? "YES" : "NO "), new Vector2(0, 16));

                    GameMethods.ShowOptionSelector(
                        new Vector2(-66, -70),
                        new List <Option>()
                    {
                        fullscreenOption,
                        muteOption,
                        new Option("back", "BACK", new Vector2(0, 32))
                    },
                        optResult =>
                    {
                        if (optResult == "fullscreen")
                        {
                            MonoXEngineGame.Instance.Graphics.ToggleFullScreen();
                            fullscreenOption.Text = "FULL SCREEN: " + ((MonoXEngineGame.Instance.Graphics.IsFullScreen) ? "YES" : "NO");
                        }
                        if (optResult == "mute")
                        {
                            Global.AudioController.MasterVolume = ((Global.AudioController.MasterVolume == 0) ? 1 : 0);
                            muteOption.Text = "MUTE: " + ((Global.AudioController.MasterVolume == 0) ? "YES" : "NO");
                        }
                        else if (optResult == "back")
                        {
                            GameMethods.CurrentOptionSelector.Close();
                            MainMenu();
                        }
                    }
                        , false
                        );
                }
            });
        }
    public GameController(CityCheckContext context)
    {
        this.context = context;

        this.gameMethods = new GameMethods(context);
    }
Пример #15
0
 public KeyboardSaga(Menu menuF)
 {
     //Form Initialization
     InitializeComponent();
     Icon                = Properties.Resources.logo;
     animationCycles     = 0;
     gameOverCycles      = 0;
     mapImage            = GameMethods.GetImageByName("0_");
     menuForm            = menuF;
     Font                = new Font(menuForm.FontCollection.Families[0], 20F);
     gameOverFont        = new Font(menuForm.FontCollection.Families[0], 40F);
     game                = new Game();
     pauseGame           = false;
     gameOverSoundPlayed = false;
     #region Sounds Initialization
     var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     healRechargeSound                 = new WindowsMediaPlayer();
     healRechargeSound.URL             = Path.Combine(currentDirectory, @"sounds\heal_recharge.wav");
     healRechargeSound.settings.volume = 15;
     healRechargeSound.controls.stop();
     healSound                 = new WindowsMediaPlayer();
     healSound.URL             = Path.Combine(currentDirectory, @"sounds\heal.wav");
     healSound.settings.volume = 15;
     healSound.controls.stop();
     hitSound                 = new WindowsMediaPlayer();
     hitSound.URL             = Path.Combine(currentDirectory, @"sounds\hit.wav");
     hitSound.settings.volume = 10;
     hitSound.controls.stop();
     gameOverSound                 = new WindowsMediaPlayer();
     gameOverSound.URL             = Path.Combine(currentDirectory, @"sounds\game_over.wav");
     gameOverSound.settings.volume = 100;
     gameOverSound.controls.stop();
     #endregion
     AutoScaleMode   = AutoScaleMode.Dpi;
     AutoValidate    = AutoValidate.Disable;
     DoubleBuffered  = true;
     Name            = "KeyboardSaga";
     Text            = "eyboardSaga";
     FormBorderStyle = FormBorderStyle.None;
     WindowState     = FormWindowState.Maximized;
     ClientSize      = new Size(1280, 720);
     coordinates     = new Point((ClientSize.Width - game.MapImage.Width) / 2,
                                 (ClientSize.Height - game.MapImage.Height) / 2);
     BackColor    = Color.FromArgb(47, 40, 58);
     Paint       += new PaintEventHandler(OnPaint);
     KeyDown     += new KeyEventHandler(OnKeyPress);
     SizeChanged += new EventHandler((sender, args) =>
     {
         coordinates = new Point((ClientSize.Width - game.MapImage.Width) / 2,
                                 (ClientSize.Height - game.MapImage.Height) / 2);
         pauseButton.Location   = new Point((ClientSize.Width - pauseButton.Image.Width - 30), 30);
         restartButton.Location = new Point(
             (coordinates.X + game.MapImage.Width / 2 - restartButton.Image.Width / 2),
             (ClientSize.Height / 2 - restartButton.Image.Height));
         menuButton.Location = new Point((coordinates.X + game.MapImage.Width / 2 - menuButton.Image.Width / 2),
                                         (restartButton.Location.Y + 15 + restartButton.Image.Height));
         Invalidate();
     });
     //Timer
     timer = new Timer(components)
     {
         Enabled  = true,
         Interval = 20
     };
     timer.Tick += new EventHandler(OnFrameChanged);
     #region Pause Button
     pauseButton          = new PictureBox();
     pauseButton.Image    = GameMethods.GetImageByName("PAUSE");
     pauseButton.Size     = new Size(pauseButton.Image.Width, pauseButton.Image.Height);
     pauseButton.Location = new Point((ClientSize.Width - pauseButton.Image.Width - 40), 20);
     pauseButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                  { if (!pauseGame)
                                                    {
                                                        pauseButton.Image = GameMethods.GetImageByName("PAUSE_ACTIVE");
                                                    }
                                                  });
     pauseButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                    pauseButton.Image = GameMethods.GetImageByName("PAUSE_PRESSED_ACTIVE"));
     pauseButton.MouseClick += new MouseEventHandler((sender, args) =>
     {
         menuForm.PlayClickSound();
         pauseGame             = !pauseGame;
         restartButton.Enabled = !restartButton.Enabled;
         restartButton.Visible = !restartButton.Visible;
         menuButton.Enabled    = !menuButton.Enabled;
         menuButton.Visible    = !menuButton.Visible;
     });
     pauseButton.MouseEnter += new EventHandler((sender, args) =>
                                                { if (!pauseGame)
                                                  {
                                                      pauseButton.Image = GameMethods.GetImageByName("PAUSE_ACTIVE");
                                                  }
                                                });
     pauseButton.MouseLeave += new EventHandler((sender, args) =>
                                                { if (!pauseGame)
                                                  {
                                                      pauseButton.Image = GameMethods.GetImageByName("PAUSE");
                                                  }
                                                });
     pauseButton.BackColor = Color.Transparent;
     #endregion
     Controls.Add(pauseButton);
     #region Restart Button
     restartButton          = new PictureBox();
     restartButton.Image    = GameMethods.GetImageByName("RESTART");
     restartButton.Size     = new Size(restartButton.Image.Width, restartButton.Image.Height);
     restartButton.Location = new Point((coordinates.X + game.MapImage.Width / 2 - restartButton.Image.Width / 2),
                                        (ClientSize.Height / 2 - restartButton.Image.Height));
     restartButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                    restartButton.Image = GameMethods.GetImageByName("RESTART_ACTIVE"));
     restartButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                      restartButton.Image = GameMethods.GetImageByName("RESTART_PRESSED"));
     restartButton.MouseClick += new MouseEventHandler((sender, args) =>
     {
         menuForm.PlayClickSound();
         game.Reset();
         animationCycles = 0;
         gameOverCycles  = 0;
         gameOverSound.controls.stop();
         gameOverSoundPlayed = false;
         mapImage            = GameMethods.GetImageByName("0_");
         PausePress();
     });
     restartButton.MouseEnter += new EventHandler((sender, args) =>
                                                  restartButton.Image = GameMethods.GetImageByName("RESTART_ACTIVE"));
     restartButton.MouseLeave += new EventHandler((sender, args) =>
                                                  restartButton.Image = GameMethods.GetImageByName("RESTART"));
     restartButton.BackColor = Color.Transparent;
     restartButton.Enabled   = false;
     restartButton.Visible   = false;
     #endregion
     Controls.Add(restartButton);
     #region Exit To Menu Button
     menuButton          = new PictureBox();
     menuButton.Image    = GameMethods.GetImageByName("EXIT");
     menuButton.Size     = new Size(menuButton.Image.Width, menuButton.Image.Height);
     menuButton.Location = new Point((coordinates.X + game.MapImage.Width / 2 - menuButton.Image.Width / 2),
                                     (restartButton.Location.Y + 15 + restartButton.Image.Height));
     menuButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                 menuButton.Image = GameMethods.GetImageByName("EXIT_ACTIVE"));
     menuButton.MouseDown += new MouseEventHandler((sender, args) =>
                                                   menuButton.Image = GameMethods.GetImageByName("EXIT_PRESSED"));
     menuButton.MouseClick += new MouseEventHandler((sender, args) =>
     {
         menuForm.PlayClickSound();
         menuForm.Open(this);
     });
     menuButton.MouseEnter += new EventHandler((sender, args) =>
                                               menuButton.Image = GameMethods.GetImageByName("EXIT_ACTIVE"));
     menuButton.MouseLeave += new EventHandler((sender, args) =>
                                               menuButton.Image = GameMethods.GetImageByName("EXIT"));
     menuButton.BackColor = Color.Transparent;
     menuButton.Enabled   = false;
     menuButton.Visible   = false;
     #endregion
     Controls.Add(menuButton);
     Invalidate();
 }
Пример #16
0
 public Tutorial(Menu menuF)
 {
     //Form Initialization
     InitializeComponent();
     Icon         = Properties.Resources.logo;
     menuForm     = menuF;
     hitSound     = new WindowsMediaPlayer();
     hitSound.URL =
         Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"sounds\hit.wav");
     hitSound.settings.volume = 10;
     hitSound.controls.stop();
     mapImage            = GameMethods.GetImageByName("0_");
     tutorialFinished    = false;
     arrow               = GameMethods.GetImageByName("arrow");
     exclamationMark     = GameMethods.GetImageByName("exclamation_mark");
     game                = new Game();
     pauseGame           = false;
     animationCycles     = 0;
     markAnimationCycles = 0;
     AutoScaleMode       = AutoScaleMode.Dpi;
     AutoValidate        = AutoValidate.Disable;
     DoubleBuffered      = true;
     Name                = "KeyboardSaga";
     Text                = "eyboardSaga";
     FormBorderStyle     = FormBorderStyle.None;
     WindowState         = FormWindowState.Maximized;
     ClientSize          = new Size(1280, 720);
     coordinates         = new Point(
         (ClientSize.Width - game.MapImage.Width) / 2,
         (ClientSize.Height - game.MapImage.Height) / 2);
     BackColor    = Color.FromArgb(47, 40, 58);
     Paint       += new PaintEventHandler(OnPaint);
     KeyDown     += new KeyEventHandler(OnKeyPress);
     SizeChanged += new EventHandler((sender, args) =>
     {
         coordinates = new Point(
             (ClientSize.Width - game.MapImage.Width) / 2,
             (ClientSize.Height - game.MapImage.Height) / 2);
         pauseButton.Location = new Point((ClientSize.Width - pauseButton.Image.Width - 30), 30);
         menuButton.Location  = menuButton.Location = new Point(
             (coordinates.X + game.MapImage.Width / 2 - menuButton.Image.Width / 2),
             (ClientSize.Height / 2 - menuButton.Image.Height));
         Invalidate();
     });
     //Timer
     timer = new Timer(components)
     {
         Enabled  = true,
         Interval = 20
     };
     timer.Tick += new EventHandler(OnFrameChanged);
     #region Pause Button
     pauseButton          = new PictureBox();
     pauseButton.Image    = GameMethods.GetImageByName("PAUSE");
     pauseButton.Size     = new Size(pauseButton.Image.Width, pauseButton.Image.Height);
     pauseButton.Location = new Point((ClientSize.Width - pauseButton.Image.Width - 40), 20);
     pauseButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                  { if (!pauseGame)
                                                    {
                                                        pauseButton.Image = GameMethods.GetImageByName("PAUSE_ACTIVE");
                                                    }
                                                  });
     pauseButton.MouseDown += new MouseEventHandler((sender, args) =>
     {
         pauseButton.Image = GameMethods.GetImageByName("PAUSE_PRESSED_ACTIVE");
     });
     pauseButton.MouseClick += new MouseEventHandler((sender, args) =>
     {
         menuForm.PlayClickSound();
         PausePress();
     });
     pauseButton.MouseEnter += new EventHandler((sender, args) =>
                                                { if (!pauseGame)
                                                  {
                                                      pauseButton.Image = GameMethods.GetImageByName("PAUSE_ACTIVE");
                                                  }
                                                });
     pauseButton.MouseLeave += new EventHandler((sender, args) =>
                                                { if (!pauseGame)
                                                  {
                                                      pauseButton.Image = GameMethods.GetImageByName("PAUSE");
                                                  }
                                                });
     pauseButton.BackColor = Color.Transparent;
     #endregion
     Controls.Add(pauseButton);
     #region Menu Button
     menuButton          = new PictureBox();
     menuButton.Image    = GameMethods.GetImageByName("EXIT");
     menuButton.Size     = new Size(menuButton.Image.Width, menuButton.Image.Height);
     menuButton.Location = new Point(
         (coordinates.X + game.MapImage.Width / 2 - menuButton.Image.Width / 2),
         (ClientSize.Height / 2 - menuButton.Image.Height));
     menuButton.MouseUp += new MouseEventHandler((sender, args) =>
                                                 menuButton.Image = GameMethods.GetImageByName("EXIT_ACTIVE"));
     menuButton.MouseDown += new MouseEventHandler((sender, args) =>
     {
         menuButton.Image = GameMethods.GetImageByName("EXIT_PRESSED");
     });
     menuButton.MouseClick += new MouseEventHandler((sender, args) =>
     {
         menuForm.PlayClickSound();
         menuForm.Open(this);
     });
     menuButton.MouseEnter += new EventHandler((sender, args) =>
                                               menuButton.Image = GameMethods.GetImageByName("EXIT_ACTIVE"));
     menuButton.MouseLeave += new EventHandler((sender, args) =>
                                               menuButton.Image = GameMethods.GetImageByName("EXIT"));
     menuButton.BackColor = Color.Transparent;
     menuButton.Enabled   = false;
     menuButton.Visible   = false;
     #endregion
     Controls.Add(menuButton);
     Invalidate();
 }
Пример #17
0
 public async Task ControlRow(List <string> allColumns, string user)
 {
     await Clients.All.SendAsync("IsRow?", GameMethods.IsRow(allColumns), user);
 }
Пример #18
0
 public void GetImagesTest()
 {
     Assert.DoesNotThrow(() => GameMethods.GetKeys());
     Assert.DoesNotThrow(() => GameMethods.GetSpriteSheets());
 }