Пример #1
0
        public static HomePlanet CreateHomePlanet(Empire empire, float radius, float density, bool isStatic = false, int segmentCount = 32)
        {
            Color color  = Color.DarkGray;
            var   planet = new HomePlanet();

            planet.OwnedBy.Empire = empire;
            planet.LifeStatus.MaximumLifePoints = 500;
            planet.LifeStatus.Refill();

            planet.DrawStrategy = new PhysicsCirlceDrawStrategy()
            {
                SegmentCount = segmentCount,
                Color        = color
            };

            planet.Physics.FixtureDescription = new CircleDescription()
            {
                Radius   = radius,
                Density  = density,
                IsStatic = isStatic
            };

            planet.LifeStatus.Destroyed += sender => {
                if (planet.Scene != null)
                {
                    Behave.This(planet)
                    .BlendOut(forSeconds: 10)
                    .Despawn();
                }
            };

            return(planet);
        }
Пример #2
0
        private static BlackHole CreateBlackHole(float density, float blackHoleActiveTime)
        {
            var hole = new BlackHole()
            {
                Name = "Black Hole"
            };

            hole.DrawStrategy = new PhysicsShapeDrawStrategy()
            {
                Color = Color.Violet
            };

            hole.Physics.FixtureDescription = new CircleDescription()
            {
                Radius            = 2.0f,
                Density           = density,
                CollisionCategory = Category.None
            };

            Behave.This(hole)
            .BlendIn(forSeconds: 0.7f)
            .AndAtTheSameTime()
            .After(blackHoleActiveTime)
            .BlendOut(forSeconds: 1)
            .Despawn();

            return(hole);
        }
Пример #3
0
        private void OnDamageApplied(Damaging sender, IFlyEntity e)
        {
            // ToDo: Add bounce support!

            Behave.This(this)
            .BlendOut(forSeconds: 1)
            .Despawn();
        }
Пример #4
0
        private void OnBroken(Breakable sender)
        {
            var asteroid = this;

            Behave.This(asteroid)
            .After(DespawnTime)
            .BlendOut(forSeconds: 3)
            .Despawn()
            .AndAtTheSameTime()
            .Spawn(CreateMineral, asteroid.Destroyable.MaximumLifePoints / 3);
        }
Пример #5
0
        public Bullet(float activeTime)
        {
            this.Components.BeginSetup();
            this.Components.Add(this.damaging);
            this.Components.Add(this.behaveable);
            this.Components.EndSetup();

            Behave.This(this)
            .After(activeTime)
            .BlendOut(forSeconds: 1)
            .Despawn();

            this.damaging.DamagedOther += this.OnDamageApplied;
        }
Пример #6
0
        private static IFlyEntity CreateMineral(Asteroid a)
        {
            var mineral = EntityFactory.CreateMineral();

            mineral.Position = a.Physics.PhysicsPosition;

            Behave.This(mineral)
            .BlendIn(forSeconds: 1)
            .AndAtTheSameTime()
            .After(seconds: 10)
            .BlendOut(forSeconds: 2)
            .Despawn();

            return(mineral);
        }
Пример #7
0
 private void Despawn()
 {
     Behave.This(this)
     .BlendOut(forSeconds: 0.33f)
     .Despawn();
 }
Пример #8
0
 private void RemoveFromScene()
 {
     Behave.This(this)
     .BlendOut(forSeconds: 0.5f)
     .Despawn();
 }