public void GameLevelActionLimiter_TwoRequests_TimeNotStarted()
        {
            var time    = new GameLevelTime();
            var limiter = new GameLevelActionLimiter(time, TimeSpan.FromSeconds(1));

            Assert.IsTrue(limiter.CanDoStuff());
            limiter.DoingIt();

            Assert.IsFalse(limiter.CanDoStuff());
            limiter.DoingIt();
        }
        public async Task GameLevelActionLimiter_TwoRequests_TimeStarted()
        {
            var time    = new GameLevelTime();
            var limiter = new GameLevelActionLimiter(time, TimeSpan.FromMilliseconds(100));

            time.Start();
            Assert.IsTrue(limiter.CanDoStuff());
            limiter.DoingIt();

            await Task.Delay(TimeSpan.FromMilliseconds(200));

            Assert.IsTrue(limiter.CanDoStuff());
            limiter.DoingIt();
        }
Exemplo n.º 3
0
        public override void Update(TimeSpan timeDelta)
        {
            switch (TowerStateEnum)
            {
            case TowerStateEnum.Setup:
                LocationCenter = _inputManager.GetMousePosition();
                break;

            case TowerStateEnum.Active:
                if (_shootLimiter.CanDoStuff())
                {
                    Shoot();
                }
                break;

            default:
                throw new IndexOutOfRangeException(nameof(TowerStateEnum));
            }
        }
Exemplo n.º 4
0
        public override void Update(TimeSpan timeDelta)
        {
            switch (TowerStateEnum)
            {
            case TowerStateEnum.Setup:
                SetLocationCenter(Point.Add(_inputManager.GetMousePosition(), _sprite.Size.Invert()));
                break;

            case TowerStateEnum.Active:
                //_sprite.IsRelativeToMap = true;
                if (_shootLimiter.CanDoStuff())
                {
                    Shoot();
                }
                ;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }