private void RequestMovement(ITimerUpdateVO vo) { _view.Update(_model.RoundIndependentUpdate(new FlashGlanceEventRequestVO(FlashGlanceEventType.ItemMovement))); FlashGlanceEventVo moveConfig = GetEventConfig(FlashGlanceEventType.ItemMovement); _moveTimer.Start(GetRandomDelay(moveConfig)); }
private void RequestSwap(ITimerUpdateVO vo) { _view.Update(_model.RoundIndependentUpdate(new FlashGlanceEventRequestVO(FlashGlanceEventType.ItemSwitching))); FlashGlanceEventVo swichConfig = GetEventConfig(FlashGlanceEventType.ItemSwitching); _switchTimer.Start(GetRandomDelay(swichConfig)); }
private void RequestNewItem(ITimerUpdateVO vo) { _view.Update(_model.RoundIndependentUpdate(new FlashGlanceEventRequestVO(FlashGlanceEventType.ItemSpawning))); FlashGlanceEventVo spawnConfig = GetEventConfig(FlashGlanceEventType.ItemSpawning); _spawnTimer.Start(GetRandomDelay(spawnConfig)); }
private void updateEvantTimer(FlashGlanceEventType eventType) { FlashGlanceEventVo eventConfig = GetEventConfig(eventType); ITimer timer = null; switch (eventType) { case FlashGlanceEventType.ItemSpawning: timer = _spawnTimer; break; case FlashGlanceEventType.ItemMovement: timer = _moveTimer; break; case FlashGlanceEventType.ItemSwitching: timer = _switchTimer; break; } if (timer != null) { if (eventConfig.Amount > 0 && eventConfig.MinDelay > 0 && eventConfig.MaxDelay > 0) { // Action present if (!timer.IsRunning) { timer.Start(GetRandomDelay(eventConfig)); } } else { // No action if (timer.IsRunning) { timer.Stop(); } } } }
private double GetRandomDelay(FlashGlanceEventVo eventVo) { var delay = ((_random.NextDouble() * (eventVo.MaxDelay - eventVo.MinDelay) + eventVo.MinDelay) * 1000); return(delay); }