/// <summary>
 /// Construct a new black hole
 /// </summary>
 /// <param name="position">location of black hole center</param>
 /// <param name="gravMagnitude">strength of gravitational force</param>
 /// <param name="radius">max distance that black hole will consume units</param>
 public BlackHole(Vector2 position, float gravMagnitude, float radius, float capacity)
 {
     Position = position;
     Gravity = new Gravity(position, gravMagnitude);
     _radius = radius;
     _particleEffect = new ParticleEffect("BlackHoleEffect");
     _totalCapacity = capacity;
     _capacityUsed = 0.0f;
     _overdriveTimer = TimeSpan.FromSeconds(SECONDS_FOR_OVERDRIVE);
 }
 /// <summary>
 /// Construct a new black hole
 /// </summary>
 /// <param name="position">location of black hole center</param>
 /// <param name="gravMagnitude">strength of gravitational force</param>
 /// <param name="radius">max distance that black hole will consume units</param>
 public BlackHole(BlackHoleData data)
 {
     Position = new Vector2(data.X, data.Y);
     Gravity = new Gravity(Position, data.Gravity);
     _radius = data.Radius;
     _particleEffect = new ParticleEffect("BlackHoleEffect");
     _totalCapacity = data.Capacity;
     _capacityUsed = 0.0f;
     _overdriveTimer = TimeSpan.FromSeconds(SECONDS_FOR_OVERDRIVE);
 }
 /// <summary>
 /// Construct a new black hole
 /// </summary>
 /// <param name="position">location of black hole center</param>
 /// <param name="gravMagnitude">strength of gravitational force</param>
 /// <param name="radius">max distance that black hole will consume units</param>
 public BlackHole(Vector2 position, float gravMagnitude, float radius, float capacity)
 {
     Position = position;
     Gravity = new Gravity(position, gravMagnitude);
     _radius = radius;
     _particleEffects = new ParticleEffect[] {
         new ParticleEffect("BlackHoleEffect1"),
         new ParticleEffect("BlackHoleEffect2")};
     _totalCapacity = capacity;
     _capacityUsed = 0.0f;
 }
Example #4
0
 public Unicorn(UnicornData data)
 {
     _startTime = TimeSpan.FromSeconds(data.StartTime);
     _endTime = TimeSpan.FromSeconds(data.EndTime);
     _spawnTime = TimeSpan.FromSeconds(data.SpawnTime);
     _timer = _spawnTime;
     _standingEffect = new ParticleEffect(STAND_PARTICLE_EFFECT);
     _chargeEffect = new ParticleEffect(MOVE_PARTICLE_EFFECT);
     _explodeEffect = new ParticleEffect(EXPLODE_PARTICLE_EFFECT);
     _sprite = new Sprite(SPRITE_NAME, Sprite.SpriteType.Unit);
     _state = State.Dormant;
     _gravity = new Gravity(_position, UNICORN_GRAVITY);
     _hitRect = new Rectangle(0, 0, (int)_sprite.Width, (int)_sprite.Height);
     _spawnEnable = true;
 }
 public void ApplyGravity(Gravity gravity, GameTime theGameTime)
 {
     Vector2 direction;
     if (_lifeState == LifeState.Shattered)
     {
         for (int y = 0; y < ICE_DIVISIONS; y++)
             for (int x = 0; x < ICE_DIVISIONS; x++)
             {
                 direction = gravity.Position - _fragments[y,x].Position;
                 direction.Normalize();
                 _fragments[y, x].Acceleration += direction * gravity.Magnitude * (float)theGameTime.ElapsedGameTime.TotalSeconds;
             }
     }
     direction = gravity.Position - Position;
     //float distance = direction.Length();
     direction.Normalize();
     //_acceleration += gravity.Magnitude * direction * (float)theGameTime.ElapsedGameTime.TotalSeconds / (distance * 0.01f);
     _acceleration += direction * gravity.Magnitude * (float)theGameTime.ElapsedGameTime.TotalSeconds;
 }
 public void ApplyGravity(Gravity gravity, GameTime theGameTime)
 {
     Vector2 direction = gravity.Position - Position;
     //float distance = direction.Length();
     direction.Normalize();
     //_acceleration += gravity.Magnitude * direction * (float)theGameTime.ElapsedGameTime.TotalSeconds / (distance * 0.01f);
     _acceleration += gravity.Magnitude * direction * (float)theGameTime.ElapsedGameTime.TotalSeconds;
 }
 private void goOverdrive()
 {
     _state = BlackHoleState.Overdrive;
     _explosionTimer = TimeSpan.FromSeconds(SECONDS_BEFORE_EXPLODE);
     _particleEffect.IntensityFactor = 3.0f;
     Gravity = new Gravity(Position, Gravity.Magnitude * 1.4f);
 }