Ejemplo n.º 1
0
    //let the server run on fixed ticks
    void FixedUpdate()
    {
        bool reset = false;

        if (started)
        {
            foreach (ServerClient _client in Server.clients.Values)
            {
                if (_client.player != null)
                {
                    _client.player.UpdatePlayer();
                    if (!_client.player.status.alive)
                    {
                        _client.player = null;
                    }
                }
            }
            foreach (Projectile _projectile in Server.projectiles.Values)
            {
                _projectile.UpdateProjectile();
            }
            foreach (int i in destroyId)
            {
                //Debug.Log($"Destroying: {i}");
                Server.projectiles.Remove(i);
                reset = true;
            }
            Walls.UpdateWalls();
            BattleBus.UpdateBus();
        }
        else if (!Server.joinable)
        {
            foreach (ServerClient _client in Server.clients.Values)
            {
                if (_client.connected)
                {
                    //Debug.Log(_client.mousePosition);
                    ServerSend.SendMousePosition(_client.id, _client.mousePosition);
                }
            }
        }
        if (reset)
        {
            destroyId = new List <int>();
        }
        if (Input.GetKey(KeyCode.I))
        {
            serverLog.SetActive(true);
        }
        if (Input.GetKey(KeyCode.O))
        {
            serverLog.SetActive(false);
        }
    }
Ejemplo n.º 2
0
 public static void Reset()
 {
     Server.projectiles  = new Dictionary <int, Projectile>();
     Server.joinable     = true;
     ServerStart.started = false;
     Walls.Reset();
     BattleBus.Reset();
     ServerSend.Reset();
     foreach (ServerClient client in Server.clients.Values)
     {
         if (client.connected)
         {
             client.player = null;
         }
     }
 }