예제 #1
0
		public static void AddPipe(IPipe pipe)
		{
			foreach( var existingPipe in _pipeline )
			{
				if( existingPipe.GetType () == pipe.GetType () )
					return;
			}
			_pipeline.Add (pipe);
		}
예제 #2
0
        public static void AddPipe(IPipe pipe)
        {
            if (Pipeline.Any(existingPipe => existingPipe.GetType() == pipe.GetType()))
            {
                return;
            }

            Pipeline.Add(pipe);
        }
예제 #3
0
 public static void AddPipe(IPipe pipe)
 {
     foreach (var existingPipe in _pipeline)
     {
         if (existingPipe.GetType() == pipe.GetType())
         {
             return;
         }
     }
     _pipeline.Add(pipe);
 }
예제 #4
0
        public void HandleCollision(IObject mover, IObject target, Direction direction)
        {
            IMario mario = (IMario)mover;
            IPipe  pipe  = (IPipe)target;
            var    key   = (pipe.GetType(), pipe.Teleported, direction);

            if (handlerDictionary.ContainsKey(key))
            {
                handlerDictionary[key](mario, pipe, direction);
            }
        }
예제 #5
0
        public static void pipeCreator(IPipe displayPipe, IDictionary <Type, int> pipeDict, List <IPipe> pipes, int x, int y)
        {
            switch (pipeDict[displayPipe.GetType()])
            {
            case 0:
                pipes.Add(new SmallPipe(new Vector2(x, y), false, "", new Vector2(0, 0)));
                break;

            case 1:
                pipes.Add(new MediumPipe(new Vector2(x, y), false, "", new Vector2(0, 0)));
                break;

            case 2:
                pipes.Add(new LargePipe(new Vector2(x, y), false, "", new Vector2(0, 0)));
                break;
            }
        }
예제 #6
0
        public static void HandleCollision(IPlayer player, IPipe pipe, Game1.Side side)
        {
            int collisionFix = 3;

            if (side.Equals(Game1.Side.Left))
            {
                hasCollided = true;

                player.ManualMoveX(collisionFix);
                player.SetVelo(0);
            }
            else if (side.Equals(Game1.Side.Right))
            {
                hasCollided = true;
                player.SetVelo(0);

                if (pipe.GetType() == typeof(UndergroundSidePipe) && pipe.IsWarp() && player.GetDirection() == MarioDirection.RIGHT)
                {
                    if (!player.IsInSpecialAnimationState())
                    {
                        collisionFix = 0;
                        player.PipeRightAnimation();
                    }
                    else if (!player.HasFinishedSpecialAnimationState())
                    {
                        player.PipeRightAnimation();
                    }

                    if (player.HasFinishedSpecialAnimationState())
                    {
                        //Signal for mario to move down and then load new level
                        WorldManager.switchLevel        = true;
                        WorldManager.currentFilename    = pipe.GetFileName();
                        LevelManager.marioStartLocation = pipe.GetSpawnCoords();
                        WorldManager.marioStartLocation = pipe.GetSpawnCoords();
                    }
                }
                else
                {
                    player.ManualMoveX(-1 * collisionFix);
                }
            }

            else if (side.Equals(Game1.Side.Bottom))
            {
                if (player.GetVerticalVelocity() > 0)
                {
                    //player.ManualMoveY(-1 * player.GetVerticalVelocity());         //player.GetVerticalVelocity() * (-1.0));

                    int displacement = player.GetRectangle().Bottom - pipe.GetRectangle().Top;

                    if ((displacement) > 1)
                    {
                        player.ManualMoveY(-1 * displacement);
                    }
                }

                player.SetVerticalVelocity(0);

                if (pipe.GetType() == typeof(LargePipe) && pipe.IsWarp() && player.GetDirection() == MarioDirection.DOWN)
                {
                    if (!player.IsInSpecialAnimationState())
                    {
                        player.PipeDownAnimation();
                    }
                    else if (!player.HasFinishedSpecialAnimationState())
                    {
                        player.PipeDownAnimation();
                    }

                    if (player.HasFinishedSpecialAnimationState())
                    {
                        //Signal for mario to move down and then load new level
                        WorldManager.switchLevel        = true;
                        WorldManager.currentFilename    = pipe.GetFileName();
                        WorldManager.marioStartLocation = pipe.GetSpawnCoords();
                    }
                }
            }

            if (hasCollided)
            {
                player.LockMov();
            }
            else
            {
                player.UnlockMov();
            }
            hasCollided = false;
        }