Exemplo n.º 1
0
        private static UniTask <SkySphere> CreateSky(WorldLayer layer)
        {
            var sky = new SkySphere();

            sky.Shader = SkyShader.Instance;
            sky.Scale  = new Vector3(500f);
            return(sky.Activate(layer));
        }
Exemplo n.º 2
0
 private void DrawSkySphere()
 {
     if (skyspheretexture == -1)
     {
         skyspheretexture = LoadTexture(getfile.GetFile("skysphere.png"));
     }
     SkySphere skysphere = new SkySphere();
     ushort[] elements = skysphere.CalculateElements(1000, 1000, 20, 20);
     SkySphere.VertexP3N3T2[] vertices = skysphere.CalculateVertices(1000, 1000, 20, 20);
     GL.PushMatrix();
     GL.Translate(LocalPlayerPosition);
     GL.Color3(Color.White);
     GL.BindTexture(TextureTarget.Texture2D, skyspheretexture);
     GL.Begin(BeginMode.Triangles);
     for (int i = 0; i < elements.Length; i++)
     {
         var v = vertices[elements[i]];
         GL.TexCoord2(v.TexCoord);
         GL.Vertex3(v.Position);
     }
     GL.End();
     GL.PopMatrix();
     return;
 }
Exemplo n.º 3
0
        public void LoadLevel(string fileName)
        {
            // Set fade in effect
            GraphicEffect.FadeIn();
            CleanScene();
            var scenesToLoad = new Dictionary <string, bool>();

            string sceneFile = string.Empty;

            if (File.Exists(fileName))
            {
                sceneFile = fileName;
            }
            else if (File.Exists(Path.Combine(Application.StartupPath, fileName)))
            {
                sceneFile = Path.Combine(Application.StartupPath, fileName);
            }

            // First add scene file since we will generate mini map from it.
            scenesToLoad.Add(sceneFile, true);
            // Add global.xml if it exists.
            var globalScene = Path.Combine(new FileInfo(sceneFile).Directory.FullName, "global.xml");

            if (File.Exists(globalScene))
            {
                scenesToLoad.Add(globalScene, false);
            }

            foreach (var scene in scenesToLoad)
            {
                var xDoc = XDocument.Load(scene.Key);

                #region Mesh
                var meshQuery = from e in xDoc.Descendants("Objects")
                                from i in e.Descendants("Object")
                                where Helpers.GetBool(i.Element("IsAnimated").Value) == false
                                select new
                {
                    Name            = i.Element("Name").Value,
                    FileName        = i.Element("FileName").Value,
                    Visible         = Helpers.GetBool(i.Element("Visible").Value),
                    Position        = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation        = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale           = Helpers.GetVector3D(i.Element("Scale").Value),
                    Mass            = Helpers.GetFloat(i.Element("Mass").Value),
                    StaticFriction  = Helpers.GetFloat(i.Element("StaticFriction").Value),
                    KineticFriction = Helpers.GetFloat(i.Element("KineticFriction").Value),
                    Softness        = Helpers.GetFloat(i.Element("Softness").Value),
                    Bounciness      = Helpers.GetFloat(i.Element("Bounciness").Value),
                    Bounding        = Helpers.GetBoundingType(i.Element("Bounding").Value),
                    ScriptEnabled   = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script          = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters      = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in meshQuery)
                {
                    var entity = new Mesh(Core)
                    {
                        Name            = e.Name,
                        FileName        = e.FileName,
                        Visible         = e.Visible,
                        Position        = e.Position,
                        Rotation        = e.Rotation,
                        Scale           = e.Scale,
                        Mass            = e.Mass,
                        StaticFriction  = e.StaticFriction,
                        KineticFriction = e.KineticFriction,
                        Softness        = e.Softness,
                        Bounciness      = e.Bounciness,
                        Bounding        = e.Bounding,
                        ScriptEnabled   = e.ScriptEnabled,
                        Script          = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Mesh>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Trigger
                var triggerQuery = from e in xDoc.Descendants("Triggers")
                                   from i in e.Descendants("Trigger")
                                   select new
                {
                    Name          = i.Element("Name").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in triggerQuery)
                {
                    var entity = new Trigger(Core)
                    {
                        Name          = e.Name,
                        Position      = e.Position,
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        Color         = Globals.RGBA(e.Color.x / 255f, e.Color.y / 255f, e.Color.z / 255f, 1),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Trigger>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region DirectionalLight
                var directionalLightQuery = from e in xDoc.Descendants("Lights")
                                            from i in e.Descendants("Directional")
                                            where Helpers.GetBool(i.Element("Visible").Value) == true
                                            select new
                {
                    Name          = i.Element("Name").Value,
                    Direction     = Helpers.GetVector3D(i.Element("Direction").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in directionalLightQuery)
                {
                    var entity = new DirectionalLight(Core)
                    {
                        Name          = e.Name,
                        Direction     = e.Direction,
                        Color         = System.Drawing.Color.FromArgb((int)e.Color.x, (int)e.Color.y, (int)e.Color.z),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <DirectionalLight>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region PointLight
                var pointLightQuery = from e in xDoc.Descendants("Lights")
                                      from i in e.Descendants("Point")
                                      where Helpers.GetBool(i.Element("Visible").Value) == true
                                      select new
                {
                    Name          = i.Element("Name").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Radius        = Helpers.GetFloat(i.Element("Radius").Value),
                    Color         = Helpers.GetVector3D(i.Element("Color").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in pointLightQuery)
                {
                    var entity = new PointLight(Core)
                    {
                        Name          = e.Name,
                        Position      = e.Position,
                        Radius        = e.Radius,
                        Color         = System.Drawing.Color.FromArgb((int)e.Color.x, (int)e.Color.y, (int)e.Color.z),
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <PointLight>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Particle
                var particleQuery = from e in xDoc.Descendants("Particles")
                                    from i in e.Descendants("Particle")
                                    select new
                {
                    Name          = i.Element("Name").Value,
                    FileName      = i.Element("FileName").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    Visible       = Helpers.GetBool(i.Element("Visible").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in particleQuery)
                {
                    var entity = new Particle(Core)
                    {
                        Name          = e.Name,
                        FileName      = e.FileName,
                        Position      = e.Position,
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        Visible       = e.Visible,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Particle>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Sound
                var soundQuery = from e in xDoc.Descendants("Sounds")
                                 from i in e.Descendants("Sound")
                                 select new
                {
                    Name          = i.Element("Name").Value,
                    FileName      = i.Element("FileName").Value,
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Volume        = Helpers.GetFloat(i.Element("Volume").Value),
                    Stopped       = Helpers.GetBool(i.Element("Stopped").Value),
                    Loop          = Helpers.GetBool(i.Element("Loop").Value),
                    Is3D          = Helpers.GetBool(i.Element("Is3D").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in soundQuery)
                {
                    var entity = new Sound(Core)
                    {
                        Name          = e.Name,
                        FileName      = e.FileName,
                        Position      = e.Position,
                        Volume        = e.Volume * Helpers.GameSettings.FXVolume / 100f,
                        Stopped       = e.Stopped,
                        Loop          = e.Loop,
                        Is3D          = e.Is3D,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Sound>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region SkySphere
                var skySphereQuery = from e in xDoc.Descendants("Sky")
                                     from i in e.Descendants("SkySphere")
                                     select new
                {
                    Rotation      = Helpers.GetVector3D(i.Element("Rotation").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    PolyCount     = Helpers.GetInt(i.Element("PolyCount").Value),
                    FileName      = i.Element("Texture").Value,
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in skySphereQuery)
                {
                    var entity = new SkySphere(Core)
                    {
                        Rotation      = e.Rotation,
                        Scale         = e.Scale,
                        PolyCount     = e.PolyCount,
                        FileName      = e.FileName,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <SkySphere>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region SkyBox
                var skyBoxQuery = from e in xDoc.Descendants("Sky")
                                  from i in e.Descendants("SkyBox")
                                  select new
                {
                    FrontTexture  = i.Element("FrontTexture").Value,
                    BackTexture   = i.Element("BackTexture").Value,
                    LeftTexture   = i.Element("LeftTexture").Value,
                    RightTexture  = i.Element("RightTexture").Value,
                    TopTexture    = i.Element("TopTexture").Value,
                    BottomTexture = i.Element("BottomTexture").Value,
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in skyBoxQuery)
                {
                    var entity = new SkyBox(Core)
                    {
                        FrontTexture  = e.FrontTexture,
                        BackTexture   = e.BackTexture,
                        LeftTexture   = e.LeftTexture,
                        RightTexture  = e.RightTexture,
                        TopTexture    = e.TopTexture,
                        BottomTexture = e.BottomTexture,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <SkyBox>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                #region Water
                var waterQuery = from e in xDoc.Descendants("WaterPlanes")
                                 from i in e.Descendants("Water")
                                 select new
                {
                    Position      = Helpers.GetVector3D(i.Element("Position").Value),
                    Scale         = Helpers.GetVector3D(i.Element("Scale").Value),
                    ScriptEnabled = Helpers.GetBool(i.Descendants("CustomScript").Select(p => p.Element("Enabled")).FirstOrDefault().Value),
                    Script        = i.Descendants("CustomScript").Select(p => p.Element("Script")).FirstOrDefault().Value,
                    Parameters    = i.Descendants("CustomParameters").Descendants("Parameter").ToList()
                };

                foreach (var e in waterQuery)
                {
                    var entity = new Water(Core)
                    {
                        Position      = e.Position,
                        Scale         = e.Scale,
                        ScriptEnabled = e.ScriptEnabled,
                        Script        = e.Script
                    };

                    SetCustomParameters(entity, e.Parameters);

                    Core.LoadComponent <Water>(entity);
                    gameObjects.Add(entity);
                }
                #endregion

                // Generate minimap for scene file (not global).
                if (scene.Value == true)
                {
                    var fi        = new FileInfo(scene.Key);
                    var imageFile = Path.Combine(fi.DirectoryName, fi.Name.Replace(fi.Extension, ".png"));
                    //if (!File.Exists(imageFile))
                    {
                        var minimap = Helpers.CreateMinimap(gameObjects);
                        minimap.Save(imageFile, ImageFormat.Png);
                        minimap.Dispose();
                    }
                }

                // Get some information about the scene.
                skySphereExist = gameObjects.FindAll(o => o.GetType().Equals(typeof(SkySphere))).Count > 0;
                skyBoxExist    = gameObjects.FindAll(o => o.GetType().Equals(typeof(SkyBox))).Count > 0;
                waterExists    = Helpers.GetGameObjects <Water>(gameObjects).Count > 0;
            }
        }
Exemplo n.º 4
0
 public void SetSkySphere(SkySphere sky)
 {
     SkySphere = sky;
 }
Exemplo n.º 5
0
 public void SetSkySphere(string texture)
 {
     SkySphere = new SkySphere(@"models\skySphere", texture, this, Vector3.Zero);
 }
Exemplo n.º 6
0
        protected override bool setup()
        {
            #region setup world
            // scene light
            Vector3 lightDir = new Vector3(1f, -1f, 1f);
            light = new DirectionalLight(lightDir.Normalized(), new Vector3(1, 1, 1));
            AddLight(light);

            // shadow material (unused)
            //ShadowMaterial = new ShadowMaterial();
            //if (!ShadowMaterial.Ready) return false;

            // create skysphere
            skySphere = new SkySphere(2000f, 2);
            if (!skySphere.Ready)
            {
                return(false);
            }
            AddNode(skySphere);

            // load level file
            Data = new LevelFile(Config.DATA_FOLDER + "maps/level0-" + levelNumber + ".dat");
            if (!Data.Ready)
            {
                return(false);
            }

            Name = Data.Name;

            // load level atlas texture file
            int atlasNumber = levelNumber;
            if (levelNumber == 7)
            {
                atlasNumber = 1;                   // original game has this hardcoded too
            }
            Atlas = new AtlasMaterial("images/level0-" + atlasNumber + ".png", false);
            if (!Atlas.Ready)
            {
                return(false);
            }

            // create terrain
            Terrain = new LevelTerrain("Terrain Level " + levelNumber, Data, Atlas);
            if (!Terrain.Ready)
            {
                return(false);
            }
            AddNode(Terrain);

            // player (camera controller really)
            Camera = new CameraController(new Vector3(6f, Terrain.Size.Y + 6f, 6f), new Vector3(10f, Terrain.Size.Y + 5f, 10f));

            // create building node and add columns
            Buildings = new SceneNode();
            AddNode(Buildings);

            columnsByPosition = new Dictionary <int, Column>();

            foreach (var columnPosPair in Data.Columns)
            {
                addColumn(columnPosPair.Value, columnPosPair.Key);
            }

            // create entities and link columns with their morph source
            createEntities();
            #endregion

            #region temporary

            /*
             * mouseLine = new Line(Vector3.Zero, Vector3.UnitZ, new Vector4(1, 1, 1, 1));
             * AddNode(mouseLine);
             *
             */

            /*
             * Craft craft = new Craft("JET0-0", box.Position);
             * AddNode(craft);
             */

            // level bounds rectangle

            /*
             * Line line;
             * line = new Line(new Vector3(0f, Terrain.Size.Y, 0f), new Vector3(256f, Terrain.Size.Y, 0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f));
             * if (!line.Ready) return false;
             * line.Extend(new Vector3(256f, Terrain.Size.Y, 160f)).Extend(new Vector3(0f, Terrain.Size.Y, 160f)).Extend(line.A);
             * AddNode(line);
             */
            #endregion

            #region helpers
            // X / Y / Z
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(20f, 0f, 0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)));
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(0f, 20f, 0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)));
            AddNode(new Line(new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 20f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)));

            // setup collision helper for superfast Hi-Octane world box collisions
            Collisions = new LevelCollision(this, Data);
            #endregion
            return(true);
        }
Exemplo n.º 7
0
 private void Start()
 {
     skySphere = GetComponent <SkySphere>();
     time      = skySphere.currentTime;
 }
Exemplo n.º 8
0
        public void Initialize()
        {
            if(LowSky)
            {
                skySphere = new SkySphere(game.Content, graphicsDevice, game.Content.Load<TextureCube>("textures//Skybox//skybox"));
            }
            else
            {
                GameTime gt = new GameTime();
                sky = new SkyDomeSystem(game, camera, gt, graphicsDevice);
                Theta = sky.Theta = 2.4f;
                Gr = sky.Gr;
                sky.Parameters.NumSamples = 10;
                TIME = random.Next(5, 10); // 510

                sky.prevWeather = SkyDomeSystem.Weather.Clear;
                sky.WeatherChange(ref sky.prevWeather);
                weather = SkyDomeSystem.Weather.Clear;
                sky.WeatherChange(ref weather);
            }
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        GameObject s = new GameObject();

        sky = s.AddComponent <SkySphere>();
    }