Exemplo n.º 1
0
        // Update is called once per frame
        private void Update()
        {
            if (isLocalPlayer)
            {
                // клиент: сообщаем на сервер положение кнопки
                var doFire = _input.Fire();
                if (doFire ^ _isFiring)
                {
                    CmdFire(doFire);
                }
            }

            if (isServer)
            {
                // сервер: стреляем
                if (_isFiring && _canFire)
                {
                    var projectile = _pool.Spawn();
                    projectile.Launch(ProjectileSpawn, gameObject);

                    // кулдаун
                    _canFire = false;
                    _delayedExecutor.Add(() => _canFire = true, Cooldown);
                }
            }
        }