public void Connect()
        {
            try
            {
                DisposeWorkersAndTimer();

                ControlWorker = WorkerFactory.CreateControlWorker();
                ControlWorker.Disconnected += ControlSocketOnDisconnected;

                CommandWorker = WorkerFactory.CreateCommandWorker();

                NavDataWorker = WorkerFactory.CreateNavDataWorker();
                NavDataWorker.NavDataReceived += NavDataWorkerOnNavDataReceived;

                ControlWorker.Run();
                CommandWorker.Run();

                CommandTimer = TimerFactory.CreateTimer();

                NavDataWorker.Run();

                QueueInitialCommands();

                Connected = true;
            }
            catch
            {
                Disconnect();
                throw;
            }
        }
Exemple #2
0
        public void CreateCommandTimer_ReturnsTimer()
        {
            // Arrange

            // Act
            var result = _target.CreateTimer();

            // Assert
            result.Should().BeOfType <Timer>();
            result.Dispose();
        }
    protected override void Awake()
    {
        this.isPersistent = false;
        base.Awake();

        mainCamera = Camera.main;

        this.timer               = TimerFactory.CreateTimer(TimerType.Seconds, 0.01f);
        this.timer.TickEvent    += (float obj) => { ShakeRandom(); };
        this.timer.ElapsedEvent += ReturnPosition;
        this.oldPos              = this.mainCamera.transform.localPosition;
    }
Exemple #4
0
        public GamePlayer AddPlayer <GamePlayer>(GamePlayer player) where GamePlayer : Engine.GamePlayer
        {
            if (!_playerIds.Contains(player.Id))
            {
                _playerIds.Add(player.Id);
                player.IsSpectator      = false; //Default them to being in game except in exigent circumstances (e.g. they chose to spectate)
                player.Game             = this;
                player.AllowedTankTypes = Gamemode.GetPlayerAllowedTankTypes(player);
                _playersById.Add(player.Id, player);
            }

            if (Authoritative)
            {
                if (Running && !Gamemode.HotJoinEnabled)
                {
                    player.IsSpectator = true; //Force spectator
                }
                else if (Running && Gamemode.HotJoinCanPlayerJoin(player))
                {
                    player.IsSpectator = false;
                    //Let them join - first find the team and size the player list correctly
                    player.Team = Gamemode.HotJoinGetPlayerTeam(player);
                    var newPlayerArray = new Engine.GamePlayer[player.Team.Players.Length + 1];
                    Array.Copy(player.Team.Players, newPlayerArray, player.Team.Players.Length);
                    newPlayerArray[newPlayerArray.Length - 1] = player;
                    player.Team.Players = newPlayerArray;

                    //Then tanks
                    player.AllowedTankTypes = Gamemode.HotJoinGetAllowedTankTypes(player);

                    //And add a timeout for them
                    TimerFactory.CreateTimer(a =>
                    {
                        if (player.HasTank || player.HasSelectedTankYet)
                        {
                            return;
                        }
                        _hotJoinPlayersWaitingForTankSelection.Remove(player);
                        SetupPlayer(player);
                    }, Settings.HotJoinTankSelectionTime);

                    _hotJoinPlayersWaitingForTankSelection.Add(player);
                }
            }
            return(player);
        }
Exemple #5
0
    public Selector(Transform target, float step = 1.0f, float downClamp = 120.0f, float upClamp = 240.0f)
    {
        this.Target    = target;
        this.Step      = step;
        this.DownClamp = downClamp;
        this.UpClamp   = upClamp;

        this.timer = TimerFactory.CreateTimer(TimerType.EndOfFrame);

        this.timer.ElapsedEvent += MakeStep;
        this.timer.ElapsedEvent += Loop;

        this.triggerEnter         = this.Target.gameObject.GetBehaviour <OnTriggerEnterMessage>();
        this.triggerEnter.action += CollisionEventHandler;

        this.triggerExit         = this.Target.gameObject.GetBehaviour <OnTriggerExitMessage>();
        this.triggerExit.action += OnTriggerExitEventHandler;
    }
Exemple #6
0
 /// <summary>
 /// Perform Run actions
 /// </summary>
 protected override void PerformRun()
 {
     // Play sound
     this.timer = timerFactory.CreateTimer(this.Duration, this.TimerCompleted, false, this.Scene);
 }
 /// <summary>
 /// Creates timer
 /// </summary>
 /// <param name="timeSpan">Time span</param>
 /// <returns>The timer</returns>
 public static ITimer CreateTimer(this TimeSpan timeSpan)
 {
     return(TimerFactory.CreateTimer(timeSpan));
 }
Exemple #8
0
 void InternalInitializationOfVariables()
 {
     this.deathTimer = TimerFactory.CreateTimer(TimerType.Seconds);
     this.deathTimer.ElapsedEvent += Destroy;
 }