Example #1
0
    private static void PlaySwinGameIntro()
    {
        const int ANI_CELL_COUNT = 11;

        Audio.PlaySoundEffect(_StartSound);
        SwinGame.Delay(200);
        int i;

        for (i = 0; (i  // play the intro by refreshing screen and draw the screen
                     <= (ANI_CELL_COUNT - 1)); i++)
        {
            SwinGame.DrawBitmap(_Background, 0, 0);
            SwinGame.Delay(20);
            SwinGame.RefreshScreen();
            SwinGame.ProcessEvents();
        }

        SwinGame.Delay(1500);
    }
Example #2
0
        private static void PlaySwinGameIntro()
        {
            const int ANI_CELL_COUNT = 11;

            Audio.PlaySoundEffect("StartSound");
            SwinGame.Delay(200);
            int i;

            for (i = 0; (i
                         <= (ANI_CELL_COUNT - 1)); i++)
            {
                SwinGame.DrawBitmap("loadBackground", 0, 0);
                SwinGame.Delay(20);
                SwinGame.RefreshScreen();
                SwinGame.ProcessEvents();
            }

            SwinGame.Delay(1500);
        }
Example #3
0
    // Prepares the background
    private static void PlaySwinGameIntro()
    {
        const int ANI_CELL_COUNT = 11;

        Audio.PlaySoundEffect(_StartSound);
        SwinGame.Delay((uint)200);

        int i = 0;

        for (i = 0; i <= ANI_CELL_COUNT - 1; i++)
        {
            SwinGame.DrawBitmap(_Background, 0, 0);
            SwinGame.Delay((uint)20);
            SwinGame.RefreshScreen();
            SwinGame.ProcessEvents();
        }

        SwinGame.Delay((uint)1500);  // Geez, how long does this need to be? Consider this to be a FIXME for issue #7
    }
Example #4
0
    private static void ShowMessage(string message, int number)
    {
        const int BG_Y  = 453;
        int       TX    = 310;
        int       TY    = 493;
        int       TW    = 200;
        int       TH    = 25;
        int       STEPS = 5;
        int       BG_X  = 279;
        int       fullW;

        fullW = (260 * number);
        STEPS;
        SwinGame.DrawBitmap(_LoaderEmpty, BG_X, BG_Y);
        SwinGame.DrawBitmapPart(_LoaderFull, 0, 0, fullW, 66, BG_X, BG_Y);
        SwinGame.DrawTextLines(message, Color.White, Color.Transparent, _LoadingFont, FontAlignment.AlignCenter, TX, TY, TW, TH);
        SwinGame.RefreshScreen();
        SwinGame.ProcessEvents();
    }
Example #5
0
    private static void PlaySwinGameIntro()
    {
        const int ANI_CELL_COUNT = 11;

        Audio.PlaySoundEffect(_StartSound);
        SwinGame.Delay(200);

        int i = 0;

        for (i = 0; i <= ANI_CELL_COUNT - 1; i++)
        {
            SwinGame.DrawBitmap(_Background, 0, 0);
            SwinGame.Delay(20);
            SwinGame.RefreshScreen();
            SwinGame.ProcessEvents();
        }

        SwinGame.Delay(1500);
    }
Example #6
0
    /// <summary>
    /// Draws the deployment screen showing the field and the ships
    /// that the player can deploy.
    /// </summary>
    public static void DrawDeployment()
    {
        UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

        //Draw the Left/Right and Up/Down buttons
        if (_currentDirection == Direction.LeftRight)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
            //SwinGame.DrawText("U/D", Color.Gray, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
            //SwinGame.DrawText("L/R", Color.White, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
        }
        else
        {
            SwinGame.DrawBitmap(GameResources.GameImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
            //SwinGame.DrawText("U/D", Color.White, GameFont("Menu"), UP_DOWN_BUTTON_LEFT, TOP_BUTTONS_TOP)
            //SwinGame.DrawText("L/R", Color.Gray, GameFont("Menu"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP)
        }


        //DrawShips
        foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
        {
            int i = 0;
            i = ((int)sn) - 1;
            if (i >= 0)
            {
                if (sn == _selectedShip)
                {
                    SwinGame.DrawBitmap(GameResources.GameImage("SelectedShip"), SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT);
                    //    SwinGame.FillRectangle(Color.LightBlue, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                    //Else
                    //    SwinGame.FillRectangle(Color.Gray, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                }

                //SwinGame.DrawRectangle(Color.Black, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT)
                //SwinGame.DrawText(sn.ToString(), Color.Black, GameFont("Courier"), SHIPS_LEFT + TEXT_OFFSET, SHIPS_TOP + i * SHIPS_HEIGHT)
            }
        }
        // '' <summary>
        // '' Gets the ship that the mouse is currently over in the selection panel.
        // '' </summary>
        // '' <returns>The ship selected or none</returns>
    }
Example #7
0
        private static void DrawVolumeButtons()
        {
            int       level   = 1;
            int       xOffset = 1;
            Rectangle toDraw  = new Rectangle();
            int       btnTop  = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;
            int       btnLeft = MENU_LEFT + BUTTON_SEP * xOffset;

            toDraw.X      = btnLeft + TEXT_OFFSET - 12;
            toDraw.Y      = btnTop + TEXT_OFFSET;
            toDraw.Width  = BUTTON_WIDTH + 17;
            toDraw.Height = BUTTON_HEIGHT;

            int volumePercent = Convert.ToInt32(UtilityFunctions.VolumeLevel * 100);

            SwinGame.DrawText("VOLUME: %" + volumePercent.ToString(), MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, toDraw);
            SwinGame.DrawBitmap(GameResources.GameImage("Plus", GameResources.GameTheme), VOLUME_BUTTON_X, VOLUME_BUTTON_Y);
            SwinGame.DrawBitmap(GameResources.GameImage("Minus", GameResources.GameTheme), VOLUME_BUTTON_X + VOLUME_BUTTON_SIZE + VOLUME_BUTTON_GAP, VOLUME_BUTTON_Y);
        }
Example #8
0
        public TileMap(string tmxPath, EntityManager entityManager)
        {
            _map = new TmxMap(tmxPath);

            _bitmap = SwinGame.CreateBitmap(_map.Width * _map.TileWidth, _map.Height * _map.TileHeight);
            SwinGame.ClearSurface(_bitmap, Color.Cyan);

            Bitmap background = SwinGame.LoadBitmap(@"Resources\background.png");

            SwinGame.DrawBitmap(_bitmap, background, 0, 0);

            Dictionary <TmxTileset, Bitmap> tilesetBitmaps = LoadTilesetBitmaps(_map);

            DrawLayersToBitmap(_map, tilesetBitmaps);

            FreeTilesetBitmaps(tilesetBitmaps);

            LoadEntities(entityManager);
        }
        /// <summary>
        /// main
        /// the main entry point for the program
        /// </summary>
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow(Title + " v" + Version, 800, 600);

            GameResources.LoadResources();
            GameScores.Initalise();
            GameObjects.Player = new PlayerEntity(PlayerType.NarrowA);

            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                RandomPlacementOfItems();

                SwinGame.ClearScreen(Color.Grey);
                SwinGame.DrawRectangle(Color.DarkGray, true, 40, 20, 460, 560);

                SwinGame.ProcessEvents();

                GameObjects.Player.ProcessEvents();

                foreach (ItemEntity item in GameObjects.Items)
                {
                    item.ProcessEvents();
                }

                SwinGame.DrawBitmap(GameResources.GameImage("GameArea"), 0, 0);
                SwinGame.DrawText("Score: " + GameScores.Score, Color.Black, 540, 40);
                SwinGame.DrawText("Lives: " + GameScores.Player, Color.Black, 540, 60);
                SwinGame.DrawText("Bombs: " + GameScores.Bomb, Color.Black, 540, 80);
                SwinGame.DrawText("Power: " + GameScores.Power, Color.Black, 540, 120);
                SwinGame.DrawText("Graze: " + GameScores.Graze, Color.Black, 540, 140);
                SwinGame.DrawText("Bonus: " + GameScores.Bonus, Color.Black, 540, 160);

                SwinGame.DrawFramerate(0, 0);

                tick++;

                SwinGame.RefreshScreen(60);
            }
            GameResources.FreeResources();
        }
Example #10
0
    //
    private static void ShowMessage(string message, bool number)
    {
        const int BG_Y = 453;
        const int TX   = 310;
        const int TY   = 493;
        const int TW   = 200;
        const int TH   = 25;
        const int BG_X = 279;

        if (number == false)
        {
            SwinGame.DrawBitmap(_loaderEmpty, BG_X, BG_Y);
        }
        else
        {
            SwinGame.DrawCell(_loaderFull, 0, BG_X, BG_Y);
        }

        //int fullW = (260 * number) / 5;
        //int h = 66;
        //int x = 0;
        //int y = 0;
        //Rectangle tooDraw = new Rectangle();
        //tooDraw.X = x;
        //tooDraw.Y = y;
        //tooDraw.Width = fullW;
        //tooDraw.Height = h;
        //SwinGame.DrawBitmap(_loaderFull, BG_X, BG_Y, SwinGame.OptionPartBmp(x, y, fullW, h));

        Rectangle toDraw = new Rectangle();

        toDraw.X      = TX;
        toDraw.Y      = TY;
        toDraw.Width  = TW;
        toDraw.Height = TH;

        SwinGame.DrawText(message, Color.White, Color.Transparent, _loadingFont, FontAlignment.AlignCenter, toDraw);


        SwinGame.RefreshScreen();
        SwinGame.ProcessEvents();
    }
Example #11
0
    /// <summary>
    /// Draws the game during the attack phase.
    /// </summary>s
    public static void DrawDiscovery()
    {
        const int SCORES_LEFT = 172;
        const int SHOTS_TOP   = 157;
        const int HITS_TOP    = 206;
        const int SPLASH_TOP  = 256;

        //Added By Jesse
        const int SCORE_TOP = 306;

        if (((SwinGame.KeyDown(KeyCode.vk_LSHIFT) | SwinGame.KeyDown(KeyCode.vk_RSHIFT)) & SwinGame.KeyDown(KeyCode.vk_c)))
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true);
        }
        else
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false);
        }

        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        UtilityFunctions.DrawMessage();

        //Added by Voon.
        //Draw Destroyed Ships.
        UtilityFunctions.DrawDestroyField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);

        SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP);

        //Added by Jesse
        SwinGame.DrawText(GameController.HumanPlayer.Score.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SCORE_TOP);


        //Added by Voon.
        //Draw the number of ships left that need to destroy.
        SwinGame.DrawText("Number of Ships left: ", Color.White, GameResources.GameFont("Menu"), 350, 90);
        SwinGame.DrawText((5 - GameController.ComputerPlayer.PlayerGrid.ShipsKilled).ToString(), Color.Yellow, GameResources.GameFont("Menu"), 515, 90);

        //added by jesse -- gaming page with home button to return home page
        SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), 685, 70);
    }
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>
        public static void DrawBackground()
        {
            switch (GameController.CurrentState)
            {
            case GameState.ViewingMainMenu:
            case GameState.ViewingGameMenu:
            case GameState.AlteringSettings:
            {
                SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
                break;
            }

            case GameState.ViewingHighScores:
            {
                SwinGame.DrawBitmap(GameResources.GameImage("High"), 0, 0);
                break;
            }

            case GameState.Discovering:
            case GameState.EndingGame: {
                SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
                break;
            }

            case GameState.Deploying: {
                SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
                break;
            }

            case GameState.Guide: {
                SwinGame.DrawBitmap(GameResources.GameImage("High"), 0, 0);
                break;
            }

            default: {
                SwinGame.ClearScreen();
                break;
            }
            }

            SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
        }
Example #13
0
        private static void ShowLoadingScreen()
        {
            SwinGame.LoadBitmapNamed("loadBackground", SwinGame.PathToResource("SplashBack.png", ResourceKind.BitmapResource));
            SwinGame.DrawBitmap("loadBackground", 0, 0);

            SwinGame.RefreshScreen();
            SwinGame.ProcessEvents();

            _Animation = SwinGame.LoadBitmap(SwinGame.PathToResource("SwinGameAni.jpg", ResourceKind.BitmapResource));
            SwinGame.LoadBitmapNamed("loadBitmap", SwinGame.PathToResource("SwinGameAni.jpg", ResourceKind.BitmapResource));
            //SwinGame.Animation

            SwinGame.LoadFontNamed("LoadingFont", "arial.ttf", 12);
            SwinGame.LoadSoundEffectNamed("StartSound", "SwinGameStart.ogg");

            SwinGame.LoadBitmapNamed("LoaderFull", "loader_full.png");
            SwinGame.LoadBitmapNamed("LoaderEmpty", "loader_empty.png");

            GameResources.PlaySwinGameIntro();
        }
 public void fire()
 {
     if (getFaceDirection == Movement.Left)
     {
         SwinGame.DrawBitmap("bulletleft.png", getBullet.GetX, getBullet.GetY);
     }
     else if (getFaceDirection == Movement.Right)
     {
         SwinGame.DrawBitmap("bulletright.png", getBullet.GetX, getBullet.GetY);
     }
     else if (getFaceDirection == Movement.Bottom)
     {
         SwinGame.DrawBitmap("bulletbottom.png", getBullet.GetX, getBullet.GetY);
     }
     else
     {
         SwinGame.DrawBitmap("bullet.png", getBullet.GetX, getBullet.GetY);
     }
     getBullet.Moving(_facedirection);
 }
    /// <summary>
    /// Draws the game during the attack phase.
    /// </summary>s
    public static void DrawDiscovery()
    {
        const int SCORES_LEFT = 172;
        const int SHOTS_TOP   = 157;
        const int HITS_TOP    = 206;
        const int SPLASH_TOP  = 256;
        const int SCORE_TOP   = 306;
        const int TIMER_LEFT  = 440;
        const int TIMER_TOP   = 85;

        //Show enemy ships
        if ((SwinGame.KeyDown(KeyCode.vk_LCTRL) && SwinGame.KeyDown(KeyCode.vk_v)))
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, true);
        }

        //Terminate the game directly
        if ((SwinGame.KeyDown(KeyCode.vk_LCTRL) && SwinGame.KeyDown(KeyCode.vk_t)))
        {
            GameController.SwitchState(GameState.EndingGame);
        }


        else
        {
            UtilityFunctions.DrawField(GameController.HumanPlayer.EnemyGrid, GameController.ComputerPlayer, false);
        }

        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        UtilityFunctions.DrawMessage();


        SwinGame.DrawBitmap(GameResources.GameImage("PauseButton"), 722, 72);

        SwinGame.DrawText(GameController.HumanPlayer.Shots.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SHOTS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Hits.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, HITS_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Missed.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP);
        SwinGame.DrawText(GameController.HumanPlayer.Score.ToString(), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SCORE_TOP);
        SwinGame.DrawText("Time left: ", Color.White, GameResources.GameFont("Menu"), TIMER_LEFT, TIMER_TOP);
        SwinGame.DrawText(GameController.timeCount(480000), Color.White, GameResources.GameFont("MenuMedium"), TIMER_LEFT + 135, TIMER_TOP - 4);
    }
Example #16
0
    /// <summary>
    /// Draws the background for the current state of the game
    /// </summary>
    public static void DrawBackground()
    {
        switch (GameController.CurrentState)
        {
        case GameState.ViewingMainMenu:
        case GameState.ViewingGameMenu:
        case GameState.AlteringSettings:
        case GameState.ViewingHighScores:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            break;
        }

        case GameState.Discovering:
        case GameState.EndingGame:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            break;
        }

        case GameState.Deploying:
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            break;
        }

        default:
        {
            SwinGame.ClearScreen();
            break;
        }
        }


        // hides the games' fps unless the user presses down the tab key
        if (SwinGame.KeyDown(KeyCode.TabKey))
        {
            // moved the fps so that its within the size of the game's window
            SwinGame.DrawFramerate(600, 585);
        }
    }
Example #17
0
        // Draw the moving direction of agent
        public void DrawAction(string direction, int x, int y)
        {
            SwinGame.ProcessEvents();

            if (direction == "up")
            {
                SwinGame.DrawBitmap("up", x + 32, y + 35);
            }
            if (direction == "left")
            {
                SwinGame.DrawBitmap("left", x + 32, y + 35);
            }
            if (direction == "down")
            {
                SwinGame.DrawBitmap("down", x + 32, y + 35);
            }
            if (direction == "right")
            {
                SwinGame.DrawBitmap("right", x + 32, y + 35);
            }
        }
Example #18
0
    /// <summary>
    ///     ''' Draws the background for the current state of the game
    ///     ''' </summary>
    public static void DrawBackground()
    {
        if ((((((GameController.CurrentState == GameState.ViewingMainMenu) || (GameController.CurrentState == GameState.ViewingGameMenu)) || (GameController.CurrentState == GameState.AlteringSettings)) || (GameController.CurrentState == GameState.ViewingHighScores)) || (GameController.CurrentState == GameState.AlteringOption)) || (GameController.CurrentState == GameState.ChangingMusic))       //Recently added
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
        }
        else if ((GameController.CurrentState == GameState.Discovering) || (GameController.CurrentState == GameState.EndingGame))
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
        }
        else if (GameController.CurrentState == GameState.Deploying)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
        }
        else
        {
            SwinGame.ClearScreen();
        }

        SwinGame.DrawFramerate(675, 585, GameResources.GameFont("CourierSmall"));
    }
Example #19
0
        /// <summary>
        /// Draws the background for the current state of the game
        /// </summary>
        public static void DrawBackground()
        {
            if ((((GameController.CurrentState == GameState.ViewingMainMenu) || (GameController.CurrentState == GameState.ViewingGameMenu)) || (GameController.CurrentState == GameState.AlteringSettings)) || (GameController.CurrentState == GameState.ViewingHighScores))
            {
                SwinGame.DrawBitmap(GameResources.GameImage("Menu"), 0, 0);
            }
            else if ((GameController.CurrentState == GameState.Discovering) || (GameController.CurrentState == GameState.EndingGame))
            {
                SwinGame.DrawBitmap(GameResources.GameImage("Discovery"), 0, 0);
            }
            else if (GameController.CurrentState == GameState.Deploying)
            {
                SwinGame.DrawBitmap(GameResources.GameImage("Deploy"), 0, 0);
            }
            else
            {
                SwinGame.ClearScreen();
            }

            SwinGame.DrawFramerate(675, 585);
        }
Example #20
0
        /// <summary>
        /// Draws tiles based on their mapped bitmap
        /// </summary>
        public void DrawWorldBitmaps()
        {
            int size = Escapade.GetWorld().Size;

            for (int x = 0; x < Escapade.GetWorld().Width; x++)
            {
                for (int y = 0; y < Escapade.GetWorld().Height; y++)
                {
                    if (Escapade.GetWorld().Map [x, y].Type == TileType.Rock)
                    {
                        SwinGame.DrawBitmap(_maskmap [Escapade.GetWorld().Map [x, y].Mask], x * size, y * size);
                        Mineral m = Escapade.GetWorld().Map [x, y].Mineral;
                        if (m != null)
                        {
                            string mineralBitmap = "overlay_" + m.GetType().ToString().ToLower().Split('.').Last();
                            SwinGame.DrawBitmap(_bitmaps [mineralBitmap], x * size, y * size);
                        }
                    }
                }
            }
        }
 public void Draw()
 {
     if (getFaceDirection == Movement.Left)
     {
         //SwinGame.DrawBitmap ("ship.left.png", _pmove.GetX, _pmove.GetY);
         SwinGame.DrawBitmap("cannonleft.png", _pmove.GetX, _pmove.GetY);
     }
     else if (getFaceDirection == Movement.Right)
     {
         SwinGame.DrawBitmap("cannonright.png", _pmove.GetX, _pmove.GetY);
     }
     else if (getFaceDirection == Movement.Bottom)
     {
         SwinGame.DrawBitmap("cannonbottom.png", _pmove.GetX, _pmove.GetY);
     }
     else
     {
         //SwinGame.DrawBitmap ("ship.top.png", _pmove.GetX, _pmove.GetY);
         SwinGame.DrawBitmap("cannon.png", _pmove.GetX, _pmove.GetY);
     }
 }
Example #22
0
        /// <summary>
        /// Back button !!!Havent Implement yet!!!
        /// </summary>
        public static void BackButton()
        {
            int xPosition    = 100;
            int yPosition    = 70;
            int buttonwidth  = 50;
            int buttonheight = 50;

            if (IsAtRectangle(SwinGame.MousePosition(), xPosition, yPosition, buttonwidth, buttonheight))
            {
                SwinGame.DrawBitmap(SwinGame.BitmapNamed("BackButton"), xPosition, yPosition);
                SwinGame.FillRectangle(Color.Red, xPosition, yPosition, buttonwidth, buttonheight);
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    GameController.EndCurrentState();
                }
            }
            else
            {
                SwinGame.DrawBitmap(SwinGame.BitmapNamed("BackButton"), xPosition, yPosition);
            }
        }
    ///<summary>
    ///DrawDeployment draws the deployment screen showing the field and the ships
    ///that the player can deploy.
    /// </summary>
    public static void DrawDeployment()
    {
        UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

        //Draw back button
        SwinGame.DrawBitmap(GameResources.GameImage("Back"), 8, 8);

        // Draw the Left/Right and Up/Down buttons
        if (_currentDirection == Direction.LeftRight)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }
        else
        {
            SwinGame.DrawBitmap(GameResources.GameImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        // DrawShips
        foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
        {
            int i;
            i = (int)(sn) - 1;
            if (i >= 0)
            {
                if (sn == _selectedShip)
                {
                    SwinGame.DrawBitmap(GameResources.GameImage("SelectedShip"), SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT);
                }
            }
        }

        if (GameController.HumanPlayer.ReadyToDeploy)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("PlayButton"), PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        SwinGame.DrawBitmap(GameResources.GameImage("RandomButton"), RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP);

        UtilityFunctions.DrawMessage();
    }
        public void DrawEverything()
        {
            SwinGame.ClearScreen(Color.White);

            //Drawgrid
            for (float i = 1f; i < _width; i++)
            {
                SwinGame.DrawLine(Color.Black, i * 32f, 0f, i * 32f, _height * 32f);
            }
            for (float i = 1f; i < _height; i++)
            {
                SwinGame.DrawLine(Color.Black, 0f, i * 32f, _width * 32f, i * 32f);
            }

            foreach (Speciman S in _Specimans)
            {
                S.Draw();
            }
            foreach (Rover R in _rovers)
            {
                R.Draw();
            }
            _textBox.AddLine("");
            _textBox.AddLine("");
            _textBox.AddLine(_Specimans.Count + " Specimans remaining to be found");
            foreach (Speciman S in _Specimans)
            {
                if (S.Sensed)
                {
                    _textBox.AddLine("----------");
                    S.GiveInformation(this);
                }
            }
            _textBox.Draw();
            foreach (Point2D PT in SearchedArea)
            {
                SwinGame.DrawBitmap(Directory.GetCurrentDirectory() + "\\Resources\\RoverResources\\Cross.png", PT.X * 32, PT.Y * 32);
            }
            SwinGame.RefreshScreen(24);
        }
    // '' <summary>
    // '' Draws the deployment screen showing the field and the ships
    // '' that the player can deploy.
    // '' </summary>
    public static void DrawDeployment()
    {
        UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

        // Draw the Left/Right and Up/Down buttons
        if ((_currentDirection == Direction.LeftRight))
        {
            // the button for ext
            SwinGame.DrawBitmap(GameResources.GameImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }
        else
        {
            SwinGame.DrawBitmap(GameResources.GameImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        // Draw ships depend on the selection
        foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
        {
            int i = (int)(sn) - 1;

            if (i >= 0)
            {
                if ((sn == _selectedShip))
                {
                    SwinGame.DrawBitmap(GameResources.GameImage("SelectedShip"), SHIPS_LEFT, (SHIPS_TOP + (i * SHIPS_HEIGHT)));
                }

                SwinGame.DrawRectangle(Color.Blue, SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT, SHIPS_WIDTH, SHIPS_HEIGHT);
                SwinGame.DrawText(sn.ToString(), Color.White, GameResources.GameFont("Courier"), SHIPS_LEFT + TEXT_OFFSET, SHIPS_TOP + i * SHIPS_HEIGHT);
            }
        }

        if (GameController.HumanPlayer.ReadyToDeploy)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("PlayButton"), PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        SwinGame.DrawBitmap(GameResources.GameImage("RandomButton"), RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP);
        UtilityFunctions.DrawMessage();
    }
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), HOME_BUTTON_LEFT, TOP_BUTTONS_TOP);
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Example #27
0
        /// <summary>
        /// Displays the instructions of the game
        /// </summary>
        public void Instructions()
        {
            SwinGame.ResumeMusic();
            int page = 1;

            while (page <= 2)
            {
                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawBitmap(GameResources.GameImage("instructions"), 0, 0);
                DisplayInstructionsContent(page);
                SwinGame.ProcessEvents();

                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    page++;
                }
                SwinGame.RefreshScreen(60);
            }
            SwinGame.PauseMusic();
            _gameStates.Push(GameState.ViewingMainMenu);
            ControlGameState();
        }
    private static void ShowMessage(string message, int number)
    {
        const int _tx    = 310;
        const int _ty    = 493;
        const int _tw    = 200;
        const int _th    = 25;
        const int _steps = 5;
        const int _bgX   = 279;
        const int _bgY   = 453;

        int _fullW = 0;

        _fullW = 260 * number / _steps;
        SwinGame.DrawBitmap(_loaderEmpty, _bgX, _bgY);
        SwinGame.DrawBitmap(_loaderFull, 0, 0);

        SwinGame.DrawText(message, Color.White, Color.Transparent, _loadingFont, FontAlignment.AlignCenter, SwinGame.CreateRectangle(_tx, _ty, _tw, _th));


        SwinGame.RefreshScreen();
        SwinGame.ProcessEvents();
    }
Example #29
0
    /// <summary>
    ///     ''' Draws the deployment screen showing the field and the ships
    ///     ''' that the player can deploy.
    ///     ''' </summary>
    public static void DrawDeployment()
    {
        UtilityFunctions.DrawField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer, true);

        // Draw the Left/Right and Up/Down buttons
        if (_currentDirection == Direction.LeftRight)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("LeftRightButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }
        else
        {
            SwinGame.DrawBitmap(GameResources.GameImage("UpDownButton"), LEFT_RIGHT_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        // DrawShips
        foreach (ShipName sn in Enum.GetValues(typeof(ShipName)))
        {
            int i = 0;
            i = System.Convert.ToInt32(System.Convert.ToInt32(sn) - 1);
            if (i >= 0)
            {
                if (sn == _selectedShip)
                {
                    SwinGame.DrawBitmap(GameResources.GameImage("SelectedShip"), SHIPS_LEFT, SHIPS_TOP + i * SHIPS_HEIGHT);
                }
            }
        }

        if (GameController.HumanPlayer.ReadyToDeploy)
        {
            SwinGame.DrawBitmap(GameResources.GameImage("PlayButton"), PLAY_BUTTON_LEFT, TOP_BUTTONS_TOP);
        }

        SwinGame.DrawBitmap(GameResources.GameImage("RandomButton"), RANDOM_BUTTON_LEFT, TOP_BUTTONS_TOP);

        UtilityFunctions.DrawMessage();

        SwinGame.DrawText("Press 'esc' to exit the game!", Color.White, 40, 570);
    }
Example #30
0
    private static void ShowMessage(string message, int number)
    {
        const int TX    = 310;
        const int TY    = 493;
        const int TW    = 200;
        const int TH    = 25;
        const int STEPS = 5;
        const int BG_X  = 279;
        const int BG_Y  = 453;

        int fullW = 0;

        fullW = 260 * number / STEPS;
        SwinGame.DrawBitmap(_LoaderEmpty, BG_X, BG_Y);
        SwinGame.DrawBitmap(_LoaderFull, 0, 0);

        SwinGame.DrawText(message, Color.White, Color.Transparent, _LoadingFont,
                          FontAlignment.AlignCenter, SwinGame.RectangleFrom(new Point2D(), TW, TH));

        SwinGame.RefreshScreen();
        SwinGame.ProcessEvents();
    }