예제 #1
0
    void Start()
    {
        width          = 32;
        height         = 32;
        player         = GameObject.Find("Player");
        this.pathLimit = 45;
        map            = new TileData[width, height];
        this.walkMap   = new bool[width, height];
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                map[i, j]     = new TileData();
                walkMap[i, j] = true;
            }
        }

        Debug.Log("Creating wolrd?");
        this.worldLoader = GetComponent <WorldLoader>();
        worldLoader.intializeWorldData(map, walkMap, width, height);
        worldLoader.loadWorld();

        this.heightMap = GameObject.Find("Terrain").GetComponent <TerrainGenerator>().getHeightMap();
        Debug.Log(this.heightMap[1, 1]);
        Debug.Log(this.heightMap.Length);
    }
예제 #2
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ExtractXmlModelLoader ext  = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");
            ModelLoaderData       data = ext.Load(factory, GraphicInfo, "leonScene");
            WorldLoader           wl   = new WorldLoader();

            wl.OnCreateIObject += new CreateIObject(wl_OnCreateIObject);
            wl.OnCreateILight  += new CreateILight(wl_OnCreateILight);
            wl.LoadWorld(factory, GraphicInfo, World, data);

            //IModelo model = new SimpleModel(factory, "Model/leonScene");
            //IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            //GhostObject po = new GhostObject();
            //IShader shader = new ForwardXNABasicShader();
            //ForwardMaterial dm = new ForwardMaterial(shader);
            //this.World.AddObject(new IObject(dm, model, po));

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);

            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker());
        }
예제 #3
0
    void Start()
    {
        world = new World(worldWidth);

        texture2d            = new Texture2D(worldWidth, worldWidth, TextureFormat.RGBA32, false, true);
        texture2d.filterMode = FilterMode.Point;

        GenerateEmptyWorld();
        GenerateHeightmap();

        texture2d.Apply();
        //heightmapMaterial.SetTexture("_MainTex", texture2d);

        PlaceCliffs(0);
        PlaceCliffs(1);
        PlaceCliffs(2);

        TrimCliffs(0);
        TrimCliffs(1);
        TrimCliffs(2);

        for (int i = 0; i < world.GetLevels(); i++)
        {
            FillLayerRandomOnFloor(i, World.Tile.Pfb_Flower, 0.1f, true);
            //FillLayerRandomOnFloor(i, World.Tile.Pfb_Entity_Slime, 0.02f, true);
        }

        WorldLoader.InstantiateWorld(world);
    }
예제 #4
0
        private static void PlayModeStarted()
        {
            var state = StatePreference.Value;

            if (state.LoadWorld)
            {
                var hasScene = !string.IsNullOrEmpty(state.MainScene);
                var hasZone  = !string.IsNullOrEmpty(state.StartZone);
                var hasSpawn = !string.IsNullOrEmpty(state.StartSpawn);

                if (!hasScene && hasZone)
                {
                    PlayModeFailed(_mainSceneNotSetError);
                }
                else if (hasScene && !hasZone)
                {
                    PlayModeFailed(_noZonesError);
                }
                else
                {
                    var game = hasScene && hasZone ? new GameSaveData {
                        MainScene = state.MainScene, StartingZone = state.StartZone, PlayerSpawn = hasSpawn ? new SpawnPoint {
                            Name = state.StartSpawn
                        } : SpawnPoint.Default
                    } : null;
                    var result = WorldLoader.Load(game, FilePreference.Value);

                    result.OnError = PlayModeFailed;
                }
            }
        }
예제 #5
0
 void CreateSystems()
 {
     addEntityProcessor(chunkMeshGenerator = new ChunkMeshGenerator(ChunkTextures));
     addEntityProcessor(worldLoader        = new WorldLoader(chunkMeshGenerator, 2, 2));
     addEntityProcessor(tileEntitySystem   = new TileEntitySystem());
     addEntityProcessor(world = new World(new SandboxGenerator()));
 }
예제 #6
0
        private static void Main(string[] args)
        {
            var worldLoader = new WorldLoader();
            var world       = worldLoader.Load <World.World>("resources/world.json");

            System.Console.WriteLine(world);
        }
예제 #7
0
        /// <summary>
        /// Called when an object is found
        ///Return the object, return null to not add this object
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="factory">The factory.</param>
        /// <param name="ginfo">The ginfo.</param>
        /// <param name="mi">The mi.</param>
        /// <returns></returns>
        IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi)
        {
            ///Do what default would do.
            IObject[] objs = WorldLoader.CreateOBJ(world, factory, ginfo, mi);
            ///Change object property here !!!
            foreach (var obj in objs)
            {
                DeferredCustomShader cd = (obj.Material.Shader as DeferredCustomShader); ///the world loader uses deferredCustomShader for all objects
                System.Diagnostics.Debug.Assert(cd != null);
                ///if the obj does not use specular map
                if (!cd.UseSpecular)
                {
                    ///set a constant specular for all the object
                    cd.SpecularIntensity = 0.3f;
                    cd.SpecularPower     = 150;
                }
            }

            ///If you want, create the object on your own, without using the World Loader,
            ///THIS IS WHAT WorldLoader.CreateOBJ DOES
            //IModelo model = new CustomModel(factory, mi.modelName, new BatchInformation[] { mi.batchInformation}, mi.difuse, mi.bump, mi.specular, mi.glow);
            //IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
            //IShader shader = new DeferredCustomShader(mi.HasTexture(TextureType.GLOW), mi.HasTexture(TextureType.BUMP), mi.HasTexture(TextureType.SPECULAR), mi.HasTexture(TextureType.PARALAX));
            //DeferredMaterial dm = new DeferredMaterial(shader);
            //return new IObject(dm, model, po);

            return(objs);
        }
예제 #8
0
        public bool TryLoadNewestWorld()
        {
            FileInfo fileInfo = (from wf in SavedWorldsDatabase.AllWorldFiles
                                 orderby wf.LastWriteTime descending
                                 select wf).FirstOrDefault <FileInfo>();

            if (fileInfo == null)
            {
                return(false);
            }

            SaveFileInfo saveFileInfo = new SaveFileInfo(fileInfo);

            if (VersionControl.BuildFromVersionString(saveFileInfo.GameVersion)
                != VersionControl.BuildFromVersionString(VersionControl.CurrentVersionFull))
            {
                return(false);
            }

            string fullName = fileInfo.FullName;

            WorldLoader.LoadWorldFromFile(fullName);

            if (!ModListsMatch(ScribeHeaderUtility.loadedModsList, (from mod in LoadedModManager.LoadedMods
                                                                    select mod.name).ToList()))
            {
                return(false);
            }

            return(true);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                {
                    ///Create the xml file model extractor
                    ///Loads a XML file that was export by our 3DS MAX plugin
                    ExtractXmlModelLoader ext = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");
                    this.AttachCleanUpAble(ext);
                    ///Extract all the XML info (Model,Cameras, ...)
                    ModelLoaderData data = ext.Load(factory, GraphicInfo, "ilha");
                    ///Create the WOrld Loader
                    ///Convert the ModelLoaderData in World Entities
                    WorldLoader wl = new WorldLoader(); ///all default
                    wl.LoadWorld(factory, GraphicInfo, World, data);
                }
            }

            {
                SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
                sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red, false), TextureType.DIFFUSE);
                DeferredNormalShader nd  = new DeferredNormalShader();
                IMaterial            m   = new DeferredMaterial(nd);
                SphereObject         pi2 = new SphereObject(new Vector3(100, 50, 0), 1, 10, 10, MaterialDescription.DefaultBepuMaterial());
                IObject o = new IObject(m, sm2, pi2);
                this.World.AddObject(o);

                sound2 = new ObjectFollower3DSound(factory, "Songs/pianosong", o);
                this.World.AddSoundEmitter(sound2, true);
            }

            lt = new LightThrowBepu(this.World, factory);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion


            CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo);
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
        }
예제 #10
0
        private void handleCreateInteriorBtn()
        {
            var interiorDimensions = new Point(20, 20);
            var player             = SimulationGame.Player;
            var currentWorldPart   = player.InteriorID == Interior.Outside ? (WorldPart)SimulationGame.World.GetFromRealPoint((int)player.Position.X, (int)player.Position.Y) : SimulationGame.World.InteriorManager.Get(player.InteriorID);
            var dialog             = new InputDialog("Interior Dimensions", JToken.FromObject(interiorDimensions, SerializationUtils.Serializer).ToString(Formatting.Indented));

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                interiorDimensions = SerializationUtils.Serializer.Deserialize <Point>(new JTokenReader(JToken.Parse(dialog.ResultText)));

                var newInterior = new Interior(interiorDimensions);

                newInterior.SetPersistent(true);

                for (int i = 0; i < interiorDimensions.X; i++)
                {
                    for (int j = 0; j < interiorDimensions.Y; j++)
                    {
                        newInterior.SetBlockType(i, j, 1);
                    }
                }

                var interiorWorldLink = new WorldLink(new WorldPosition(0, 0, newInterior.ID), player.Position.ToBlockPosition());

                newInterior.AddWorldLink(interiorWorldLink);

                WorldLoader.SaveInterior(newInterior);

                currentWorldPart.SetPersistent(true);
                currentWorldPart.AddWorldLink(interiorWorldLink.SwapFromTo());
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            var objContext  = new SingleUsageObjectContextAdapter(new DbContextFactory <HotelAdminContext>());
            var hotelRep    = new HotelRepository(objContext);
            var factTypeRep = new FactTypeRepository(objContext);
            var historyRep  = new DummyHistoryItemRepository();

            FactTypeService factTypeService = new FactTypeService(objContext, factTypeRep);
            HotelService    hotelService    = new HotelService(objContext, hotelRep, historyRep);

            if (args != null && args.Length > 0 && args[0] == "world")
            {
                int numberOfHotels = 100;
                if (args.Length > 1)
                {
                    if (!int.TryParse(args[1], out numberOfHotels))
                    {
                        numberOfHotels = 100; // Default to 100
                    }
                }
                WorldLoader.LoadWorld(hotelService, factTypeService, numberOfHotels);
                return;
            }

            Console.WriteLine("Usage: HotelAdmin.Loader.exe {{world}} [maxItems] ");
        }
예제 #12
0
 IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] oi)
 {
     foreach (var mi in oi)
     {
         mi.batchInformation.ModelLocalTransformation = mi.batchInformation.ModelLocalTransformation * Matrix.CreateScale(0.5f);
     }
     return(WorldLoader.CreateOBJ(world, factory, ginfo, oi));
 }
예제 #13
0
        private void handleRemoveInteriorBtn()
        {
            var confirmResult = System.Windows.Forms.MessageBox.Show("Are you sure to delete the interior?", "Confirm Delete!", System.Windows.Forms.MessageBoxButtons.YesNo);

            if (confirmResult == System.Windows.Forms.DialogResult.Yes)
            {
                Interior interior = SimulationGame.World.InteriorManager.Get(SimulationGame.Player.InteriorID);

                if (interior.WorldLinks == null || interior.WorldLinks.Count == 0)
                {
                    SimulationGame.Player.UpdatePosition(new WorldPosition(0, 0, Interior.Outside));
                }

                // Check if durable entities are inside besides player
                if (interior.ContainedObjects != null)
                {
                    foreach (var containedObject in interior.ContainedObjects)
                    {
                        if (containedObject is DurableEntity && containedObject is Player == false)
                        {
                            System.Windows.Forms.MessageBox.Show("Cannot delete interior because a durable entity is inside");
                            return;
                        }
                    }
                }

                // Delete all WorldLinks
                if (interior.WorldLinks != null)
                {
                    bool playerTeleported = false;

                    WorldLink[] wordLinks = new WorldLink[interior.WorldLinks.Count];
                    interior.WorldLinks.Values.CopyTo(wordLinks, 0);

                    foreach (var worldLink in wordLinks)
                    {
                        if (playerTeleported == false)
                        {
                            SimulationGame.Player.UpdatePosition(worldLink.ToRealWorldPositionTo());
                            playerTeleported = true;
                        }

                        try
                        {
                            SimulationGame.World.UpdateWorldLink(worldLink);
                        }
                        catch (Exception e)
                        {
                            System.Windows.Forms.MessageBox.Show("Couldn't delete WorldLink: " + e.Message);
                        }
                    }
                }

                // Unload and Erase File
                SimulationGame.World.InteriorManager.RemoveChunk(interior.ID);
                WorldLoader.EraseInterior(interior);
            }
        }
예제 #14
0
        private void DrawFilePicker(bool playing)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.PrefixLabel("Save File");

                if (playing)
                {
                    EditorGUILayout.SelectableLabel(WorldManager.Instance.SaveFilename, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.MinWidth(5));

                    if (GUILayout.Button(_saveButton.Content, GUILayout.MinWidth(20)))
                    {
                        WorldLoader.Save(WorldManager.Instance);
                    }
                }
                else
                {
                    EditorGUILayout.SelectableLabel(SceneLoader.FilePreference.Value, GUILayout.Height(EditorGUIUtility.singleLineHeight), GUILayout.MinWidth(5));

                    if (GUILayout.Button(_newButton.Content, GUILayout.MinWidth(20)))
                    {
                        var path = EditorUtility.SaveFilePanel("Create Save File", Application.persistentDataPath, "Editor Save", "mmk");

                        if (!string.IsNullOrEmpty(path))
                        {
                            File.WriteAllText(path, "{}");
                            SceneLoader.FilePreference.Value = path;

                            if (SceneLoader.ZoneTypePreference.Value == SceneLoader.LoadSavedZone)
                            {
                                SceneLoader.ZoneTypePreference.Value = SceneLoader.LoadActiveZone;
                            }
                        }
                    }

                    if (GUILayout.Button(_openButton.Content, GUILayout.MinWidth(20)))
                    {
                        var path = EditorUtility.OpenFilePanel("Open Save File", Application.persistentDataPath, "mmk");

                        if (!string.IsNullOrEmpty(path))
                        {
                            SceneLoader.FilePreference.Value = path;
                        }
                    }

                    if (GUILayout.Button(_clearButton.Content, GUILayout.MinWidth(20)))
                    {
                        SceneLoader.FilePreference.Value = "";

                        if (SceneLoader.ZoneTypePreference.Value == SceneLoader.LoadSavedZone)
                        {
                            SceneLoader.ZoneTypePreference.Value = SceneLoader.LoadActiveZone;
                        }
                    }
                }
            }
        }
예제 #15
0
// public
    public WorldScreen(Size size, LevelPlayer player, WorldLoader world) : base(size)
    {
        base.Initialize(new Point(), size);
        this.player          = player;
        this.levelIsComplete = false;
        this.world           = world;
        this.camera          = new Camera(new WorldBox(size), new WorldBox(size));
        this.createSubviews(new Point(), size);
        this.world.RegisterForUpdates(this);
    }
예제 #16
0
 public static void PreLoadTextureHook(On.RoomCamera.orig_PreLoadTexture orig, RoomCamera rCam, Room room, int camPos)
 {
     if (!ShouldScroll(room))
     {
         orig(rCam, room, camPos);
         return;
     }
     rCam.quenedTexture = WorldLoader.FindRoomFileDirectory(room.abstractRoom.name, true) + ".png";
     rCam.www           = new WWW(rCam.quenedTexture);
     orig(rCam, room, 0);
 }
예제 #17
0
 public void clientInitialize(Entity playerEntity)
 {
     wl                    = GetComponent <WorldLoader>();
     wl.world              = world;
     wl.player             = playerEntity;
     playerCommandExecutor = new CommandExecutor(playerEntity, world);
     AssignPlayer.Assign(playerEntity);
     playerEntity.initialize(world);
     world.loadedEntities.Add(playerEntity);
     UnityEngine.Debug.Log("client initialized");
 }
예제 #18
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     if (graphics.IsFullScreen)
     {
         Content.RootDirectory = "fullScreen";
     }
     Content.RootDirectory = "Content";
     WorldLoader           = new WorldLoader();
     BackgroundColor       = Color.CornflowerBlue;
     AchiTracker           = new AchievementTracker(this);
 }
예제 #19
0
        /// <summary>
        /// Initializes the application.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            bool FSEM = true;

            Graphics.SynchronizeWithVerticalRetrace = true;
            if (FSEM)
            {
                //Getting the maximum supported resolution.
                var maxResolution = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode;

                //Setting the game to start in full screen mode.
                Graphics.PreferredBackBufferWidth  = maxResolution.Width;
                Graphics.PreferredBackBufferHeight = maxResolution.Height;
                Graphics.ToggleFullScreen();
            }
            else
            {
                Graphics.PreferredBackBufferWidth  = 1224;
                Graphics.PreferredBackBufferHeight = 550;
            }
            Graphics.ApplyChanges();

            ((CustomManager)Manager).MainWindow = MainWindow;
            MainWindow.Alpha              = 0;
            MainWindow.StayOnBack         = true;
            MainWindow.CloseButtonVisible = false;

            StorageDevice.BeginShowSelector(result => { _storageDevice = StorageDevice.EndShowSelector(result); }, null);
            Persister.DepdencyInjection(_storageDevice);

            WorldLoader.SetInstance(new WorldLoader(this, Content));
            TransportFactory.SetInstance(new TransportFactory(Content));

            InitScreenManager();

            _music          = _backgroundMusic.CreateInstance();
            _music.IsLooped = true;
            _music.Play();


            // Toggles admin mode when 'Admin Please' is typed
            _AdminListener = new InputListener {
                // "Admin please"
                Keys = new[] {
                    Keys.A, Keys.D, Keys.M, Keys.I, Keys.N,
                    Keys.Space,
                    Keys.P, Keys.L, Keys.E, Keys.A, Keys.S, Keys.E
                },
                Callback = ChangeAdminMode
            };
        }
예제 #20
0
    void Start()
    {
        this.chunkMetaData.chunkSize     = 16;          //Hehe
        this.chunkMetaData.depth         = 4;
        this.chunkMetaData.textureLoader = new TextureLoader(this.chunkMetaData);



        this.playerPosition = new Vector3(0, 0, 0);
        this.loader         = new WorldLoader(new Vector3(0, 0, 0), this.landSize, this.cacheShiftSize, this.viewDistance);

        Noise.Seed(seed);
    }
예제 #21
0
        private void CreateNewWorld()
        {
            World world;

            var worldLoader = new WorldLoader();
            world = worldLoader.LoadWorld("Data.xlsx");

            var worldCreator = new WorldCreator();
            int worldId = worldCreator.CreateWorld(world);

            Console.WriteLine("Initializing season...");
            worldSimulator.SwitchDefaultWorld(worldId);
        }
예제 #22
0
        protected override void OnClosing(CancelEventArgs e)
        {
            Shader.DestroyAll();
            ModelManager.Cleanup();
            TextureManager.Destroy();

            if (World != null)
            {
                WorldLoader.SaveWorld(World);
            }

            base.OnClosing(e);
        }
예제 #23
0
        protected override Interior loadUnguarded(string key)
        {
            if (Thread.CurrentThread.ManagedThreadId == 1)
            {
                GameConsole.WriteLine("ChunkLoading", "Interior " + key + " loaded in main thread");
            }

            var interior = WorldLoader.LoadInterior(key);

            interior.Connected = true;

            return(interior);
        }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ExtractXmlModelLoader ext = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");
            ModelLoaderData data = ext.Load(factory, GraphicInfo, "techdemo");
            WorldLoader wl = new WorldLoader();
            wl.OnCreateIObject += new CreateIObject(wl_OnCreateIObject);
            wl.OnCreateILight += new CreateILight(wl_OnCreateILight);
            wl.LoadWorld(factory, GraphicInfo, World, data);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);
            {
                l = new DirectionalLightPE(new Vector3(0.2f, -1, 0.2f), Color.White);
                l.CastShadown = true;
                float lii = 0.6f;
                l.LightIntensity = lii;
                this.World.AddLight(l);
            }

            #region NormalLight
            //DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            //DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            //DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            //DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            //DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            //DirectionalLightPE ld6 = new DirectionalLightPE(Vector3.Up, Color.White);
            //float li = 0.5f;
            //ld1.LightIntensity = li;
            //ld2.LightIntensity = li;
            //ld3.LightIntensity = li;
            //ld4.LightIntensity = li;
            //ld5.LightIntensity = li;
            //ld6.LightIntensity = li;
            //this.World.AddLight(ld1);
            //this.World.AddLight(ld2);
            //this.World.AddLight(ld3);
            //this.World.AddLight(ld4);
            //this.World.AddLight(ld5);
            //this.World.AddLight(ld6);

            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.FarPlane = 1000;
            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());

        }
예제 #25
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ExtractXmlModelLoader ext  = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");
            ModelLoaderData       data = ext.Load(factory, GraphicInfo, "sponza");
            WorldLoader           wl   = new WorldLoader();

            wl.LoadWorld(factory, GraphicInfo, World, data);

            LightThrowBepu lt = new LightThrowBepu(this.World, factory);

            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.1f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);

            //ld1 = new DirectionalLightPE(new Vector3(0.2f, -1, 0.2f), Color.White);
            //ld1.CastShadown = true;
            //float li = 0.9f;
            //ld1.LightIntensity = li;
            //this.World.AddLight(ld1);

            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            //cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            /////Interpolator to change lightDirection
            //inter.Start(new Vector3(0, -1, 0), new Vector3(1, -1, 1), 3, true);

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker());
            this.RenderTechnic.AddPostEffect(new BloomPostEffect());
            //HdrPostEffect HdrPostEffect = new HdrPostEffect();
            //HdrPostEffect.bloomMultiplier = 0.3f;
            //this.RenderTechnic.AddPostEffect(HdrPostEffect);
        }
예제 #26
0
        protected override void Initialize()
        {
            Controllers = new Collection <IController>();
            WorldLoader.InitializeLists();
            GamePadController  gamepad  = new GamePadController(this);
            KeyboardController keyboard = new KeyboardController(this);

            keyboard.RegisterKeys(this);
            gamepad.RegisterButtons(this);
            Controllers.Add(gamepad);
            Controllers.Add(keyboard);
            Camera.SetViewportAndOrigin(GraphicsDevice.Viewport);
            base.Initialize();
        }
예제 #27
0
        protected override void OnClosing(CancelEventArgs e)
        {
            Shader.DestroyAll();
            ModelManager.Cleanup();
            TextureManager.Destroy();
            SoundEngine.Destroy();

            if (World is WorldClient wc)
            {
                WorldLoader.SaveWorld(wc);
            }

            base.OnClosing(e);
        }
예제 #28
0
        private WorldLoader makeWorld(List <ChallengeStats> blockStats, Size realityBubbleSize)
        {
            double worldHeight = 2000;
            double worldWidth  = 0;

            foreach (ChallengeStats stats in blockStats)
            {
                worldWidth += stats.Width;
            }
            Size        size        = new Size(worldWidth, worldHeight);;
            WorldLoader worldLoader = new WorldLoader(size, realityBubbleSize);
            double      blockX      = 0;
            Dictionary <int, WeaponStats> weaponsByLevel = new Dictionary <int, WeaponStats>();

            foreach (ChallengeStats stats in blockStats)
            {
                double      blockWidth  = stats.Width;
                int         numEnemies  = stats.NumEnemies;
                BasicWeapon basicWeapon = new BasicWeapon();

                int weaponLevel = (int)stats.EnemyWeaponLevel;
                if (!weaponsByLevel.ContainsKey(weaponLevel))
                {
                    weaponsByLevel[weaponLevel] = this.makeWeapon(weaponLevel);
                }
                WeaponStats weaponStats = weaponsByLevel[weaponLevel];

                for (int i = 0; i < stats.NumEnemies; i++)
                {
                    double enemyX            = this.randomGenerator.NextDouble() * blockWidth + blockX;
                    double enemyY            = this.randomGenerator.NextDouble() * worldHeight / 4;
                    int    enemyIntelligence = (int)stats.EnemyIntelligence;
                    enemyIntelligence = Math.Max(Math.Min(enemyIntelligence, 1), 0);
                    double enemyHitpoints = stats.EnemyHitpoints;

                    Enemy enemy = new Enemy(ImageLoader.loadImage("archer.png"),
                                            new Point(enemyX, enemyY),
                                            new GameRectangle(26, 41),
                                            new double[] { stats.EnemyAcceleration, 0 },
                                            stats.EnemyHitpoints,
                                            950,
                                            enemyIntelligence);
                    worldLoader.addItem(enemy);
                }

                blockX += blockWidth;
            }
            return(worldLoader);
        }
예제 #29
0
        protected override WorldGridChunk loadUnguarded(ulong key)
        {
            Point chunkPos = GeometryUtils.GetPointFromLong(key);

            if (Thread.CurrentThread.ManagedThreadId == 1)
            {
                GameConsole.WriteLine("ChunkLoading", chunkPos.X + "," + chunkPos.Y + " loaded in main thread");
            }

            var walkableGridChunkPosition = GeometryUtils.GetChunkPosition(chunkPos.X * WorldChunkPixelSize.X, chunkPos.Y * WorldChunkPixelSize.Y, WalkableGrid.WalkableGridPixelChunkSize.X, WalkableGrid.WalkableGridPixelChunkSize.Y);

            WalkableGrid.Get(GeometryUtils.ConvertPointToLong(walkableGridChunkPosition.X, walkableGridChunkPosition.Y));

            return(WorldLoader.LoadWorldGridChunk(chunkPos.X, chunkPos.Y));
        }
예제 #30
0
        public void Run()
        {
            Console.SetWindowSize(120, 60);
            Console.SetBufferSize(120, 600);

            var loader = new WorldLoader();
            world = loader.LoadWorld("Data.xlsx");

            var singleMatchTests = new SingleMatchTests(world);
            singleMatchTests.Perform();
            Console.ReadLine();

            var multipleMatchesTests = new MultipleMatchesTests(world);
            multipleMatchesTests.Perform(1000);
            Console.ReadLine();
        }
예제 #31
0
        public void LoadWorld(string saveName)
        {
            if (World != null)
            {
                return;
            }

            ParticleRenderer = new ParticleRenderer();
            SkyboxRenderer   = new SkyboxRenderer();

            World loadedWorld = WorldLoader.LoadWorld(saveName);

            if (loadedWorld == null)
            {
                Console.WriteLine("DEBUG: generating World");

                BlockPos playerPos = new BlockPos(MathUtil.NextFloat(-100, 100), 10, MathUtil.NextFloat(-100, 100));

                World = new World("MyWorld", "Tomlow's Fuckaround",
                                  SettingsManager.GetValue("worldseed").GetHashCode());

                Player = new EntityPlayerSP(World, playerPos.ToVec());

                World.AddEntity(Player);

                Player.SetItemStackInInventory(0, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockCraftingTable>())));
                Player.SetItemStackInInventory(1, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockFurnace>())));
                Player.SetItemStackInInventory(2, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockCobbleStone>())));
                Player.SetItemStackInInventory(3, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockPlanks>())));
                Player.SetItemStackInInventory(4, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockGlass>())));
                Player.SetItemStackInInventory(5, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockCraftingTable>())));
                Player.SetItemStackInInventory(6, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockSlab>())));
                Player.SetItemStackInInventory(7, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockLadder>())));
                Player.SetItemStackInInventory(8, new ItemStack(new ItemBlock(BlockRegistry.GetBlock <BlockTallGrass>())));
            }
            else
            {
                World = loadedWorld;
            }

            ResetMouse();

            MouseState state = OpenTK.Input.Mouse.GetState();

            _mouseLast = new Point(state.X, state.Y);
        }
예제 #32
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ExtractXmlModelLoader ext = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//");

            this.AttachCleanUpAble(ext);
            ModelLoaderData data = ext.Load(factory, GraphicInfo, "shadow");
            WorldLoader     wl   = new WorldLoader();

            wl.OnCreateIObject += new CreateIObject(wl_OnCreateIObject);
            wl.OnCreateILight  += new CreateILight(wl_OnCreateILight);
            wl.LoadWorld(factory, GraphicInfo, World, data);

            #region NormalLight
            {
                ld1             = new DirectionalLightPE(new Vector3(0.2f, -1, 0.2f), Color.White);
                ld1.CastShadown = false;
                float li = 0.9f;
                ld1.LightIntensity = li;
                this.World.AddLight(ld1);
            }

            {
                ld1             = new DirectionalLightPE(new Vector3(0.2f, -1, 0.2f), Color.Red);
                ld1.CastShadown = true;
                float li = 2.0f;
                ld1.LightIntensity = li;
                this.World.AddLight(ld1);
            }


            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

            ///Interpolator to change lightDirection
            inter.Start(new Vector3(0, -1, 0), new Vector3(1, -1, 1), 3, true);

            this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect());
        }
 void OnEnable()
 {
     loader = (WorldLoader) target;
 }