Exemple #1
0
 public void Execute()
 {
     teno.Jump();
 }
        public void TenoBlockCollide(Teno teno, Block block, List <Block> detroyedBlocks, List <Block> standingBlock)
        {
            Rectangle tenoRect     = teno.state.GetBoundingBox(teno.position);
            Rectangle blockRect    = block.GetBoundingBox();
            Rectangle intersection = Rectangle.Intersect(tenoRect, blockRect);

            if (intersection.Height > intersection.Width)
            {
                if (tenoRect.Right > blockRect.Left && tenoRect.Right < blockRect.Right)
                {
                    teno.position.X -= intersection.Width;
                }
                else
                {
                    teno.position.X += intersection.Width;
                }
            }
            else if (intersection.Height < intersection.Width)
            {
                if (tenoRect.Bottom > blockRect.Top && tenoRect.Bottom < blockRect.Bottom)
                {
                    if (!teno.isJumping)
                    {
                        teno.velocity.Y = 0;
                    }
                    if (intersection.Height > 1)
                    {
                        teno.position.Y -= intersection.Height;
                    }
                    if (!standingBlock.Contains(block))
                    {
                        standingBlock.Add(block);
                    }
                }
                else
                {
                    teno.position.Y += intersection.Height;
                    if (!game.isVVVVVV)
                    {
                        block.Reaction();
                        teno.physState = new FallingState(teno, game);
                        teno.tenoHight = 0;

                        /*if (block.state.GetType().Equals(new BrickBlockState().GetType()) && mario.isBig)
                         * {
                         *  block.Explode();
                         * }*/
                        if (block.state is TrampolineBlockState)
                        {
                            teno.Jump();
                        }

                        if (block.state is DamageBlockState)
                        {
                            teno.MakeDeadTeno();
                        }
                    }
                    //else
                    //standingBlock.Add(block);
                }
            }
        }