示例#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);
 }