private void RespondToCollisionWithMario(Side side, IMario mario, Rectangle intersectRect)
 {
     mario.OnTransPipe       = false;
     mario.TouchingTransPipe = false;
     if (this.Pipe is PipeTop)
     {
         PipeTop pipeTop = (PipeTop)this.Pipe;
         if (pipeTop.IsTransitional)
         {
             if (IsAbleToEnterPipe(side, pipeTop, intersectRect))
             {
                 mario.OnTransPipe = true;
             }
             else if ((SideGeneralizer.IsLeft(side) || SideGeneralizer.IsRight(side)) && pipeTop.Side)
             {
                 mario.TouchingTransPipe = true;
             }
         }
     }
 }
예제 #2
0
        public void SpawnPipe(Vector2 Position, String s, bool isTransitional)
        {
            IPipe p;

            switch (s[1])
            {
            case 'U':
                if (s[2] == 'B')
                {
                    p = new PipeBody(Position, isTransitional, false);
                }
                else
                {
                    p = new PipeTop(Position, isTransitional, false);
                }
                this.level.Pipes.Add(p);
                break;

            case 'S':
                if (s[2] == 'B')
                {
                    p = new PipeBody(Position, isTransitional, true);
                }
                else if (s[2] == 'T')
                {
                    p = new PipeTop(Position, isTransitional, true);
                }
                else if (s[2] == 'M')
                {
                    p = new PipeMerge(Position, isTransitional, true);
                }
                else
                {
                    p = new PipeMerge(Position, isTransitional, false);
                }
                this.level.Pipes.Add(p);
                break;
            }
        }
 private static bool IsAbleToEnterPipe(Side side, PipeTop pipeTop, Rectangle intersectRect)
 {
     return(SideGeneralizer.IsTop(side) && !pipeTop.Side &&
            (Math.Abs(intersectRect.Center.X - (pipeTop.CurrentPosition.X + pipeTop.Width / 2)) < Level1Config.MarioOnPipeCenterTolerance));
 }