Esempio n. 1
0
 private void Update()
 {
     if (!Server.getInstance().isStarted)
     {
         return;
     }
     CalculatePlayerMovement();
     CalculatePlayerDeathTime();
 }
Esempio n. 2
0
 private void CalculatePlayerMovement()
 {
     foreach (ClientData _client in Server.getInstance().clients.Values)
     {
         if (_client == null || !Server.getInstance().clientsTransform.ContainsKey(_client.ID))
         {
             continue;
         }
         MovementController.getInstance().UpdatePlayerPosition(_client);
     }
 }
Esempio n. 3
0
        public void SpawnPlayer(ClientData _client)
        {
            if (!_client.HasTeam())
            {
                return;
            }
            GameObject player = Instantiate(playerPrefab);

            player.name = _client.ID.ToString();
            Server.getInstance().clientsTransform.Add(_client.ID, player.transform);
            player.transform.position = _client.Team.spawn;
        }
Esempio n. 4
0
        private void Start()
        {
            ID = Utils.GetFreeID();
            Debug.Log("PrefabID: " + ID);
            Server.getInstance().netObjs.Add(ID, this);
            Position = transform.position;
            Rotation = transform.rotation.eulerAngles;

            if (!Server.getInstance().isStarted)
            {
                return;
            }
            PacketController.getInstance().SendNetworkObjectSpawn(this);
        }
Esempio n. 5
0
        private void CalculatePlayerDeathTime()
        {
            foreach (ClientData _client in Server.getInstance().clients.Values)
            {
                if (_client == null || !_client.IsDead)
                {
                    continue;
                }

                if (_client.DeathTime > 0)
                {
                    _client.DeathTime -= Time.deltaTime;
                }
                else
                {
                    Server.getInstance().clients[_client.Connection.RemoteEndPoint] =
                        new ClientData(_client.Connection, _client.ID);
                    SpawnPlayer(_client);
                    PacketController.getInstance().SendPlayerRespawn(_client);
                }
            }
        }
Esempio n. 6
0
 private void OnDestroy()
 {
     Server.getInstance().netObjs.Remove(ID);
     PacketController.getInstance().SendNetworkObjectDestroy(this);
 }