Files
old-profesor-atom/Profesor Atom/Library/metadata/d8/d85480da87762944399dab6c99985eef

303 lines
13 KiB
Plaintext
Raw Normal View History

2017-05-17 12:25:25 +03:00
w2<>5.6.1f1<00><><EFBFBD><EFBFBD><00><><EFBFBD>0<05><><EFBFBD><EFBFBD>L.`?^<5E>0D7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00><00><00><00><00><00><00><00><00>#<00><00>+H<00>3<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00> Q<00>j<00>
<00><00>< <00><00>H H<00>Z<00><><EFBFBD><EFBFBD> <00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00><00><00>g<00><00><00><00><00><00>#<00><00>+v~<00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><><00><00><> <00><00><>!<00><00><>"<00><00><>#<00><00>$<00><00>%<00><00>&<00><00>#<00><><EFBFBD><EFBFBD>'<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>(<00><00><00><00>)H<00>j<00><><EFBFBD><EFBFBD><EFBFBD>*<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>+@<00><00><00>,Q<00>j<00>-<00><00>*.<00><00>8/AssetMetaDataguiddata[0]data[1]data[2]data[3]pathNametimeCreatedoriginalChangesetoriginalNameoriginalParentHash128originalDigestbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]labelsassetStoreReflicenseType <00><>z{<0E>@<40><05><>5^(<28>H'<00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00> <00><00> <00><00>#.<00>,<00><00><><00> <00><00>#.<00>,H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>
Q<00>j<00> <00><00>5<00><><EFBFBD><EFBFBD> <00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> <00><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00>#.<00>, <00>I@<00><00>X @<00><00>#.<00>,H<00>]<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>H<00>h<00><><EFBFBD><EFBFBD><00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>!Q<00>j<00>"H<00>z<00><><EFBFBD><EFBFBD>#<00>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>$@<00><00><00>%Q<00>j<00>&MonoImporterPPtr<EditorExtension>m_FileIDm_PathIDm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariants<00><><EFBFBD>8-l'<27><>愁h<E68481>ΐA,<00><00>7<00><><EFBFBD><EFBFBD><EFBFBD><00><00><00><><00><00><00> <00><00>.<00><00><00><><00> <00><00>.<00>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>
Q<00>j<00> H<00><><00><><EFBFBD><EFBFBD><EFBFBD> <01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>Q<00>j<00><00><00>(<00><><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD><01><00><00><00><00>j<00><><EFBFBD><EFBFBD><EFBFBD><01>H<00><><00><><EFBFBD><EFBFBD><EFBFBD><01>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>@<00><00><00>Q<00>j<00>y<00>
<00> <00><00>.<00>y<00>< <00><00>.<00><00><00>CH<00>T<00><><EFBFBD><EFBFBD><10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD> @<00><00><00>!Q<00>j<00>"H<00>`<00><><EFBFBD><EFBFBD>#<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>$@<00><00><00>%Q<00>j<00>&H<00>l<00><><EFBFBD><EFBFBD>'<10>1<00>1<00><><EFBFBD><EFBFBD><EFBFBD>(@<00><00><00>)Q<00>j<00>*L<00>{+PPtr<EditorExtension>m_FileIDm_PathIDm_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacem_AssemblyNamem_IsEditorScript<00><00>@<00>y<EFBFBD><00><00>!<00><>^\a<><61>M<EFBFBD>Q<EFBFBD>| <09>e.<00>E<08>xg<78>D<EFBFBD>ٺƙ<D9BA><C699><EFBFBD>=Assets/SteamVR/InteractionSystem/Longbow/Scripts/ArrowHand.csr<><72>U<00><>* ArrowHandb!//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: The object attached to the player's hand that spawns and fires the
// arrow
//
//=============================================================================
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class ArrowHand : MonoBehaviour
{
private Hand hand;
private Longbow bow;
private GameObject currentArrow;
public GameObject arrowPrefab;
public Transform arrowNockTransform;
public float nockDistance = 0.1f;
public float lerpCompleteDistance = 0.08f;
public float rotationLerpThreshold = 0.15f;
public float positionLerpThreshold = 0.15f;
private bool allowArrowSpawn = true;
private bool nocked;
private bool inNockRange = false;
private bool arrowLerpComplete = false;
public SoundPlayOneshot arrowSpawnSound;
private AllowTeleportWhileAttachedToHand allowTeleport = null;
public int maxArrowCount = 10;
private List<GameObject> arrowList;
//-------------------------------------------------
void Awake()
{
allowTeleport = GetComponent<AllowTeleportWhileAttachedToHand>();
allowTeleport.teleportAllowed = true;
allowTeleport.overrideHoverLock = false;
arrowList = new List<GameObject>();
}
//-------------------------------------------------
private void OnAttachedToHand( Hand attachedHand )
{
hand = attachedHand;
FindBow();
}
//-------------------------------------------------
private GameObject InstantiateArrow()
{
GameObject arrow = Instantiate( arrowPrefab, arrowNockTransform.position, arrowNockTransform.rotation ) as GameObject;
arrow.name = "Bow Arrow";
arrow.transform.parent = arrowNockTransform;
Util.ResetTransform( arrow.transform );
arrowList.Add( arrow );
while ( arrowList.Count > maxArrowCount )
{
GameObject oldArrow = arrowList[0];
arrowList.RemoveAt( 0 );
if ( oldArrow )
{
Destroy( oldArrow );
}
}
return arrow;
}
//-------------------------------------------------
private void HandAttachedUpdate( Hand hand )
{
if ( bow == null )
{
FindBow();
}
if ( bow == null )
{
return;
}
if ( allowArrowSpawn && ( currentArrow == null ) ) // If we're allowed to have an active arrow in hand but don't yet, spawn one
{
currentArrow = InstantiateArrow();
arrowSpawnSound.Play();
}
float distanceToNockPosition = Vector3.Distance( transform.parent.position, bow.nockTransform.position );
// If there's an arrow spawned in the hand and it's not nocked yet
if ( !nocked )
{
// If we're close enough to nock position that we want to start arrow rotation lerp, do so
if ( distanceToNockPosition < rotationLerpThreshold )
{
float lerp = Util.RemapNumber( distanceToNockPosition, rotationLerpThreshold, lerpCompleteDistance, 0, 1 );
arrowNockTransform.rotation = Quaternion.Lerp( arrowNockTransform.parent.rotation, bow.nockRestTransform.rotation, lerp );
}
else // Not close enough for rotation lerp, reset rotation
{
arrowNockTransform.localRotation = Quaternion.identity;
}
// If we're close enough to the nock position that we want to start arrow position lerp, do so
if ( distanceToNockPosition < positionLerpThreshold )
{
float posLerp = Util.RemapNumber( distanceToNockPosition, positionLerpThreshold, lerpCompleteDistance, 0, 1 );
posLerp = Mathf.Clamp( posLerp, 0f, 1f );
arrowNockTransform.position = Vector3.Lerp( arrowNockTransform.parent.position, bow.nockRestTransform.position, posLerp );
}
else // Not close enough for position lerp, reset position
{
arrowNockTransform.position = arrowNockTransform.parent.position;
}
// Give a haptic tick when lerp is visually complete
if ( distanceToNockPosition < lerpCompleteDistance )
{
if ( !arrowLerpComplete )
{
arrowLerpComplete = true;
hand.controller.TriggerHapticPulse( 500 );
}
}
else
{
if ( arrowLerpComplete )
{
arrowLerpComplete = false;
}
}
// Allow nocking the arrow when controller is close enough
if ( distanceToNockPosition < nockDistance )
{
if ( !inNockRange )
{
inNockRange = true;
bow.ArrowInPosition();
}
}
else
{
if ( inNockRange )
{
inNockRange = false;
}
}
// If arrow is close enough to the nock position and we're pressing the trigger, and we're not nocked yet, Nock
if ( ( distanceToNockPosition < nockDistance ) && hand.controller.GetPress( SteamVR_Controller.ButtonMask.Trigger ) && !nocked )
{
if ( currentArrow == null )
{
currentArrow = InstantiateArrow();
}
nocked = true;
bow.StartNock( this );
hand.HoverLock( GetComponent<Interactable>() );
allowTeleport.teleportAllowed = false;
currentArrow.transform.parent = bow.nockTransform;
Util.ResetTransform( currentArrow.transform );
Util.ResetTransform( arrowNockTransform );
}
}
// If arrow is nocked, and we release the trigger
if ( nocked && ( !hand.controller.GetPress( SteamVR_Controller.ButtonMask.Trigger ) || hand.controller.GetPressUp( SteamVR_Controller.ButtonMask.Trigger ) ) )
{
if ( bow.pulled ) // If bow is pulled back far enough, fire arrow, otherwise reset arrow in arrowhand
{
FireArrow();
}
else
{
arrowNockTransform.rotation = currentArrow.transform.rotation;
currentArrow.transform.parent = arrowNockTransform;
Util.ResetTransform( currentArrow.transform );
nocked = false;
bow.ReleaseNock();
hand.HoverUnlock( GetComponent<Interactable>() );
allowTeleport.teleportAllowed = true;
}
bow.StartRotationLerp(); // Arrow is releasing from the bow, tell the bow to lerp back to controller rotation
}
}
//-------------------------------------------------
private void OnDetachedFromHand( Hand hand )
{
Destroy( gameObject );
}
//-------------------------------------------------
private void FireArrow()
{
currentArrow.transform.parent = null;
Arrow arrow = currentArrow.GetComponent<Arrow>();
arrow.shaftRB.isKinematic = false;
arrow.shaftRB.useGravity = true;
arrow.shaftRB.transform.GetComponent<BoxCollider>().enabled = true;
arrow.arrowHeadRB.isKinematic = false;
arrow.arrowHeadRB.useGravity = true;
arrow.arrowHeadRB.transform.GetComponent<BoxCollider>().enabled = true;
arrow.arrowHeadRB.AddForce( currentArrow.transform.forward * bow.GetArrowVelocity(), ForceMode.VelocityChange );
arrow.arrowHeadRB.AddTorque( currentArrow.transform.forward * 10 );
nocked = false;
currentArrow.GetComponent<Arrow>().ArrowReleased( bow.GetArrowVelocity() );
bow.ArrowReleased();
allowArrowSpawn = false;
Invoke( "EnableArrowSpawn", 0.5f );
StartCoroutine( ArrowReleaseHaptics() );
currentArrow = null;
allowTeleport.teleportAllowed = true;
}
//-------------------------------------------------
private void EnableArrowSpawn()
{
allowArrowSpawn = true;
}
//-------------------------------------------------
private IEnumerator ArrowReleaseHaptics()
{
yield return new WaitForSeconds( 0.05f );
hand.otherHand.controller.TriggerHapticPulse( 1500 );
yield return new WaitForSeconds( 0.05f );
hand.otherHand.controller.TriggerHapticPulse( 800 );
yield return new WaitForSeconds( 0.05f );
hand.otherHand.controller.TriggerHapticPulse( 500 );
yield return new WaitForSeconds( 0.05f );
hand.otherHand.controller.TriggerHapticPulse( 300 );
}
//-------------------------------------------------
private void OnHandFocusLost( Hand hand )
{
gameObject.SetActive( false );
}
//-------------------------------------------------
private void OnHandFocusAcquired( Hand hand )
{
gameObject.SetActive( true );
}
//-------------------------------------------------
private void FindBow()
{
bow = hand.otherHand.GetComponentInChildren<Longbow>();
}
}
}
<00><>* ArrowHandValve.VR.InteractionSystemAssembly-CSharp.dll