Exemple #1
0
        public static void CreateWormHole(GameTile[] gametiles, CanvasBitmap sprite)
        {
            drawable = new Drawable(sprite, Vector2.Zero, 0.1f, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale));
            GameEngine.drawables.Add(drawable);

            _gameTiles    = gametiles;
            StartPosition = gametiles[0];
            NewPosition(10);
        }
Exemple #2
0
        /// <summary>
        /// Creates all of the game tiles
        /// </summary>
        /// <param name="sprites">a reference to the GameEngine sprites</param>
        /// <returns></returns>
        public static GameTile[] CreateGameTiles(Dictionary <string, CanvasBitmap> sprites) // this should be cleaned up
        {
            const int gameTileCount = 12 * 4;
            const int homeLocation  = gameTileCount / 8;
            const int redHome       = 1;
            const int greenHome     = homeLocation * 2 + 1;
            const int yellowHome    = homeLocation * 4;
            const int blueHome      = homeLocation * 6;

            float baseLocation = 800;
            float distance     = 900;
            float tileSize     = 1;
            float angle        = 360.0f / gameTileCount * MathF.PI / 180.0f;
            float angleOffset  = 45 * MathF.PI / 180;

            List <GameTile> gameTiles    = new List <GameTile>();
            GameTile        previousTile = null;

            GameTile[] homeTiles = null;
            GameTile   blackhole = CreateTile(sprites["blackhole"], Vector2.Zero, 0.3f, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale), GameRace.None, null);

            for (int i = 0; i < gameTileCount; i++)
            {
                Vector2 tilePosition = new Vector2(MathF.Sin(angle * i + angleOffset) * distance, MathF.Cos(angle * i + angleOffset) * distance);
                switch (i)
                {
                case redHome:
                    homeTiles = CreateHomeTiles(distance, tileSize, angle, i, tilePosition, angleOffset, sprites["redTile"], (GameRace)1, previousTile, blackhole);
                    gameTiles.AddRange(homeTiles);
                    previousTile = homeTiles[0];

                    break;

                case greenHome:
                    homeTiles = CreateHomeTiles(distance, tileSize, angle, i, tilePosition, angleOffset, sprites["greenTile"], (GameRace)2, previousTile, blackhole);
                    gameTiles.AddRange(homeTiles);
                    previousTile = homeTiles[0];
                    break;

                case yellowHome:
                    homeTiles = CreateHomeTiles(distance, tileSize, angle, i, tilePosition, angleOffset, sprites["yellowTile"], (GameRace)3, previousTile, blackhole);
                    gameTiles.AddRange(homeTiles);
                    previousTile = homeTiles[0];
                    break;

                case blueHome:
                    homeTiles = CreateHomeTiles(distance, tileSize, angle, i, tilePosition, angleOffset, sprites["blueTile"], (GameRace)4, previousTile, blackhole);
                    gameTiles.AddRange(homeTiles);
                    previousTile = homeTiles[0];
                    break;

                default:
                    previousTile = CreateTile(sprites["whiteTile"], tilePosition, tileSize, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale), 0, previousTile);
                    gameTiles.Add(previousTile);
                    break;
                }
            }

            gameTiles[0].previousTile = gameTiles[gameTiles.Count - 1];

            CreateBaseTile(sprites["redBase"], gameTiles, new Vector2(baseLocation, baseLocation), (GameRace)1, redHome);
            CreateBaseTile(sprites["greenBase"], gameTiles, new Vector2(baseLocation, -baseLocation), (GameRace)2, greenHome + 4);
            CreateBaseTile(sprites["yellowBase"], gameTiles, new Vector2(-baseLocation, -baseLocation), (GameRace)3, yellowHome + 8);
            CreateBaseTile(sprites["blueBase"], gameTiles, new Vector2(-baseLocation, baseLocation), (GameRace)4, blueHome + 12);

            gameTiles.Add(blackhole);

            return(gameTiles.ToArray());
        }
Exemple #3
0
        private static GameTile[] CreateHomeTiles(float distance, float tileSize, float angle, int i, Vector2 tilePosition, float angleOffset, CanvasBitmap sprite, GameRace gameRace, GameTile previousTile, GameTile gameTile)
        {
            List <GameTile> homeTiles        = new List <GameTile>();
            GameTile        previousHomeTile = CreateTile(sprite, tilePosition, tileSize, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale), gameRace, previousTile);

            homeTiles.Add(previousHomeTile);
            for (int j = 1; j < 5; j++)
            {
                Vector2 homeTilePosition = new Vector2(MathF.Sin(angle * (i + j) + angleOffset) * (distance - (distance / 6) * (j)), MathF.Cos(angle * (i + j) + angleOffset) * (distance - (distance / 6) * (j)));
                previousHomeTile = CreateTile(sprite, homeTilePosition, tileSize, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale), gameRace, previousHomeTile);
                homeTiles.Add(previousHomeTile);
            }
            homeTiles[homeTiles.Count - 1].nextTile = gameTile;
            return(homeTiles.ToArray());
        }
Exemple #4
0
        /// <summary>
        /// Creates the base tile
        /// </summary>
        /// <param name="sprite"></param>
        /// <param name="gameTiles"></param>
        /// <param name="baseLocation"></param>
        /// <param name="race"></param>
        /// <param name="homeTileIndex"></param>
        private static void CreateBaseTile(CanvasBitmap sprite, List <GameTile> gameTiles, Vector2 baseLocation, GameRace race, int homeTileIndex)
        {
            GameTile baseTile = CreateTile(sprite, baseLocation, 0.15f, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale), race, null);

            baseTile.nextTile = gameTiles[homeTileIndex + 5];

            gameTiles.Add(baseTile);
        }
Exemple #5
0
        /// <summary>
        /// Creates a single game piece and the drawable that it needs to be drawn
        /// </summary>
        /// <param name="race">The race of the player</param>
        /// <param name="sprite">The prite used for the game pieces</param>
        /// <param name="offsetPosition">The position to place the pieces when at baseTile</param>
        /// <returns>The created game piece</returns>
        private static GamePiece CreateGamePiece(GameRace race, CanvasBitmap sprite, Vector2 offsetPosition, GameTile baseTile)
        {
            Drawable draw = new Drawable(sprite, baseTile.Position + offsetPosition, 1, (bitmap, scale) => Scaler.ImgUniform(bitmap, scale));

            GameEngine.drawables.Add(draw);
            return(new GamePiece(race, offsetPosition, baseTile, draw));
        }