Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch_LayerLowest = new SpriteBatch(GraphicsDevice);
            SpriteBatch_HUD         = new SpriteBatch(GraphicsDevice);

            lvl = new Level(Content, CurrentLevel);

            ThePlayer = new Player(Content, "Player/", 15, lvl.PlayerSpawnPosition);

            MyCamera = new Camera(GraphicsDevice.Viewport, lvl, ref ThePlayer);

            ThePlayer.SetSpawnPosition(lvl.PlayerSpawnPosition);
            ThePlayer.Respawn();

            TheSoundPlayer = new SoundPlayer(Content);
            StaticSoundPlayer.SetSoundPlayer(ref TheSoundPlayer);

            TheSpawnableEffect_List = new SpawnableEffect_List(Content);
            StaticSpawnableEffect.SetSpawnableEffect_List(ref TheSpawnableEffect_List);

            TheGameHud = new GameHud(Content);
            // TODO: use this.Content to load your game content here
        }
Пример #2
0
 public override void Update(Level lvl, GameTime gt)
 {
     if (Active)
     {
         UpdateCounter += (int)gt.ElapsedGameTime.Milliseconds;
     }
     if (UpdateCounter > UpdateDelay)
     {
         StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.TINY_STARS, Position, 50, false);
         UpdatePositionRectangle();
         UpdateAnimations(gt);
         UpdateCounter = 0;
     }
 }
Пример #3
0
        public void Update(Level lvl, GameTime gt, Vector2 OwnerPosition)
        {
            if (Active)
            {
                UpdateCounter += gt.ElapsedGameTime.Milliseconds;
                WaitCounter   += gt.ElapsedGameTime.Milliseconds;
            }

            if (Active && UpdateCounter >= UpdateDelay)
            {
                UpdateCounter = 0;

                switch (ProjectileState)
                {
                case Projectile_State.IN_MOTION:
                    Movement();
                    Gravity();
                    LevelCollision(lvl, gt);
                    if (lvl.LevelProjectileObjectCollision(this, gt))
                    {
                        Active   = false;
                        Position = Vector2.Zero;
                    }
                    Position += Velocity;
                    StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.FIRE_SPARK, Position, 75, 1);
                    if (WaitCounter >= Wait * 2)
                    {
                        Active = false;
                    }
                    break;

                case Projectile_State.CHARGING:
                    Position = OwnerPosition;
                    if (WaitCounter >= Wait)
                    {
                        WaitCounter     = 0;
                        ProjectileState = Projectile_State.IN_MOTION;
                        SetProjectileTrajectory();
                        if (!GoingRight)
                        {
                            Velocity.X = -Velocity.X;
                        }
                    }
                    break;
                }
            }
            UpdatePositionRectangle();
            UpdateAnimations(gt);
        }
Пример #4
0
        public override void Update(Level lvl, GameTime gt)
        {
            if (Active)
            {
                UpdateCounter             += (int)gt.ElapsedGameTime.Milliseconds;
                LockAnimationStateCounter += (int)gt.ElapsedGameTime.Milliseconds;
            }

            if (Health <= 0)
            {
                this.Kill(gt);
            }

            if (UpdateCounter >= UpdateDelay && UpdateCounter >= Wait && Active)
            {
                Gravity();
                LevelCollision(lvl, gt);
                Position += Velocity;
                UpdatePositionRectangle();
                VelocityDecay();

                if (ResetVelocityY)
                {
                    Velocity.Y     = 0;
                    ResetVelocityY = false;
                }
                if (gt.TotalGameTime.TotalMilliseconds < HealthInvunerabilityTimer && Health > 0)
                {
                    StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.BUBBLE, Position, 20, 1);
                }
                //Update states
                switch (GameObjectState)
                {
                case GameObject_State.Air:
                    if (Velocity.Y < 0)
                    {
                        ChangeAnimationState(Animation_State.jumping);
                    }
                    else if (Velocity.Y > 0)
                    {
                        ChangeAnimationState(Animation_State.falling);
                    }
                    break;

                case GameObject_State.onGround:
                    if (Velocity.X != 0)
                    {
                        ChangeAnimationState(Animation_State.running);
                    }
                    else if (Velocity.X == 0 && ((Keyboard.GetState().IsKeyDown(Keys.A) || Keyboard.GetState().IsKeyDown(Keys.D))))
                    {
                        ChangeAnimationState(Animation_State.byWall);
                    }
                    else
                    {
                        ChangeAnimationState(Animation_State.idle);
                    }
                    if (Velocity.X > 0)
                    {
                        GoingRight = true;
                    }
                    else if (Velocity.X < 0)
                    {
                        GoingRight = false;
                    }
                    UsedAirRoll = false;
                    break;

                case GameObject_State.Flying:
                    break;

                case GameObject_State.AirRoll:
                    if (gt.TotalGameTime.TotalMilliseconds >= AirRollTimer)
                    {
                        ChangeGameObjectState(GameObject_State.Air);
                        Velocity /= 3;
                    }
                    StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.TINY_STARS, Position, 90, 1);
                    break;

                case GameObject_State.Death:
                    if (gt.TotalGameTime.TotalMilliseconds >= DeathDelayTimer)
                    {
                        Active = false;
                    }
                    break;
                }
                Wait          = 0;
                UpdateCounter = 0;
            }
            UpdateAnimations(gt);
        }
Пример #5
0
        public void Behaviour(GameTime gt, Player ThePlayer, Level lvl)
        {
            if (Active && GameObjectState != GameObject_State.Death)
            {
                counterEnemyCycle += (int)gt.ElapsedGameTime.Milliseconds;
            }
            if (GameObjectState != GameObject_State.Death)
            {
                switch (Type)
                {
                //Jumper
                case EnemyType.Purple:
                    if (counterEnemyCycle >= EnemyCycleTimer)
                    {
                        Jump(gt);
                        counterEnemyCycle = 0;

                        if (!GoingRight && GameObjectState == GameObject_State.Air)
                        {
                            Velocity.X = 5;
                        }
                        else if (GoingRight && GameObjectState == GameObject_State.Air)
                        {
                            Velocity.X = -5;
                        }
                        GoingRight = !GoingRight;
                    }
                    break;

                //Shooter
                case EnemyType.Orange:
                    FacePlayer(ThePlayer);
                    if (counterEnemyCycle >= EnemyCycleTimer)
                    {
                        ShootProjectile();
                        counterEnemyCycle = 0;
                    }
                    break;

                //Thwomp
                case EnemyType.DarkGray:
                    FacePlayer(ThePlayer);
                    if (GameObjectState == GameObject_State.onGround)
                    {
                        StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.SMOKE_PUFF_RIGHT, new Vector2(Position.X, Position.Y + Hitbox.Height / 2), 300, true, false, 3, 0);
                        StaticSpawnableEffect.AddSpawnableEffect(SpawnableEffect_Type.SMOKE_PUFF_LEFT, new Vector2(Position.X, Position.Y + Hitbox.Height / 2), 300, true, false, -3, 0);

                        ChangeAnimationState(Animation_State.falldamage);
                        LockAnimation(Animations[ActiveAnimation]);
                        Velocity.Y      = -4;
                        GameObjectState = GameObject_State.Jumping;
                        Wait            = 1000;
                    }
                    else if (GameObjectState == GameObject_State.Flying)
                    {
                        Velocity.Y = 0;

                        if (Position.X - ThePlayer.Position.X < 50 && Position.X - ThePlayer.Position.X > -50)
                        {
                            GameObjectState = GameObject_State.Air;
                        }
                    }
                    else if (GameObjectState == GameObject_State.Air)
                    {
                        Velocity.Y += 1;
                    }
                    else if (GameObjectState == GameObject_State.Jumping)
                    {
                        ChangeAnimationState(Animation_State.jumping);
                        Velocity.Y = -4;
                        if (SpawnPoint.Y - Position.Y > 3)
                        {
                            GameObjectState = GameObject_State.Flying;
                        }
                    }
                    break;

                //FireWalker
                case EnemyType.DarkRed:
                    if (counterEnemyCycle >= EnemyCycleTimer)
                    {
                        Velocity.X        = 4;
                        counterEnemyCycle = 0;
                    }
                    break;
                    //Yoyo fiende. Pappas idé.
                }
            }
        }