Exemple #1
0
        private void MakeGame()
        {
            var getfile = this.getfile;
            var gamedata = new GameDataCsv();
            var clientgame = w;
            ICurrentSeason currentseason = clientgame;
            gamedata.CurrentSeason = currentseason;
            var network = w;
            var mapstorage = clientgame;
            var config3d = new Config3d();
            var mapManipulator = new MapManipulator();
            var the3d = new The3d();
            the3d.d_GetFile = getfile;
            the3d.d_Config3d = config3d;
            the3d.d_ViewportSize = w;
            w.d_The3d = the3d;
            var localplayerposition = w;
            var physics = new CharacterPhysics();
            var internetgamefactory = this;
            ICompression compression = new CompressionGzip(); //IsSinglePlayer ? (ICompression)new CompressionGzip() : new CompressionGzip();
            network.d_Compression = compression;
            network.d_ResetMap = this;
            if (IsSinglePlayer)
            {
                var socket = new SocketDummy() { network = this.dummyNetwork };
                network.main = socket;
            }
            else
            {
                network.main = new SocketNet(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));
            }
            var terrainTextures = new TerrainTextures();
            terrainTextures.d_GetFile = getfile;
            terrainTextures.d_The3d = the3d;
            bool IsMono = Type.GetType("Mono.Runtime") != null;
            terrainTextures.d_TextureAtlasConverter = new TextureAtlasConverter();
            if (IsMono)
            {
                terrainTextures.d_TextureAtlasConverter.d_FastBitmapFactory = () => { return new FastBitmapDummy(); };
            }
            else
            {
                terrainTextures.d_TextureAtlasConverter.d_FastBitmapFactory = () => { return new FastBitmap(); };
            }
            terrainTextures.Start();
            w.d_TerrainTextures = terrainTextures;
            var blockrenderertorch = new BlockRendererTorch();
            blockrenderertorch.d_TerainRenderer = terrainTextures;
            blockrenderertorch.d_Data = gamedata;
            //InfiniteMapChunked map = new InfiniteMapChunked();// { generator = new WorldGeneratorDummy() };
            var map = w;
            var terrainchunktesselator = new TerrainChunkTesselator();
            terrainchunktesselator.d_Config3d = config3d;
            terrainchunktesselator.d_Data = gamedata;
            terrainchunktesselator.d_MapStorage = clientgame;
            terrainchunktesselator.d_MapStoragePortion = map;
            terrainchunktesselator.d_MapStorageLight = clientgame;
            w.d_TerrainChunkTesselator = terrainchunktesselator;
            var frustumculling = new FrustumCulling() { d_GetCameraMatrix = the3d };
            w.d_Batcher = new MeshBatcher() { d_FrustumCulling = frustumculling };
            w.d_FrustumCulling = frustumculling;
            w.BeforeRenderFrame += (a, b) => { frustumculling.CalcFrustumEquations(); };
            terrainchunktesselator.d_BlockRendererTorch = blockrenderertorch;
            terrainchunktesselator.d_TerrainTextures = terrainTextures;
            //w.d_Map = clientgame.mapforphysics;
            w.d_Physics = physics;
            w.d_Clients = clientgame;
            w.d_Data = gamedata;
            w.d_DataMonsters = new GameDataMonsters(getfile);
            w.d_GetFile = getfile;
            w.d_Config3d = config3d;
            w.d_MapManipulator = mapManipulator;
            w.PickDistance = 4.5f;
            var skysphere = new SkySphere();
            skysphere.d_MeshBatcher = new MeshBatcher() { d_FrustumCulling = new FrustumCullingDummy() };
            skysphere.d_LocalPlayerPosition = localplayerposition;
            skysphere.d_The3d = the3d;
            w.skysphere = skysphere;
            var textrenderer = new ManicDigger.Renderers.TextRenderer();
            w.d_TextRenderer = textrenderer;
            Inventory inventory = Inventory.Create();
            weapon = new WeaponBlockInfo() { d_Data = gamedata, d_Terrain = terrainTextures, d_Viewport = w, d_Map = clientgame, d_Shadows = w, d_Inventory = inventory, d_LocalPlayerPosition = w };
            w.d_Weapon = new WeaponRenderer() { d_Info = weapon, d_BlockRendererTorch = blockrenderertorch, d_LocalPlayerPosition = w };
            var playerrenderer = new CharacterRendererMonsterCode();
            playerrenderer.Load(new List<string>(MyStream.ReadAllLines(getfile.GetFile("player.mdc"))));
            w.d_CharacterRenderer = playerrenderer;
            particle = new ParticleEffectBlockBreak() { d_Data = gamedata, d_Map = clientgame, d_Terrain = terrainTextures };
            w.particleEffectBlockBreak = particle;
            w.ENABLE_FINITEINVENTORY = false;
            w.d_Shadows = w;
            clientgame.d_Data = gamedata;
            clientgame.d_CraftingTableTool = new CraftingTableTool() { d_Map = mapstorage };
            clientgame.d_Audio = audio;
            clientgame.d_RailMapUtil = new RailMapUtil() { d_Data = gamedata, d_MapStorage = clientgame };
            clientgame.d_MinecartRenderer = new MinecartRenderer() { d_GetFile = getfile, d_The3d = the3d };
            clientgame.d_TerrainTextures = terrainTextures;
            clientgame.d_GetFile = getfile;
            var craftingrecipes = new CraftingRecipes();
            craftingrecipes.data = gamedata;
            w.d_CraftingRecipes = craftingrecipes;
            network.d_CraftingRecipes = craftingrecipes;
            w.Reset(10 * 1000, 10 * 1000, 128);
            clientgame.d_Map = map;
            PlayerSkinDownloader playerskindownloader = new PlayerSkinDownloader();
            playerskindownloader.d_Exit = exit;
            playerskindownloader.d_The3d = the3d;
            playerskindownloader.skinserver = "http://fragmer.net/md/skins/";
            w.playerskindownloader = playerskindownloader;
            w.d_FpsHistoryGraphRenderer = new HudFpsHistoryGraphRenderer() { d_Draw = the3d, d_ViewportSize = w };
            w.d_Screenshot = new Screenshot() { d_GameWindow = maingamewindow };
            w.d_FrustumCulling = frustumculling;
            physics.d_Map = clientgame.mapforphysics;
            physics.d_Data = gamedata;
            audio.d_GetFile = getfile;
            audio.d_GameExit = exit;
            this.map = map;
            the3d.d_Terrain = terrainTextures;
            the3d.d_TextRenderer = textrenderer;
            w.d_CurrentShadows = this;
            var sunmoonrenderer = new SunMoonRenderer() { d_Draw2d = the3d, d_LocalPlayerPosition = w, d_GetFile = getfile, d_The3d = the3d };
            w.d_SunMoonRenderer = sunmoonrenderer;
            clientgame.d_SunMoonRenderer = sunmoonrenderer;
            this.heightmap = new InfiniteMapChunked2d() { d_Map = map };
            heightmap.Restart();
            network.d_Heightmap = heightmap;
            this.light = new InfiniteMapChunkedSimple() { d_Map = map };
            light.Restart();
            this.terrainchunktesselator = terrainchunktesselator;
            w.d_TerrainChunkTesselator = terrainchunktesselator;
            terrainchunktesselator.d_Shadows = w;
            if (fullshadows)
            {
                UseShadowsFull();
            }
            else
            {
                UseShadowsSimple();
            }
            w.d_HudChat = new ManicDigger.Gui.HudChat() { d_Draw2d = the3d, d_ViewportSize = w };

            var dataItems = new GameDataItemsBlocks() { d_Data = gamedata };
            var inventoryController = clientgame;
            var inventoryUtil = new InventoryUtil();
            var hudInventory = new HudInventory();
            hudInventory.dataItems = dataItems;
            hudInventory.inventory = inventory;
            hudInventory.inventoryUtil = inventoryUtil;
            hudInventory.controller = inventoryController;
            hudInventory.viewport_size = w;
            hudInventory.mouse_current = w;
            hudInventory.the3d = the3d;
            hudInventory.getfile = getfile;
            hudInventory.ActiveMaterial = w;
            hudInventory.viewport3d = w;
            w.d_Inventory = inventory;
            w.d_InventoryController = inventoryController;
            w.d_InventoryUtil = inventoryUtil;
            inventoryUtil.d_Inventory = inventory;
            inventoryUtil.d_Items = dataItems;

            clientgame.d_Inventory = inventory;
            w.d_HudInventory = hudInventory;
            if (Debugger.IsAttached)
            {
                new DependencyChecker(typeof(InjectAttribute)).CheckDependencies(
                    w, audio, gamedata, clientgame, network, mapstorage, getfile,
                    config3d, mapManipulator, w, the3d, exit,
                    localplayerposition, physics,
                    internetgamefactory, blockrenderertorch, playerrenderer,
                    map, terrainchunktesselator);
            }
        }
 private void MakeGame(bool singleplayer)
 {
     var gamedata = new GameDataTilesManicDigger();
     var clientgame = new GMFortressLogic();
     ICurrentSeason currentseason = clientgame;
     gamedata.CurrentSeason = currentseason;
     INetworkClientFortress network;
     if (singleplayer)
     {
         network = new NetworkClientDummyInfinite() { gameworld = clientgame };
         clientgame.Players[0] = new Player() { Name = "gamer1" };
     }
     else
     {
         network = new NetworkClientFortress();
     }
     var mapstorage = clientgame;
     var getfile = new GetFilePath(new[] { "mine", "minecraft" });
     var config3d = new Config3d();
     var mapManipulator = new MapManipulator();
     var terrainDrawer = new TerrainRenderer();
     var the3d = w;
     var exit = w;
     var localplayerposition = w;
     var worldfeatures = new WorldFeaturesDrawerDummy();
     var physics = new CharacterPhysics();
     var mapgenerator = new MapGeneratorPlain();
     var internetgamefactory = this;
     if (singleplayer)
     {
         var n = (NetworkClientDummyInfinite)network;
         n.players = clientgame;
         n.localplayerposition = localplayerposition;
     }
     else
     {
         var n = (NetworkClientFortress)network;
         n.Map = w;
         n.Clients = clientgame;
         n.Chatlines = w;
         n.Position = localplayerposition;
         n.ENABLE_FORTRESS = true;
         n.NetworkPacketReceived = clientgame;
     }
     terrainDrawer.the3d = the3d;
     terrainDrawer.getfile = getfile;
     terrainDrawer.config3d = config3d;
     terrainDrawer.mapstorage = clientgame;
     terrainDrawer.data = gamedata;
     terrainDrawer.exit = exit;
     terrainDrawer.localplayerposition = localplayerposition;
     terrainDrawer.worldfeatures = worldfeatures;
     terrainDrawer.OnCrash += (a, b) => { CrashReporter.Crash(b.exception); };
     var blockdrawertorch = new BlockDrawerTorch();
     blockdrawertorch.terraindrawer = terrainDrawer;
     blockdrawertorch.data = gamedata;
     var terrainChunkDrawer = new TerrainChunkRenderer();
     terrainChunkDrawer.config3d = config3d;
     terrainChunkDrawer.data = gamedata;
     terrainChunkDrawer.mapstorage = clientgame;
     terrainDrawer.terrainchunkdrawer = terrainChunkDrawer;
     terrainChunkDrawer.blockdrawertorch = blockdrawertorch;
     terrainChunkDrawer.terrainrenderer = terrainDrawer;
     mapManipulator.getfile = getfile;
     mapManipulator.mapgenerator = mapgenerator;
     w.map = clientgame.mapforphysics;
     w.physics = physics;
     w.clients = clientgame;
     w.network = network;
     w.data = gamedata;
     w.getfile = getfile;
     w.config3d = config3d;
     w.mapManipulator = mapManipulator;
     w.terrain = terrainDrawer;
     w.PickDistance = 4.5f;
     weapon = new WeaponBlockInfo() { data = gamedata, terrain = terrainDrawer, viewport = w, map = clientgame, shadows = shadowssimple };
     w.weapon = new WeaponRenderer() { info = weapon, blockdrawertorch = blockdrawertorch, playerpos = w };
     var playerdrawer = new CharacterRendererMonsterCode();
     playerdrawer.Load(new List<string>(File.ReadAllLines(getfile.GetFile("player.mdc"))));
     w.characterdrawer = playerdrawer;
     w.particleEffectBlockBreak = new ParticleEffectBlockBreak() { data = gamedata, map = clientgame, terrain = terrainDrawer };
     w.ENABLE_FINITEINVENTORY = false;
     clientgame.terrain = terrainDrawer;
     clientgame.viewport = w;
     clientgame.data = gamedata;
     clientgame.network = network;
     clientgame.craftingtabletool = new CraftingTableTool() { map = mapstorage };
     InfiniteMapChunked map = new InfiniteMapChunked() { generator = new WorldGeneratorDummy() };
     map.Reset(10 * 1000, 10 * 1000, 128);
     clientgame.map = map;
     terrainDrawer.ischunkready = map;
     w.game = clientgame;
     w.login = new LoginClientDummy();
     w.internetgamefactory = internetgamefactory;
     PlayerSkinDownloader playerskindownloader = new PlayerSkinDownloader();
     playerskindownloader.exit = w;
     playerskindownloader.the3d = the3d;
     playerskindownloader.skinserver = "http://fragmer.net/md/skins/";
     w.playerskindownloader = playerskindownloader;
     w.fpshistorygraphrenderer = new FpsHistoryGraphRenderer() { draw = w, viewportsize = w };
     physics.map = clientgame.mapforphysics;
     physics.data = gamedata;
     mapgenerator.data = gamedata;
     audio.getfile = getfile;
     audio.gameexit = w;
     this.clientgame = clientgame;
     this.map = map;
     w.currentshadows = this;
     shadowsfull = new Shadows() { data = gamedata, map = clientgame, terrain = terrainDrawer,
         localplayerposition = localplayerposition, config3d = config3d, ischunkready = map };
     shadowssimple = new ShadowsSimple() { data = gamedata, map = clientgame };
     if (fullshadows)
     {
         UseShadowsFull();
     }
     else
     {
         UseShadowsSimple();
     }
     if (Debugger.IsAttached)
     {
         new DependencyChecker(typeof(InjectAttribute)).CheckDependencies(
             w, audio, gamedata, clientgame, network, mapstorage, getfile,
             config3d, mapManipulator, terrainDrawer, the3d, exit,
             localplayerposition, worldfeatures, physics, mapgenerator,
             internetgamefactory, blockdrawertorch, playerdrawer,
             map, w.login, shadowsfull, shadowssimple, terrainChunkDrawer);
     }
 }
Exemple #3
0
        private void MakeGame(bool singleplayer)
        {
            var gamedata = new GameDataTilesMinecraft();

            INetworkClient network;
            if (singleplayer)
            {
                network = new NetworkClientDummy();
            }
            else
            {
                network = new NetworkClientMinecraft();
            }
            clientgame = new GameMinecraft();
            /* fix for crash */
            //w.fpshistorygraphrenderer = new FpsHistoryGraphRenderer() { draw = w, viewportsize = w };
            var mapstorage = clientgame;
            var getfile = new GetFilePath(new[] { "mine", "minecraft" });
            var config3d = new Config3d();
            var mapManipulator = new MapManipulator();
            var terrainDrawer = new TerrainRenderer();
            var the3d = w;
            var exit = w;
            var localplayerposition = w;
            var worldfeatures = new WorldFeaturesDrawer();
            var physics = new CharacterPhysics();
            var mapgenerator = new MapGeneratorPlain();
            var internetgamefactory = this;
            if (singleplayer)
            {
                var n = (NetworkClientDummy)network;
                n.player = localplayerposition;
                n.Gui = w;
                n.Map1 = w;
                n.Map = mapstorage;
                n.Data = gamedata;
                n.Gen = new fCraft.MapGenerator();
                n.Gen.data = gamedata;
                n.Gen.log = new fCraft.FLogDummy();
                n.Gen.map = new MyFCraftMap() { data = gamedata, map = mapstorage, mapManipulator = mapManipulator };
                n.Gen.rand = new GetRandomDummy();
                n.DEFAULTMAP = "mountains";
            }
            else
            {
                var n = (NetworkClientMinecraft)network;
                n.Map = w;
                n.Clients = clientgame;
                n.Chatlines = w;
                n.Position = localplayerposition;
                n.gameworld = new GameWorldTodoDummy();
            }
            terrainDrawer.the3d = the3d;
            terrainDrawer.getfile = getfile;
            terrainDrawer.config3d = config3d;
            terrainDrawer.mapstorage = clientgame;
            terrainDrawer.data = gamedata;
            terrainDrawer.exit = exit;
            terrainDrawer.localplayerposition = localplayerposition;
            terrainDrawer.worldfeatures = worldfeatures;
            terrainDrawer.OnCrash += (a, b) => { CrashReporter.Crash(b.exception); };
            var terrainChunkDrawer = new TerrainChunkRenderer();
            terrainChunkDrawer.config3d = config3d;
            terrainChunkDrawer.data = gamedata;
            terrainChunkDrawer.mapstorage = clientgame;
            terrainDrawer.terrainchunkdrawer = terrainChunkDrawer;
            terrainChunkDrawer.terrainrenderer = terrainDrawer;
            worldfeatures.getfile = getfile;
            worldfeatures.localplayerposition = localplayerposition;
            worldfeatures.mapstorage = mapstorage;
            worldfeatures.the3d = the3d;
            mapManipulator.getfile = getfile;
            mapManipulator.mapgenerator = mapgenerator;
            w.map = clientgame;
            w.physics = physics;
            w.clients = clientgame;
            w.network = network;
            w.data = gamedata;
            w.getfile = getfile;
            w.config3d = config3d;
            w.mapManipulator = mapManipulator;
            w.terrain = terrainDrawer;
            bool IsMono = Type.GetType("Mono.Runtime") != null;
            terrainDrawer.textureatlasconverter = new TextureAtlasConverter();
            if (IsMono)
            {
                terrainDrawer.textureatlasconverter.fastbitmapfactory = () => { return new FastBitmapDummy(); };
            }
            else
            {
                terrainDrawer.textureatlasconverter.fastbitmapfactory = () => { return new FastBitmap(); };
            }
            weapon = new WeaponBlockInfo() { data = gamedata, terrain = terrainDrawer, viewport = w, map = clientgame, shadows = shadowssimple };
            w.weapon = new WeaponRenderer() { info = weapon, playerpos = w }; //no torch in mine mode
            var playerdrawer = new CharacterRendererMonsterCode();
            playerdrawer.Load(new List<string>(File.ReadAllLines(getfile.GetFile("player.mdc"))));
            w.characterdrawer = playerdrawer;
            w.particleEffectBlockBreak = new ParticleEffectBlockBreak() {  d_Data = gamedata, d_Map = clientgame, d_Terrain = terrainDrawer, d_Shadows = shadowsfull};
            clientgame.terrain = terrainDrawer;
            clientgame.network = network;

            clientgame.viewport = w;
            clientgame.data = gamedata;
            w.game = clientgame;
            w.login = new LoginClientMinecraft();
            w.internetgamefactory = internetgamefactory;
            PlayerSkinDownloader playerskindownloader = new PlayerSkinDownloader();
            playerskindownloader.exit = w;
            playerskindownloader.the3d = the3d;
            playerskindownloader.skinserver = "http://minecraft.net/skin/";
            w.playerskindownloader = playerskindownloader;
            physics.map = clientgame;
            physics.data = gamedata;
            mapgenerator.data = gamedata;
            audio.getfile = getfile;
            audio.gameexit = w;
            shadowsfull = new Shadows()
            {
                data = gamedata,
                map = clientgame,
                terrain = terrainDrawer,
                localplayerposition = localplayerposition,
                config3d = config3d
            };
            shadowssimple = new ShadowsSimple() { data = gamedata, map = clientgame};
            UseShadowsSimple();
            w.currentshadows = this;

            var frustumculling = new FrustumCulling() { the3d = the3d };
            terrainDrawer.frustumculling = frustumculling;
            terrainDrawer.batcher = new MeshBatcher() { frustumculling = frustumculling };
            terrainDrawer.frustumculling = frustumculling;
            w.RenderFrame += (a, b) => { frustumculling.CalcFrustumEquations(); };
            var dirtychunks = new DirtyChunks() { mapstorage = clientgame };
            terrainDrawer.ischunkready = dirtychunks;
            terrainDrawer.ischunkready.frustum = frustumculling;
            terrainDrawer.ischunkready.Start();
            //clientgame.ischunkready = dirtychunks;

            if (Debugger.IsAttached)
            {
                new DependencyChecker(typeof(InjectAttribute)).CheckDependencies(
                    w, audio, gamedata, clientgame, network, mapstorage, getfile,
                    config3d, mapManipulator, terrainDrawer, the3d, exit,
                    localplayerposition, worldfeatures, physics, mapgenerator,
                    internetgamefactory, playerdrawer, mapManipulator,
                    w.login, shadowsfull, shadowssimple, terrainChunkDrawer);
            }
        }