Пример #1
0
        public override void UpdateScale(float scaleX, float scaleY, float screenWidth, float screenHeight)
        {
            foreach (var projectile in Projectiles)
            {
                projectile.UpdateScale(GameRoot.ScaleToHighDPI(projectileSize * scaleX), GameRoot.ScaleToHighDPI(projectileSize * scaleY), screenWidth, screenHeight);
            }

            base.UpdateScale(scaleX, scaleY, screenWidth, screenHeight);
        }
Пример #2
0
        private void CreateProjectiles(GameTime gameTime)
        {
            if (Projectiles.Count < projectileCount && (lastProjectile + projectileInterval) < gameTime.TotalGameTime.TotalMilliseconds)
            {
                var projectile = new Projectile(Art.Lazer, GameRoot.ScaleToHighDPI(projectileSize * ScaleX), GameRoot.ScaleToHighDPI(projectileSize * ScaleY));

                projectile.SetPosition(new Vector2(Position.X, Position.Y - (Height / 2)), new Vector2(0, -3 * projectileSpeed));
                Projectiles.Add(projectile);
                lastProjectile = gameTime.TotalGameTime.TotalMilliseconds;
            }
        }
Пример #3
0
        public void UpdateScale(float scaleX, float scaleY, float screenWidth, float screenHeight)
        {
            foreach (var ship in Ships)
            {
                ship.UpdateScale(scaleX, scaleY, screenWidth, screenHeight);
            }

            foreach (var projectile in Projectiles)
            {
                projectile.UpdateScale(GameRoot.ScaleToHighDPI(projectileSize * scaleX), GameRoot.ScaleToHighDPI(projectileSize * scaleY), screenWidth, screenHeight);
            }
        }
Пример #4
0
        private int CreateShips(GameTime gameTime, float screenWidth, double totalGameTime)
        {
            int score       = 0;
            var enemyTicker = ((int)totalGameTime / 10);
            int enemyCount  = enemyTicker > 100 ? 100 : enemyTicker;

            Color color1 = new Color(0, 50, 255);

            if (Ships.Count < enemyCount + 1)
            {
                var enemy = new Ship(this.Texture, GameRoot.ScaleToHighDPI(this.ScaleX), GameRoot.ScaleToHighDPI(this.ScaleY));
                enemy.Enemy = true; enemy.HITBOXSCALE = .9f;

                int maxEnemySpeed = (int)(shipSpeed + (float)totalGameTime);

                float enemyX  = rand.Next(10, (int)screenWidth - 10);
                float enemyDY = rand.Next((int)shipSpeed, maxEnemySpeed > 500 ? 500 : maxEnemySpeed);
                float enemyDX = 0f;

                if (rand.Next(1, 10) == 1)
                {
                    if (enemyDY > 300)
                    {
                        enemy.Color = new Color(255, 100, 0);
                        enemyDY     = 300f;
                        enemyDX     = GetPositiveOrNegative() * rand.NextFloat(40, 80);
                    }
                    else
                    {
                        enemy.Color = new Color(255, 255, 50);
                        enemyDY     = shipSpeed;
                        enemyDX     = GetPositiveOrNegative() * rand.NextFloat(20, 40);
                    }
                    enemy.SetPosition(new Vector2(enemyX, 0), new Vector2(enemyDX, enemyDY));
                }
                else
                {
                    enemy.Color = GetEnemyColor(enemyDY);
                    enemy.SetPosition(new Vector2(enemyX, 0), new Vector2(0, enemyDY));
                }
                Ships.Add(enemy);
                score++;
            }

            return(score);
        }