コード例 #1
0
        public void GameCreated(GameModel model)
        {
            game.Log("Player " + this.ConnectUserId + " started playing.");

            this.model = model;
            model.OnGameEnded += GameEnded;
            this.Send("Game started");
        }
コード例 #2
0
        /// <summary>
        /// Вызывает другого игрока на игру.
        /// </summary>
        /// <param name="other">Вызванный игрок.</param>
        public void ChallengePlayer(Player other)
        {
            game.Log("Player " + this.ConnectUserId + " challenged player " + other.ConnectUserId + ".");

            if (other == this) {
                this.Send("Denied", "You can't challenge yourself.");
                return;
            }
            if (challenged != null) {
                challenged.Send("Challenge revoked", this.ConnectUserId);
            }
            challenged = other;
            other.Send("Challenged", this.ConnectUserId);

            if (other.Challenged == this) {
                GameModel model = new GameModel(this, other);
                this.GameCreated(model);
                other.GameCreated(model);
            }
        }
コード例 #3
0
        private void GameEnded()
        {
            game.Log("Player " + this.ConnectUserId + " stopped playing.");

            model = null;
            this.Send("Game ended");
        }