Ejemplo n.º 1
0
        protected virtual void OnCollisionResponse(ITile tile, CollisionSide side)
        {
            if (isInBlock || currentState == ItemState.Idle)
            {
                return;
            }

            if (currentState == ItemState.Moving)
            {
                if (side == CollisionSide.Left)
                {
                    movingLeft = false;
                }
                else if (side == CollisionSide.Right)
                {
                    movingLeft = true;
                }
            }

            if (currentState.Equals(ItemState.Moving) && side.Equals(CollisionSide.Bottom))
            {
                position.Y -= yDifference;
                velocity    = ONE;
            }
            CorrectPosition(side, tile);
        }
Ejemplo n.º 2
0
 protected virtual void OnCollisionResponse(ITile tile, CollisionSide side)
 {
     if (side.Equals(CollisionSide.Bottom) && currentHealth != EnemyHealth.Flipped)
     {
         if (tile is BreakableBrickTile && ((BreakableBrickTile)tile).IsChangingState)
         {
             if (this is KoopaEnemy)
             {
                 ChangeState(EnemyState.Dead);
             }
             else
             {
                 ChangeState(EnemyState.Flipped);
             }
             currentHealth = EnemyHealth.Flipped;
             Score.increaseScoreMario(200);
         }
         else if (tile is QuestionBlockTile && ((QuestionBlockTile)tile).IsChangingState)
         {
             if (this is KoopaEnemy)
             {
                 ChangeState(EnemyState.Dead);
             }
             else
             {
                 ChangeState(EnemyState.Flipped);
             }
             currentHealth = EnemyHealth.Flipped;
             Score.increaseScoreMario(200);
         }
         position.Y -= yDifference;
         velocity    = 1;
     }
     if (side.Equals(CollisionSide.Right) && currentHealth != EnemyHealth.Flipped)
     {
         ChangeState(EnemyState.WalkRight);
         isLeft      = true;
         position.Y -= adjustYDifference;
     }
     else if (side.Equals(CollisionSide.Left) && currentHealth != EnemyHealth.Flipped)
     {
         ChangeState(EnemyState.WalkLeft);
         isLeft      = false;
         position.Y -= adjustYDifference;
     }
 }
        protected override void OnCollisionResponse(IPlayer player, CollisionSide side)
        {
            if (currentState != KoopaShellStates.Sliding)
            {
                if (side.Equals(CollisionSide.Right))
                {
                    isMovingRight = false;
                }
                else if (side.Equals(CollisionSide.Left))
                {
                    isMovingRight = true;
                }
                SoundEffectFactory.Instance.PlayKick();
                CorrectPosition(side, player);
            }

            hitCount++;
            if (hitCount >= 1)
            {
                currentState = KoopaShellStates.Sliding;
                isKicked     = true;
            }
        }
Ejemplo n.º 4
0
 protected override void OnCollisionResponse(IPlayer mario, CollisionSide side)
 {
     if (side.Equals(CollisionSide.Top) && currentHealth == EnemyHealth.Normal)
     {
         Damage();
         SoundEffectFactory.Instance.PlayStomp();
     }
     else if (mario is Mario && ((Mario)mario).StarPowered && currentHealth == EnemyHealth.Normal)
     {
         ChangeState(EnemyState.Dead);
         SoundEffectFactory.Instance.PlayStomp();
         currentHealth = EnemyHealth.Flipped;
         Score.increaseScoreMario(200);
     }
 }
Ejemplo n.º 5
0
        protected override void OnCollisionResponse(IPlayer Mario, CollisionSide side)
        {
            if (this.currentState.Equals(BlockState.Idle) && side.Equals(CollisionSide.Bottom))
            {
                if (this.numItemsLeft == ONE)
                {
                    this.ChangeState();
                }
                else
                {
                    this.numItemsLeft--;
                }
                this.beingCollided = true;
                int curItem = items.Length - numItemsLeft;
                if (items != null && curItem >= ZERO && curItem < items.Length)
                {
                    //If the first item is grow mushroom, then the second item must be flower.
                    if (items[ZERO] is GrowMushroomItem)
                    {
                        if (((Mario)Mario).CurrentState == MarioStateMachine.MarioState.Small)
                        {
                            items[ZERO].Spawn();
                        }
                        else
                        {
                            items[ONE].Spawn();
                        }
                        this.numItemsLeft = ZERO;
                        this.ChangeState();
                    }
                    else
                    {
                        if (currentState != BlockState.Used)
                        {
                            this.currentState = BlockState.Bumped;
                            preBumpPos        = PosY;
                        }
                        items[curItem].Spawn();
                    }
                }

                if (this.items.Length == ZERO)
                {
                    if (((Mario)Mario).CurrentState == MarioStateMachine.MarioState.Big || ((Mario)Mario).CurrentState == MarioStateMachine.MarioState.Fire)
                    {
                        this.currentState = BlockState.Breaking;
                        SoundEffectFactory.Instance.PlayBrickBlock();
                        breakingBricks.Add(TileSpriteFactory.Instance.CreateSprite_BrickPieceLeft());
                        breakingBricks.Add(TileSpriteFactory.Instance.CreateSprite_BrickPieceRight());
                        breakingBricks.Add(TileSpriteFactory.Instance.CreateSprite_BrickPieceLeft());
                        breakingBricks.Add(TileSpriteFactory.Instance.CreateSprite_BrickPieceRight());
                        breakingBricks[ZERO].SetSpriteScreenPosition(this.Bounds.X, this.Bounds.Y);
                        positions.Add(new Vector2(this.Bounds.X, this.Bounds.Y));
                        breakingBricks[ONE].SetSpriteScreenPosition(this.Bounds.X + this.Bounds.Width, this.Bounds.Y);
                        positions.Add(new Vector2(this.Bounds.X + this.Bounds.Width, this.Bounds.Y));
                        breakingBricks[TWO].SetSpriteScreenPosition(this.Bounds.X, this.Bounds.Y + this.Bounds.Height);
                        positions.Add(new Vector2(this.Bounds.X, this.Bounds.Y + this.Bounds.Height));
                        breakingBricks[THREE].SetSpriteScreenPosition(this.Bounds.X + this.Bounds.Width, this.Bounds.Y + this.Bounds.Height);
                        positions.Add(new Vector2(this.Bounds.X + this.Bounds.Width, this.Bounds.Y + this.Bounds.Height));
                    }
                    else if (((Mario)Mario).CurrentState == MarioStateMachine.MarioState.Small)
                    {
                        SoundEffectFactory.Instance.PlayBump();
                        this.currentState = BlockState.Bumped;
                        preBumpPos        = PosY;
                    }
                }
            }
        }