コード例 #1
0
ファイル: InventoryHandler.cs プロジェクト: VRUN-Game/VRUN
 /// <summary>
 /// Funktion, leert das Inventar und setzt den Timer zurück.
 /// </summary>
 private void GameResetInventory()
 {
     RemoveItem();
     _activeItemName   = ItemType.None;
     _timer            = null;
     _previousTimerVal = 0;
 }
コード例 #2
0
        private void RetryConnect()
        {
            // Unless we're ssl only, try toggling between ws & wss
            if (!this.encrypted)
            {
#if !SILVERLIGHT
                // not supported by silverlight
                this.ToggleSecure();
#endif
            }

            // Retry with increasing delay, with a maximum interval of 10s
            var retry_delay = Math.Min(this.retry_counter * 1000, 10000);
            Pusher.Log("Pusher : Retrying connection in " + retry_delay + "ms");

            int interval = Pusher.connection_timeout + (this.retry_counter * 1000);
            var timerRef = new TimerRef();
            timerRef.Ref = new Timer(delegate(object state)
            {
                this.Connect();

                try { timerRef.Ref.Dispose(); }
                catch { }
            }, timerRef, retry_delay, retry_delay);

            this.retry_counter = this.retry_counter + 1;
        }
コード例 #3
0
        public void Connect()
        {
            string url;

            if (this.encrypted || this.secure)
            {
                url = "wss://" + Pusher.host + ":" + Pusher.wss_port + this.path;
            }
            else
            {
                url = "ws://" + Pusher.host + ":" + Pusher.ws_port + this.path;
            }

            Pusher.allow_reconnect = true;
            Pusher.Log("Pusher : connecting : " + url);

            var self = this;

            IWebSocket ws = CreateWebSocket(url);

            // Timeout for the connection to handle silently hanging connections
            // Increase the timeout after each retry in case of extreme latencies
            int interval = Pusher.connection_timeout + (this.retry_counter * 1000);

            var timerRef = new TimerRef();

            timerRef.Ref = new Timer(delegate(object state)
            {
                Pusher.Log("Pusher : connection timeout after " + interval + "ms");
                ws.Close();
                try { timerRef.Ref.Dispose(); }
                catch { }
            }, null, interval, interval);

            ws.OnData  += (sender, e) => OnMessage(e);
            ws.OnClose += (sender, e) =>
            {
                try { timerRef.Ref.Dispose(); }
                catch { }
                OnClose();
            };
            ws.OnOpen += (sender, e) =>
            {
                try { timerRef.Ref.Dispose(); }
                catch { }
                OnOpen();
            };

            this.connection = ws;

            ws.Open();
        }
コード例 #4
0
ファイル: InventoryHandler.cs プロジェクト: VRUN-Game/VRUN
    /// <summary>
    /// Funktion, wird von Unity jeden Frame nach dem Auufruf aller Update Methoden aufgerufen.
    /// </summary>
    private void LateUpdate()
    {
        EventManager.UpdateTimerDisplay();
        if (_timer != null)
        {
            if (GlobalDataHandler.GetGameModus())
            {
                if (!_timer.ElapsedCountdownTimer() || _activeItemName.Equals(ItemType.None))
                {
                    return;
                }
                if (_timer.ElapsedCountdownTimer())
                {
                    _timer = null;
                }
            }
            else
            {
                _timer = null;
            }
        }
        else
        {
            _previousTimerVal = TimerInitVal;
        }

        // Wird ausgeführt wenn der Timer des aktuellen Items ausgelaufen ist
        // Dabei werden alle Änderungen die durch die Items ausgelöst wurden zurückgeführt
        if ((_activeItemName.Equals(ItemType.Faster) || _activeItemName.Equals(ItemType.Slower)) && GlobalDataHandler.GetRunMode() != RunMode.Idle)
        {
            GlobalDataHandler.SetRunMode(RunMode.Normal);
        }
        else if (GlobalDataHandler.IsMultiplierActive())
        {
            GlobalDataHandler.SetMultiplierActive(!GlobalDataHandler.IsMultiplierActive());
        }

        _activeItemName = ItemType.None;
    }
コード例 #5
0
ファイル: InventoryHandler.cs プロジェクト: VRUN-Game/VRUN
    /// <summary>
    /// Funktion, aktiviert ein Item, welches sich im Inventar befindet. Falls kein Item im Inventar ist, passiert nichts.
    /// </summary>
    private void ActivateItem()
    {
        // Unterbreche die Funktion im Fehlerfall, dass sie aufgerufen wurde obwohl kein Item
        // eingesammelt wurde.
        if (_item == null || !_activeItemName.Equals(ItemType.None))
        {
            return;
        }

        /* Timer setzen */
        // Wenn der Timer bereits aktiv ist prüfen ob gleiches Item auch in der _itemBag vorhanden ist.
        if (_timer != null)
        {
            if (!_timer.ElapsedCountdownTimer() && _item.GetComponent <ControllerItem>().ItemType.Equals(_activeItemName))
            {
                _timer = new TimerRef(_timer.GetTime() + TimerDuration);
            }
        }
        else
        // Erstelle einen neuen Timer wenn noch kein Item aktiv ist.
        {
            _timer = new TimerRef(5);
        }

        // Item aktivieren
        if (_item.GetComponent <ControllerItem>().ItemType.Equals(ItemType.ScoreMultiplier))
        {
            GlobalDataHandler.SetMultiplierActive(!GlobalDataHandler.IsMultiplierActive());
        }
        else
        {
            GlobalDataHandler.SetRunMode((_item.GetComponent <ControllerItem>().ItemType.Equals(ItemType.Faster))
                ? RunMode.Faster
                : RunMode.Slower);
        }

        _activeItemName = _item.GetComponent <ControllerItem>().ItemType;
        RemoveItem();
    }
コード例 #6
0
        private void RetryConnect()
        {
            // Unless we're ssl only, try toggling between ws & wss
            if (!this.encrypted)
            {
            #if !SILVERLIGHT
                // not supported by silverlight
                this.ToggleSecure();
            #endif
            }

            // Retry with increasing delay, with a maximum interval of 10s
            var retry_delay = Math.Min(this.retry_counter * 1000, 10000);
            Pusher.Log("Pusher : Retrying connection in " + retry_delay + "ms");

            int interval = Pusher.connection_timeout + (this.retry_counter * 1000);
            var timerRef = new TimerRef();
            timerRef.Ref = new Timer(delegate(object state)
            {
                this.Connect();

                try { timerRef.Ref.Dispose(); }
                catch { }

            }, timerRef, retry_delay, retry_delay);

            this.retry_counter = this.retry_counter + 1;
        }
コード例 #7
0
        public void Connect()
        {
            string url;
            if (this.encrypted || this.secure)
            {
                url = "wss://" + Pusher.host + ":" + Pusher.wss_port + this.path;
            }
            else
            {
                url = "ws://" + Pusher.host + ":" + Pusher.ws_port + this.path;
            }

            Pusher.allow_reconnect = true;
            Pusher.Log("Pusher : connecting : " + url);

            var self = this;

            IWebSocket ws = CreateWebSocket(url);

            // Timeout for the connection to handle silently hanging connections
            // Increase the timeout after each retry in case of extreme latencies
            int interval = Pusher.connection_timeout + (this.retry_counter * 1000);

            var timerRef = new TimerRef();
            timerRef.Ref = new Timer(delegate(object state)
            {
                Pusher.Log("Pusher : connection timeout after " + interval + "ms");
                ws.Close();
                try { timerRef.Ref.Dispose(); }
                catch { }

            }, null, interval, interval);

            ws.OnData += (sender, e) => OnMessage(e);
            ws.OnClose += (sender, e) =>
            {
                try { timerRef.Ref.Dispose(); }
                catch { }
                OnClose();
            };
            ws.OnOpen += (sender, e) =>
            {
                try { timerRef.Ref.Dispose(); }
                catch { }
                OnOpen();
            };

            this.connection = ws;

            ws.Open();
        }