Ejemplo n.º 1
0
    //Start match on specific state
    public void startMatch(int startState)
    {
        new Thread(() => {
            int timeout = 10;
            while (timeout-- >= 0)
            {
                Thread.Sleep(1000);
            }
            match.setMatchGuests(guests);

            foreach (Guest g in guests)
            {
                g.seekingWins = 0;
                g.hidingWins  = 0;
            }

            match.start(startState);

            foreach (Guest g in guests)
            {
                Broadcast("start/" + g.isHider, new List <Guest>()
                {
                    g
                });
            }

            gameStarted = true;
        });
    }
Ejemplo n.º 2
0
    //Host Pressed on Start Match
    public void startMatch()
    {
        match = new MatchOrchestrator(guests);

        foreach (Guest g in guests)
        {
            g.seekingWins = 0;
            g.hidingWins  = 0;
        }

        //Assigning each player a role (Hider or Seeker)
        List <bool> roles = match.generateRoles();

        System.Random rand = new System.Random();
        if (roles != null)
        {
            if (roles.Count > 1)
            {
                int hiders = 0, seekers = 0;
                for (int i = 0; i < roles.Count; i++)
                {
                    if (roles[i])
                    {
                        hiders++;
                    }
                    else
                    {
                        seekers++;
                    }
                }
                if (hiders > seekers)
                {
                    isHider = false;
                }
                else if (hiders < seekers)
                {
                    isHider = true;
                }
                else
                {
                    isHider = rand.Next(0, 2) == 1 ? false : true;
                }
            }
            else
            {
                isHider = !roles[0];
            }
        }
        else
        {
            isHider = rand.Next(0, 2) == 1 ? false : true;
        }

        match.start();

        foreach (Guest g in guests)
        {
            Broadcast("start/" + g.isHider, new List <Guest>()
            {
                g
            });
        }

        gameStarted = true;
    }