Exemple #1
0
 public TextRenderBehavior(LostSoulGame game, string text)
 {
     this.game = game;
     Text      = text;
     Font      = game.ContentLoader.Font;
     Color     = Color.White;
 }
Exemple #2
0
 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;
 }
Exemple #4
0
        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);
        }
Exemple #6
0
 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);
 }
Exemple #7
0
 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;
     }
 }
Exemple #9
0
 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;
 }
Exemple #10
0
        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;
        }
Exemple #11
0
        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);
        }
Exemple #13
0
 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;
     }
 }
Exemple #14
0
        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);
        }
Exemple #15
0
        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);
            }
        }
Exemple #16
0
        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);
        }
Exemple #17
0
 public Entity(LostSoulGame game)
 {
     this.game = game;
 }
Exemple #18
0
 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);
 }
Exemple #22
0
        private LostSoul PickSoul(LostSoulGame game)
        {
            var klass = PickSoulClass();

            return(new LostSoul(game, klass));
        }
Exemple #23
0
 public AtomBomb(LostSoulGame game)
     : base(game)
 {
     actionBehavior = new AtomBombAction();
 }
Exemple #24
0
 public LostSoulSpawner(LostSoulGame game)
     : base(game)
 {
     actionBehavior = new LostSoulSpawnerBehavior();
 }
Exemple #25
0
 public FactorModifierActor(LostSoulGame game, float factor, float countdown)
     : base(game)
 {
     actionBehavior = new FactorModifierBehavior(factor, countdown);
 }
Exemple #26
0
 public LostSoulAnimation(LostSoulGame game)
 {
     left  = game.ContentLoader.SkullLeft;
     right = game.ContentLoader.SkullRight;
 }