Exemplo n.º 1
0
            public void OnNext(GameSeriesEvent e)
            {
                var message = e
                              switch
                {
                    GameSeriesStarted start => $"a new game series of {start.Plan.Rounds.Count} rounds was started",
                    RoundStarted roundStarted => $"a new round started",
                    RoundEnded roundEnded => $"round finished. {PointInfo(roundEnded.Result.PlayerResults)}",
                    _ => e.ToString(),
                };

                Render(message, ConsoleColor.DarkMagenta);
                if (e is GameSeriesStarted s)
                {
                    _playerNames = s.Players.Select(p => p.Name).ToList();
                    _totalScores = s.Players.Select(_ => 0).ToList();
                }
                else if (e is RoundEnded end)
                {
                    foreach (var(r, i) in end.Result.PlayerResults.Select((r, i) => (r, i)))
                    {
                        _totalScores[i] += r.Score;
                    }
                    Render("Total scores: " + string.Join(", ", Enumerable.Zip(_playerNames, _totalScores)), ConsoleColor.DarkMagenta);
                }
            }
Exemplo n.º 2
0
        public void OnNext(RoundStarted started)
        {
            var settings = started.Settings;
            var dto      = new RoundStartedDto(started.GameUuid, settings.StartingPlayerIndex, settings.TricksToPlay);

            _client.GameRoundStarted(dto);
        }
Exemplo n.º 3
0
        public void StartMatch()
        {
            IsRunning = true;
            var player = GetPlayerWhoHasNotPlayed();

            MatchStarted?.Invoke(this, EventArgs.Empty);
            RoundStarted?.Invoke(this, new RoundStartedEventArgs(CurrentRound));

            StartPreparationTimer(player);
        }
Exemplo n.º 4
0
 void RoundStartedUp(RoundStarted obj)
 {
     if (obj.players.IndexOf(player) == 0)
     {
         Events.Publish(new SmallBlindAdded(10, player));
         wasSmall = true;
     }
     else if (obj.players.IndexOf(player) == 1)
     {
         Events.Publish(new BigBlindAdded(20, player));
         wasBig = true;
     }
 }
Exemplo n.º 5
0
    IEnumerator RoundStart()
    {
        roundNumber++;
        if (RoundStarted != null)
        {
            RoundStarted.Invoke(this, new EventArgs());
        }
        //角色加入忽略层
        Units.ForEach(u => u.gameObject.layer = 2);
        yield return(new WaitForSeconds(roundStartTime));

        Units.ForEach(u => { u.OnRoundStart(); });
        StartCoroutine(TurnStart());
    }
Exemplo n.º 6
0
        private IEnumerator StartCountdown()
        {
            RoundCountdown?.Invoke();

            while (_countdown > 0)
            {
                _countdown -= Time.deltaTime;

                yield return(null);
            }

            _gameState = GameState.Started;
            _isStarted = true;

            RoundStarted?.Invoke();

            _updateManager.StartCoroutine(StartTimer());
        }
Exemplo n.º 7
0
        private IEnumerator StartCountdown()
        {
            _round++;
            _gameState = GameState.Countdown;

            RoundCountdown?.Invoke();

            while (_countdown > 0)
            {
                _countdown -= Time.deltaTime;

                yield return(null);
            }

            _gameState = GameState.Started;

            RoundStarted?.Invoke();
        }
Exemplo n.º 8
0
        private void RefreshRoom()
        {
            players.AddRange(playersWaitingForNextRound);
            playersWaitingForNextRound.Clear();
            food.Clear();
            ClearAllCells();

            foreach (Player player in players)
            {
                SubscribeOnPlayerEvents(player);
            }

            GenerateplayersFirstCircles();

            Console.WriteLine("Round started");
            RoundStarted roundStartedGameEvent = new RoundStarted(players);

            OnGameEventOccured?.Invoke(this, new GameEventOccuredEventArgs(roundStartedGameEvent));

            GenerateFood(FOOD_AMOUNT_ON_START);
        }
Exemplo n.º 9
0
        public Result StartGame()
        {
            round = new Round();
            RoundStarted?.Invoke();

            round.WinnerFound += player => {
                if (player == player1)
                {
                    round.result = Result.PlayerOneWon;
                    scores.player1Score++;
                }

                if (player == player2)
                {
                    round.result = Result.PlayerTwoWon;
                    scores.player2Score++;
                }
            };

            DrawBoard?.Invoke();
            do
            {
                round.Move(player1);
                DrawBoard?.Invoke();

                if (round.inPlay)
                {
                    round.Move(player2);
                    DrawBoard?.Invoke();
                }
            } while (round.inPlay);

            if (round.result == Result.Draw)
            {
                scores.draws++;
            }

            RoundEnded?.Invoke();
            return(round.result);
        }
Exemplo n.º 10
0
        private void Match_SubRoundFinished(object sender, EventArgs e)
        {
            WordToDraw    = null;
            RemainingTime = RoundLength;
            ResetHasGuessed();

            var player = GetCurrentlyDrawingPlayer();

            if (player != null)
            {
                player.Status = PlayerStatus.Guessing;

                PlayedPlayers.Add(player);
            }

            if (PlayedPlayers.Count >= Players.Count)
            {
                //Runde Beendet
                PlayedPlayers.Clear();
                RoundFinished?.Invoke(this, EventArgs.Empty);

                if (CurrentRound == Rounds)
                {
                    IsRunning  = false;
                    IsFinished = true;
                    MatchFinished?.Invoke(this, EventArgs.Empty);
                    return;
                }

                CurrentRound++;

                RoundStarted?.Invoke(this, new RoundStartedEventArgs(CurrentRound));
            }

            player = GetPlayerWhoHasNotPlayed();
            StartPreparationTimer(player);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Called after the start of a new round.
 /// </summary>
 public static void OnRoundStarted() => RoundStarted.InvokeSafely();
Exemplo n.º 12
0
 public RoundStartedPayload(RoundStarted roundStarted)
 {
     Settings = roundStarted.Settings;
 }
Exemplo n.º 13
0
 protected virtual void OnRoundStarted(ReportUpdateEventArgs eventArgs)
 {
     RoundStarted?.Invoke(eventArgs);
 }
Exemplo n.º 14
0
 public GameState When(RoundStarted @event) => new GameState
 {
     Status = GameStatus.Started
 };
Exemplo n.º 15
0
 public void RoundHasStarted(Int32 roundNumber, TimeSpan roundTime)
 {
     RoundStarted?.Invoke(this, (Round: roundNumber, RoundTime: roundTime));
 }
Exemplo n.º 16
0
    public static void HandlePackage(byte[] package, int playerId = -1)
    {
        try
        {
            IncomingGameEvent gameEvent;

            Debug.Log((IncomingGameEventTypes)package[0]);

            switch ((IncomingGameEventTypes)package[0])
            {
            case IncomingGameEventTypes.CirclesFrameUpdate:
                gameEvent = new CirclesFrameUpdate(package);
                break;

            case IncomingGameEventTypes.RoundStarted:
                gameEvent = new RoundStarted(package);
                break;

            case IncomingGameEventTypes.PlayerAdded:
                gameEvent = new PlayerAdded(package);
                break;

            case IncomingGameEventTypes.PlayerDied:
                gameEvent = new PlayerDied(package);
                break;

            case IncomingGameEventTypes.RoundOver:
                gameEvent = new RoundOver(package);
                break;

            case IncomingGameEventTypes.CirclesAdded:
                gameEvent = new CirclesAdded(package);
                break;

            case IncomingGameEventTypes.CirclesRemoved:
                gameEvent = new CirclesRemoved(package);
                break;

            case IncomingGameEventTypes.FoodAdded:
                gameEvent = new FoodAdded(package);
                break;

            case IncomingGameEventTypes.FoodRemoved:
                gameEvent = new FoodRemoved(package);
                break;

            case IncomingGameEventTypes.PlayerLeft:
                gameEvent = new PlayerLeft(package);
                break;

            default:
                throw new Exception(String.Format("Incorrect package type: {0}", (IncomingGameEventTypes)package[0]));
                break;
            }

            GameManager.Instance.GameEvents.Enqueue(gameEvent);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
        }
    }