Ejemplo n.º 1
0
        public ModValidator( string path )
        {
            resources = GameResources.Deserialize( GetResourceManifest() );
            ExpansionResourcesUsed = new GameResources();

            mod = ContentDirectory.Create( path, false );
        }
Ejemplo n.º 2
0
        public ModValidator( Stream stream )
        {
            resources = GameResources.Deserialize( GetResourceManifest() );
            ExpansionResourcesUsed = new GameResources();

            mod = ContentDirectory.Create( stream );
        }
Ejemplo n.º 3
0
        static void Main( string[] args )
        {
            if ( args.Length == 0 )
            {
                Console.WriteLine( "No directory specified." );
            }
            else if ( !Directory.Exists( args[ 0 ] ) )
            {
                Console.WriteLine( "Directory not found." );
            }
            else
            {
                var path = args[ 0 ];

                ContentDirectory core = ContentDirectory.Create( path, true );

                GameResources resources = new GameResources();
                resources.LoadResources( core );

            #if DEBUG
                resources.SerializeToFile( @".\ResourceManifest.xml" );
            #else
                resources.SerializeToFile( @"..\..\..\DredmorXmlValidation\ResourceManifest.xml" );
            #endif
            }

            Console.Beep();
        }
Ejemplo n.º 4
0
 public static void DrawMessage()
 {
     SwinGame.DrawText(Message, MESSAGE_COLOR, GameResources.GameFont("Courier"), FIELD_LEFT, MESSAGE_TOP);
 }
Ejemplo n.º 5
0
    /// <summary>
    /// Draws the high scores to the screen.
    /// </summary>
    public static void DrawHighScores()
    {
        const int SCORES_HEADING = 40;
        const int SCORES_TOP     = 80;
        const int SCORE_GAP      = 30;

        if (_Scores.Count == 0)
        {
            LoadScores();
        }

        SwinGame.DrawText("   High Scores   ", Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_HEADING);

        //For all of the scores
        int i = 0;

        for (i = 0; i <= _Scores.Count - 1; i++)
        {
            Score s = default(Score);

            s = _Scores[i];

            //for scores 1 - 9 use 01 - 09
            if (i < 9)
            {
                SwinGame.DrawText(" " + (i + 1) + ":   " + s.Name + "   " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
            }
            else
            {
                SwinGame.DrawText(i + 1 + ":   " + s.Name + "   " + s.Value, Color.White, GameResources.GameFont("Courier"), SCORES_LEFT, SCORES_TOP + i * SCORE_GAP);
            }
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Draw the end of the game screen, shows the win/lose state
    /// </summary>
    public static void DrawEndOfGame()
    {
        UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);
        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);

        if ((int)SwinGame.TimerTicks(GameController.Timer) >= 480000)
        {
            SwinGame.DrawTextLines("TIMES OUT! YOU LOSE!", Color.White, Color.Transparent, GameResources.GameFont("ArialMedium"), FontAlignment.AlignCenter, 0, 100, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Shots:" + GameController.HumanPlayer.Shots.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Hits:" + GameController.HumanPlayer.Hits.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 290, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Splashes:" + GameController.HumanPlayer.Missed.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 330, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Score:" + GameController.HumanPlayer.Score.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 370, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Right-Click To Quit The Game", Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 460, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }

        else if (GameController.HumanPlayer.IsDestroyed)
        {
            SwinGame.DrawTextLines("YOU LOSE!", Color.White, Color.Transparent, GameResources.GameFont("ArialMedium"), FontAlignment.AlignCenter, 0, 100, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Shots:" + GameController.HumanPlayer.Shots.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Hits:" + GameController.HumanPlayer.Hits.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 290, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Splashes:" + GameController.HumanPlayer.Missed.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 330, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Score:" + GameController.HumanPlayer.Score.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 370, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Right-Click To Quit The Game", Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 460, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }

        else
        {
            SwinGame.DrawTextLines("-- WINNER --", Color.White, Color.Transparent, GameResources.GameFont("ArialMedium"), FontAlignment.AlignCenter, 0, 100, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Shots:" + GameController.HumanPlayer.Shots.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Hits:" + GameController.HumanPlayer.Hits.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 290, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Splashes:" + GameController.HumanPlayer.Missed.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 330, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Score:" + GameController.HumanPlayer.Score.ToString(), Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 370, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
            SwinGame.DrawTextLines("Right-Click To Quit The Game", Color.White, Color.Transparent, GameResources.GameFont("ArialSmall"), FontAlignment.AlignCenter, 0, 460, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Initialise background image
 /// </summary>
 public void InitialiseBackground()
 {
     _background = GameResources.GetImage("background");
 }
Ejemplo n.º 8
0
    /// <summary>
    /// Draws the menu at the indicated level.
    /// </summary>
    /// <param name="menu">the menu to draw</param>
    /// <param name="level">the level (height) of the menu</param>
    /// <param name="xOffset">the offset of the menu</param>
    /// <remarks>
    /// The menu text comes from the _menuStructure field. The level indicates the height
    /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally
    /// to allow the submenus to be positioned correctly.
    /// </remarks>
    private static void DrawButtons(int menu, int level, int xOffset)
    {
        int btnTop = 0;

        btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;
        int i = 0;

        for (i = 0; i <= _menuStructure [menu].Length - 1; i++)
        {
            int btnLeft = 0;
            btnLeft = MENU_LEFT + BUTTON_SEP * (i + xOffset);
            //SwinGame.FillRectangle(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT)
            SwinGame.DrawTextLines(_menuStructure [menu] [i], MENU_COLOR, Color.Orange, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);

            if (IsMouseOverMenu(i, level, xOffset))
            {
                SwinGame.DrawTextLines(_menuStructure [menu] [i], MENU_COLOR, Color.White, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);

                ///if (SwinGame.MouseDown (MouseButton.LeftButton) & IsMouseOverMenu (i, level, xOffset)) {
                ///SwinGame.DrawRectangle (HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
            }
        }
    }
Ejemplo n.º 9
0
    ///<summary>
    ///AttackCompleted listens for attacks to be completed.
    ///It will display a message, play a sound and redraw the screen.
    ///</summary>
    ///<param name="sender">The current game Object.</param>
    ///<param name="result">The result of the attack.</param>
    private static void AttackCompleted(object sender, AttackResult result)
    {
        bool isHuman;

        isHuman = _theGame.Player == HumanPlayer;

        if (isHuman)
        {
            UtilityFunctions.Message = "You " + result.ToString();
        }
        else
        {
            UtilityFunctions.Message = "The AI " + result.ToString();
        }

        switch (result.Value)
        {
        case ResultOfAttack.Destroyed:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
            if (isHuman)
            {
                aiShipsLeft--;
            }
            else
            {
                humanShipsLeft--;
            }
            break;
        }

        case ResultOfAttack.GameOver:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));

            while (Audio.SoundEffectPlaying(GameResources.GameSound("Sink")))
            {
                SwinGame.RefreshScreen();
            }

            if (_human.IsDestroyed)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
            }
            else
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Winner"));
            }
            break;
        }

        case ResultOfAttack.Hit:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            break;
        }

        case ResultOfAttack.Miss:
        {
            PlayMissSequence(result.Row, result.Column, isHuman);
            break;
        }

        case ResultOfAttack.ShotAlready:
        {
            Audio.PlaySoundEffect(GameResources.GameSound("Error"));
            break;
        }
        }
    }
        /// <summary>
        /// Validates all fo the XML files.
        /// </summary>
        /// <param name="xmlFiles"></param>
        /// <param name="resources">An instance of <see cref="GameResources"/> containing all valid resources from the core game and optionally a mod.</param>
        /// <param name="expansionResourcesUsed">An instance of <see cref="GameResources"/> to which expansion resources found to be used will be added.</param>
        /// <returns></returns>
        public static List<XmlFileValidationErrorList> Validate( IEnumerable<ContentFile> xmlFiles, GameResources resources, GameResources expansionResourcesUsed = null )
        {
            List<XmlFileValidationErrorList> result = new List<XmlFileValidationErrorList>();

            foreach ( var file in xmlFiles )
            {
                try
                {
                    XmlResourceValidator res = XmlResourceValidator.Create( file, resources, expansionResourcesUsed );
                    result.Add( res.Validate() );
                }
                catch ( XmlException ex )
                {
                    result.Add( new XmlFileValidationErrorList( file.FullName, ex ) );
                }
            }

            return result;
        }
        protected XmlResourceValidator( ContentFile file, GameResources resources, GameResources expansionResourcesUsed )
        {
            this.resources = resources;
            this.path = file.FullName;
            this.expansionResourcesUsed = expansionResourcesUsed;

            using ( Stream xmlStream = file.OpenRead() )
            {
                this.doc = XDocument.Load( xmlStream, LoadOptions.SetLineInfo );
            }

            this.isCoreGame = file.Directory.IsCoreGame;
            this.expansionNumber = file.ExpansionNumber;

            this.result = new XmlFileValidationErrorList
            {
                Path = this.path,
                Errors = new List<XmlValidationError>()
            };
        }
Ejemplo n.º 12
0
    /// <summary>
    /// main game loop - responsible to controlling the game
    /// </summary>
    /// <param name="args"></param>
    public static void Main(string[] args)
    {
        //initialise varaiables
        //new game window
        gameWindow = new Window("SwinExplorer", WINDOW_WIDTH, WINDOW_HEIGHT);

        //Displays loading screen
        GameResources.LoadingScreen();

        //initialise Main Menu
        _mainMenu = new MainMenu();

        //initialise UI
        _ui = new UI();

        //initialse map
        theMap = new Map();

        //starting with travelling state
        _currentState = GameState.MainMenu.ToString();


        do
        {
            //control for drawing to screen
            gameWindow.Clear(Color.White);
            switch (_currentState)
            {
            case ("MainMenu"):
                _mainMenu.Draw();
                break;

            case ("Travelling"):
            case ("InClassroom"):
            case ("InBuilding"):
                _ui.Draw();
                break;

            case ("FullscreenMap"):
                theMap.Draw();
                break;

            default:
                break;
            }

            Point2D pos = SplashKit.MousePosition();
            gameWindow.DrawText(pos.X.ToString(), Color.Black, 10, 10);
            gameWindow.DrawText(pos.Y.ToString(), Color.Black, 10, 30);
            gameWindow.Refresh();

            //get user input and process events
            SplashKit.ProcessEvents();
            switch (_currentState)
            {
            case ("MainMenu"):
                MainMenuController.HandleInput();
                break;

            case ("Travelling"):
            case ("InClassroom"):
            case ("InBuilding"):
                TravellingController.HandleInput();
                break;

            case ("FullscreenMap"):
                MapController.HandleInput();
                break;

            default:
                break;
            }
        }while (!SplashKit.WindowCloseRequested(gameWindow) && _currentState != "Exit");
    }
Ejemplo n.º 13
0
    //Draws the player's grid and ships.
    //<param name="grid">the grid to show</param>
    //<param name="thePlayer">the player to show the ships of</param>
    //<param name="small">true if the small grid is shown</param>
    //<param name="showShips">true if ships are to be shown</param>
    //<param name="left">the left side of the grid</param>
    //<param name="top">the top of the grid</param>
    //<param name="width">the width of the grid</param>
    //<param name="height">the height of the grid</param>
    //<param name="cellWidth">the width of each cell</param>
    //<param name="cellHeight">the height of each cell</param>
    //<param name="cellGap">the gap between the cells</param>
    private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap)
    {
        //Note: not use this value
        // SwinGame.FillRectangle(Color.Blue, left, top, width, height)
        int rowTop;
        int colLeft;

        //Note: Draw the grid
        for (int row = 0; row <= 9; row++)
        {
            rowTop = (top + ((cellGap + cellHeight) * row));
            for (int col = 0; col <= 9; col++)
            {
                colLeft = (left + ((cellGap + cellWidth) * col));
                Color fillColor = SMALL_MISS;
                bool  draw      = true;
                switch (grid[row, col])
                {
                case TileView.Ship:
                    draw = false;
                    break;

                case TileView.Miss:
                    if (small)
                    {
                        fillColor = SMALL_MISS;
                    }
                    else
                    {
                        fillColor = LARGE_MISS;
                    }

                    break;

                case TileView.Hit:
                    if (small)
                    {
                        fillColor = SMALL_HIT;
                    }
                    else
                    {
                        fillColor = LARGE_HIT;
                    }

                    break;

                case TileView.Sea:
                    if (small)
                    {
                        fillColor = SMALL_SEA;
                    }
                    else
                    {
                        draw = false;
                    }

                    break;
                }
                if (draw)
                {
                    SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight);
                    if (!small)
                    {
                        SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight);
                    }
                }
            }
        }

        if (!showShips)
        {
            return;
        }

        int    shipHeight;
        int    shipWidth;
        string shipName;

        //Note: Draw the ships

        foreach (Ship s in thePlayer)
        {
            if (s == null || !s.IsDeployed)
            {
                continue;
            }

            rowTop  = (top + (((cellGap + cellHeight) * s.Row) + SHIP_GAP));
            colLeft = (left + (((cellGap + cellWidth) * s.Column) + SHIP_GAP));
            if ((s.Direction == Direction.LeftRight))
            {
                shipName   = ("ShipLR" + s.Size);
                shipHeight = (cellHeight - (SHIP_GAP * 2));
                shipWidth  = (((cellWidth + cellGap) * s.Size) - ((SHIP_GAP * 2) - cellGap));
            }
            else
            {
                // Up down
                shipName   = ("ShipUD" + s.Size);
                shipHeight = (((cellHeight + cellGap) * s.Size) - ((SHIP_GAP * 2) - cellGap));
                shipWidth  = (cellWidth - (SHIP_GAP * 2));
            }

            if (!small)
            {
                SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop);
            }
            else
            {
                SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight);
                SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight);
            }
        }
    }
Ejemplo n.º 14
0
    //Draws the background for the current state of the game
    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;

        case GameState.Instructions:
            SwinGame.DrawBitmap(GameResources.GameImage("InstructionsPage"), 0, 0);
            SwinGame.DrawText("--Instructions for Battleship--", Color.Blue, GameResources.GameFont("Courier"), 250, 10);

            SwinGame.DrawText("--BASIC STUFF--", Color.Yellow, GameResources.GameFont("Courier"), 100, 40);
            SwinGame.DrawText("--DIFFICULTY--", Color.Yellow, GameResources.GameFont("Courier"), 100, 60);
            SwinGame.DrawText("Choose between 3 Difficulties; Easy, Medium and Hard", Color.White, GameResources.GameFont("Courier"), 100, 80);

            SwinGame.DrawText("--HIGH SCORES--", Color.Yellow, GameResources.GameFont("Courier"), 100, 100);
            SwinGame.DrawText("Click on the scores button to view the Player's high score", Color.White, GameResources.GameFont("Courier"), 100, 120);

            SwinGame.DrawText("--AIM OF THE GAME--", Color.Yellow, GameResources.GameFont("Courier"), 100, 140);
            SwinGame.DrawText("Destroy all the opponent's ships in order to win", Color.White, GameResources.GameFont("Courier"), 100, 160);

            SwinGame.DrawText("--SCORING--", Color.Yellow, GameResources.GameFont("Courier"), 100, 190);
            SwinGame.DrawText("Each time the player hits the opponent's ship, 1 point will be given", Color.White, GameResources.GameFont("Courier"), 100, 210);

            SwinGame.DrawText("--GAME INSTRUCTIONS--", Color.Yellow, GameResources.GameFont("Courier"), 100, 300);
            SwinGame.DrawText("1. During Ship deployment stage, you can either place the ship on the grid", Color.White, GameResources.GameFont("Courier"), 100, 320);
            SwinGame.DrawText("horizontally or vertically. Or you can select the random shuffle which deploys", Color.White, GameResources.GameFont("Courier"), 100, 340);
            SwinGame.DrawText("all the ship on the grid for you. Note: All ship must be deployed before", Color.White, GameResources.GameFont("Courier"), 100, 360);
            SwinGame.DrawText("starting the game.", Color.White, GameResources.GameFont("Courier"), 100, 380);
            SwinGame.DrawText("2.During the attack stage, you will just need to Click on the grid", Color.White, GameResources.GameFont("Courier"), 100, 430);
            SwinGame.DrawText("in order to attack enemy's ship.", Color.White, GameResources.GameFont("Courier"), 100, 450);
            break;

        default:
            SwinGame.ClearScreen();
            break;
        }
        SwinGame.DrawFramerate(675, 585);
    }
Ejemplo n.º 15
0
 private static void LoadMusic()
 {
     GameResources.NewMusic("Background", "horrordrone.mp3");
 }
Ejemplo n.º 16
0
 private static void NewTransparentColourImage(string imageName, string fileName, Color transColor)
 {
     GameResources.NewTransparentColorImage(imageName, fileName, transColor);
 }
Ejemplo n.º 17
0
    /// <summary>
    /// Listens for attacks to be completed.
    /// </summary>
    /// <param name="sender">the game</param>
    /// <param name="result">the result of the attack</param>
    /// <remarks>
    /// Displays a message, plays sound and redraws the screen
    /// </remarks>
    private static void AttackCompleted(object sender, AttackResult result)
    {
        bool isHuman = false;

        isHuman = object.ReferenceEquals(_theGame.Player, HumanPlayer);

        if (isHuman)
        {
            UtilityFunctions.Message = "You " + result.ToString();
        }
        else
        {
            UtilityFunctions.Message = "The AI " + result.ToString();
        }

        switch (result.Value)
        {
        case ResultOfAttack.Destroyed:
            PlayHitSequence(result.Row, result.Column, isHuman);
            if (SOUNDSTATE)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
            }
            break;

        case ResultOfAttack.GameOver:
            PlayHitSequence(result.Row, result.Column, isHuman);
            if (SOUNDSTATE)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
            }
            if (SOUNDSTATE)
            {
                while (Audio.SoundEffectPlaying(GameResources.GameSound("Sink")))
                {
                    SwinGame.Delay(10);
                    SwinGame.RefreshScreen();
                }
            }

            if (HumanPlayer.IsDestroyed)
            {
                if (SOUNDSTATE)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
                }
            }
            else
            {
                if (SOUNDSTATE)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Winner"));
                }
            }

            break;

        case ResultOfAttack.Hit:
            PlayHitSequence(result.Row, result.Column, isHuman);
            break;

        case ResultOfAttack.Miss:
            PlayMissSequence(result.Row, result.Column, isHuman);
            break;

        case ResultOfAttack.ShotAlready:
            if (SOUNDSTATE)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Error"));
            }
            break;
        }
    }
Ejemplo n.º 18
0
 /// <summary>
 /// Force preload
 /// </summary>
 static Main()
 {
     // Load data
     GameResources.GetInstance();
 }
 /// <summary>
 /// Factory method to create appropriate validator for the specified file.
 /// </summary>
 /// <param name="file"></param>
 /// <param name="resources">An instance of <see cref="GameResources"/> containing all valid resources from the core game and optionally a mod.</param>
 /// <param name="expansionResourcesUsed">An instance of <see cref="GameResources"/> to which expansion resources found to be used will be added.</param>
 /// <returns></returns>
 public static XmlResourceValidator Create( ContentFile file, GameResources resources, GameResources expansionResourcesUsed = null )
 {
     switch ( file.Name.ToLower() )
     {
         case "craftdb.xml":
             return new CraftXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "itemdb.xml":
             return new ItemXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "mondb.xml":
             return new MonsterXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "soundfx.xml":
             return new SoundXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "spelldb.xml":
             return new SpellXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "skilldb.xml":
             return new SkillXmlResourceValidator( file, resources, expansionResourcesUsed );
         case "rooms.xml":
             return new RoomXmlResourceValidator( file, resources, expansionResourcesUsed );
         default:
             throw new InvalidOperationException( "The specified file is not supported." );
     }
 }
Ejemplo n.º 20
0
    /// <summary>
    /// Listens for attacks to be completed.
    /// </summary>
    /// <param name="sender">the game</param>
    /// <param name="result">the result of the attack</param>
    /// <remarks>
    /// Displays a message, plays sound and redraws the screen
    /// </remarks>
    private static void AttackCompleted(object sender, AttackResult result)
    {
        int  randomLose    = rnd.Next(1, 3);
        int  randomDestroy = rnd.Next(1, 4);
        bool isHuman       = false;

        isHuman = ReferenceEquals(_theGame.Player, HumanPlayer);

        if (isHuman)
        {
            UtilityFunctions.Message = "You " + result.ToString();
        }
        else
        {
            UtilityFunctions.Message = "The AI " + result.ToString();
        }

        if (result.Value == ResultOfAttack.Destroyed)
        {
            PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));

            if (randomDestroy == 1)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Destroy1"));
            }

            else if (randomDestroy == 2)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Destroy2"));
            }

            else if (randomDestroy == 3)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Destroy3"));
            }

            else
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Destroy4"));
            }
        }
        else if (result.Value == ResultOfAttack.GameOver)
        {
            PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));

            while (Audio.SoundEffectPlaying(GameResources.GameSound("Sink")))
            {
                SwinGame.Delay(10);
                SwinGame.RefreshScreen();
            }

            if (HumanPlayer.IsDestroyed)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
                if (randomLose == 1)
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Lose1"));
                }
                else
                {
                    Audio.PlaySoundEffect(GameResources.GameSound("Lose2"));
                }
            }
            else
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Winner"));
                Audio.PlaySoundEffect(GameResources.GameSound("Win1"));
            }
        }
        else if (result.Value == ResultOfAttack.Hit)
        {
            PlayHitSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
        }
        else if (result.Value == ResultOfAttack.Miss)
        {
            PlayMissSequence(System.Convert.ToInt32(result.Row), System.Convert.ToInt32(result.Column), isHuman);
        }
        else if (result.Value == ResultOfAttack.ShotAlready)
        {
            Audio.PlaySoundEffect(GameResources.GameSound("Error"));
        }
    }
Ejemplo n.º 21
0
    // <summary>
    // Draws the menu at the indicated level.
    // </summary>
    // <param name="menu">the menu to draw</param>
    // <param name="level">the level (height) of the menu</param>
    // <param name="xOffset">the offset of the menu</param>
    // <remarks>
    // The menu text comes from the _menuStructure field. The level indicates the height
    // of the menu, to enable sub menus. The xOffset repositions the menu horizontally
    // to allow the submenus to be positioned correctly.
    // </remarks>
    private static void DrawButtons(int menu, int level, int xOffset)
    {
        string FontName = "Menu";

        if (menu == 0 || menu == 2)
        {
            FontName = "Menu0";
        }
        else if (menu == 1)
        {
            FontName = "Menu1";
        }
        int       btnTop;
        Rectangle toDraw = default(Rectangle);

        btnTop = MENU_TOP - ((MENU_GAP + BUTTON_HEIGHT) * level);
        int i      = default(int);
        var loopTo = _menuStructure[menu].Length - 1;

        for (i = 0; i <= loopTo; i++)
        {
            int btnLeft = default(int);

            btnLeft = MENU_LEFT + (BUTTON_SEP * (i + xOffset));
            // SwinGame.FillRectangle(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT)
            toDraw.X      = btnLeft + TEXT_OFFSET;
            toDraw.Y      = btnTop + TEXT_OFFSET;
            toDraw.Width  = BUTTON_WIDTH;
            toDraw.Height = BUTTON_HEIGHT;
            SwinGame.DrawText(_menuStructure[menu][i], MENU_COLOR, Color.Transparent, GameResources.GameFont(FontName), FontAlignment.AlignCenter, toDraw);
            if (SwinGame.MouseDown(MouseButton.LeftButton) & IsMouseOverMenu(i, level, xOffset))
            {
                SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
            }
        }
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Draws the menu at the indicated level.
    /// </summary>
    /// <param name="menu">The menu to draw.</param>
    /// <param name="level">The level (height) of the menu.</param>
    /// <param name="xOffset">The offset of the menu.</param>
    /// <remarks>
    /// The menu text comes from the _menuStructure field. The level indicates the height
    /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally
    /// to allow the submenus to be positioned correctly.
    /// </remarks>
    private static void DrawButtons(int menu, int level, int xOffset)
    {
        int btnTop = 0;

        btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;
        int i = 0;

        for (i = 0; i <= _menuStructure[menu].Length - 1; i++)
        {
            int btnLeft = 0;
            btnLeft = MENU_LEFT + BUTTON_SEP * (i + xOffset);
            // SwinGame.FillRectangle(Color.White, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT).
            if (menu == GAME_MENU)
            {
                SwinGame.DrawTextLines("Selecting 'Return' will bring you back to the battle.", MENU_COLOR, Color.Black, GameResources.GameFont("GameMenu"), FontAlignment.AlignLeft, 30, 450, 455, BUTTON_HEIGHT);
                SwinGame.DrawTextLines("Selecting 'Surrender' will end the round.", MENU_COLOR, Color.Black, GameResources.GameFont("GameMenu"), FontAlignment.AlignLeft, 30, 475, 360, BUTTON_HEIGHT);
                SwinGame.DrawTextLines("Selecting 'Quit' will end the game itself.", MENU_COLOR, Color.Black, GameResources.GameFont("GameMenu"), FontAlignment.AlignLeft, 30, 500, 360, BUTTON_HEIGHT);
                SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, Color.Transparent, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);
                //btnLeft will always be 30, 105, 180
                //btnTop will always be 550
            }
            else
            {
                SwinGame.DrawTextLines(_menuStructure[menu][i], MENU_COLOR, Color.Transparent, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, btnLeft + TEXT_OFFSET, btnTop + TEXT_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT);
            }

            if (SwinGame.MouseDown(MouseButton.LeftButton) && IsMouseOverMenu(i, level, xOffset))
            {
                SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
            }
        }
    }
Ejemplo n.º 23
0
 public static void WriteInstruction()
 {
     SwinGame.DrawText("HOW TO PLAY BATTLESHIP GAME", Color.White, GameResources.GameFont("highscoreSmall"), LEFT + 280, 20);
     SwinGame.DrawText("-----------------------------------------------------------------------------------------------------------", Color.White, GameResources.GameFont("Courier"), 0, 40);
     SwinGame.DrawText(">>Player will take turn to fire shots on opponent's battleship board", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 90);
     SwinGame.DrawText(">>Upon player's turn, click on a tile on the opponent's board to hit the opponent's ship", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 120);
     SwinGame.DrawText(">>If the player manage to hit a tile which contains a ship,", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 150);
     SwinGame.DrawText("  the tile will turn into red coloured background", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 170);
     SwinGame.DrawText(">>If the tile is empty, the tile will turn into blue colored background", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 200);
     SwinGame.DrawText(">>The player will get another chance to hit the opponent's board if ", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 230);
     SwinGame.DrawText("  player manage to hit the tile that contains a ship", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 250);
     SwinGame.DrawText(">>Otherwise, the other player will have their turn to hit the opponent's board.", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 280);
     SwinGame.DrawText(">>The game consist 5 ships with different sizes.", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 310);
     SwinGame.DrawText(">>Therefore, the player who hit all the 5 five ships first wins", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 340);
     SwinGame.DrawText(">>Each round of the game is only limited to 2 minutes and 30 seconds", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 370);
     SwinGame.DrawText(">>Player need to finish the game in the timegiven,or else the player will lose in the game", Color.White, GameResources.GameFont("highscoreSmall"), LEFT, 400);
     SwinGame.DrawText("Press 'Esc' or 'Mouse 1' to exit the page", Color.White, GameResources.GameFont("highscoreSmall"), LEFT + 150, 500);
 }
Ejemplo n.º 24
0
    /// <summary>
    /// Draw the end of the game screen, shows the win/lose state
    /// </summary>
    public static void DrawEndOfGame()
    {
        UtilityFunctions.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);
        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);

        if (GameController.HumanPlayer.IsDestroyed)
        {
            SwinGame.DrawTextLinesOnScreen("YOU LOSE!", Color.Yellow, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        }
        else
        {
            SwinGame.DrawTextLinesOnScreen("-- WINNER --", Color.LightSteelBlue, Color.Transparent, GameResources.GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight());
        } return;
    }
Ejemplo n.º 25
0
 /// <summary>
 /// Initialse scroll object
 /// </summary>
 private void InitialiseScroll()
 {
     _scroll = new UIObject(GameResources.GetImage("scroll"),
                            CreateMask(GameController.WINDOW_WIDTH - GameResources.GetImage("scroll").Width, 0, GameResources.GetImage("scroll").Width, GameResources.GetImage("scroll").Height));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Initialise font for main menu
 /// </summary>
 public void InitialiseFont()
 {
     _mainFont = GameResources.GetFont("gameFont");
 }
Ejemplo n.º 27
0
        public LogInForm(ushort wid)
        {
            InitializeComponent();
            string text;

            if (GameResources.IsChineseWorld(wid) || GameResources.IsKoreanWorld(wid))
            {
                text = string.Format($"A {XIVHuntNet} account is required.", GameResources.GetWorldName(wid));
            }
            else
            {
                text = string.Format($"A {XIVHuntNet} account, with a verified character on {{0}}, is required.", GameResources.GetWorldName(wid));
            }
            var link = new Hyperlink(new Run(XIVHuntNet))
            {
                NavigateUri = new Uri(AccountLoginUrl),
            };

            link.RequestNavigate += Link_RequestNavigate;
            var run1 = new Run(text.Substring(0, text.IndexOf(XIVHuntNet)));
            var run2 = new Run(text.Substring(text.IndexOf(XIVHuntNet) + XIVHuntNet.Length));

            InfoTextBlock.Inlines.Add(run1);
            InfoTextBlock.Inlines.Add(link);
            InfoTextBlock.Inlines.Add(run2);
        }
    /// <summary>
    /// Draws the player's grid and ships.
    /// </summary>
    /// <param name="grid">the grid to show</param>
    /// <param name="thePlayer">the player to show the ships of</param>
    /// <param name="small">true if the small grid is shown</param>
    /// <param name="showShips">true if ships are to be shown</param>
    /// <param name="left">the left side of the grid</param>
    /// <param name="top">the top of the grid</param>
    /// <param name="width">the width of the grid</param>
    /// <param name="height">the height of the grid</param>
    /// <param name="cellWidth">the width of each cell</param>
    /// <param name="cellHeight">the height of each cell</param>
    /// <param name="cellGap">the gap between the cells</param>
    private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight,
                                        int cellGap)
    {
        //SwinGame.FillRectangle(Color.Blue, left, top, width, height)

        int rowTop  = 0;
        int colLeft = 0;

        //Draw the grid
        for (int row = 0; row <= 9; row++)
        {
            rowTop = top + (cellGap + cellHeight) * row;

            for (int col = 0; col <= 9; col++)
            {
                colLeft = left + (cellGap + cellWidth) * col;

                Color fillColor = default(Color);
                bool  draw      = false;

                draw = true;

                switch (grid[row, col])
                {
                //case TileView.Ship:
                //	draw = false;
                //	break;
                //If small Then fillColor = _SMALL_SHIP Else fillColor = _LARGE_SHIP
                case TileView.Miss:
                    if (small)
                    {
                        fillColor = SMALL_MISS;
                    }
                    else
                    {
                        fillColor = LARGE_MISS;
                    }
                    break;

                case TileView.Hit:
                    if (small)
                    {
                        fillColor = SMALL_HIT;
                    }
                    else
                    {
                        fillColor = LARGE_HIT;
                    }
                    break;

                case TileView.Sea:
                case TileView.Ship:
                    if (small)
                    {
                        fillColor = SMALL_SEA;
                    }
                    else
                    {
                        draw = false;
                    }
                    break;
                }

                if (draw)
                {
                    SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight);
                    if (!small)
                    {
                        SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight);
                    }
                }
            }
        }
        //if it doesnt show ships then return
        if (!showShips)
        {
            return;
        }

        int    shipHeight = 0;
        int    shipWidth  = 0;
        string shipName   = null;

        //Draw the ships
        foreach (Ship s in thePlayer)
        {
            //continue if ship is null or not deployed
            if (s == null || !s.IsDeployed)
            {
                continue;
            }
            rowTop  = top + (cellGap + cellHeight) * s.Row + SHIP_GAP;
            colLeft = left + (cellGap + cellWidth) * s.Column + SHIP_GAP;
            //Left right
            if (s.Direction == Direction.LeftRight)
            {
                shipName   = "ShipLR" + s.Size;
                shipHeight = cellHeight - (SHIP_GAP * 2);
                shipWidth  = (cellWidth + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap;
            }
            else
            {
                //Up down
                shipName   = "ShipUD" + s.Size;
                shipHeight = (cellHeight + cellGap) * s.Size - (SHIP_GAP * 2) - cellGap;
                shipWidth  = cellWidth - (SHIP_GAP * 2);
            }

            if (!small)
            {
                SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop);
            }
            else
            {
                SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight);
                SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight);
            }
        }
    }
Ejemplo n.º 29
0
        internal void ProcessChatCommand(object sender, CommandEventArgs e)
        {
            LogHost.Default.Info($"[{nameof(ProcessChatCommand)}] New command: {e?.ToString()}");
            FFXIVMemory mem = sender is FFXIVMemory ? sender as FFXIVMemory : Program.mem;

            if (mem == null)
            {
                return;
            }
            if (e.Command == Command.Hunt && hunts != null)
            {
                if (GameResources.TryGetDailyHuntInfo(e.Parameter, out Tuple <ushort, ushort, float, float> hi))
                {
                    _ = mem.WriteChatMessage(ChatMessage.MakePosChatMessage(string.Format(Properties.Resources.LKICanBeFoundAt, GameResources.GetEnemyName(hi.Item1, true)), hi.Item2, hi.Item3, hi.Item4));
                    return;
                }
                else if (hunts.Hunts.Exists(x => x.Name.Equals(e.Parameter, StringComparison.OrdinalIgnoreCase)))
                {
                    _ = hunts.LastKnownInfoForHunt(hunts.Hunts.First(x => x.Name.Equals(e.Parameter, StringComparison.OrdinalIgnoreCase)).Id);
                    return;
                }
                else if (GameResources.GetEnemyId(e.Parameter, out ushort bnpcid))
                {
                    _ = hunts.RandomPositionForBNpc(bnpcid);
                    return;
                }
                ushort fid = GameResources.GetFateId(e.Parameter, true);
                if (fid > 0)
                {
                    _ = hunts.LastKnownInfoForFATE(fid);
                    if (Settings.Default.TrackFATEAfterQuery)
                    {
                        vm.FATEEntries.SingleOrDefault(x => x.ID == fid).Announce = true;
                    }
                }
                else if (Enum.TryParse(e.Parameter.Split(' ').Last(), out HuntRank hr) && hr != HuntRank.FATE && GameResources.TryGetZoneID(e.Parameter.Substring(0, e.Parameter.Length - 2).Trim(), out ushort ZoneID) && FFXIVHunts.MapHunts.ContainsKey(ZoneID))
                {
                    foreach (ushort hid in FFXIVHunts.MapHunts[ZoneID].Where(x => hunts.HuntRankFor(x) == hr))
                    {
                        _ = hunts.LastKnownInfoForHunt(hid);
                    }
                }
                else if (!string.IsNullOrWhiteSpace(e.Parameter))
                {
                    string[] pwords   = e.Parameter.Split(' ');
                    bool     hqprefer = pwords.Last().Equals("HQ", StringComparison.OrdinalIgnoreCase);
                    Task.Factory.StartNew(async() => {
                        Item item = await hunts.QueryItem(hqprefer ? string.Join(" ", pwords.Take(pwords.Length - 1)) : e.Parameter);
                        if (item != null)
                        {
                            await mem.WriteChatMessage(ChatMessage.MakeItemChatMessage(item, HQ: hqprefer));
                        }
                    });
                }
            }
            else if (e.Command == Command.Perform)
            {
                if (!Directory.Exists(Settings.Default.PerformDirectory))
                {
                    LogHost.Default.Error(Properties.Resources.PerformDirectoryNotExists);
                    _ = mem.WriteChatMessage(new ChatMessage {
                        MessageString = Properties.Resources.PerformDirectoryNotExists
                    });
                    return;
                }
                string nametxt = e.Parameter;
                if (!nametxt.EndsWith(".txt"))
                {
                    nametxt += ".txt";
                }
                string namemml = e.Parameter;
                if (!namemml.EndsWith(".mml"))
                {
                    namemml += ".mml";
                }
                string pathnametxt = Path.Combine(Settings.Default.PerformDirectory, nametxt);
                string pathnamemml = Path.Combine(Settings.Default.PerformDirectory, namemml);
                if (File.Exists(pathnametxt))
                {
                    StopPerformance();
                    var p = new Performance(string.Join(",", File.ReadAllLines(pathnametxt)));
                    if (p.Sheet.Count > 0)
                    {
                        _ = mem.PlayPerformance(p, cts.Token);
                    }
                    else
                    {
                        TryMML(pathnametxt);
                    }
                }
                else if (File.Exists(pathnamemml))
                {
                    StopPerformance();
                    TryMML(pathnamemml);
                }
                else
                {
                    LogHost.Default.Error("Neither of these files were found:" + Environment.NewLine + pathnametxt + Environment.NewLine + pathnamemml);
                }
            }
            else if (e.Command == Command.PerformStop && cts != null)
            {
                cts.Cancel();
            }
            else if (e.Command == Command.Flag)
            {
                string[] coords = e.Parameter.Split(',');
                if (coords.Length > 1 && float.TryParse(coords[0], out float xR) && float.TryParse(coords[1], out float yR))
                {
                    ushort zid = Program.mem.GetZoneId();
                    ushort mid = Program.mem.GetMapId();
                    float  x   = Entity.GetCoordFromReadable(xR, zid, mid);
                    float  y   = Entity.GetCoordFromReadable(yR, zid, mid);
                    var    cm  = ChatMessage.MakePosChatMessage(string.Empty, zid, x, y, string.Empty, mid);
                    _ = mem.WriteChatMessage(cm);
                }
            }
        }
    /// <summary>
    /// Draws the game during the attack phase.
    /// </summary>s
    public static void DrawDiscovery(uint time)
    {
        const int SCORES_LEFT = 172;
        const int SHOTS_TOP   = 157;
        const int HITS_TOP    = 206;
        const int SPLASH_TOP  = 256;
        const int SLEFT_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.DrawField(GameController.ComputerPlayer.PlayerGrid, GameController.ComputerPlayer, true);
        UtilityFunctions.DrawSmallField(GameController.HumanPlayer.PlayerGrid, GameController.HumanPlayer);
        UtilityFunctions.DrawMessage();
        TimeSpan timetick = TimeSpan.FromSeconds(time);

        SwinGame.DrawText(playerName.getName(), Color.White, GameResources.GameFont("Name"), SCORES_LEFT, 95);
        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("Total Ships Left:  " + GameController.ShLeft.ToString(), Color.White, GameResources.GameFont("Menu"), 100, SLEFT_TOP);
        SwinGame.DrawText(timetick.ToString(@"mm\:ss"), Color.White, GameResources.GameFont("Menu"), SCORES_LEFT, SPLASH_TOP + 20);
    }
Ejemplo n.º 31
0
        private async Task GetFATEZones()
        {
            IsFetchingZones = true;
            string e;
            var    r = await FFXIVHunts.Http.GetAsync(FFXIVHunts.baseUrl + "api/worlds/FATEIDZoneID/");

            if (r.IsSuccessStatusCode)
            {
                e = await r.Content.ReadAsStringAsync();

                var fateidzoneid = JsonConvert.DeserializeObject <Dictionary <ushort, ushort[]> >(e);
                await Task.Run(() =>
                {
                    foreach (FATEListViewItem i in FATEEntries.Where(x => fateidzoneid.ContainsKey(x.ID)))
                    {
                        i.Zones = string.Join(", ", fateidzoneid[i.ID].Distinct().Select(x => GameResources.GetZoneName(x)).Distinct());
                    }
                });

                GotFATEZones = true;
            }
            IsFetchingZones = false;
        }
Ejemplo n.º 32
0
    // '' <summary>
    // '' Draws the player's grid and ships.
    // '' </summary>
    // '' <param name="grid">the grid to show</param>
    // '' <param name="thePlayer">the player to show the ships of</param>
    // '' <param name="small">true if the small grid is shown</param>
    // '' <param name="showShips">true if ships are to be shown</param>
    // '' <param name="left">the left side of the grid</param>
    // '' <param name="top">the top of the grid</param>
    // '' <param name="width">the width of the grid</param>
    // '' <param name="height">the height of the grid</param>
    // '' <param name="cellWidth">the width of each cell</param>
    // '' <param name="cellHeight">the height of each cell</param>
    // '' <param name="cellGap">the gap between the cells</param>
    private static void DrawCustomField(ISeaGrid grid, Player thePlayer, bool small, bool showShips, int left, int top, int width, int height, int cellWidth, int cellHeight, int cellGap)
    {
        // SwinGame.FillRectangle(Color.Blue, left, top, width, height)
        int rowTop  = 0;
        int colLeft = 0;

        // Draw the grid
        for (int row = 0; (row <= 9); row++)   // for each row,  color will be filled
        {
            rowTop = top + (cellGap + cellHeight) * row;
            for (int col = 0; (col <= 9); col++)   // for each colum,  color will be filled
            {
                colLeft = left + (cellGap + cellWidth) * col;
                Color fillColor = default(Color);
                bool  draw      = true;

                switch (grid[row, col])   // check what tile it is

                {
                case TileView.Miss:
                    if (small)
                    {
                        fillColor = SMALL_MISS;
                    }
                    else
                    {
                        fillColor = LARGE_MISS;
                    }

                    break;

                case TileView.Hit:
                    if (small)
                    {
                        fillColor = SMALL_HIT;
                    }
                    else
                    {
                        fillColor = LARGE_HIT;
                    }

                    break;

                case TileView.Sea:


                case TileView.Ship:
                    if (small)
                    {
                        fillColor = SMALL_SEA;
                    }
                    else
                    {
                        draw = false;
                    }

                    break;
                }
                if (draw)
                {
                    SwinGame.FillRectangle(fillColor, colLeft, rowTop, cellWidth, cellHeight);
                    if (!small)
                    {
                        SwinGame.DrawRectangle(OUTLINE_COLOR, colLeft, rowTop, cellWidth, cellHeight);
                    }
                }
            }
        }

        if (!showShips)   // if ship doesnt want to be shown it will end
        {
            return;
        }

        int    shipHeight;
        int    shipWidth;
        string shipName;

        // Draw the ships
        foreach (Ship s in thePlayer)
        {
            if (s == null || !s.IsDeployed)
            {
                continue;
            }
            rowTop  = top + (cellGap + cellHeight) * s.Row + SHIP_GAP;
            colLeft = left + (cellGap + cellWidth) * s.Column + SHIP_GAP;
            if ((s.Direction == Direction.LeftRight))
            {
                shipName   = ("ShipLR" + s.Size);
                shipHeight = (cellHeight
                              - (SHIP_GAP * 2));
                shipWidth = (((cellWidth + cellGap)
                              * s.Size)
                             - ((SHIP_GAP * 2)
                                - cellGap));
            }
            else
            {
                // Up down
                shipName   = ("ShipUD" + s.Size);
                shipHeight = (((cellHeight + cellGap) * s.Size) - ((SHIP_GAP * 2) - cellGap));
                shipWidth  = (cellWidth - (SHIP_GAP * 2));
            }

            if (!small)   // check if small or not
            {
                SwinGame.DrawBitmap(GameResources.GameImage(shipName), colLeft, rowTop);
            }
            else
            {
                SwinGame.FillRectangle(SHIP_FILL_COLOR, colLeft, rowTop, shipWidth, shipHeight);
                SwinGame.DrawRectangle(SHIP_OUTLINE_COLOR, colLeft, rowTop, shipWidth, shipHeight);
            }
        }
    }
Ejemplo n.º 33
0
    /// <summary>
    /// Draws the menu at the indicated level.
    /// </summary>
    /// <param name="menu">the menu to draw</param>
    /// <param name="level">the level (height) of the menu</param>
    /// <param name="xOffset">the offset of the menu</param>
    /// <remarks>
    /// The menu text comes from the _menuStructure field. The level indicates the height
    /// of the menu, to enable sub menus. The xOffset repositions the menu horizontally
    /// to allow the submenus to be positioned correctly.
    /// </remarks>
    private static void DrawButtons(int menu, int level, int xOffset)
    {
        int       btnTop = 0;
        Rectangle toDraw = new Rectangle();

        btnTop = MENU_TOP - (MENU_GAP + BUTTON_HEIGHT) * level;
        int i = 0;

        for (i = 0; i <= _menuStructure[menu].Length - 1; i++)
        {
            int btnLeft = 0;

            btnLeft       = MENU_LEFT + BUTTON_SEP * (i + xOffset);
            toDraw.X      = btnLeft + TEXT_OFFSET;
            toDraw.Y      = btnTop + TEXT_OFFSET;
            toDraw.Width  = BUTTON_WIDTH;
            toDraw.Height = BUTTON_HEIGHT;
            SwinGame.DrawTextLines(System.Convert.ToString(_menuStructure[menu][i]), MENU_COLOR, Color.Black, GameResources.GameFont("Menu"), FontAlignment.AlignCenter, toDraw);

            if (SwinGame.MouseDown(MouseButton.LeftButton) && IsMouseOverMenu(i, level, xOffset))
            {
                SwinGame.DrawRectangle(HIGHLIGHT_COLOR, btnLeft, btnTop, BUTTON_WIDTH, BUTTON_HEIGHT);
            }
        }
    }
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes this script
 /// </summary>
 public override void Initialize()
 {
     resources = HUD.Instance.GetResources();
 }
Ejemplo n.º 35
0
 protected void Awake()
 {
     this.balloonPrefab = GameResources.Load(BalloonClusterController.BALLOON_PREFAB_PATH);
     this.clusterPrefab = GameResources.Load(BalloonClusterController.CLUSTER_PREFAB_PATH);
     this.camera        = Camera.main;
 }
Ejemplo n.º 36
0
 private void OnEnable()
 {
     SO = new SerializedObject(target);
     myGR = (GameResources)target;
 }
Ejemplo n.º 37
0
 private void ReceiveHunt(Hunt hunt)
 {
     LogHost.Default.Debug(string.Format(CultureInfo.CurrentCulture, "[{0}] Report received: {1}", GameResources.GetWorldName(hunt.WorldId), hunt.Name));
     if (this.PutInChat(hunt) && Settings.Default.FlashTaskbarIconOnHuntAndFATEs)
     {
         if (hunt.LastAlive)
         {
             NativeMethods.FlashTaskbarIcon(Program.mem.Process, 45u, true);
             return;
         }
         NativeMethods.StopFlashWindowEx(Program.mem.Process);
     }
 }
Ejemplo n.º 38
0
 internal FFXIVHunts(Window1 pw1)
 {
     this.w1 = pw1;
     FFXIVHunts.CreateWorldsOnDC(GameResources.GetWorld(Program.mem.GetHomeWorldId()).GetWorldsOnSameDataCenter());
     this.CreateConnection();
 }
 public SpellXmlResourceValidator( ContentFile file, GameResources resources, GameResources expansionResourcesUsed )
     : base(file, resources, expansionResourcesUsed)
 {
 }