Esempio n. 1
0
    private void Awake()
    {
        IWeaponAnimation  weaponAnimation = new WeaponAnimationInfo(weaponAnimations.OnEquipTime, weaponAnimations.UnequipTime);
        List <ISlashInfo> slashes         = new List <ISlashInfo>();

        for (int i = 0; i < meleeAttacks.Slashes.Count; i++)
        {
            slashes.Add(meleeAttacks.Slashes[i]);
        }
        ISlashLogic slashLogic = new SlashLogic(meleeAttacks.TimeToWait, ref slashes);

        IWeaponInfo weaponInfo = new MeleeWeaponInfo(slashLogic, baseWeaponInfo.WeaponName);

        IWeaponPlace weaponPlace = new WeaponPlaces(ref idle, ref use);

        this.meleeWeapon = new Weapon(ref weaponAnimation, ref weaponInfo, ref weaponPlace, this.transform);
        this.meleeWeapon.PlaceWeapon(true);
    }
Esempio n. 2
0
    IEnumerator Start()
    {
        MaxRenderScale = SteamVR_Camera.sceneResolutionScale;
        MinRenderScale = SteamVR_Camera.sceneResolutionScale * 0.1f;
        //if (PlayerPrefs.GetInt("dynamic_resolution", 0) == 1) {
        StartCoroutine(FPS());
        //}
        yield return(new WaitForSeconds(1f));

        while (RightHand.transform.localPosition == Vector3.zero)
        {
            yield return(null);
        }

        if (VRInputBridge.instance.aimScript_ref.primaryHand == HandSide.Left)
        {
            LHandSphere.SetActive(false);
            RHandSphere.SetActive(true);
        }
        else
        {
            LHandSphere.SetActive(true);
            RHandSphere.SetActive(false);
        }

        if (VRInputBridge.instance.aimScript_ref.gun_script.HasGunComponent(GunAspect.FIRING))
        {
            muzzlepos    = VRInputBridge.instance.aimScript_ref.gun_instance.GetComponent <FiringComponent>().point_muzzle;
            canFrontGrab = muzzlepos.localPosition.z > 0.3f;
        }
        else
        {
            canFrontGrab = false;
        }

        if (ImGuiUnity.instance != null)
        {
            ImGuiUnity.instance.vrHandObject   = RightHand;
            ImGuiUnity.instance.vrCameraObject = Head;
        }


        if (VRInputBridge.instance.aimScript_ref.gun_script.HasGunComponent(GunAspect.TRIGGER_VISUAL))
        {
            Renderer triggerRenderer = VRInputBridge.instance.aimScript_ref.gun_script.GetComponent <TriggerVisualComponent>().trigger.GetComponent <MeshRenderer>();
            if (triggerRenderer == null)
            {
                triggerRenderer = VRInputBridge.instance.aimScript_ref.gun_script.GetComponentInChildren <TriggerVisualComponent>().trigger.GetComponent <MeshRenderer>();
            }
            if (triggerRenderer != null)
            {
                localTriggerCenter = triggerRenderer.transform.parent.InverseTransformPoint(triggerRenderer.bounds.center);
                if (RightHand.transform.GetChild(0).Find("trigger").GetChild(0) != null)
                {
                    controllerTriggerCenter = RightHand.transform.GetChild(0).Find("trigger").GetChild(0).localPosition;
                }
                relativeTriggerOffset = (localTriggerCenter - controllerTriggerCenter) - (Vector3.forward * 0.035f);
                readyInit             = true;
            }
        }

        meleeWeapon = VRInputBridge.instance.aimScript_ref.gun_script.gameObject.GetComponentInChildren <MeleeWeaponInfo>();
        if (meleeWeapon != null)
        {
            MeleeWeaponInfo info = meleeWeapon;
            localTriggerCenter = VRInputBridge.instance.aimScript_ref.gun_script.transform.InverseTransformPoint(info.MainGrip.position);
            meleeWeapon.MainGrip.GetComponentInParent <Animator>().SetBool("VRPose", true);
            controllerTriggerCenter = RightMeleeGrip.transform.localPosition;
            relativeTriggerOffset   = (localTriggerCenter - controllerTriggerCenter);
            readyInit = true;
        }

        /*Renderer[] gunRenderers = VRInputBridge.instance.aimScript_ref.gun_script.GetComponentsInChildren<Renderer>();
         *
         * bool WasGunShader = gunRenderers[0].material.shader.name.ToLower().Contains("gunshader");
         *
         * if (WasGunShader) {
         *  float oldDeet = gunRenderers[0].material.GetFloat(0);
         *  float oldScale = gunRenderers[0].material.GetFloat(1);
         *  float oldMetallic = gunRenderers[0].material.GetFloat(2);
         *  float oldSmoothness = gunRenderers[0].material.GetFloat(3);
         *
         *  gunMat.SetFloat(0, oldDeet);
         *  gunMat.SetFloat(1, oldScale);
         *  gunMat.SetFloat(2, oldMetallic);
         *  gunMat.SetFloat(3, oldSmoothness);
         *
         *  if(gunRenderers[0].material.mainTexture != null) {
         *      gunMat.SetTexture(0, gunRenderers[0].material.mainTexture);
         *  }
         *
         *  foreach (Renderer rend in gunRenderers) {
         *      rend.material = gunMat;
         *  }
         * }
         * else {
         *  float oldMetallic = gunRenderers[0].material.GetFloat(0);
         *  float oldSmoothness = gunRenderers[0].material.GetFloat(1);
         *
         *  gunMat.SetFloat(0, oldMetallic);
         *  gunMat.SetFloat(1, oldSmoothness);
         *
         *  if (gunRenderers[0].material.mainTexture != null) {
         *      gunMat.SetTexture(0, gunRenderers[0].material.mainTexture);
         *  }
         *
         *  foreach (Renderer rend in gunRenderers) {
         *      rend.material = gunMat;
         *  }
         * }*/
    }