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); }
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); }
private void OnDamageApplied(Damaging sender, IFlyEntity e) { // ToDo: Add bounce support! Behave.This(this) .BlendOut(forSeconds: 1) .Despawn(); }
private void OnBroken(Breakable sender) { var asteroid = this; Behave.This(asteroid) .After(DespawnTime) .BlendOut(forSeconds: 3) .Despawn() .AndAtTheSameTime() .Spawn(CreateMineral, asteroid.Destroyable.MaximumLifePoints / 3); }
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; }
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); }
private void Despawn() { Behave.This(this) .BlendOut(forSeconds: 0.33f) .Despawn(); }
private void RemoveFromScene() { Behave.This(this) .BlendOut(forSeconds: 0.5f) .Despawn(); }