protected BowserState(Sprite sprite, Bowser context) { mario = context.Level.Mario; Sprite = sprite; Context = context; Delay = 10; }
public override States HandleActivation(MarioContext activator, Point direction) { if (!SolidTo(activator, direction)) { return(SelfEnum); } int points = (272 - (int)activator.BoundingBox.Rectangle.Bottom) / 16; Level.Spawn(typeof(Points), activator.Position, (Enum)Enum.GetValues(typeof(PointValue)).GetValue(points)); activator.ActionStates.CurrentState = ActionEnum.FLAG; activator.DisableEvents = true; activator.Flipped = true; activator.HasGravity = false; activator.BoundingBox.Active = false; Level.PauseTime = true; activator.Position = new Vector2(Block.Position.X - 8, (float)Math.Round(activator.Position.Y)); activator.Velocity = Vector2.Zero; activator.Commands += new Message("flagpole").Until(m => m.CollidingWith.Any(e => ((BlockEntity)e.entity).BlockStates.CurrentState == States.Castle)); activator.Commands += new Command[] { new Move(0, 1).AddCondition(new Until(e => e.BoundingBox.Rectangle.Bottom >= 270)), new MethodCall <MarioContext>(m => { m.Flipped = false; m.Sprite.Delay = -1; m.Position += new Point(16, 0); }), new Move(0, 0).Repeat(50), // new Move(2, 0), new MethodCall <MarioContext>(m => { m.Flipped = true; m.Velocity = new Vector2(1, 0); }), new MethodCall <MarioContext>(m => { m.ActionStates.CurrentState = ActionEnum.WALKING; m.BoundingBox.Active = true; m.HasGravity = true; }), new Wait().AddCondition(new Until(m => m.CollidingWith.Count > 0)), new MethodCall <MarioContext>(m => m.ActionStates.CurrentState = ActionEnum.WALKING) .AddCondition(new Until(m => m.CollidingWith.Any(e => ((BlockEntity)e.entity).BlockStates.CurrentState == States.Castle))), new MethodCall <MarioContext>(m => m.Sprite.Visible = false), new MethodCall <MarioContext>(m => { m.Level.Time--; m.Level.Game.Points += 50; }).AddCondition(new Until(m => m.Level.Time == 0)), new Move(0, 0).Repeat(10), new MethodCall <MarioContext>(m => m.Level.GoToNextLevel()) }; IEntity f = Level.Collider.GridAt(activator.Position).FirstOrDefault(e => (e as BlockEntity).BlockStates.CurrentState == States.Flag); if (f == null) { f = Level.Collider.GridAt(activator.Position + new Vector2(0, 16)).FirstOrDefault(e => (e as BlockEntity).BlockStates.CurrentState == States.Flag); } if (f != null) { f.Commands += new Move(0, 1).Until(e => e.BoundingBox.Rectangle.Bottom >= 272); } Level.MusicPlayer.PlaySoundEffect("WorldClear"); MusicPlayer.StopBGM(); return(SelfEnum); }
public StarState(MarioContext context, Sprite[,] normalSprites, Sprite[,] largeSprites) { Context = context; this.normalSprites = normalSprites; this.largeSprites = largeSprites; }