public void Tick() { var players = PlayerStorage.GetPlayers(); var finish = FieldStorage.GetFinishes(); foreach (var player in players) { if (player.IsSpotted) { _gameLoopView.ShowLoseGame(); GameIsOver = true; } } if (finish.NodeIsTouched) { _gameLoopView.ShowWinGame(); GameIsOver = true; } if (GameIsOver) { if (Input.GetKeyDown(KeyCode.Space)) { Restart(); } } }
public void Tick() { var guards = GuardStorage.GetGuards(); var players = PlayerStorage.GetPlayers(); foreach (var player in players) { foreach (var guard in guards) { if (CanSeeTarget(guard, player)) { player.PlayerVisibleTimer += Time.deltaTime; } else { player.PlayerVisibleTimer -= Time.deltaTime; } player.PlayerVisibleTimer = Mathf.Clamp(player.PlayerVisibleTimer, 0, player.TimeToSpotPlayer); float _visability = player.PlayerVisibleTimer / player.TimeToSpotPlayer; guard.Color = Color.Lerp(Color.green, Color.red, _visability); GuardStorage.UpdateItem(guard); } PlayerStorage.UpdateItem(player); } }