Ejemplo n.º 1
0
        public void RemovePlayer(Guid id)
        {
            PlayerHandler player = Players[id];

            UsernameDatabase.Save(player.username, player);
            ChunkManager.Get.RemovePlayer(player);

            Destroy(player.gameObject);
            Players.Remove(id);
        }
Ejemplo n.º 2
0
        private void OnApplicationQuit()
        {
            foreach (var player in Players.Values)
            {
                UsernameDatabase.Save(player.username, player);
            }
            UsernameDatabase.Save();

            GameData data = new GameData();

            data.ServerTick = ServerTick;
            GameData.Save(data);
        }
Ejemplo n.º 3
0
        private void Awake()
        {
            if (Get != this)
            {
                Debug.Log("Instance already exists, destroying object!");
                Destroy(this);
                return;
            }
            UsernameDatabase.Load();

            GameData data = GameData.Load();

            ServerTick = data.ServerTick;
        }
Ejemplo n.º 4
0
        public void AddPlayer(Guid id, PlayerHandler player)
        {
            Players.Add(id, player);
            ChunkManager.Get.AddPlayer(player);
            var data = UsernameDatabase.Load(player.username, id);

            if (data != null)
            {
                player.inventory          = data.Inventory;
                player.transform.position = data.Pos + new Vector3(0, 0.5f, 0);
                player.transform.rotation = data.Rot;
            }
            else
            {
                player.transform.position = World.Get.GenerateSpawnPoint(id);
            }

            InventoryManager.Get.AddInventory(player);
            Debug.Log("Added Player at Position: " + player.transform.position);
        }