Example #1
0
        private static Vector2 RandomVector2(float spread, float baseValue)
        {
            Vector2 v = new Vector2(2 * SRandom.NextFloat() - 1, 2 * SRandom.NextFloat() - 1);

            v.Normalize();
            v *= RandomFloat(spread, baseValue);
            return(v);
        }
Example #2
0
 public static void Update(GameTime gameTime)
 {
     if (!shakeTimer.IsFinished)
     {
         shakeTimer.CountDown(gameTime);
         offset = new Vector2(1 - SRandom.NextFloat() * 2, 1 - SRandom.NextFloat() * 2) * multiplier;
         if (shakeTimer.IsFinished)
         {
             offset = Vector2.Zero;
         }
     }
 }
        private void UpdateSpawnHandlers(GameTime gameTime)
        {
            if (SRandom.NextFloat() > 0.9980f) //! background asteroid chance
            {
                Enemies.SpawnAsteroid(spawnPointGen.GetAsteroidSpawnPoint());
            }

            Drops.SpawnAt(dropPoints.SpawnPositions());
            Drops.SpawnMoneyAt(dropPoints.MoneySpawnPositions());
            spawnPointGen.Update(gameTime);
            if (!finishedSpawning && spawnTimer.Update(gameTime))
            {
                SpawnWave();
            }
        }
Example #4
0
        public static void GenerateDeathParticles(Sprite sprite, Vector2 position, int ID, float angle, bool showDeathParticles)
        {
            List <Color> colors = sprite.Colors;

            if (showDeathParticles)
            {
                List <Sprite> sList        = sprite.SplitSprites;
                Vector2       initialForce = 50 * new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
                CreateParticle(sList[0], position, -initialForce, angle, 0, Color.White, Vector2.One, 1, IDs.DEATH);
                CreateParticle(sList[1], position, initialForce, angle, 0, Color.White, Vector2.One, 1, IDs.DEATH);
            }
            for (int i = 0; i < 20; i++)
            {
                CreateExplosion(1, position, 20, 80, 0.5f, colors[SRandom.Next(0, colors.Count)], 1, 1, 1);
            }
        }
Example #5
0
        public static void GenerateParticles(List <Vector2> edges, Vector2 position, Vector2 origin, int ID, float angle = 0, Color?color = null)
        {
            switch (ID)
            {
                #region Shield Visuals 7
            case 7:
                for (int i = 0; i < 10; i++)
                {
                    Vector2 currentEdge = edges[(int)(SRandom.NextFloat() * edges.Count)];
                    currentEdge = Vector2.Transform(currentEdge, Matrix.CreateRotationZ(angle));
                    GenerateParticles(currentEdge + position, 7, angle);
                }
                break;

                #endregion
                #region Red Burning 13
            case 13:
            {
                if (SRandom.NextFloat() < 0.2f)
                {
                    Vector2 currentEdge = edges[(int)(SRandom.NextFloat() * edges.Count)];
                    currentEdge = Vector2.Transform(currentEdge, Matrix.CreateRotationZ(angle));
                    GenerateParticles(currentEdge + position, 13, angle);
                }
                break;
            }

                #endregion
                #region Yellow Bar 15
            case 15:
            {
                if (color.HasValue)
                {
                    if (SRandom.NextFloat() < 0.4f)
                    {
                        Vector2 currentEdge = edges[(int)(SRandom.NextFloat() * edges.Count)];
                        CreateExplosion(1, currentEdge + position, 10, 40, 0.5f, color.Value, 0.5f, 0.5f, 0.5f);
                    }
                }
                break;
            }
                #endregion
            }
        }
Example #6
0
 private static float RandomFloat(float spread, float baseValue)
 {
     return(SRandom.NextFloat() * spread + baseValue);
 }