Esempio n. 1
0
 public QuestionBlock(Vector2 position)
 {
     StateMachine = new BlockQuestionState();
     Collided     = false;
     BlockPhysics = new BlockPhysics(position);
     Broken       = false;
 }
Esempio n. 2
0
 public BeveledBlock(Vector2 position)
 {
     StateMachine = new BlockBeveledState();
     BlockPhysics = new BlockPhysics(position);
     Collided     = false;
     Broken       = false;
 }
Esempio n. 3
0
 public Coral(Vector2 position)
 {
     StateMachine = new CoralState();
     BlockPhysics = new BlockPhysics(position);
     Collided     = false;
     Broken       = false;
 }
Esempio n. 4
0
 public UnderwaterBlock(Vector2 position)
 {
     StateMachine = new UnderwaterBlockState();
     BlockPhysics = new BlockPhysics(position);
     Collided     = false;
     Broken       = false;
 }
Esempio n. 5
0
 public BlankBlock(Vector2 position)
 {
     StateMachine = new BlockBlankState();
     BlockPhysics = new BlockPhysics(position);
     Collided     = true;
     Broken       = false;
 }
Esempio n. 6
0
 public void CollisionWithMario(IWorld level, IPlayer mario, Direction direction)
 {
     if (direction == Direction.Bottom)
     {
         BecomeUsed();
         if (!hasBeUsed)
         {
             SoundFactory.Instance.PlayBumpBlockSound();
             caseNumber = (Bonus)(new Random()).Next(Util.Instance.QBrandomLimitLow, Util.Instance.QBrandomLimitHigh);
             level.Items.Add(InitiateBonus(caseNumber));
             hasBeUsed = true;
             BlockPhysics.BlockJump();
         }
     }
     MarioBlockHandler.UpateLocation(mario, this, direction);
 }
Esempio n. 7
0
 //Called by the block that is currently being held by the user
 //Checks if there is already another block in the current position and tries to combine them if there is
 public void CheckBlockGridCombination(int x, int y, BlockPhysics block)
 {
     x = Mathf.Clamp(x, 0, width);
     y = Mathf.Clamp(y, 0, height);
     if (gridPoints[x, y] != null && gridPoints[x, y] != block)
     {
         if (gridPoints[x, y].blockRank == block.blockRank)
         {
             BlockPhysics newBlock = CombineBlocks(gridPoints[x, y], block);
             gridPoints[x, y] = newBlock;
         }
         else
         {
             Debug.Log("Blocks of different ranks are in the same space! " + block.gameObject.name + " at " + x + ", " + y, block.gameObject);
             block.transform.position = anchorPoints[x, y + 1];
         }
     }
 }
Esempio n. 8
0
 public void CollisionWithMario(IWorld level, IPlayer mario, Direction direction)
 {
     if (direction == Direction.Bottom)
     {
         if (!(mario.CurrentPowerState is MarioSmallState) && !(mario.CurrentPowerState is MarioStarSmallState))
         {
             Disappear();
         }
         else
         {
             SoundFactory.Instance.PlayBumpBlockSound();
             BlockPhysics.BlockJump();
         }
     }
     if (!(State is BlockDisappearedState))
     {
         MarioBlockHandler.UpateLocation(mario, this, direction);
     }
 }
Esempio n. 9
0
 public void Update(GameTime gametime)
 {
     BlockPhysics.Update(gametime);
 }
Esempio n. 10
0
 //Instantiates a new block from the combination of a and b, removes a and b from the scene, and returns the created object
 private BlockPhysics CombineBlocks(BlockPhysics a, BlockPhysics b)
 {
     BombPhysics bombA;
     BombPhysics bombB;
     if ((bombA = a as BombPhysics) && (bombB = b as BombPhysics))
     {
         bombA.Explode();
         Destroy(bombA.gameObject);
         Destroy(bombB.gameObject);
         return null;
     }
     else if(a.blockRank == b.blockRank && a.blockRank < blockPrefabs.Length)
     {
         BlockPhysics newBlock = Instantiate(blockPrefabs[a.blockRank]) as BlockPhysics;
         if(newBlock.blockRank > maxRank)
         {
             maxRank = newBlock.blockRank;
             SetTimerBasedOnMaxRank();
         }
         if(newBlock.blockRank == blockPrefabs.Length)
         {
             AddHighestBlockToScore(newBlock);
         }
         newBlock.transform.position = a.transform.position;
         Destroy(a.gameObject);
         Destroy(b.gameObject);
         return newBlock;
     }
     else
     {
         Debug.Log("can't combine, block ranks should match!");
         return null;
     }
 }
Esempio n. 11
0
    private void AddHighestBlockToScore(BlockPhysics block)
    {
        //Call ScoreHandler
        scoreBoard.addToScore(100);

        //Play some kind of particle effect

        //Remove the block from the game and clear the grid space
        Destroy(block.gameObject, 0.5f);
    }
Esempio n. 12
0
 //Called when the user moves a block with the mouse
 public void SetBlockGridPosition(int x, int y, BlockPhysics block)
 {
     x = Mathf.Clamp(x, 0, width);
     y = Mathf.Clamp(y, 0, height);
     if (block == null || gridPoints[x, y] == null)
     {
         gridPoints[x, y] = block;
     }
     else CheckBlockGridCombination(x, y, block);
 }