Esempio n. 1
0
        public double[] GetLimits(ShipType shipType, ShipTier shipTier)
        {
            LimitsTier[] limitsTier;
            switch (shipType)
            {
            case ShipType.AirCarrier:
                limitsTier = AirCarrier;
                break;

            case ShipType.Battleship:
                limitsTier = Battleship;
                break;

            case ShipType.Destroyer:
                limitsTier = Destroyer;
                break;

            case ShipType.Cruiser:
                limitsTier = Destroyer;
                break;

            default:
                limitsTier = new LimitsTier[0];
                break;
            }
            return(limitsTier.SingleOrDefault(l => l.ShipTier == shipTier)?.Values);
        }
Esempio n. 2
0
        /*
        // Implemented by GLib
        /// <summary>
        /// Generates a new Vector2 between minValue and maxValue
        /// </summary>
        /// <param name="random">Random number generator to use</param>
        /// <param name="minValue">Inclusive minimum value</param>
        /// <param name="maxValue">Exclusive maximum value</param>
        /// <remarks>
        /// Vectors are rounded to integers during randomization... floating point minimums and maximums won't work.
        /// The returned Vector2 will not be floating point, it will have an integer-convertible value (so no return value of .5 anything).
        /// If minValue.X is equal to maxValue.X, only Y-axis is randomized; if minValue.Y is equal to maxValue.Y, only X-axis is randomized.
        /// Both X and Y components cannot be equal in minValue and maxValue.
        /// </remarks>
        /// <returns>A new, random Vector2 object.</returns>
        public static Vector2 NextVector2(this Random random, Vector2 minValue, Vector2 maxValue)
        {
            if (minValue.X > maxValue.X)
            {
                throw new ArgumentException("minValue.X cannot exceed maxValue.X");
            }
            else if (minValue.Y > maxValue.Y)
            {
                throw new ArgumentException("minValue.Y cannot exceed maxValue.Y");
            }
            else if(minValue == maxValue)
            {
                throw new ArgumentException("minValue cannot equal maxValue.");
            }

            float x = minValue.X == maxValue.X ? minValue.X : random.Next(minValue.X.Round(), maxValue.X.Round()).ToFloat();
            float y = minValue.Y == maxValue.Y ? minValue.Y : random.Next(minValue.Y.Round(), maxValue.Y.Round()).ToFloat();

            return new Vector2(x, y);
        }
        */
        /// <summary>
        /// Generates a new ShipTier between minValue and maxValue, inclusively
        /// </summary>
        /// <param name="random">Random number generator to use</param>
        /// <param name="minValue">Inclusive minimum value</param>
        /// <param name="maxValue">Inclusive maximum value</param>
        /// <remarks>Both minimum and maximum values are inclusive for this extension method</remarks>
        /// <returns>ShipTier value</returns>
        public static ShipTier NextShipTier(this Random random, ShipTier minValue, ShipTier maxValue)
        {
            if(minValue >= maxValue)
            {
                throw new ArgumentException("Minimum ship tier must be smaller than maximum ship tier");
            }

            return (ShipTier)random.Next(minValue.ToInt(), maxValue.ToInt() + 1);
        }
Esempio n. 3
0
        /// <summary>
        /// Generates a new ShipTier between minValue and maxValue, inclusively
        /// </summary>
        /// <param name="random">Random number generator to use</param>
        /// <param name="minValue">Inclusive minimum value</param>
        /// <param name="maxValue">Inclusive maximum value</param>
        /// <remarks>Both minimum and maximum values are inclusive for this extension method</remarks>
        /// <returns>ShipTier value</returns>
        public static ShipTier NextShipTier(this Random random, ShipTier minValue, ShipTier maxValue)
        {
            if (minValue >= maxValue)
            {
                throw new ArgumentException("Minimum ship tier must be smaller than maximum ship tier");
            }

            return((ShipTier)random.Next(minValue.ToInt(), maxValue.ToInt() + 1));
        }
Esempio n. 4
0
        public static void InitializeSingleplayerGameScreen(ShipType type, ShipTier tier)
        {
            switch (type)
            {
            case ShipType.BattleCruiser:
                InitializeSingleplayerGameScreen <BattleCruiser>(tier);
                return;

            case ShipType.FighterCarrier:
                InitializeSingleplayerGameScreen <FighterCarrier>(tier);
                return;

            case ShipType.TorpedoShip:
                InitializeSingleplayerGameScreen <TorpedoShip>(tier);
                return;

            default:
                throw new NotImplementedException("Not a supported ship.");
            }
        }
Esempio n. 5
0
 public ShipStats(ShipType type, ShipTier tier)
 {
     Type = type;
     Tier = tier;
 }
Esempio n. 6
0
        public void InitializeScreen <TShip>(ShipTier tier) where TShip : BaseAllyShip
        {
            //Reset music
            _gameHasStarted = false;
            //_allowMusicHandling = false;
            playerSbObjects.Clear();
            Sprites.Sprites.Clear();
            enemies.Clear();

            BackgroundSprite bgspr = new BackgroundSprite(bgImg, Sprites.SpriteBatch, 10, 2);

            bgspr.Drawn     += new EventHandler(bgspr_Drawn);
            worldCam.Pos     = new Vector2(bgspr.TotalWidth / 2, bgspr.TotalHeight - (bgspr.Height / 2));
            BackgroundSprite = bgspr;

            Vector2 minSpawnArea = _playableAreaOffset;
            Vector2 maxSpawnArea = new Vector2(bgspr.TotalWidth, bgspr.TotalHeight) - _playableAreaOffset;

            for (int i = 0; i < 4; i++)
            {
                Texture2D  enemyTexture = GameContent.GameAssets.Images.Ships[ShipType.Drone, StateManager.RandomGenerator.NextShipTier(ShipTier.Tier1, ShipTier.Tier2)];
                EnemyDrone enemy        = new EnemyDrone(GameContent.GameAssets.Images.Ships[ShipType.EnemyBattleCruiser, ShipTier.Tier1], Vector2.Zero, Sprites.SpriteBatch);

                enemy.WorldCoords = StateManager.RandomGenerator.NextVector2(minSpawnArea, maxSpawnArea);

                //TODO: Different texture
                enemy.Color = Color.Green;
                enemy.Tier  = ShipTier.Tier1;

                Sprites.Add(enemy);
                enemies.Add(enemy);
            }

            miniMap               = new Sprite(new PlainTexture2D(Sprites.SpriteBatch.GraphicsDevice, 1, 1, new Color(Color.Navy.R, Color.Navy.G, Color.Navy.B, 128)), Vector2.Zero, playerSb);
            miniMap.Width         = bgspr.TotalWidth / MinimapDivAmount;
            miniMap.Color         = Color.Transparent;
            miniMap.Height        = bgspr.TotalHeight / MinimapDivAmount;
            miniMap.Y             = 7.5f;
            miniMap.Updated      += new EventHandler(miniMap_Updated);
            miniMap.X             = playerSb.GraphicsDevice.Viewport.Width - miniMap.Width - 7.5f;
            miniShipInfoBg        = new Sprite(new PlainTexture2D(Sprites.SpriteBatch.GraphicsDevice, 1, 1, new Color(0, 0, 0, 192)), new Vector2(7.5f, miniMap.Y), playerSb);
            miniShipInfoBg.Height = 0.01f;
            miniShipInfoBg.Width  = 767.5f - miniShipInfoBg.X - 7.5f - miniMap.Width - 266.6666667f;
            miniShipInfoBg.X      = miniMap.X - miniShipInfoBg.Width - 7.5f;
            miniShipInfoBg.Color  = Color.Transparent;
            playerSbObjects.Add(miniShipInfoBg);
            playerSbObjects.Add(miniMap);

            if (typeof(TShip) == typeof(Drone))
            {
                throw new Exception("Can't create a Drone as the main ship");
            }

            TShip ship = null;

            if (typeof(TShip) == typeof(FighterCarrier))
            {
                ship = new FighterCarrier(null, Vector2.Zero, playerSb, GameContent.GameAssets.Images.Ships[ShipType.Drone, ShipTier.Tier1]).Cast <TShip>();
            }
            else
            {
                ship = Activator.CreateInstance(typeof(TShip), null, Vector2.Zero, playerSb).Cast <TShip>();
            }

            ship.Texture           = GameContent.GameAssets.Images.Ships[ship.ShipType, ShipTier.Tier1];
            ship.UseCenterAsOrigin = true;
            ship.WorldSb           = Sprites.SpriteBatch;
            ship.Tier                     = tier;
            ship.Position                 = ship.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport, true);
            playerShip                    = ship;
            playerShip.IsPlayerShip       = true;
            playerShip.RotateTowardsMouse = true;
            playerSbObjects.Add(ship);

            playerShip.InitialHealth = 100;

            //Set as own ship
            playerShip.PlayerType = PlayerType.MyShip;
        }
Esempio n. 7
0
 public Texture2D this[ShipType ship, ShipTier tier]
 {
     get { return(_bulletTextures[new KeyValuePair <ShipType, ShipTier>(ship, tier)]); }
 }
Esempio n. 8
0
        public static BaseAllyShip CreateShip(ShipType type, ShipTier tier, SpriteBatch spawnSpriteBatch, Boolean isAllyShip)
        {
            BaseAllyShip bas = null;
            switch (type)
            {
                case ShipType.BattleCruiser:
                    bas = new BattleCruiser(GameContent.Assets.Images.Ships[type, tier], Vector2.Zero, spawnSpriteBatch, isAllyShip);
                    break;
                case ShipType.FighterCarrier:
                    bas = new FighterCarrier(GameContent.Assets.Images.Ships[type, tier], Vector2.Zero, spawnSpriteBatch, GameContent.Assets.Images.Ships[ShipType.Drone, ShipTier.Tier1], isAllyShip);
                    break;
                case ShipType.TorpedoShip:
                    bas = new TorpedoShip(GameContent.Assets.Images.Ships[type, tier], Vector2.Zero, spawnSpriteBatch, isAllyShip);
                    break;

                default:
                    throw new NotImplementedException("Cannot create the specified ship type.");
            }

            bas.Tier = tier;
            bas.UseCenterAsOrigin = true;
            //bas.FriendlyName = type.ToFriendlyString();

            return bas;
        }
Esempio n. 9
0
 /// <summary>
 /// Initializes the game for single player based on selected ship type and tier
 /// </summary>
 /// <typeparam name="T">Ship type</typeparam>
 /// <param name="tier">Ship tier</param>
 public static void InitializeSingleplayerGameScreen <T>(ShipTier tier) where T : PGCGame.Ships.Allies.BaseAllyShip
 {
     AllScreens[ScreenType.Game.ToString()].Cast <Screens.GameScreen>().InitializeScreen <T>(tier);
 }