Пример #1
0
        public override bool Update(GameTime gameTime, float percent)
        {
            var newSpawns = new List <Vector2>();

            foreach (var spawn in Spawns)
            {
                if (spawn.X > Position.X)
                {
                    newSpawns.Add(spawn);
                }
                else
                {
                    ActiveSpawn = new Vector2(spawn.X, spawn.Y);
                }
            }
            Spawns.Clear();
            Spawns.AddRange(newSpawns);

            Position = new Vector2(Position.X + Velocity.X * percent, Position.Y + Velocity.Y * percent);
            ActionState.UpdateHitBox();

            if (BoundingBox.Dimensions.Bottom >= MarioCloneGame.LevelAreas[LevelArea].Bottom)
            {
                if (!(PowerupState is MarioDead2))
                {
                    BecomeDead();
                }
            }
            else
            {
                if (Gravity)
                {
                    Velocity = new Vector2(Velocity.X, Velocity.Y + GravityAcceleration * percent);
                }
                Gravity = true;
            }

            //TODO fix update to be inside the states or smth, or give mario a BecomeFall() method
            if (!(ActionState is MarioFall2 || ActionState is MarioDash) && Velocity.Y > 1.5)
            {
                StateMachine.TransitionFall();
            }

            StateMachine.UpdateDash(gameTime);

            PowerupState.Update(gameTime);
            _FireBallPool.Update(gameTime);

            if (Position.X < 19000 && outSideBoss == false)
            {
                EventManager.Instance.TriggerEnterBossRoom(this);
                outSideBoss = true;
            }
            else if (Position.X > 19000 && outSideBoss == true)
            {
                EventManager.Instance.TriggerEnterBossRoom(this);
                outSideBoss = false;
            }

            return(base.Update(gameTime, percent));
        }