예제 #1
0
 public Player(Gamer gamer)
 {
     AvatarDescription.BeginGetFromGamer(gamer, LoadGamerAvatar, null);
     PlayersName = gamer.Gamertag;
     CurrentAvatarAnimation = new AvatarAnimation(AvatarAnimationPreset.MaleIdleLookAround);
     Ship = new Ship();
     NumberOfLives = 3;
     Level = 1;
     ScoreMultiplier = 1;
     SpeedMultiplier = 1;
     EnemyShipList = new EnemyShip[GameConstants.NumberOfEnemyShip];
     BulletList = new Bullet[GameConstants.NumBullets];
     LoadBulletList();
     CurrentGameState = GameState.TitleScreen;
     ResetEnemyShips();
 }
예제 #2
0
        public void ResetEnemyShips()
        {
            float xStart;
            float yStart;

            for (var i = 0; i < GameConstants.NumberOfEnemyShip; i++)
            {
                EnemyShipList[i] = new EnemyShip(random);
                EnemyShipList[i].IsActive = true;

                if (random.Next(2) == 0)
                    xStart = (float)-GameConstants.PlayfieldSizeX;
                else
                    xStart = (float)GameConstants.PlayfieldSizeX;

                yStart = (float)random.NextDouble() * GameConstants.PlayfieldSizeY;
                EnemyShipList[i].position = new Vector3(xStart, yStart, 0.0f);
                double angle = random.NextDouble() * 2 * Math.PI;
                EnemyShipList[i].direction.X = -(float)Math.Sin(angle);
                EnemyShipList[i].direction.Y = (float)Math.Cos(angle);
                EnemyShipList[i].Speed = GameConstants.EnemyShipMinSpeed + (float)random.NextDouble() * SpeedMultiplier;
            }
        }