示例#1
0
        /// <summary>
        /// Initialize MapServer
        /// </summary>
        /// <param name="port">Port where the MapServer will run</param>
        /// <param name="connName">Connection string for connection</param>
        /// <param name="mapName">Name of the map</param>
        /// <param name="mapIndex">Index of the map</param>
        public void Init(int port, string connName, string mapName, int mapIndex)
        {
            MapName  = mapName;
            MapIndex = mapIndex;

            statisticsStopwatch = new Stopwatch();
            mobStopwatch        = new Stopwatch();

            statisticsStopwatch.Start();
            mobStopwatch.Start();

            statistics = Statistics.None;

            _netPeerConfig = new NetPeerConfiguration(connName);
            _netPeerConfig.SetMessageTypeEnabled(NetIncomingMessageType.ConnectionApproval, true);
            _netPeerConfig.PingInterval      = 3f;
            _netPeerConfig.ConnectionTimeout = 6.5f;
            //_netPeerConfig.SimulatedMinimumLatency = 0.1f;
            //_netPeerConfig.SimulatedRandomLatency = 0.01f;
            _netPeerConfig.Port = (int)port;

            NetServer = new NetServer(_netPeerConfig);
            Data      = new WorldDataHandler(ServerIndex);
            OutgoingMessageHandler = new OutgoingMessageHandler(NetServer, Data);
            IncomingMessageHandler = new IncomingMessageHandler(this);

            InitTeleporter(new Vector3(450, 0, 450), 2.5f, mapIndex == 0 ? 1 : 0);

            InitSpawners(mapsFolderPath);

            Console.WriteLine("Server UP");
            ServerUp = true;
        }
示例#2
0
    private void Awake()
    {
        button           = GetComponent <Button>();
        worldDataHandler = FindObjectOfType <WorldDataHandler>();

        UpdateState();
    }
示例#3
0
    private void Awake()
    {
        worldPath        = Application.persistentDataPath + "/worlds/";
        worldDataHandler = FindObjectOfType <WorldDataHandler>();

        if (worldDataHandler)
        {
            var worldData = worldDataHandler.LoadCurrentWorld();
            worldName   = worldData.name;
            seed        = worldData.seed;
            last_played = worldData.last_played;
        }
        else
        {
            Debug.Log("WARNING: No world saving");
            seed = FindObjectOfType <TerrainNoise>().seed;
        }
    }
示例#4
0
文件: GridCell.cs 项目: FeXyK/Authory
        public GridCell(int x, int y, int width, int height, WorldDataHandler data)
        {
            Data     = data;
            _next_id = 0;

            AllPlayerCount = 0;
            AllEntityCount = 0;

            PlayerCount = 0;
            EntityCount = 0;

            Area       = new Rectangle(x, y, width, height);
            Neighbours = new List <GridCell>();

            MobEntities = new ConcurrentDictionary <ushort, Entity>();
            PlayersById = new ConcurrentDictionary <ushort, PlayerEntity>(2, 1000);

            ResourceEntites = new ConcurrentDictionary <ushort, EntityBase>();
        }
示例#5
0
    private void Awake()
    {
        player               = FindObjectOfType <PlayerController>().transform;
        voxelMap             = FindObjectOfType <VoxelMap>();
        chunkSaveLoadManager = FindObjectOfType <ChunkSaveLoadManager>();
        worldManager         = FindObjectOfType <WorldManager>();
        terrainNoise         = FindObjectOfType <TerrainNoise>();
        worldDataHandler     = FindObjectOfType <WorldDataHandler>();

        isActive = false;

        debugInfo     = transform.GetChild(0);
        worldNameText = debugInfo.GetChild(0).GetComponent <TextMeshProUGUI>();
        worldSeedText = debugInfo.GetChild(1).GetComponent <TextMeshProUGUI>();
        gameModeText  = debugInfo.GetChild(2).GetComponent <TextMeshProUGUI>();
        playerPosText = debugInfo.GetChild(3).GetComponent <TextMeshProUGUI>();
        chunkPosText  = debugInfo.GetChild(4).GetComponent <TextMeshProUGUI>();
        regionPosText = debugInfo.GetChild(5).GetComponent <TextMeshProUGUI>();
        mousePosText  = debugInfo.GetChild(6).GetComponent <TextMeshProUGUI>();

        SetInfoState(isActive);
    }
示例#6
0
        public WorldDataHandler GetWorldHandling()
        {
            var ret = new WorldDataHandler();

            ItemGeneratorDictionary = new ItemGeneratorDictionary();
            RegisterItemGenerators(ItemGeneratorDictionary);


            var generator = new WorldGenerator(1337, 2, Engine);
            var provider  = new SerialWorldProvider();

            if (UseFileDataStore)
            {
                var entityHandler = new EntityHandler(this, Engine, _inventoryCache);
                var chunkHandler  = new ChunkHandler(this);
                //var triggerHandler = new TriggerHandler(this);

                chunkHandler.Init();
                entityHandler.Init();

                provider.AddChunkLoader(chunkHandler);
                provider.AddEntityLoader(entityHandler);
                //provider.AddTriggerLoader(triggerHandler);

                ret.WorldSaver = new WorldSaverWrapper(entityHandler, chunkHandler, null);
                _entityHandler = entityHandler;
            }
            else
            {
                ret.WorldSaver = new WorldSaverWrapper();
            }

            provider.AddChunkLoader(generator);
            provider.AddEntityLoader(generator);
            provider.AddTriggerLoader(generator);
            ret.WorldProvider = provider;

            return(ret);
        }
示例#7
0
 private void Awake()
 {
     chunkSaveLoadManager = FindObjectOfType <ChunkSaveLoadManager>();
     worldDataHandler     = FindObjectOfType <WorldDataHandler>();
 }
示例#8
0
 private void OnEnable()
 {
     worldDataHandler = FindObjectOfType <WorldDataHandler>();
     Setup();
 }
示例#9
0
 private void OnEnable()
 {
     worldDataHandler = FindObjectOfType <WorldDataHandler>();
     errorText.text   = "";
 }
示例#10
0
 private void Awake()
 {
     worldDataHandler = FindObjectOfType <WorldDataHandler>();
 }