public TextRenderBehavior(LostSoulGame game, string text) { this.game = game; Text = text; Font = game.ContentLoader.Font; Color = Color.White; }
public Background(LostSoulGame game) : base(game) { bodyBehavior = new PlaneBodyBehavior(this); renderBehavior = new SpriteRenderBehavior(game, game.ContentLoader.Backgrounds[currentBackgroundIndex]); animationBehavior = new BackgroundAnimationBehavior(this); }
public SpriteRenderBehavior(LostSoulGame game, Texture2D texture) { this.game = game; Color = Color.White; Texture = texture; Scale = Vector2.One; }
public LostSoul(LostSoulGame game, LostSoulClass klass) : base(game) { Klass = klass; bodyBehavior = new GameObjectBodyBehavior(this); renderBehavior = new SpriteRenderBehavior(game, game.ContentLoader.SkullLeft); Render.CenterOrigin(); Render.Color = klass.Color; Render.Scale = klass.Scale; bodyBehavior.Size = Vector2.Multiply(renderBehavior.Size, klass.Scale); movementBehavior = new MovementBehavior(); animationBehavior = new LostSoulAnimation(game); collisionBehavior = new CollisionBehavior(this); healthBehavior = new HealthBehavior(this); HealthBehavior.Health = klass.Health; HealthBehavior.DeathEvent += OnDeath; HealthBehavior.DamagedEvent += OnDamaged; positionObserver = new LostSoulPositionObserver(this); foreach (FactorModifierActor actor in game.World.EnemySpeedModifierActors) { if (!actor.Expired) { movementBehavior.AddSpeedModifier(actor); } } game.World.SpeedModifierActorAdded += World_SpeedModifierActorAdded; }
private void SpawnExplosion(LostSoulGame game, Vector2 position) { var explosion = new Explosion(game); explosion.BodyBehavior.Position = position; game.World.AddActor(explosion); }
private static void InitPixel(LostSoulGame game) { pixel = new Texture2D(game.GraphicsDevice, 1, 1); Color[] colorData = new Color[1]; pixel.GetData <Color>(colorData); colorData[0] = Color.White; pixel.SetData <Color>(colorData); }
public static void LoadContent(LostSoulGame game) { slow = new LostSoulSlow(); average = new LostSoulAverage(); fast = new LostSoulFast(); ultraFast = new LostSoulUltraFast(); big = new LostSoulBig(game); }
private void RunExplosion(GameTime gameTime, LostSoulGame game) { countDownUntilNextBoom -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (countDownUntilNextBoom <= 0.0f) { SpawnExplosion(game, positions.ElementAt(0)); positions.RemoveAt(0); countDownUntilNextBoom = intervalBetweenBooms; } }
public LostSoulBig(LostSoulGame game) { KillScore = 300; DamageScore = 50; Health = 3; Speed = 45.0f; Color = Color.White; DifficultyFactor = 3.0f; Scale = new Vector2(3.0f, 3.0f); ActivationSound = game.ContentLoader.SkullShowSound; }
public Explosion(LostSoulGame game) : base(game) { bodyBehavior = new GameObjectBodyBehavior(this); renderBehavior = new SpriteRenderBehavior(game, game.ContentLoader.Explosion[0]); bodyBehavior.Size = renderBehavior.Size; var animationBehavior = new AnimationBehavior(AnimationFrame.MkCentered(game.ContentLoader.Explosion), 0.1f); animationBehavior.MarkEntityAsExpiredWhenDone = true; this.animationBehavior = animationBehavior; collisionBehavior = new CollisionBehavior(this); CollisionBehavior.CollisionDetected += CollisionDetectedHandler; }
public Player(LostSoulGame game) : base(game) { Score = 0; Texture2D texture = game.ContentLoader.Crosshair; bodyBehavior = new GameObjectBodyBehavior(this); renderBehavior = new SpriteRenderBehavior(game, texture); RenderBehavior.CenterOrigin(); inputBehavior = new PlayerInputBehavior(game); actionBehavior = new PlayerActionBehavior(); healthBehavior = new HealthBehavior(this); }
private List <Vector2> CalculateExplosionPositions(LostSoulGame game) { var result = new List <Vector2>(); var explosionPrototype = new Explosion(game); var size = explosionPrototype.BodyBehavior.Size; var playField = game.World.PlayField; for (float x = size.X; x < playField.Width; x += size.X) { for (float y = size.Y; y < playField.Height; y += size.Y) { result.Add(new Vector2(x, y)); } } return(result); }
static void Main() { try { using (var game = new LostSoulGame()) game.Run(); } catch (Exception e) { string stackfile = System.IO.Path.GetTempPath() + "lostsoul_" + Guid.NewGuid().ToString(); System.IO.StreamWriter file = new System.IO.StreamWriter(stackfile); WriteExceptionsUntilNoMoreInner(e, file); file.Close(); throw e; } }
public Bonus(LostSoulGame game, BonusClass bonusClass) : base(game) { this.bonusClass = bonusClass; bodyBehavior = new GameObjectBodyBehavior(this); bodyBehavior.Size = new Vector2(32.0f, 32.0f); renderBehavior = bonusClass.MkRender(this); renderBehavior.CenterOrigin(); healthBehavior = new HealthBehavior(this); healthBehavior.DeathEvent += OnDeathHandler; collisionBehavior = new CollisionBehavior(this); actionBehavior = new ExpirationActionBehavior(2.0f); }
private Vector2 PickLocation(LostSoulGame game, Edge edge) { var playField = game.World.PlayField; switch (edge) { case Edge.Left: return(new Vector2(playField.Left, random.Next(playField.Top, playField.Bottom))); case Edge.Right: return(new Vector2(playField.Right, random.Next(playField.Top, playField.Bottom))); case Edge.Top: return(new Vector2(random.Next(playField.Left, playField.Right), playField.Top)); case Edge.Bottom: return(new Vector2(random.Next(playField.Left, playField.Right), playField.Bottom)); default: throw new NotImplementedException("unknown edge " + edge); } }
private Vector2 PickVelocity(LostSoulGame game, LostSoul soul) { float speed = soul.Klass.Speed; if (random.NextDouble() < ChanceOfFasterSpeed) { speed *= 2.0f; } var playField = game.World.PlayField; var position = soul.BodyBehavior.Position; Vector2 diff = new Vector2(playField.Center.X, playField.Center.Y) - position; diff = Vector2.Normalize(diff); float angle = MathHelper.ToRadians(22.5f - (45.0f * (float)random.NextDouble())); Vector2 rotated = new Vector2() { X = (float)(diff.X * Math.Cos(angle) - diff.Y * Math.Sin(angle)), Y = (float)(diff.Y * Math.Cos(angle) + diff.X * Math.Sin(angle)) }; return(rotated * speed); }
public Entity(LostSoulGame game) { this.game = game; }
public HudElement(LostSoulGame game) : base(game) { bodyBehavior = new PlaneBodyBehavior(this); Visible = true; }
public HudElementText(LostSoulGame game, string text = "") : base(game) { bodyBehavior = new RenderDependentBodyBehavior(this); renderBehavior = new TextRenderBehavior(Game, text); }
public PlayerInputBehavior(LostSoulGame game) { this.game = game; }
public LostSoulWorld(LostSoulGame game) : base(game) { inputBehavior = new LostSoulWorldInputBehavior(this); }
private LostSoul PickSoul(LostSoulGame game) { var klass = PickSoulClass(); return(new LostSoul(game, klass)); }
public AtomBomb(LostSoulGame game) : base(game) { actionBehavior = new AtomBombAction(); }
public LostSoulSpawner(LostSoulGame game) : base(game) { actionBehavior = new LostSoulSpawnerBehavior(); }
public FactorModifierActor(LostSoulGame game, float factor, float countdown) : base(game) { actionBehavior = new FactorModifierBehavior(factor, countdown); }
public LostSoulAnimation(LostSoulGame game) { left = game.ContentLoader.SkullLeft; right = game.ContentLoader.SkullRight; }