Пример #1
0
        public bool Validate(GameHub hub)
        {
            if (!Validation(hub))
            {
                return(false);
            }

            if (next != null)
            {
                return(next.Validate(hub));
            }

            return(true);
        }
Пример #2
0
        protected override bool Validation(GameHub hub)
        {
            GameHandler.players.TryGetValue(hub.Context.ConnectionId, out GameHandler.PlayerStats clientPlayer);

            if (clientPlayer.name == null)
            {
                clientPlayer.name = "Player";
            }

            string newName = clientPlayer.name;
            bool   unique  = true;
            int    sufix   = 1;

            while (true)
            {
                foreach (var player in GameHandler.players)
                {
                    if (player.Value.name == newName && player.Key != hub.Context.ConnectionId)
                    {
                        unique = false;
                        break;
                    }
                }

                if (!unique)
                {
                    newName = $"{clientPlayer.name}{sufix++}";
                    unique  = true;
                    continue;
                }
                break;
            }

            if (newName != clientPlayer.name)
            {
                _ = hub.OverrideName(newName);
            }
            return(true);
        }
Пример #3
0
 protected override bool Validation(GameHub hub)
 {
     return(!GameHandler.isGameStarted);
 }
Пример #4
0
 abstract protected bool Validation(GameHub hub);
Пример #5
0
 protected override bool Validation(GameHub hub)
 {
     return(GameHandler.players.Count < GameHandler.maxPlayerCount);
 }