Exemplo n.º 1
0
 private void SearchMovingEntityObjects(ArrayList collideObjects, ICharacter mainCharacter, int row, int column)
 {
     if (mainCharacter.Type == Sprint5Main.CharacterType.Mario)
     {
         MarioCharacter mario = (MarioCharacter)mainCharacter;
         foreach (ICharacter character in MovingEntities[row * MapSize.X + column])
         {
             if (!collideObjects.Contains(character) && !character.Parameters.IsHidden && !mario.Invincible)
             {
                 collideObjects.Add(character);
             }
             else if (!collideObjects.Contains(character) && !character.Parameters.IsHidden &&
                      (character.Type != Sprint5Main.CharacterType.Enemy || character is BossEnemyCharacter) && !(character is BombCharacter))
             {
                 collideObjects.Add(character);
             }
         }
     }
     else if (mainCharacter.Type == Sprint5Main.CharacterType.Fireball) // fireball only collide with enemy among moving objects.
     {
         foreach (ICharacter character in MovingEntities[row * MapSize.X + column])
         {
             if (character.Type == Sprint5Main.CharacterType.Enemy && !collideObjects.Contains(character) && !character.Parameters.IsHidden)
             {
                 collideObjects.Add(character);
             }
         }
     }
 }
Exemplo n.º 2
0
 public GamepadController(MarioCharacter mario, Sprint5Main game)
 {
     // GamepadController set up
     Game              = game;
     this.mario        = mario;
     controllerDicMove = new Dictionary <Buttons, ICommand>();
     controllerDic     = new Dictionary <Buttons, ICommand>();
     prevGamePadState  = GamePad.GetState(PlayerIndex.One);
     GetCommand();
 }
 public KeyboardController(MarioCharacter mario, Sprint5Main game /*Bricks[] blockList*/)
 {
     // KeyboardController set up
     this.mario = mario;
     /*this.blockList = blockList;*/
     controllerDic     = new Dictionary <Keys, ICommand>();
     controllerDicMove = new Dictionary <Keys, ICommand>();
     Game = game;
     GetCommand();
 }
Exemplo n.º 4
0
 public void Handle(Blocks brick)
 {
     mario = Sprint5Main.Game.Scene.Mario;
     if (mario.IsSuper && brick.BType == BlockType.BNormal)
     {
         brick.ChangeToDestroyed();
     }
     else
     {
         brick.Bumping();
     }
 }
 public CollisionDetector(MarioCharacter mario, ArrayList characterList, ArrayList fireBallCharacterList)
 {
     if (characterList is null || fireBallCharacterList is null)
     {
         throw new ArgumentNullException(nameof(characterList));
     }
     CharacterList      = characterList;
     FireBallCharacters = fireBallCharacterList;
     DivideIntoList(); //divide all objects into two lists
     Mario        = mario;
     CollidePairs = new List <CollidePair>();
     Map          = new TileMap(new Point(10, 5), CharacterList, new Point((int)Stage.MapBoundary.X, (int)Stage.MapBoundary.Y));
 }
Exemplo n.º 6
0
 public void Collide()
 {
     // tell mario what he collide with by check object's type and tell the object mario collide with it.
     if (Character1.Type == Sprint5Main.CharacterType.Mario)
     {
         MarioCharacter MarioCharacters = (MarioCharacter)Character1;
         if (Character2.Type == Sprint5Main.CharacterType.Block)
         {
             Character2.MarioCollide((Time == yTime) && (relativeVelocity.Y < 0));
         }
         else if (Character2 is PlantEnemyCharacter || Character2 is CloudEnemyCharacter)
         {
             Character2.MarioCollide(false);
         }
         else
         {
             Character2.MarioCollide((Time == yTime) && (relativeVelocity.Y > 0));
         }
         if (!MarioCharacters.IsDied())
         {
             MarioCharacters.OnPipe = false;
             MarioCharacters.CollideWith(Character2, Time == yTime, relativeVelocity.Y > 0);
         }
     }
     else if (Character1.Type == Sprint5Main.CharacterType.Fireball)
     {
         Character1.Parameters.IsHidden = true; // fireball will hide no matter what it hit
         //only mario has response when collide with fireball
         if (Character2.Type == Sprint5Main.CharacterType.Enemy)
         {
             Character2.MarioCollide(true);
         }
     }
     else //items and enemies
     {
         if (Character1.Parameters.Velocity.X * relativeVelocity.X >= 0)
         {
             Character1.BlockCollide((Time == yTime) && (relativeVelocity.Y > 0));
         }
         if (Character1 is BossEnemyCharacter && Character2 is BlockCharacter)
         {
             BlockCharacter block = (BlockCharacter)Character2;
             block.BossEnemyCollide();
         }
     }
 }
Exemplo n.º 7
0
        public Tuple <IGameObject, ICharacter> CreateCharacter(
            string type,
            IWorld world,
            IPlayer player,
            Point location,
            IListener <IGameObject> listener,
            IListener <ISoundable> soundListener)
        {
            switch (type)
            {
            case "Mario":
                MarioCharacter mario = new MarioCharacter(world, player, location, listener, soundListener);
                return(new Tuple <IGameObject, ICharacter>(mario, mario));

            default:
                return(null);
            }
        }
Exemplo n.º 8
0
 public ThrowFireCommand(MarioCharacter mario)
 {
     Mario = mario;
 }
Exemplo n.º 9
0
 public MoveSuperCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
Exemplo n.º 10
0
 public MoveDownCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
 public BuyFireStateCommand(MarioCharacter mario)
 {
     Mario = mario;
 }
 public MoveRightCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
Exemplo n.º 13
0
 public ReturnCommand(MarioCharacter mario)
 {
     Mario = mario;
 }
 public MoveStandardCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
 public BuySuperStateCommand(MarioCharacter mario)
 {
     Mario = mario;
 }
Exemplo n.º 16
0
 public JumpHigherCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
 public MoveDestroyCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }
Exemplo n.º 18
0
 public PulseCommand(MarioCharacter mario)
 {
     Mario = mario;
 }
Exemplo n.º 19
0
 public MoveFireCommand(MarioCharacter mario)
 {
     this.mario = mario;
 }