コード例 #1
0
        public override int GetHashCode()
        {
            int hashCode = 0;

            unchecked {
                hashCode += 1000000007 * Scale1.GetHashCode();
                hashCode += 1000000009 * CameraHeight.GetHashCode();
                hashCode += 1000000021 * CameraAngle.GetHashCode();
                hashCode += 1000000033 * Background.GetHashCode();
                hashCode += 1000000087 * FogDistance.GetHashCode();
                hashCode += 1000000093 * MaxLightStrength.GetHashCode();
                hashCode += 1000000097 * Scale2.GetHashCode();
                hashCode += 1000000103 * ViewDistance.GetHashCode();
                if (Objects != null)
                {
                    hashCode += 1000000123 * Objects.GetHashCode();
                }
                if (Floors != null)
                {
                    hashCode += 1000000181 * Floors.GetHashCode();
                }
                if (ObjectInfos != null)
                {
                    hashCode += 1000000207 * ObjectInfos.GetHashCode();
                }
                if (Walls != null)
                {
                    hashCode += 1000000223 * Walls.GetHashCode();
                }
            }
            return(hashCode);
        }
コード例 #2
0
        internal static void Save()
        {
            try
            {
                SaveSetting("UserName", UserName);
                SaveSetting("Server", Server);
                SaveSetting("Port", Port.ToString());
                SaveSetting("LastWorld", LastWorld);
                SaveSetting("Mode", Mode.ToString());
                SaveSetting("Windowed", Windowed);
                SaveSetting("Maximized", Maximized);
                SaveSetting("InvertMouse", InvertMouse);
                SaveSetting("VSync", VSync);
                SaveSetting("Mipmapping", Mipmapping);
                SaveSetting("Fog", Fog);
                SaveSetting("LinearMagnificationFilter", LinearMagnificationFilter);
                SaveSetting("SmoothLighting", SmoothLighting);
                SaveSetting("MOTD", MOTD);
                SaveSetting("ViewDistance", ViewDistance.ToString());
                SaveSetting("SoundEnabled", SoundEnabled);
                SaveSetting("MusicEnabled", MusicEnabled);
                SaveSetting("CreativeMode", CreativeMode);

                _configXml.Save(_configFilePath);
            }
            catch (Exception ex)
            {
                throw new Exception("Error saving config: " + ex.Message);
            }
        }
コード例 #3
0
ファイル: Misc.cs プロジェクト: hexpoint/voxelgame
 //gm: putting this here for now for lack of a better place, steps cant be done in the ViewDistance property setter because it can get called before we have a GL context.
 //-this is only needed for dynamically changing the view distance after the game is already running
 internal static void ChangeViewDistance(ViewDistance vd)
 {
     Config.ViewDistance = vd;
     Config.Save();
     Settings.Game.CalculateProjectionMatrix();
     if (!Game.Player.EyesUnderWater)
     {
         SetFogParameters();                                          //only modify fog distance when players eyes arent under water, otherwise the fog will get updated when they surface
     }
 }
コード例 #4
0
ファイル: Config.cs プロジェクト: MagistrAVSH/voxelgame
        internal static void Load()
        {
            try
            {
                AppDirectory = new DirectoryInfo(Application.StartupPath);
                if (AppDirectory == null) throw new Exception(string.Format("Failed to retrieve app directory info for: {0}", Application.StartupPath));
                _configFilePath = Path.Combine(AppDirectory.FullName, "Config.xml"); //use Path.Combine to play nice with linux
                _configXml = new XmlDocument();

                if (File.Exists(_configFilePath)) //config file exists, load it
                {
                    _configXml.Load(_configFilePath);
                }
                else //no config file, use defaults
                {
                    _configXml.LoadXml("<?xml version=\"1.0\" ?>\n<Config />");
                }
                _configXml.Schemas.Add("", XmlReader.Create(new StringReader(Properties.Resources.Config)));
                _configXml.Validate(null);

                UserName = LoadSetting("UserName");
                Server = LoadSetting("Server");
                Port = LoadSetting("Port", Blox.Server.Controller.TCP_LISTENER_PORT);
                LastWorld = LoadSetting("LastWorld");

                ModeType modeType;
                Mode = Enum.TryParse(LoadSetting("Mode"), out modeType) ? modeType : ModeType.SinglePlayer; //if the enum value in the config file is invalid then default it without failing

                Windowed = LoadSetting("Windowed", true);
                Maximized = LoadSetting("Maximized", true);
                InvertMouse = LoadSetting("InvertMouse", false);
                VSync = LoadSetting("VSync", true);
                Mipmapping = LoadSetting("Mipmapping", true);
                Fog = LoadSetting("Fog", true);
                LinearMagnificationFilter = LoadSetting("LinearMagnificationFilter", false);
                SmoothLighting = LoadSetting("SmoothLighting", true);
                MOTD = LoadSetting("MOTD");

                ViewDistance vd;
                ViewDistance = Enum.TryParse(LoadSetting("ViewDistance"), out vd) ? vd : ViewDistance.Standard; //if the enum value in the config file is invalid then default it without failing

                SoundEnabled = LoadSetting("SoundEnabled", true);
                MusicEnabled = LoadSetting("MusicEnabled", true);
                CreativeMode = LoadSetting("CreativeMode", false);

                const string SAVE_FILE_FOLDER_NAME = "SaveFiles";
                SaveDirectory = new DirectoryInfo(Path.Combine(AppDirectory.FullName, SAVE_FILE_FOLDER_NAME));
                if (!SaveDirectory.Exists) SaveDirectory = AppDirectory.CreateSubdirectory(SAVE_FILE_FOLDER_NAME);

                //set version here so the game window has access to it and so the server also loads it when starting in a new process
                Settings.Version = new Version(Application.ProductVersion);
            }
            catch (Exception ex)
            {
                Utilities.Misc.MessageError(string.Format("Error loading config, if the problem persists, try removing your Config.xml file.\n\n{0}", ex.GetBaseException().Message));
                Application.Exit(); //weird things can happen if config doesnt load properly so just exit, the client gets a nice enough message that they should be able to figure out the problem
            }
        }