コード例 #1
0
    void Update()
    {
        // fire 1
        if (Input.GetButton("Fire1"))
        {
            if (gunnerPhotonView.IsMine)
            {
                if (gunnerWeaponManager.CurrentWeaponGroupCanFire())
                {
                    Vector3 targetHitpoint;
                    if (turretController.inDeadZone)
                    {
                        targetHitpoint = CalculateTargetingHitpoint(cam);
                    }
                    else
                    {
                        targetHitpoint = CalculateTargetingHitpoint(barrelTransform);
                    }

                    gunnerWeaponManager.FireCurrentWeaponGroup(targetHitpoint);
                }
            }
        }
        // jank ram damage thing
        if (Input.GetButtonDown("Fire2"))
        {
            Debug.Log("mark fire btn press");
            if (gunnerPhotonView.IsMine)
            {
                Debug.Log("mark fire");
                VehicleHealthManager hitvm = GetClosestVehicleHealthManager(cam);
                if (hitvm != null)
                {
                    Debug.Log("mark hitvm not null");
                    NetworkPlayerVehicle npv = GetComponentInParent <NetworkPlayerVehicle>();
                    int teamId   = npv.teamId;
                    int driverId = npv.GetDriverID();
                    int gunnerId = npv.GetGunnerID();
                    // remove last mark
                    if (lastMarkedTeam != 0)
                    {
                        FindObjectOfType <PlayerTransformTracker>().GetVehicleTransformFromTeamId(lastMarkedTeam).GetComponent <PhotonView>().RPC(nameof(CollidableHealthManager.RemoveMarkedTeam_RPC), RpcTarget.All, lastMarkedTeam, driverId, gunnerId);
                    }
                    // add new mark
                    GetComponent <PhotonView>().RPC(nameof(MarkAudioPlay_RPC), RpcTarget.All);
                    hitvm.GetComponent <PhotonView>().RPC(nameof(CollidableHealthManager.MarkTeam_RPC), RpcTarget.All, teamId, driverId, gunnerId);
                    lastMarkedTeam = hitvm.gameObject.GetComponent <NetworkPlayerVehicle>().teamId;
                    Debug.Log("mark done");
                }
                if (hitvm == null)
                {
                    Debug.Log("mark is null");
                }
                if (hitvm.transform == transform.root)
                {
                    Debug.Log("mark is me");
                }
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            if (gunnerPhotonView.IsMine)
            {
                gunnerWeaponManager.CeaseFireCurrentWeaponGroup();
            }
        }

        // // relaod
        if (Input.GetButtonDown("Reload"))
        {
            if (gunnerPhotonView.IsMine)
            {
                gunnerWeaponManager.ReloadCurrentWeaponGroup();
            }
        }

        if (Input.GetButtonDown("Ultimate"))
        {
            if (gunnerPhotonView.IsMine)
            {
                gunnerWeaponManager.SelectUltimate();
            }
        }

        if (Input.GetKey(KeyCode.Space))
        {
            camera.m_Lens.FieldOfView = Mathf.Lerp(camera.m_Lens.FieldOfView, 30, 0.1f);
        }
        else
        {
            camera.m_Lens.FieldOfView = Mathf.Lerp(camera.m_Lens.FieldOfView, 60, 0.1f);
        }

        turretController.ChangeTargetYaw(cameraSensitivity * Input.GetAxis("Mouse X") * Time.deltaTime);
        turretController.ChangeTargetPitch(-(cameraSensitivity * Input.GetAxis("Mouse Y") * Time.deltaTime));
        turretController.UpdateTargeterRotation();


        float newy = Mathf.Max(cinemachineTransposer.m_FollowOffset.y - Input.mouseScrollDelta.y * 0.2f, 1.5f);
        float newz = Mathf.Min(cinemachineTransposer.m_FollowOffset.z + Input.mouseScrollDelta.y * 0.6f, -3f);

        if (newy < maxZoomOut)
        {
            cinemachineTransposer.m_FollowOffset.y = newy;
            cinemachineTransposer.m_FollowOffset.z = newz;
        }
    }