public void CreateRectangleTest()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value
     TextureFactory target = new TextureFactory(device); // TODO: Initialize to an appropriate value
     int width = 43; // TODO: Initialize to an appropriate value
     int height = 91; // TODO: Initialize to an appropriate value
     Texture2D actual = target.CreateRectangle(width, height);
     Color[] resultingData = new Color[width * height];
     actual.GetData<Color>(resultingData);
     Color[] expected = Enumerable.Repeat(Color.White, width*height).ToArray();
     for (int i = 0; i < expected.Length; i++)
     {
         Assert.AreEqual(expected[i], resultingData[i]);
     }
 }
 public void CreateRectangleTest1()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice;
     TextureFactory target = new TextureFactory(device);
     int width = 543;
     int height = 1239;
     Color color = new Color(134, 234, 65.4f, 100); // TODO: Initialize to an appropriate value
     Texture2D actual;
     actual = target.CreateRectangle(width, height, color);
     Color[] resultingData = new Color[width * height];
     actual.GetData<Color>(resultingData);
     Color[] expectedData = Enumerable.Repeat<Color>(color, width * height).ToArray();
     for (int i = 0; i < expectedData.Length; i++)
     {
         Assert.AreEqual(expectedData[i], resultingData[i]);
     }
 }
 public void CreateSquareTest()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value
     TextureFactory target = new TextureFactory(device); // TODO: Initialize to an appropriate value
     int size = 4; // TODO: Initialize to an appropriate value
     Color[] actualData = new Color[size * size];
     Texture2D actual;
     actual = target.CreateSquare(size);
     actual.GetData(actualData);
     Color[] expected = Enumerable.Repeat(Color.White, size * size).ToArray();
     for (int i = 0; i < expected.Length; i++)
     {
         Assert.AreEqual(expected[i], actualData[i]);
     }
 }
 public void WhitePixelTest()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value
     TextureFactory target = new TextureFactory(device); // TODO: Initialize to an appropriate value
     Texture2D actual;
     actual = target.WhitePixel;
     Color[] data = new Color[] { Color.Transparent };
     actual.GetData(data);
     Assert.AreEqual(Color.White, data[0]);
 }
 public void TextureFactoryConstructorTest()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice;
     TextureFactory target = new TextureFactory(device);
     Assert.IsNotNull(target.WhitePixel);
 }
 public void CreateTextureTest()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value
     //Assert.Inconclusive("Write this this test method.");
     TextureFactory target = new TextureFactory(device);
     int width = 20;
     int height = 35;
     Func<Point, Color> colorDetermine = new Func<Point,Color>(CreateTexturetestDelegate); // TODO: Initialize to an appropriate value
     Color[] expectedData = new Color[width * height];
     Texture2D actual;
     Color[] actualData = new Color[width * height];
     actual = target.CreateTexture(width, height, colorDetermine);
     actual.GetData(actualData);
     for (int w_en = 0; w_en < width; w_en++)
     {
         for (int h_en = 0; h_en < height; h_en++)
         {
             expectedData[h_en * width + w_en] = CreateTexturetestDelegate(new Point(w_en, h_en));
         }
     }
     Assert.AreEqual(expectedData.Length, actualData.Length);
     for (int i = 0; i < expectedData.Length; i++)
     {
         Assert.AreEqual(expectedData[i], actualData[i]);
     }
 }
 public void CreateSquareTest1()
 {
     GraphicsDevice device = MockDrawable.GraphicsDevice;
     TextureFactory target = new TextureFactory(device);
     int size = 6;
     Color color = new Color(3.483243f, 199, 55);
     Texture2D actual;
     actual = target.CreateSquare(size, color);
     Color[] actualData = new Color[size * size];
     actual.GetData(actualData);
     Color[] expected = Enumerable.Repeat(color, size * size).ToArray();
     for (int i = 0; i < expected.Length; i++)
     {
         Assert.AreEqual(expected[i], actualData[i]);
     }
 }
示例#8
0
        public void InitializeScreen(ShipStats ship, bool spawnEnemies)
        {
            //Reset any active ships, since we're re-initializing the game screen
            StateManager.EnemyShips.Clear();
            StateManager.AllyShips.Clear();
            playerMinimapVisible = null;
            _minimapYou = null;

            //Reset music
            _gameHasStarted = false;
            //_allowMusicHandling = false;
            playerSbObjects.Clear();
            Sprites.Clear();
            enemies.Clear();

            wcMovePrettyCode = new EventHandler(wcMovePreUpdate);

            SpriteFont SegoeUIMono = GameContent.Assets.Fonts.NormalText;

            secondaryWeaponLabel = new TextSprite(playerSb, SegoeUIMono, "No Secondary Weapon");
            secondaryWeaponLabel.Position = new Vector2((Sprites.SpriteBatch.GraphicsDevice.Viewport.Width * .1f - secondaryWeaponLabel.Width / 2) + 30, Sprites.SpriteBatch.GraphicsDevice.Viewport.Height * .1f - secondaryWeaponLabel.Height / 2);
            secondaryWeaponLabel.Color = Color.White;
            playerSbObjects.Add(secondaryWeaponLabel);

            //Initialize the game map (world)
            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;

            //Set the world size in StateManager for later access
            StateManager.WorldSize = new Rectangle(0, 0, (int)bgspr.TotalWidth, (int)bgspr.TotalHeight);

            StateManager.SpawnArea = new Rectangle(500, 500, bgspr.TotalWidth.Round() - 1000, bgspr.TotalHeight.Round() - 1000);

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

            _enemies = spawnEnemies;

            #region Enemy Spawns
            if (spawnEnemies)
            {

                if (StateManager.CurrentLevel.ToInt() == 4)
                {
                    foreach (SignedInGamer sig in Gamer.SignedInGamers)
                    {
                        sig.Presence.PresenceMode = GamerPresenceMode.BattlingBoss;
                    }
                    CloneBoss enemyBoss = new CloneBoss(GameContent.Assets.Images.Ships[ShipType.EnemyFighterCarrier, ShipTier.Tier4], Vector2.Zero, Sprites.SpriteBatch);
                    CloneBoss enemyCloneOne = new CloneBoss(GameContent.Assets.Images.Ships[ShipType.EnemyFighterCarrier, ShipTier.Tier4], Vector2.Zero, Sprites.SpriteBatch);
                    CloneBoss enemyCloneTwo = new CloneBoss(GameContent.Assets.Images.Ships[ShipType.EnemyFighterCarrier, ShipTier.Tier4], Vector2.Zero, Sprites.SpriteBatch);

                    enemyBoss.WorldCoords = StateManager.RandomGenerator.NextVector2(minSpawnArea, maxSpawnArea);
                    enemyCloneOne.WorldCoords = enemyBoss.WorldCoords;
                    enemyCloneTwo.WorldCoords = enemyBoss.WorldCoords;

                    enemyBoss.isClone = false;

                    enemyBoss.targetPosition = StateManager.RandomGenerator.NextVector2(new Vector2(500), new Vector2(StateManager.WorldSize.Width - 500, StateManager.WorldSize.Height - 500));
                    enemyCloneOne.targetPosition = StateManager.RandomGenerator.NextVector2(new Vector2(500), new Vector2(StateManager.WorldSize.Width - 500, StateManager.WorldSize.Height - 500));
                    enemyCloneTwo.targetPosition = StateManager.RandomGenerator.NextVector2(new Vector2(500), new Vector2(StateManager.WorldSize.Width - 500, StateManager.WorldSize.Height - 500));

                    enemyCloneOne.EnemyCounts = false;
                    enemyCloneTwo.EnemyCounts = false;

                    Sprites.Add(enemyBoss);
                    enemies.Add(enemyBoss);

                    if (StateManager.Options.SFXEnabled)
                    {
                        ClonesMade.Play();
                    }

                    Sprites.Add(enemyCloneOne);
                    enemies.Add(enemyCloneOne);

                    if (StateManager.Options.SFXEnabled)
                    {
                        ClonesMade.Play();
                    }

                    Sprites.Add(enemyCloneTwo);
                    enemies.Add(enemyCloneTwo);
                }
                else
                {
                    foreach (SignedInGamer sig in Gamer.SignedInGamers)
                    {
                        sig.Presence.PresenceMode = GamerPresenceMode.InCombat;
                    }
                    for (int i = 0; i < 4 * StateManager.CurrentLevel.ToInt(); i++)
                    {
                        Texture2D enemyTexture = GameContent.Assets.Images.Ships[ShipType.Drone, StateManager.RandomGenerator.NextShipTier(ShipTier.Tier1, ShipTier.Tier2)];
                        EnemyBattleCruiser enemy = new EnemyBattleCruiser(GameContent.Assets.Images.Ships[ShipType.EnemyBattleCruiser, ShipTier.Tier1], Vector2.Zero, Sprites.SpriteBatch);

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

                        enemy.DistanceToNose = .5f;

                        enemy.Tier = ShipTier.Tier1;

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

            TextureFactory creator = new TextureFactory(Graphics);

            miniMap = new Sprite(creator.CreateSquare(1, new Color(Color.Navy.R, Color.Navy.G, Color.Navy.B, 128)), Vector2.Zero, playerSb);
            miniMap.Width = bgspr.TotalWidth / MinimapDivAmount;
            miniMap.Color = Color.White;
            miniMap.Height = bgspr.TotalHeight / MinimapDivAmount;
            miniMap.Y = Graphics.Viewport.TitleSafeArea.Y + 7.5f;
            miniMap.X = Graphics.Viewport.TitleSafeArea.X + Graphics.Viewport.TitleSafeArea.Width - miniMap.Width - 7.5f;
            miniMap.Updated += new EventHandler(miniMap_Updated);
            miniShipInfoBg = new Sprite(creator.CreateSquare(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 (StateManager.DebugData.FogOfWarEnabled)
            {
                //Create fog of war array
                // > 9x15 = Xbox lag
                // TODO: RenderTarget conversion
                fogOfWar = new Sprite[9, 15];
            }

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

            playerShip = BaseAllyShip.CreateShip(ship, playerSb);

            playerShip.WorldSb = Sprites.SpriteBatch;
            playerShip.Position = playerShip.GetCenterPosition(Sprites.SpriteBatch.GraphicsDevice.Viewport, playerShip.Origin * playerShip.Scale);
            playerShip.WCMoved += new EventHandler(playerShip_WCMoved);
            playerShip.WCMoved += wcMovePrettyCode;
            playerShip.IsPlayerShip = true;
            playerShip.RotateTowardsMouse = true;
            playerSbObjects.Add(playerShip);

            //TODO: Tier change event handles this
            //playerShip.InitialHealth = 100;

            //Set as own ship
            playerShip.PlayerType = PlayerType.MyShip;
            playerShip.WorldCoords = worldCam.Pos;

            if (fogOfWar != null)
            {
                for (int row = 0; row <= fogOfWar.GetUpperBound(1); row++)
                {
                    for (int column = 0; column <= fogOfWar.GetUpperBound(0); column++)
                    {
                        fogOfWar[column, row] = new Sprite(creator.CreateSquare(1, Color.DarkGray), Vector2.Zero, playerSb);
                        fogOfWar[column, row].Width = miniMap.Width / fogOfWar.GetLength(0);
                        fogOfWar[column, row].Height = miniMap.Height / fogOfWar.GetLength(1);
                        fogOfWar[column, row].X = miniMap.X + fogOfWar[0, 0].Width * column;
                        fogOfWar[column, row].Y = miniMap.Y + fogOfWar[0, 0].Height * row;
                        fogOfWar[column, row].Color = Color.White;
                        StateManager.KnownMap[column, row] = false;
                    }
                }
            }

            World = Sprites.SpriteBatch;
            playerShip.BulletFired += new EventHandler<BulletEventArgs>(playerShip_BulletFired);

            _bulletsInProgress.Clear();
        }
示例#9
0
 void session_GamerJoined(object sender, GamerJoinedEventArgs e)
 {
     Screen playerList = allScreens["playerList"];
     Texture2D newGamerImage = new TextureFactory(GraphicsDevice).CreateSquare(64, Color.Red);
     try
     {
         newGamerImage = Texture2D.FromStream(GraphicsDevice, e.Gamer.GetProfile().GetGamerPicture());
     }
     catch { };
     Vector2 pos = new Vector2(100, 50);
     foreach (Sprite s in playerList.Sprites)
     {
         pos.Y += s.Height + 5;
     }
     Sprite gamerIcon = new Sprite(newGamerImage, pos, spriteBatch);
     playerList.Sprites.Add(gamerIcon);
     TextSprite gamerName = new TextSprite(spriteBatch, new Vector2(pos.X + gamerIcon.Width + 5, pos.Y), font, e.Gamer.Gamertag);
     allScreens["playerList"].AdditionalSprites.Add(gamerName);
     if (session.AllGamers.Count >= 2 && session.IsHost)
     {
         //TODO
         session.StartGame();
     }
 }