Exemplo n.º 1
0
        void _respaumTimer_Tick(object sender, object e)
        {
            List <Map_Cell> calls = CurrentMap.Calls.Where(p => !p.Used && !p.Using && !p.Block).ToList();

            _respaumTimer.Completed -= _respaumTimer_Tick;
            _respaumTimer            = null;

            if (calls.Count != 0)
            {
                Dead = false;
                CurrentMap.DeadPlayers.Remove(this);
                Health = MaxHealth;
                Mana   = MaxMana;
                StartRegenerationTimer();

                Random   rand        = new Random((int)DateTime.Now.Ticks);
                Map_Cell respaumCall = calls[rand.Next(0, calls.Count - 1)];
                this.PositionX = respaumCall.IndexLeft;
                this.PositionY = respaumCall.IndexTop;

                CurrentMap.CreateObject(this, respaumCall.IndexLeft, respaumCall.IndexTop);
                ///Отображение
                CurrentMap.MapCanvas.Children.Add(this.GameObject.View);


                Invulnerability = true;
                ///Таймер временной неуязвимости после спаума
                _inviInvulnerabilityTimer = new Storyboard()
                {
                    Duration = TimeSpan.FromSeconds(StaticVaribl.InvulnerabilityTime)
                };
                _inviInvulnerabilityTimer.Completed += _inviInvulnerabilityTimer_Tick;
                if (!Paused)
                {
                    _inviInvulnerabilityTimer.Begin();
                }
            }
            else
            {   ///Если на карте не было места где можно воскреснуть
                ///Таймер воскрешения
                _respaumTimer = new Storyboard()
                {
                    Duration = TimeSpan.FromSeconds(RespaumTime)
                };
                _respaumTimer.Completed += _respaumTimer_Tick;
                _respaumTimer.Begin();
            }
            UpdateView();
        }