Ejemplo n.º 1
0
    // --------------- CHUNK CREATION ---------------
    // --------------- CHUNK CREATION ---------------

    // --------------- NOISE DEBUGGING ---------------
    // --------------- NOISE DEBUGGING ---------------

    #region NOISE DEBUGGING

    private Texture2D MakeNoiseTexture(Vector2 worldPos, SpawnSettingType spawnType)
    {
        BiomeSetting biomeSettings = WorldSettings.GetSettingsByType(_biomeType);
        SpawnSetting noiseSettings = biomeSettings.GetSpawnSettingsByType(spawnType);

        Texture2D noiseTex = new Texture2D(noiseSettings.resolution, noiseSettings.resolution, TextureFormat.RGB24, true);

        noiseTex.wrapMode   = TextureWrapMode.Clamp;
        noiseTex.filterMode = FilterMode.Trilinear;
        noiseTex.anisoLevel = 9;
        Color[] pix          = new Color[noiseTex.width * noiseTex.height];
        float[] noiseSamples = GetNoiseSamples(worldPos, spawnType);

        for (int x = 0; x < noiseSettings.resolution; x++)
        {
            for (int y = 0; y < noiseSettings.resolution; y++)
            {
                float sample = noiseSamples[y * noiseSettings.resolution + x];
                pix[y * noiseSettings.resolution + x] = new Color(sample, sample, sample);
            }
        }

        noiseTex.SetPixels(pix);
        noiseTex.Apply();

        return(FlipTexture(noiseTex));
    }
Ejemplo n.º 2
0
    private IEnumerator AddFoliage(SpawnSettingType spawnType)
    {
        BiomeSetting biomeSettings = WorldSettings.GetSettingsByType(parent._biomeType);
        SpawnSetting spawnSettings = biomeSettings.GetSpawnSettingsByType(spawnType);

        float[] noiseSamples = parent.GetNoiseSamples(parent._worldPosition, spawnType);

        for (int x = 0; x < spawnSettings.resolution; x++)
        {
            for (int y = 0; y < spawnSettings.resolution; y++)
            {
                float sample = noiseSamples[y * spawnSettings.resolution + x];
                if (sample > 0.3f)
                {
                    int randomNumber = Random.Range(0, spawnSettings.spawnDensity + 1);
                    if (randomNumber == 1)
                    {
                        parent.SpawnObject(spawnType, new Vector2(x, y), spawnSettings.resolution);
                        if ((y * spawnSettings.resolution + x) % 20 == 0)
                        {
                            yield return(null);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    public float[] GetNoiseSamples(Vector2 worldPosition, SpawnSettingType spawnType)
    {
        BiomeSetting biomeSettings = WorldSettings.GetSettingsByType(_biomeType);
        SpawnSetting spawnSettings = biomeSettings.GetSpawnSettingsByType(spawnType);

        float[] noiseSamples = new float[spawnSettings.resolution * spawnSettings.resolution];
        float   frequency    = spawnSettings.frequency;
        float   resolution   = spawnSettings.resolution;

        float x = 0.0F;

        while (x < spawnSettings.resolution)
        {
            float y = 0.0F;
            while (y < spawnSettings.resolution)
            {
                float xCoord = (worldPosition.x) * frequency + x / resolution * frequency;
                float yCoord = (worldPosition.y) * frequency + y / resolution * frequency;
                noiseSamples[(int)(y * spawnSettings.resolution + x)] = Mathf.PerlinNoise(xCoord, yCoord);                 // TODO: Significantly faster -> Look at simplex for more performance and Voronoi for other effects
                y++;
            }
            x++;
        }

        return(noiseSamples);
    }
Ejemplo n.º 4
0
    public static int3 GetBottomBlock(int3 coord, int4 chunkPos)
    {
        int3 newCoord      = new int3(coord.x, coord.y - 1, coord.z);
        int  newBlockIndex = Utils.to1D(newCoord);

        if (coord.y == 0)
        {
            int4 newChunkPos        = new int4(chunkPos.x, chunkPos.y - 1, chunkPos.z, chunkPos.w);
            int3 newChunkCoord      = new int3(coord.x, Chunk.Height - 1, coord.z);
            int  newChunkBlockIndex = Utils.to1D(newChunkCoord);
            if (WorldSettings.Chunks.ContainsKey(newChunkPos))
            {
                return(WorldSettings.Chunks[newChunkPos].blocks[newChunkBlockIndex]);
            }
            else
            {
                return(WorldSettings.GetBlock(Utils.WorldBlockPosition(newChunkCoord, newChunkPos)));
            }
        }
        else
        {
            int3[] blocks = WorldSettings.Chunks[chunkPos].blocks;
            return(blocks[newBlockIndex]);
        }
    }
Ejemplo n.º 5
0
    void Start()
    {
        // set initial spawn loc
        WorldSettings.SetSpawnLocation(gameObject.transform.position);

        lastLegalPosition = transform.position;
        prevPos           = transform.position;


        noisePacks = new List <AudioClip[]>();
        noisePacks.Add(deathNoises);
        noisePacks.Add(attackNoises);
        noisePacks.Add(moveNoises);
        noisePacks.Add(damageNoises);
        noisePacks.Add(jumpNoises);
        noisePacks.Add(ropeStick);
        noisePacks.Add(ropeSound);
        noisePacks.Add(healthPickup);


        canPlay = new bool[noisePacks.Count];
        for (int i = 0; i < canPlay.Length; i++)
        {
            canPlay[i] = true;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        worldSettings = FindObjectOfType <WorldSettings>();
        controller    = GetComponent <CharacterController>();
        worldSettings = FindObjectOfType <WorldSettings>();
        anim          = GetComponent <Animator>();

        raycast = GetComponent <RaycastController>();
        if (raycast != null)
        {
            int inventoryLayerMask = 1 << LayerMask.NameToLayer("Enemy");
            raycast.AddLayerMask(inventoryLayerMask);
        }

        equipper         = GetComponent <ItemEquipper>();
        attack           = GetComponent <PlayerAttack>();
        treeController   = GetComponent <TreeController>();
        cameraAdjuster   = GetComponent <CameraAdjuster>();
        playerStatistics = GetComponent <PlayerStatistics>();
        itemCollector    = GetComponent <ItemCollector>();

        totalSwingTime = GetSwimgTimeByAnimator(anim);

        reticleMissColor = reticle.color;
    }
Ejemplo n.º 7
0
        private void LoadWorldandRender()
        {
            var ofd = new OpenFileDialog();

            ofd.Filter           = "Terrarial World File|*.wld|Terraria World Backup|*.bak|TEdit Backup File|*.TEdit";
            ofd.DefaultExt       = "Terrarial World File|*.wld";
            ofd.Title            = "Import Schematic File";
            ofd.InitialDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Terraria\Worlds");
            ofd.Multiselect      = false;
            if ((bool)ofd.ShowDialog())
            {
                if (!_texturesLoaded)
                {
                    WorldSettings.FindSteam();  // needs to be done with the current thread

                    Task.Factory
                    .StartNew(() => LoadWorld(ofd.FileName))
                    .ContinueWith(j => { _texturesLoaded = _renderer.LoadGameData(); })
                    .ContinueWith(k => RenderWorldTask())
                    .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);  // required to be non-async
                }
                else
                {
                    Task.Factory
                    .StartNew(() => LoadWorld(ofd.FileName))
                    .ContinueWith(k => RenderWorldTask())
                    .ContinueWith(l => RenderWorldFinish(l.Result), _uiScheduler);  // required to be non-async
                }
            }
        }
Ejemplo n.º 8
0
 void Start()
 {
     worldSettings = WorldSettings.Instance;
     System.Random random = new System.Random(DateTime.Now.Millisecond);
     worldSeed.text = random.Next(1, 99999999).ToString();
     SetupWorldTypeDropdown();
 }
Ejemplo n.º 9
0
    public void New(PlayerData data, WorldSettings settings)
    {
        manager.playerData    = data;
        manager.worldSettings = settings;

        StartCoroutine(manager.GoToScene(1));
    }
Ejemplo n.º 10
0
        public void Shutdown()
        {
            WorldSettings.Shutdown();
            WorldSettings = null;
            Camera        = null;

            foreach (IRenderer RenderAsset in Assets.Values)
            {
                RenderAsset.Shutdown();
            }

            foreach (SpatialGrid grid in navigationGrids)
            {
                grid?.Shutdown();
            }

            navigationGrids = null;
            translokatorGrid?.Shutdown();
            translokatorGrid = null;
            selectionBox.Shutdown();
            selectionBox = null;
            TranslationGizmo.Shutdown();
            TranslationGizmo = null;
            clouds.Shutdown();
            clouds = null;
            sky.Shutdown();
            sky    = null;
            Assets = null;
            D3D?.Shutdown();
            D3D = null;
        }
Ejemplo n.º 11
0
    void Awake()
    {
        // Singleton GameManager pattern.
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        // Set data manager references.
        ConnectionManager = this.gameObject.GetComponent <ConnectionManager> ();
        WorldSettings     = this.gameObject.GetComponent <WorldSettings> ();
        KeyManager        = this.gameObject.GetComponent <KeyManager> ();
        PlayerManager     = this.gameObject.GetComponent <PlayerManager> ();
        StatisticManager  = this.gameObject.GetComponent <StatisticManager> ();

        // Set program control manager references.
        GameController         = GameObject.Find("GameController").GetComponent <GameController> ();
        MsgBroadcastController = GameObject.Find("MsgBroadcastController").gameObject.GetComponent <MsgBroadcastController> ();
        WorldManager           = GameObject.Find("World").gameObject.GetComponent <WorldManager> ();
        MainMenuController     = GameObject.Find("UI").transform.Find("MainMenuCanvas").GetComponent <MainMenuController> ();
    }
Ejemplo n.º 12
0
    public static int3 GetBackBlock(int3 coord, int4 chunkPos)
    {
        int3 newCoord      = new int3(coord.x, coord.y, coord.z + 1);
        int  newBlockIndex = Utils.to1D(newCoord);

        if (coord.z == Chunk.Width - 1)
        {
            int4 newChunkPos        = new int4(chunkPos.x, chunkPos.y, chunkPos.z + 1, chunkPos.w);
            int3 newChunkCoord      = new int3(coord.x, coord.y, 0);
            int  newChunkBlockIndex = Utils.to1D(newChunkCoord);
            if (WorldSettings.Chunks.ContainsKey(newChunkPos))
            {
                return(WorldSettings.Chunks[newChunkPos].blocks[newChunkBlockIndex]);
            }
            else
            {
                return(WorldSettings.GetBlock(Utils.WorldBlockPosition(newChunkCoord, newChunkPos)));
            }
        }
        else
        {
            int3[] blocks = WorldSettings.Chunks[chunkPos].blocks;
            return(blocks[newBlockIndex]);
        }
    }
Ejemplo n.º 13
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var mcp = _container.Resolve <IMainCanvasProvider>();

            mcp.Register(MainCanvas);

            var wsp = _container.Resolve <IWorldSettingsProvider>();
            var ws  = new WorldSettings()
            {
                Size = new Vector2(400, 200)
            };

            wsp.Register(ws);

            Task.Run(() =>
            {
                var worldCenter        = new Transform();
                worldCenter.Position.X = ws.SizeDiv2.X;
                worldCenter.Position.Y = ws.SizeDiv2.Y;

                var rootComponent = new Component();
                rootComponent.Transform.Position.Set(ws.SizeDiv2);
                rootComponent.AppendBehavior(_container.Resolve <SimulatorRoot>());
                rootComponent.AppendBehavior(new FrameRenderer(ws.Size.X, ws.Size.Y, mcp));

                _runner = new Runner(_container.Resolve <IMainCanvasProvider>());
                _runner.Run(rootComponent);
            });
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Represents a form containing an editable world
        /// </summary>
        /// <param name="settings"> World settings </param>
        public FormWorld(WorldSettings settings, Form parent)
        {
            InitializeComponent();

            MdiParent = parent;

            history       = new WorldHistory();
            this.settings = settings;

            userProperties = new Dictionary <string, string>();

            InitWorld();

            scrollBarHorizontal.Scroll += scrollBarScroll;
            scrollBarVertical.Scroll   += scrollBarScroll;

            worldCanvas = new WorldCanvas(this)
            {
                ContextMenuStrip = settingsMenu
            };

            canvasPanel.Controls.Add(worldCanvas);

            worldCanvas.Dock = DockStyle.Fill;
        }
Ejemplo n.º 15
0
 public World(WorldSettings settings, Transform tileRoot)
 {
     instance      = this;
     this.settings = settings;
     this.tileRoot = tileRoot;
     Setup();
 }
Ejemplo n.º 16
0
        public void Update()
        {
            if (!World.Initialized || AIManager.IsBusy())
            {
                return;
            }

            WorldSettings wsettings         = ServerManager.WorldSettings;
            bool          toSpawnZombies    = wsettings.ZombiesEnabled && (TimeCycle.ShouldSpawnMonsters || wsettings.MonstersDayTime);
            int           monsterMultiplier = wsettings.MonstersDoubled ? 2 : 1;
            double        timeSinceStart    = Pipliz.Time.SecondsSinceStartDouble;

            var banners = BannerTracker.GetBanners();

            for (int i = 0; i < banners.Count; i++)
            {
                Banner banner = banners.GetValueAtIndex(i);

                if (banner == null || !banner.KeyLocation.IsValid)
                {
                    continue;
                }

                Colony colony = Colony.Get(banner.Owner);

                if (toSpawnZombies)
                {
                    float zombiesMax = GetMaxZombieCount(colony.FollowerCount) * monsterMultiplier;

                    if (zombiesMax > 0f)
                    {
                        if (MonsterTracker.MonstersPerPlayer(banner.Owner) < zombiesMax)
                        {
                            if (colony.InSiegeMode)
                            {
                                if (timeSinceStart - colony.LastSiegeModeSpawn < siegeModeCooldown)
                                {
                                    continue;
                                }
                                else
                                {
                                    colony.LastSiegeModeSpawn = timeSinceStart;
                                }
                            }

                            SpawnZombie(colony, banner, GetMosterType(colony.FollowerCount, zombiesMax));
                        }
                    }
                    else
                    {
                        colony.OnZombieSpawn(true);
                    }
                }
                else
                {
                    colony.OnZombieSpawn(true);
                }
            }
        }
Ejemplo n.º 17
0
        private void ImplementGeneralSettings(WorldSettings settings)
        {
            _tmpDir = settings.TmpDir;

            Directory.CreateDirectory(_tmpDir);

            InvokerInMainThread = settings.InvokerInMainThread;
        }
Ejemplo n.º 18
0
        public override void Step(float dt, WorldSettings settings, ProgressReporter reporter, CancellationTokenSource tokenSource)
        {
            base.Step(dt, settings, reporter, tokenSource);
            float dda = -Angle;

            da    += dda * dt;
            Angle += da * dt;
        }
Ejemplo n.º 19
0
 void btnOk_Click(object sender, EventArgs e)
 {
     settings = new WorldSettings()
     {
         WorldSize = new Size(worldWidth.Value, worldHeight.Value),
         TileSize  = new Size(tileWidth.Value, tileHeight.Value)
     };
 }
Ejemplo n.º 20
0
        private static TimelineLayer ProgressWorldBoard(TimelineLayer previousState, WorldSettings settings)
        {
            var newState = new TimelineLayer(settings.WorldBoardWidth, settings.WorldBoardHeight, previousState.Age + 1);



            return(newState);
        }
Ejemplo n.º 21
0
        public static void LoadWorld(string _path)
        {
            Debug.Print("Loading World...");
            try
            {
                if (!string.IsNullOrEmpty(_path))
                {
                    FileInfo _info = new FileInfo(_path);
                    if (_info.Exists)
                    {
                        if (!string.IsNullOrEmpty(_info.Extension) && _info.Extension.ToLower( ) == ".world")
                        {
                            try
                            {
        #if PIXEL_ENGINE
                                string _worldData = File.ReadAllText(_path);

                                WorldInfo _worldInfo = JsonConvert.DeserializeObject <WorldInfo>(_worldData);
                                LOADED_WORLD = _worldInfo.WORLD;

                                WORLD_SETTINGS = LOADED_WORLD.Settings;
                                WORLD_OBJECTS  = LOADED_WORLD.Objects;
        #endif

        #if PIXEL_EDITOR
                                //do editor load
        #endif
                            }
                            catch (JsonException _jsonEx)
                            {
                                throw _jsonEx;
                            }
                        }
                        else
                        {
                            throw new FileNotFoundException("Failed to load world.");
                        }
                    }
                    else
                    {
                        throw new FileNotFoundException("File '" + _path + "does not exist.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("World path is NULL or EMPTY");
                }
            }
            catch (Exception _nf)
            {
                Debug.Print(_nf.Message + ":" + _nf.StackTrace, DEBUG_LOG_TYPE.ERROR);
                throw _nf;
            }
            finally
            {
                Debug.Print("World Loaded - " + LOADED_WORLD.LocalPath);
            }
        }
Ejemplo n.º 22
0
    // Start is called before the first frame update
    void Start()
    {
        // get player object with not already set
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }

        nav         = GetComponent <NavMeshAgent>();
        playerStats = player.GetComponent <PlayerStatistics>();
        anim        = GetComponent <Animator>();
        if (anim == null)
        {
            anim = GetComponentInChildren <Animator>();
        }
        dropScript    = GetComponent <ItemSource>();
        worldSettings = FindObjectOfType <WorldSettings>();
        meshy         = GetComponentInChildren <SkinnedMeshRenderer>();

        patrolPoints = new Vector3[numPatrolPoints];

        if (!noPatrol)
        {
            for (int i = 0; i < patrolPoints.Length; i++)
            {
                float height = 0;
                // Ensures the height is appropriate so its not on top the mountain or in the water.
                while (!(height >= ySpawnMin && height <= ySpawnMax))
                {
                    // Makes random patrol point near enemy
                    patrolPoints[i] = new Vector3(Random.Range(-patrolRadius, patrolRadius) + transform.position.x, 0,
                                                  Random.Range(-patrolRadius, patrolRadius) + transform.position.y);

                    // Finds which terrain the point is on.
                    Terrain[] terrains    = Terrain.activeTerrains;
                    float     minDistance = float.MaxValue;
                    int       minIdx      = -1;
                    for (int j = 0; j < terrains.Length; j++)
                    {
                        float distance = Vector3.Distance(terrains[j].GetPosition(), patrolPoints[i]);
                        if (distance < minDistance)
                        {
                            minDistance = distance;
                            minIdx      = j;
                        }
                    }

                    // Finds height at point
                    Terrain terrain = Terrain.activeTerrains[minIdx];
                    height            = terrain.SampleHeight(patrolPoints[i]) + terrain.transform.position.y;
                    patrolPoints[i].y = height;
                }
            }
        }

        Initialize();
        elapsedTime = 0f;
    }
Ejemplo n.º 23
0
    void Start()
    {
        GameObject world_settings_object = GameObject.Find("WorldSettings");

        world_settings    = world_settings_object.GetComponent <WorldSettings>();
        build_window_rect = new Rect(Screen.width - 210, 10, 200, 400);
        SetBoxOptions();
        SetLabelOptions();
    }
Ejemplo n.º 24
0
 public ChunkData(WorldSettings settings, TimelineLayer worldBoard)
 {
     Id     = Guid.NewGuid();
     chunks = new Dictionary <Point, Chunk>();
     realityBubbleChunks = new Dictionary <Point, Chunk>();
     worldSettings       = settings;
     this.worldBoard     = worldBoard;
     initWorld();
 }
Ejemplo n.º 25
0
 public void UpdateWorld(WorldSettings settings)
 {
     // check if paused
     if (settings.paused != true)
     {
         // update chunks
         UpdateWorldChunks(settings.chunkSettings);
     }
 }
Ejemplo n.º 26
0
    // Start is called before the first frame update
    void Start()
    {
        worldSettings = FindObjectOfType <WorldSettings>();

        playerBody       = transform.parent.transform;
        worldSettings    = FindObjectOfType <WorldSettings>();
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
    }
Ejemplo n.º 27
0
        public override void WorldLoaded()
        {
            WorldSettings = UtilityWorldObjectManager.GetUtilityWorldObject <WorldSettings>();

            // Fix compatibilities with older saves
            UpdateLegacy.Update();

            VisibilityDesignator.PlanningVisibility = WorldSettings.PlanningVisibility;
            OpacityDesignator.Opacity = ModSettings.PlanOpacity;
        }
Ejemplo n.º 28
0
    public ClientWorld(WorldSettings worldSettings, ClientWorldSettings clientWorldSettings)
    {
        _worldSettings = worldSettings;
        _settings      = clientWorldSettings;

        _networkNode = new ClientNode(_worldSettings.commonNodeSettings, _settings.clientNodeSettings);

        _clientRoom = null;
        _avatar     = null;
    }
Ejemplo n.º 29
0
    public void ConfigureMercenarySettings()
    {
        WorldSettings ws   = WorldSettings.Instance;
        Difficulty    diff = ws.GetDifficulty();

        defaultSoldiers              = diff.aIParameters.startingUnitSize;
        soldierIncrease              = diff.aIParameters.extraUnitsForDefence + defaultSoldiers;
        timeBetweenAttacks           = diff.aIParameters.TimeBetweenAttacks;
        soldierIncreaseBetweenStages = diff.aIParameters.unitIncreaseBetweenTime;
    }
Ejemplo n.º 30
0
 public WorldSetupState(DwarfGame game, GameStateManager stateManager, WorldSettings settings) :
     base(game, "WorldSetupState", stateManager)
 {
     Settings      = settings;
     IsInitialized = false;
     if (settings == null)
     {
         Settings = new WorldSettings();
     }
 }
Ejemplo n.º 31
0
        public GlobalSettings(bool initializeDefaults = true)
        {
            World = new WorldSettings();
            Player = new PlayerSettings();
            Input = new InputSettings();
            Network = new NetworkSettings();
            Audio = new AudioSettings();

            if (initializeDefaults)
            {
                InitializeDefaults();
            }
        }
Ejemplo n.º 32
0
        private World()
        {
            Settings = new WorldSettings();
            EventPublisher = new Publisher();

            Map = Map.CreateMap();
            _miniMap = Map.CreateMiniMap(Map);

            _players = new Dictionary<string, Player>();
            _tribes = new Dictionary<string, Tribe>();
            _villages = new WorldVillagesCollection();

            Cache = new AutoCompleteCache();
            Views = new ViewsCollection();

            You = new Player();
        }
Ejemplo n.º 33
0
        private void LoadfilesBackground(System.Object sender, DoWorkEventArgs e)
        {
            string aerror = string.Empty;
            try {
                if (sender != null) {
                    BackgroundWorker worker = (BackgroundWorker)sender;
                    worker.DoWork -= LoadfilesBackground;
                }

                if (File.Exists(mPluginConfigfilename)) {
                    this.mPluginConfig = (PluginSettings)Util.DeSerializeObject(mPluginConfigfilename, typeof(PluginSettings));
                }

                //create default file
                if (mPluginConfig == null) {
                    mPluginConfig = new PluginSettings();
                    mPluginConfig.Shortcuts = new SDictionary<string, string>();
                    mPluginConfig.Shortcuts.Add("hr", "House Recall");
                    mPluginConfig.Shortcuts.Add("mr", "House Mansion_Recall");
                    mPluginConfig.Shortcuts.Add("ah", "Allegiance Hometown");
                    mPluginConfig.Shortcuts.Add("ls", "Lifestone");
                    mPluginConfig.Shortcuts.Add("mp", "Marketplace");
                    mPluginConfig.Alerts = getbaseAlerts();
                    mPluginConfig.AlertKeyMob = "Monster";
                    mPluginConfig.AlertKeyPortal = "Portal";
                    mPluginConfig.AlertKeySalvage = "Salvage";
                    mPluginConfig.AlertKeyScroll = "Salvage";
                    mPluginConfig.AlertKeyThropy = "Trophy";
                    mPluginConfig.Alertwawfinished = "finished.wav";
                }
                //HACK:  Still hating the sounds
            //				mplayer = new mediaplayer();
            //				mplayer.Volume = mPluginConfig.wavVolume;
                loadcolortable();

                //Check for Gamedata.xml
                if (!File.Exists(Util.docPath + "\\GameData.xml")) {
                    //Create it if !exists
                    iGameData.defaultfill();
                    Util.SerializeObject(Util.docPath + "\\GameData.xml", iGameData);
                }

                //Now that it exists, check version and update if needed
                if (File.Exists(Util.docPath + "\\GameData.xml")) {
                    iGameData = (AlincoVVS.PluginCore.GameData)Util.DeSerializeObject(Util.docPath + "\\GameData.xml", typeof(GameData));
                    //Look to code this for a single line revision of Gamedata version, currently must update in 2 locations
                    if (iGameData.version < 10) {
                        iGameData.defaultfill();
                        Util.SerializeObject(Util.docPath + "\\GameData.xml", iGameData);
                    }
                }

                mWorldConfigfilename = Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server);
                if (!Directory.Exists(mWorldConfigfilename)) {
                    Directory.CreateDirectory(mWorldConfigfilename);
                }

                mExportInventoryname = Util.docPath + "\\Inventory";
                if (!Directory.Exists(mExportInventoryname)) {
                    Directory.CreateDirectory(mExportInventoryname);
                    writebasexslt(mExportInventoryname + "\\Inventory.xslt");
                }

                mExportInventoryname += "\\" + Core.CharacterFilter.Server + ".xml";
                mWorldInventoryname = Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server) + "\\Inventory.xml";
                if (File.Exists(mWorldInventoryname)) {
                    object tobj = Util.DeSerializeObject(mWorldInventoryname, typeof(SDictionary<int, InventoryItem>));
                    if (tobj != null) {
                        mGlobalInventory = (global::AlincoVVS.PluginCore.SDictionary<int, global::AlincoVVS.PluginCore.InventoryItem>)tobj;
                        mStorageInfo = (global::AlincoVVS.PluginCore.SDictionary<int, string>)Util.DeSerializeObject(mWorldInventoryname + "storage", typeof(SDictionary<int, string>));
                    } else {
                        mGlobalInventory = new SDictionary<int, InventoryItem>();
                    }
                } else {
                    writebasexslt(Util.docPath + "\\" + Util.normalizePath(Core.CharacterFilter.Server) + "\\Inventory.xslt");
                }

                mCharConfigfilename = mWorldConfigfilename;
                mWorldConfigfilename += "\\Settings.xml";
                if (File.Exists(mWorldConfigfilename)) {
                    mWorldConfig = (WorldSettings)Util.DeSerializeObject(mWorldConfigfilename, typeof(WorldSettings));
                }

                mCharConfigfilename += "\\" + Util.normalizePath(Core.CharacterFilter.Name) + ".xml";
                if (File.Exists(mCharConfigfilename)) {
                    mCharconfig = (CharSettings)Util.DeSerializeObject(mCharConfigfilename, typeof(CharSettings));
                }

                if (mWorldConfig == null) {
                    mWorldConfig = new WorldSettings();
                }

                if (mCharconfig == null) {
                    mCharconfig = new CharSettings();
                }

                mProtectedCorpses.Add("Corpse of " + Core.CharacterFilter.Name);
                mFilesLoaded = true;

            } catch (Exception ex) {
                aerror = ex.Message + ex.StackTrace;
                Util.ErrorLogger(ex);
            }

            if (aerror != string.Empty) {
                Util.bcast(aerror);
            }
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Deserializes settings from specified location
 /// </summary>
 public static void LoadSettings(string directory)
 {
     try
     {
         Settings = (WorldSettings)SettingsBase.LoadFromPath(Settings, directory);
     }
     catch (Exception caught)
     {
         Log.Write(caught);
     }
 }
Ejemplo n.º 35
0
 public GameServerSettings()
 {
     World = new WorldSettings();
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Deserializes settings from default location
 /// </summary>
 public static void LoadSettings()
 {
     try
     {
         Settings = (WorldSettings)SettingsBase.Load(Settings);
     }
     catch (Exception caught)
     {
         Log.Write(caught);
     }
 }