Ejemplo n.º 1
0
 public void Update()
 {
     foreach (IController c in controllers)
     {
         c.Update();
     }
     CommandScheduler.ExecuteAll();
 }
 public void CollisionRight(ITangible obj)
 {
     if (obj is BowserFireball || obj is Hammer)
     {
         ICommand c = new PowerDownPlayerCommand(subject);
         CommandScheduler.Queue(c);
     }
     if (obj is Axe)
     {
         DestroyBowserBridge();
         subject.Velocity = new Vector2(subject.Velocity.X, 0f);
         subject.AutoMove = new FinishCastleAutoMovement(subject);
     }
     if (obj is FlagpoleFlag)
     {
         subject.AutoMove = new FinishLevelAutoMovement(subject);
         SoundPanel.PlaySoundEffect(Sound.flagpoleEffect);
     }
     else if (obj is FireFlower || (obj is Mushroom && subject.State is ISmallMarioState))
     {
         ICommand c = new PowerUpPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is Star)
     {
         ICommand c = new StarPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is IEnemy)
     {
         if (!(obj.State is SHammerBroDead || obj.State is SKoopaShelled || obj.State is SKoopaShelledUpsideDown || obj.State is SKoopaWarning || obj.State is SKoopaWarningUpsideDown || obj.State is SGoombaStomped || obj.State is SBuzzyBeetleShelled || obj.State is SBuzzyBeetleShelledUpsideDown || obj.State is SKoopaShellMovingRight || obj.State is SKoopaUpsideDownShellMovingRight || obj.State is SBuzzyBeetleShellMovingRight || obj.State is SBuzzyBeetleUpsideDownShellMovingRight))
         {
             ICommand c = new PowerDownPlayerCommand(subject);
             CommandScheduler.Queue(c);
         }
     }
     else if (obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle) && !(obj is LevelTransitionPoint || obj is MazeCheckpoint || obj is MazeFinish))
     {
         // handle block collision
         subject.Position = new Vector2(((IBlock)obj).Hitbox.Left() - Hitboxes.BLOCK_WIDTH + Hitboxes.SMALL_MARIO_IDLE_OFFSET_X, subject.Position.Y);
         subject.Velocity = new Vector2(0f, subject.Velocity.Y);
     }
     if (obj is IRope)
     {
         if (!(subject.State is IClimbingMarioState) && subject.State is IRightMarioState)
         {
             subject.Position = new Vector2(((IRope)obj).Hitbox.Left() - Hitboxes.SMALL_MARIO_CLIMBING_WIDTH, subject.Position.Y);
             ((IPlayerState)subject.State).Climb();
         }
         else if (obj.Hitbox.Top() - subject.Hitbox.Bottom() > -5 || subject.Hitbox.Top() - obj.Hitbox.Bottom() > -5)
         {
             subject.Position = new Vector2(subject.Position.X, subject.Position.Y + 1);
         }
     }
 }
Ejemplo n.º 3
0
 public void Update()
 {
     foreach (IController controller in controllers)
     {
         controller.Update();
     }
     CommandScheduler.ExecuteAll();
     Level.Update();
     pointer.Update();
 }
Ejemplo n.º 4
0
 public void Update()
 {
     state.Update();
     foreach (KeyValuePair <KeyboardState, ICommand> keyCommand in
              keyCommands)
     {
         if (state.Contains(keyCommand.Key))
         {
             CommandScheduler.Queue(keyCommand.Value);
         }
     }
     CustomUpdate();
 }
Ejemplo n.º 5
0
        public void Update()
        {
            foreach (IController controller in controllers)
            {
                controller.Update();
            }
//            Console.Write("Command? ");

            CommandScheduler.ExecuteAll();
            Level.Update();
            pointer.Update();
            //HUD.midpointHit[HUD.currentPlayer] = false;
        }
 public void CollisionAbove(ITangible obj)
 {
     if (obj is BowserFireball || obj is Hammer)
     {
         ICommand c = new PowerDownPlayerCommand(subject);
         CommandScheduler.Queue(c);
     }
     if (obj is Axe)
     {
         DestroyBowserBridge();
         subject.Velocity = new Vector2(subject.Velocity.X, 0f);
         subject.AutoMove = new FinishCastleAutoMovement(subject);
     }
     if (obj is FlagpoleFlag)
     {
         subject.AutoMove = new FinishLevelAutoMovement(subject);
         SoundPanel.PlaySoundEffect(Sound.flagpoleEffect);
     }
     else if (obj is FireFlower || (obj is Mushroom && subject.State is ISmallMarioState))
     {
         ICommand c = new PowerUpPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is Star)
     {
         ICommand c = new StarPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is IEnemy)
     {
         if (!(obj.State is SHammerBroDead || obj.State is SKoopaShelled || obj.State is SKoopaShelledUpsideDown || obj.State is SGoombaStomped || obj.State is SBuzzyBeetleShelled || obj.State is SBuzzyBeetleShelledUpsideDown))
         {
             ICommand c = new PowerDownPlayerCommand(subject);
             CommandScheduler.Queue(c);
         }
     }
     else if (obj is IBlock && !(obj is LevelTransitionPoint || obj is MazeCheckpoint || obj is MazeFinish))
     {
         if (subject.State is ISmallMarioState)
         {
             subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Bottom() - Hitboxes.SMALL_MARIO_IDLE_OFFSET_Y);
         }
         else
         {
             subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Bottom() - Hitboxes.BIG_MARIO_IDLE_OFFSET_Y);
         }
         subject.Velocity = new Vector2(subject.Velocity.X, 1f);
     }
 }
Ejemplo n.º 7
0
        public void Update()
        {
            if (counter > HotDAMN.TICKS_UNTIL_TIMER_DECREMENTS && !(Game.state is SLevelComplete))
            {
                HUD.TIME--;
                counter = 0;
            }
            counter++;

            foreach (IController c in controllers)
            {
                c.Update();
            }
            CommandScheduler.ExecuteAll();
            Level.Update();
        }
Ejemplo n.º 8
0
        public void Update()
        {
            Tuple <ICommand, int> t = moves[i];

            CommandScheduler.Queue(t.Item1, this);

            j++;
            if (j == t.Item2)
            {
                j = 0;
                i++;
            }
            if (i == moves.Count)
            {
                IsActive = false;
            }
        }
 public void CollisionBelow(ITangible obj)
 {
     if (obj is BowserFireball || obj is Hammer)
     {
         ICommand c = new PowerDownPlayerCommand(subject);
         CommandScheduler.Queue(c);
     }
     if (obj is Axe)
     {
         DestroyBowserBridge();
         subject.Velocity = new Vector2(subject.Velocity.X, 0f);
         subject.AutoMove = new FinishCastleAutoMovement(subject);
     }
     if (obj is FlagpoleFlag)
     {
         subject.AutoMove = new FinishLevelAutoMovement(subject);
         SoundPanel.PlaySoundEffect(Sound.flagpoleEffect);
     }
     else if (obj is FireFlower || (obj is Mushroom && subject.State is ISmallMarioState))
     {
         ICommand c = new PowerUpPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if (obj is Star)
     {
         ICommand c = new StarPlayerCommand(subject);
         CommandScheduler.Queue(c);
         SoundPanel.PlaySoundEffect(Sound.powerupEffect);
     }
     else if ((obj is Goomba && !(obj.State is SGoombaStomped)) || (obj is Koopa && !(obj.State is SKoopaShelled || obj.State is SKoopaShelledUpsideDown)))
     {
         subject.Velocity = new Vector2(subject.Velocity.X, -6f);
     }
     else if (obj is IBlock && !(obj is BlockHidden && obj.State is SBlockIdle) && !(obj is LevelTransitionPoint || obj is MazeCheckpoint || obj is MazeFinish))
     {
         subject.Position = new Vector2(subject.Position.X, ((IBlock)obj).Hitbox.Top() - Hitboxes.BIG_MARIO_IDLE_HEIGHT - Hitboxes.BIG_MARIO_IDLE_OFFSET_Y);
         subject.Velocity = new Vector2(subject.Velocity.X, 0);
         if (subject.State is IJumpingMarioState)
         {
             ((IPlayerState)subject.State).GoNowhere();
         }
     }
 }
Ejemplo n.º 10
0
        void AddBasicLevelKeyboard(Level level)
        {
            IPlayer player = level.player;

            keyCommands.Add(new KeyboardState(stillPressed: Keys.Up),
                            new GoUpPlayerCommand(player));
            keyCommands.Add(new KeyboardState(stillPressed: Keys.Down),
                            new GoDownPlayerCommand(player));
            keyCommands.Add(new KeyboardState(stillPressed: Keys.Left),
                            new GoLeftPlayerCommand(player));
            keyCommands.Add(new KeyboardState(stillPressed: Keys.Right),
                            new GoRightPlayerCommand(player));
            keyCommands.Add(new KeyboardState(stillPressed: Keys.Z),
                            new RunPlayerCommand(player));
            keyCommands.Add(new KeyboardState(justPressed: Keys.C),
                            new JumpPlayerCommand(player));

            keyCommands.Add(new KeyboardState(justPressed: Keys.C),
                            new JumpPlayerCommand(player));
            keyCommands.Add(new KeyboardState(justPressed: Keys.Z),
                            new ThrowFireballCommand(level, player));

            keyCommands.Add(new KeyboardState(stillPressed: Keys.C),
                            new HoldJumpPlayerCommand(player));

            CustomUpdate += () =>
            {
                if (!CommandScheduler.AnyIsQueued(new List <Type>()
                {
                    typeof(GoUpPlayerCommand), typeof(GoDownPlayerCommand),
                    typeof(GoLeftPlayerCommand), typeof(GoRightPlayerCommand)
                }))
                {
                    CommandScheduler.Queue(new NoPlayerActionCommand(player));
                }
            };
        }