Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 3
0
File: Bullet.cs Progetto: tivtag/Fly
        private void OnDamageApplied(Damaging sender, IFlyEntity e)
        {
            // ToDo: Add bounce support!

            Behave.This(this)
            .BlendOut(forSeconds: 1)
            .Despawn();
        }
Esempio n. 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);
        }
Esempio n. 5
0
File: Bullet.cs Progetto: tivtag/Fly
        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;
        }
Esempio n. 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);
        }
Esempio n. 7
0
 private void Despawn()
 {
     Behave.This(this)
     .BlendOut(forSeconds: 0.33f)
     .Despawn();
 }
Esempio n. 8
0
 private void RemoveFromScene()
 {
     Behave.This(this)
     .BlendOut(forSeconds: 0.5f)
     .Despawn();
 }