Exemple #1
0
    public static void StartGame()
    {
        if (Server.map.mapId != 0)
        {
            Console.WriteLine("Start Game: Game already in progress!");
            return;
        }

        Console.WriteLine("Starting Game...");

        Client[]  onlinePlayers = Server.OnlinePlayers();
        Vector3[] spawns        = GenerateSpawns(onlinePlayers.Length);

        PlayerStates[] roles = new PlayerStates[onlinePlayers.Length];
        for (int i = 0; i < roles.Length; i++)
        {
            roles[i] = PlayerStates.human;
        }
        roles[0] = PlayerStates.bunny;

        if (random == null)
        {
            random = new Random();
        }

        roles = roles.OrderBy(x => random.Next()).ToArray();

        for (int i = 0; i < onlinePlayers.Length; i++)
        {
            onlinePlayers[i].player.TeleportPlayer(spawns[i]);
            onlinePlayers[i].player.UpdatePlayerState(roles[i]);
        }

        Server.map.LoadMap(1);
    }