Exemplo n.º 1
0
        public static World getInstance()
        {
            if (Instance == null)
            {
                Instance = new World();
            }

            return Instance;
        }
Exemplo n.º 2
0
        // Loading map with two player references:
        public void loadNewMap( ref AssistManager assistManager, ref AnimationManager animationManager, ref ArtManager artManager, ref DoorManager doorManager, ref Map currentMap, ref World world, ref Camera camera, ref Collision collision, ref TimerManager timerManager, ref NPCManager npcManager, ref Player player1, ref Player player2 )
        {
            // Start loadNewMap.

            // Getting the nextRoom/Map data then wiping it:
            string mapToLoad = world.nextMap;
            Vector2 nextRoomSize = world.nextRoomSize;
            Vector2 nextRoomStart = world.nextRoomStart;
            Vector2 exitPosition = world.nextExitPosition;
            bool localMultiplayer = Game1.Instance.LocalMultiplayer;
            world.resetNextMapData();

            // Resetting major classes:
            camera = new Camera();
            currentMap = new Map( );
            camera.resetSingletonData();
            collision = new Collision();

            player1.spriteAnimation.resetSingletonReferences(); // Reseting the draw variables (IE camera) for the player.
            if ( localMultiplayer )
            {
                player2.spriteAnimation.resetSingletonReferences();
            }

            animationManager = new AnimationManager( );
            artManager.tilesetList = new TilesetList();
            doorManager = new DoorManager();

            // Checking if we should initalize the asset manager with more than one player.
            if ( localMultiplayer )
            {
                assistManager = new AssistManager( ref player1, ref player2 );
            }
            else
            {
                assistManager = new AssistManager( ref player1 );
            }

            assistManager.initalizeSingletonData();
            npcManager = new NPCManager();

            // Reloading data:
            tmxLoading( ref mapToLoad, ref nextRoomSize, ref nextRoomStart, ref currentMap, ref camera, ref collision, ref assistManager, ref animationManager, ref doorManager, ref timerManager, ref npcManager, ref player1, ref player2 );
            artManager.tilesetList.loadAll( );

            // Reseting the starting position if need be:
            if ( exitPosition != Vector2.Zero )
            { // Start Exit Position if.

                // Adding the screenoffset to the position since it was not calculated when the exit position was read in.
                //player1.spriteAnimation.position = exitPosition + camera.screenOffset;
                player1.spriteAnimation.position = exitPosition;

                if ( localMultiplayer )
                {
                    //player2.spriteAnimation.position = exitPosition + camera.screenOffset;
                    player2.spriteAnimation.position = exitPosition;
                }

            } // Start Exit Position if.
            else
            { // Start exitPosition is zero else.

                player1.spriteAnimation.position = currentMap.playerOneStart;

                if ( localMultiplayer )
                {
                    player2.spriteAnimation.position = currentMap.playerTwoStart;
                }

            } // End exitPosition is zero else.
        }