示例#1
0
    public virtual void SetupAbility()
    {
        driverPhotonView = transform.root.GetComponent <PhotonView>();
        // assign photon view to the driver
        abilityPhotonView = GetComponent <PhotonView>();
        abilityPhotonView.TransferOwnership(driverPhotonView.Owner);


        //Player gunnerPlayer = gunnerPhotonView.Owner;

        _networkPlayerVehicle = driverPhotonView.GetComponent <NetworkPlayerVehicle>();
        myVehicleManager      = driverPhotonView.GetComponent <VehicleHealthManager>();
        driverAbilityManager  = driverPhotonView.GetComponent <DriverAbilityManager>();

        if (_networkPlayerVehicle != null)
        {
            myNickName = _networkPlayerVehicle.GetDriverNickName();
            myPlayerId = _networkPlayerVehicle.GetDriverID();
            myTeamId   = _networkPlayerVehicle.teamId;
        }
        else
        {
            Debug.LogError("Ability does not belong to a valid vehicle!! Assigning owner to null");
        }

        uiCanvas      = FindObjectOfType <UiCanvasBehaviour>().GetComponent <Canvas>();
        targetOverlay = Instantiate(targetOverlayPrefab, uiCanvas.transform);
        targetOverlay.SetActive(false);
        lastTarget = transform;
        isSetup    = true;
        Invoke(nameof(GetCarList), 2f);
    }