Ejemplo n.º 1
0
    void Start()
    {
        gamestateTracker       = FindObjectOfType <GamestateTracker>();
        gamestateVehicleLookup = FindObjectOfType <GamestateVehicleLookup>();
        vehicleNames           = gamestateVehicleLookup.sortedVehicleNames;

        PlayerEntry playerEntry = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber);

        PlayerEntry.Role ourRole = (PlayerEntry.Role)playerEntry.role;
        ourTeamId = playerEntry.teamId;
        playerEntry.Release();


        // get the team we are in
        TeamEntry teamEntry = gamestateTracker.teams.Get(ourTeamId);
        short     driverId  = teamEntry.driverId;
        short     gunnerId  = teamEntry.gunnerId;

        teamEntry.Release();


        // if we are a gunner, check if the driver is a bot.
        // if so, get priority
        if (ourRole == PlayerEntry.Role.Gunner)
        {
            PlayerEntry driverEntry = gamestateTracker.players.Get(driverId);
            if (driverEntry.isBot)
            {
                priority = true;
            }
            driverEntry.Release();
        }

        // if we are a driver, get priority
        if (ourRole == PlayerEntry.Role.Driver)
        {
            priority = true;
        }


        // assign other player id, only needed if the other player is human
        // hence we only check for if we are a driver
        if (priority && ourRole == PlayerEntry.Role.Driver)
        {
            // get gunner id
            PlayerEntry gunnerEntry = gamestateTracker.players.Get(gunnerId);
            otherId = gunnerEntry.id;
            gunnerEntry.Release();
        }

        SetButtonsInteractable(priority);
        SetupButtons();
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        gamestateTracker       = FindObjectOfType <GamestateTracker>();
        gamestateVehicleLookup = FindObjectOfType <GamestateVehicleLookup>();
        dropdown = GetComponent <Dropdown>();
        dropdown.ClearOptions();

        vehicleNames = gamestateVehicleLookup.sortedVehicleNames;

        List <Dropdown.OptionData> options = new List <Dropdown.OptionData>();

        for (int i = 0; i < vehicleNames.Count; i++)
        {
            options.Add(new Dropdown.OptionData(vehicleNames[i]));
        }
        dropdown.AddOptions(options);

        selectedVehicle = vehicleNames[0];
    }