示例#1
0
        public Simulation()
        {
            Config.Instance.Load(ConfigFile);

            var world = GameManager.Instance.World;

            world.GetWorldExtent(out _worldMins, out _worldMaxs);

            float lenX = _worldMins.x < 0 ? _worldMaxs.x + Math.Abs(_worldMins.x) : _worldMaxs.x - Math.Abs(_worldMins.x);
            float lenY = _worldMins.z < 0 ? _worldMaxs.z + Math.Abs(_worldMins.z) : _worldMaxs.x - Math.Abs(_worldMins.z);

            float squareKm       = (lenX / 1000.0f) * (lenY / 1000.0f);
            float populationSize = squareKm * Config.Instance.PopulationDensity;

            _maxZombies           = (int)Math.Floor(populationSize);
            _state.WalkSpeedScale = Config.Instance.WalkSpeedScale;

            MaxSpawnedZombies = MaxAliveZombies - Mathf.RoundToInt(MaxAliveZombies * Config.Instance.ReservedSpawns);

            Log.Out("Simulation File: {0}", SimulationFile);
            Log.Out("World X: {0}, World Y: {1} -- {2}, {3}", lenX, lenY, _worldMins, _worldMaxs);
            Log.Out("Day Time: {0}", DayTimeMin);
            Log.Out("Max Offline Zombies: {0}", _maxZombies);
            Log.Out("Max Spawned Zombies: {0}", MaxSpawnedZombies);

#if !DEBUG
            if (Config.Instance.EnableViewServer)
#endif
            {
                Log.Out("Starting server...");

                _server.OnClientConnected += new ViewServer.OnClientConnectedDelegate(OnClientConnected);
                _state.OnChange           += new State.OnChangeDelegate(OnStateChanged);

                if (_server.Start(Config.Instance.ViewServerPort))
                {
                    Log.Out("ViewServer running at port {0}", Config.Instance.ViewServerPort);
                }
            }

            _biomeData.Init();
            _pois.BuildCache();
            _worldZones.BuildZones(_worldMins, _worldMaxs);

            _worker.WorkerSupportsCancellation = true;
            _worker.DoWork += BackgroundUpdate;

            Log.Out("[WalkerSim] Initialized");
        }
示例#2
0
        public Simulation()
        {
            _config.Load(ConfigFile);

            var world = GameManager.Instance.World;

            world.GetWorldExtent(out _worldMins, out _worldMaxs);

            float lenX = _worldMins.x < 0 ? _worldMaxs.x + Math.Abs(_worldMins.x) : _worldMaxs.x - Math.Abs(_worldMins.x);
            float lenY = _worldMins.z < 0 ? _worldMaxs.z + Math.Abs(_worldMins.z) : _worldMaxs.x - Math.Abs(_worldMins.z);

            float squareKm       = (lenX / 1000.0f) * (lenY / 1000.0f);
            float populationSize = squareKm * _config.PopulationDensity;

            _maxZombies = (int)Math.Floor(populationSize);

            Log.Out("Simulation File: {0}", SimulationFile);
            Log.Out("World X: {0}, World Y: {1}, {2}, {3}", lenX, lenY, _worldMins, _worldMaxs);
            Log.Out("Day Time: {0}", DayTimeMin);
            Log.Out("Day Time Scale: {0}", DayTimeScale);
            Log.Out("Max Zombies: {0}", _maxZombies);

            if (_config.EnableViewServer)
            {
                Log.Out("Starting server...");
                if (_server.Start(_config.ViewServerPort))
                {
                    Log.Out("ViewServer running at port {0}", _config.ViewServerPort);
                }
            }

            _biomeData.Init();
            _pois.BuildCache();
            _worldZones.BuildZones(_worldMins, _worldMaxs, _config);

            _worker.WorkerSupportsCancellation = true;
            _worker.DoWork += BackgroundUpdate;

            Log.Out("[WalkerSim] Initialized");
        }