Esempio n. 1
0
    private void AddNewPlayer(int deviceID)
    {
        if (playerCount >= 6)
        {
            return;
        }

        if (players.ContainsKey(deviceID))
        {
            return;
        }

        playerCount++;

        GameObject newPlayer = Instantiate <GameObject>(playerPrefab);
        var        data      = newPlayer.AddComponent <PlayerData>();
        var        render    = newPlayer.GetComponent <Renderer>();

        Vector3 pos = Vector3.zero;

        if (playerCount % 2 == 1)
        {
            data.Group = GroupType.Blue;
            int index = (int)(playerCount / 2);
            pos = blueGroupBornDummy[index].position;
            data.StartPostion     = pos;
            render.material.color = blueGroupColor;
            phase = GamePhase.WaitPlayer;
        }
        else
        {
            data.Group = GroupType.Red;
            int index = (int)(playerCount / 2) - 1;
            pos = redGroupBornDummy[index].position;
            data.StartPostion     = pos;
            render.material.color = redGroupColor;
            phase = GamePhase.Ready;
        }

        newPlayer.transform.position = pos;
        newPlayer.GetComponent <PlayerController>().SetBornTransForm(pos);
        var playerController = newPlayer.GetComponent <PlayerController>();

        players.Add(deviceID, playerController);

        OnPlayerCountChange?.Invoke(playerCount);
    }
Esempio n. 2
0
 public void ChangePlayerCountCommand(int playerCount)
 {
     OnPlayerCountChange?.Invoke(playerCount);
 }