2023-03-25 15:52:22 +08:00
|
|
|
using SHADE;
|
2022-11-21 00:12:09 +08:00
|
|
|
using SHADE_Scripting;
|
2023-02-03 19:37:18 +08:00
|
|
|
using SHADE_Scripting.Audio;
|
2022-11-02 00:25:43 +08:00
|
|
|
using System;
|
2023-02-02 20:56:55 +08:00
|
|
|
using System.Collections.Generic;
|
2022-11-02 00:25:43 +08:00
|
|
|
using static PlayerController;
|
2022-11-23 20:26:53 +08:00
|
|
|
using static Item;
|
2022-11-02 00:25:43 +08:00
|
|
|
|
|
|
|
public class PickAndThrow : Script
|
|
|
|
{
|
2023-02-20 19:53:22 +08:00
|
|
|
public Vector3 throwForce = new Vector3(10.0f, 8.0f, 10.0f);
|
2022-11-25 14:45:19 +08:00
|
|
|
public Vector3 cameraArmOffSet = new Vector3(0.0f, 0.25f, 0.0f);
|
|
|
|
public GameObject item { get; set; }
|
2022-11-21 00:12:09 +08:00
|
|
|
public float delayTimer = 1.0f;
|
|
|
|
public float aimingLength = 1.5f;
|
|
|
|
|
|
|
|
private float timer;
|
2022-11-04 17:31:53 +08:00
|
|
|
private PlayerController pc;
|
2022-11-02 17:31:57 +08:00
|
|
|
private Transform itemTransform;
|
2022-11-25 16:23:26 +08:00
|
|
|
private RigidBody itemRidigBody;
|
2022-11-25 14:45:19 +08:00
|
|
|
private Collider itemCollider;
|
2022-11-23 20:26:53 +08:00
|
|
|
private Item itemScript;
|
2022-11-25 14:45:19 +08:00
|
|
|
private Transform raccoonHoldLocation;
|
2023-03-05 15:35:57 +08:00
|
|
|
public ThirdPersonCamera tpc { get; set; }
|
2022-11-02 17:31:57 +08:00
|
|
|
private float lastXDir;
|
|
|
|
private float lastZDir;
|
2022-11-25 14:45:19 +08:00
|
|
|
private bool inRange = false;
|
2022-11-25 16:23:26 +08:00
|
|
|
public bool throwItem = false;
|
2023-03-05 15:35:57 +08:00
|
|
|
public Vector3 prevTargetOffSet { get; set; }
|
2022-11-24 14:05:02 +08:00
|
|
|
|
|
|
|
[Tooltip("Lenght of ray")]
|
2022-11-25 00:54:45 +08:00
|
|
|
public float rayDistance = 1;
|
2022-11-21 00:12:09 +08:00
|
|
|
|
2023-02-04 16:02:59 +08:00
|
|
|
[Tooltip("Height of ray")]
|
|
|
|
public float rayHeight = 0.1f;
|
|
|
|
|
2023-03-14 17:18:52 +08:00
|
|
|
[NonSerialized]
|
|
|
|
private TweenThread camArmTween;
|
|
|
|
[NonSerialized]
|
2023-03-15 19:39:12 +08:00
|
|
|
private TweenThreadVec3 offSetCamTween;
|
|
|
|
[NonSerialized]
|
2023-03-17 00:31:30 +08:00
|
|
|
private TweenThread FOVTween;
|
|
|
|
|
|
|
|
public float lerpPickUpDuration = 0.75f;
|
|
|
|
private float pickUptimer = 0.0f;
|
|
|
|
private bool foodHoldReach = false;
|
2023-03-14 17:18:52 +08:00
|
|
|
|
2023-03-15 19:39:12 +08:00
|
|
|
public float tweenAimDuration = 0.3f;
|
|
|
|
private bool camTweenUpdate = false;
|
2023-03-14 17:18:52 +08:00
|
|
|
|
2023-03-17 00:31:30 +08:00
|
|
|
public float aimingFOV = 15.0f;
|
|
|
|
|
2023-03-21 17:55:19 +08:00
|
|
|
private TrajectoryRenderable trajComp;
|
|
|
|
private Vector3 currThrowForce;
|
|
|
|
private float currentItemMass;
|
|
|
|
|
|
|
|
public uint trajMaxSteps = 50;
|
|
|
|
public float trajTimeSteps = 0.03f;
|
|
|
|
|
|
|
|
|
2022-11-02 00:25:43 +08:00
|
|
|
protected override void awake()
|
|
|
|
{
|
|
|
|
pc = GetScript<PlayerController>();
|
2023-03-25 02:38:56 +08:00
|
|
|
if (!pc)
|
2022-11-24 14:05:02 +08:00
|
|
|
Debug.LogError("PLAYER CONTROLLER EMPTY");
|
2022-11-21 00:12:09 +08:00
|
|
|
|
2022-11-02 17:31:57 +08:00
|
|
|
raccoonHoldLocation = GetComponentInChildren<Transform>();
|
2022-11-21 21:01:44 +08:00
|
|
|
if (!raccoonHoldLocation)
|
2022-11-24 14:05:02 +08:00
|
|
|
Debug.LogError("CHILD EMPTY");
|
2022-11-21 00:12:09 +08:00
|
|
|
|
|
|
|
tpc = GetScriptInChildren<ThirdPersonCamera>();
|
2023-03-25 02:38:56 +08:00
|
|
|
if (!tpc)
|
2022-11-24 14:05:02 +08:00
|
|
|
Debug.LogError("TPC EMPTY");
|
|
|
|
|
2023-03-25 02:38:56 +08:00
|
|
|
AudioHandler.audioClipHandlers["SFXThrowLarge"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_throw_large");
|
|
|
|
AudioHandler.audioClipHandlers["SFXThrowMedium"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_throw_medium");
|
|
|
|
AudioHandler.audioClipHandlers["SFXThrowSmall"] = Audio.CreateAudioClip("event:/Raccoon/raccoon_throw_small");
|
2023-02-03 19:37:18 +08:00
|
|
|
|
2022-11-21 00:12:09 +08:00
|
|
|
timer = delayTimer;
|
2023-03-21 17:55:19 +08:00
|
|
|
|
|
|
|
trajComp = GetComponentInChildren<TrajectoryRenderable>();
|
2023-03-25 02:38:56 +08:00
|
|
|
if (!trajComp)
|
2023-03-21 17:55:19 +08:00
|
|
|
Debug.LogError("TrajectoryRenderable MISSING");
|
2022-11-02 00:25:43 +08:00
|
|
|
}
|
2023-03-14 17:18:52 +08:00
|
|
|
|
|
|
|
protected override void start()
|
|
|
|
{
|
|
|
|
}
|
2022-11-02 00:25:43 +08:00
|
|
|
protected override void update()
|
|
|
|
{
|
2023-03-02 17:33:02 +08:00
|
|
|
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
|
2023-02-21 19:31:50 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-11-25 16:23:26 +08:00
|
|
|
|
2023-02-21 19:31:50 +08:00
|
|
|
if (timer <= delayTimer)
|
2022-11-21 00:12:09 +08:00
|
|
|
timer += Time.DeltaTimeF;
|
|
|
|
|
2022-11-13 21:56:28 +08:00
|
|
|
CalculateDir();
|
2022-11-25 00:54:45 +08:00
|
|
|
CastRay();
|
2022-11-02 17:31:57 +08:00
|
|
|
|
2023-03-15 19:39:12 +08:00
|
|
|
if (camTweenUpdate)
|
|
|
|
{
|
|
|
|
pc.camArm.TargetOffset = offSetCamTween.GetValue();
|
|
|
|
pc.camArm.ArmLength = camArmTween.GetValue();
|
2023-03-17 00:31:30 +08:00
|
|
|
pc.cam.FOV = FOVTween.GetValue();
|
2023-03-15 19:39:12 +08:00
|
|
|
|
2023-03-17 00:31:30 +08:00
|
|
|
if (offSetCamTween.IsCompleted() && camArmTween.IsCompleted() && FOVTween.IsCompleted())
|
2023-03-15 19:39:12 +08:00
|
|
|
camTweenUpdate = false;
|
|
|
|
}
|
|
|
|
|
2022-11-25 16:23:26 +08:00
|
|
|
if (pc && itemRidigBody && itemTransform && itemCollider)
|
2022-11-02 00:25:43 +08:00
|
|
|
{
|
2022-11-20 16:27:39 +08:00
|
|
|
if (pc.holdItem)
|
2022-11-02 17:31:57 +08:00
|
|
|
{
|
2023-03-15 19:39:12 +08:00
|
|
|
TweenFood();
|
2022-11-25 00:54:45 +08:00
|
|
|
itemTransform.LocalRotation = pc.tranform.LocalRotation;
|
2023-03-15 19:39:12 +08:00
|
|
|
itemRidigBody.ClearForces();
|
|
|
|
itemRidigBody.ClearTorque();
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody.LinearVelocity = Vector3.Zero;
|
|
|
|
itemRidigBody.AngularVelocity = Vector3.Zero;
|
2022-11-20 16:27:39 +08:00
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
|
|
|
{
|
2022-11-21 00:12:09 +08:00
|
|
|
pc.isAiming = true;
|
2023-03-17 00:31:30 +08:00
|
|
|
TweenAimCamArm(true);
|
2022-11-21 00:12:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Input.GetMouseButtonUp(Input.MouseCode.LeftButton) && pc.isAiming)
|
|
|
|
{
|
2023-03-25 02:38:56 +08:00
|
|
|
if (itemScript.currCategory == ItemCategory.LIGHT)
|
|
|
|
AudioHandler.audioClipHandlers["SFXThrowSmall"].Play();
|
|
|
|
else if (itemScript.currCategory == ItemCategory.MEDIUM)
|
|
|
|
AudioHandler.audioClipHandlers["SFXThrowMedium"].Play();
|
|
|
|
else
|
|
|
|
AudioHandler.audioClipHandlers["SFXThrowLarge"].Play();
|
|
|
|
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody.IsGravityEnabled = true;
|
|
|
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
2022-11-21 00:12:09 +08:00
|
|
|
pc.isAiming = false;
|
2023-03-17 00:31:30 +08:00
|
|
|
TweenAimCamArm(false);
|
2022-11-20 16:27:39 +08:00
|
|
|
pc.holdItem = false;
|
2023-03-17 00:31:30 +08:00
|
|
|
foodHoldReach = false;
|
2022-11-20 16:27:39 +08:00
|
|
|
inRange = false;
|
2022-11-25 16:23:26 +08:00
|
|
|
throwItem = true;
|
2023-03-14 17:18:52 +08:00
|
|
|
PlayThrowAnimation();
|
2022-11-21 00:12:09 +08:00
|
|
|
timer = 0.0f;
|
2022-11-20 16:27:39 +08:00
|
|
|
}
|
|
|
|
|
2022-11-23 20:26:53 +08:00
|
|
|
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && !pc.isAiming)
|
2022-11-20 16:27:39 +08:00
|
|
|
{
|
|
|
|
pc.holdItem = false;
|
2023-03-17 00:31:30 +08:00
|
|
|
foodHoldReach = false;
|
2022-11-20 16:27:39 +08:00
|
|
|
inRange = false;
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody.IsGravityEnabled = true;
|
|
|
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
2022-11-20 16:27:39 +08:00
|
|
|
ResetItemObject();
|
|
|
|
}
|
2022-11-23 20:26:53 +08:00
|
|
|
|
|
|
|
if (Input.GetMouseButtonDown(Input.MouseCode.RightButton) && pc.isAiming)
|
|
|
|
{
|
|
|
|
pc.isAiming = false;
|
2023-03-08 17:00:43 +08:00
|
|
|
pc.cam.FOV = Settings.cameraFOV;
|
2023-03-17 00:31:30 +08:00
|
|
|
TweenAimCamArm(false);
|
2022-11-23 20:26:53 +08:00
|
|
|
}
|
|
|
|
|
2022-11-02 17:31:57 +08:00
|
|
|
}
|
2022-11-20 16:27:39 +08:00
|
|
|
else if (!pc.holdItem)
|
2022-11-25 16:23:26 +08:00
|
|
|
{
|
|
|
|
itemRidigBody.IsGravityEnabled = true;
|
|
|
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
2022-11-25 14:45:19 +08:00
|
|
|
}
|
2022-11-02 00:25:43 +08:00
|
|
|
}
|
2022-11-13 21:56:28 +08:00
|
|
|
|
2022-11-21 00:12:09 +08:00
|
|
|
if (timer > delayTimer && pc && !pc.holdItem && inRange && Input.GetMouseButtonDown(Input.MouseCode.LeftButton))
|
2022-11-13 21:56:28 +08:00
|
|
|
{
|
2022-11-21 00:12:09 +08:00
|
|
|
if (pc.currentState == RaccoonStates.WALKING || pc.currentState == RaccoonStates.IDLE)
|
|
|
|
{
|
|
|
|
pc.holdItem = true;
|
|
|
|
RetrieveItemComponets();
|
2023-03-14 17:18:52 +08:00
|
|
|
PlayPickUpAnimation();
|
2022-11-21 00:12:09 +08:00
|
|
|
}
|
2022-11-13 21:56:28 +08:00
|
|
|
}
|
2023-03-21 17:55:19 +08:00
|
|
|
|
|
|
|
if (pc.isAiming && itemScript)
|
|
|
|
{
|
|
|
|
if (itemScript.currCategory == ItemCategory.LIGHT)
|
|
|
|
currThrowForce = new Vector3(throwForce.x * lastXDir, throwForce.y + (throwForce.y * GetPitchRatioRange()), throwForce.z * lastZDir) * 0.2f;
|
|
|
|
else if (itemScript.currCategory == ItemCategory.MEDIUM)
|
|
|
|
currThrowForce = new Vector3(throwForce.x * lastXDir, throwForce.y + (throwForce.y * GetPitchRatioRange()), throwForce.z * lastZDir) * 0.75f;
|
|
|
|
else
|
|
|
|
currThrowForce = new Vector3(throwForce.x * lastXDir, throwForce.y + (throwForce.y * GetPitchRatioRange()), throwForce.z * lastZDir);
|
|
|
|
|
|
|
|
if (pc.holdItem && trajComp)
|
|
|
|
trajComp.SimulateTrajectory(item.EntityId, currentItemMass, currThrowForce, trajTimeSteps, trajMaxSteps);
|
|
|
|
}
|
2022-11-02 00:25:43 +08:00
|
|
|
}
|
2022-11-10 13:06:37 +08:00
|
|
|
|
2022-11-24 14:05:02 +08:00
|
|
|
protected override void fixedUpdate()
|
|
|
|
{
|
2023-03-02 17:33:02 +08:00
|
|
|
if (GameManager.Instance.GamePause || !GameManager.Instance.stealFoodPopUpDone)
|
2023-02-21 19:31:50 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-25 16:23:26 +08:00
|
|
|
if (throwItem && itemRidigBody && pc)
|
|
|
|
{
|
2023-03-21 17:55:19 +08:00
|
|
|
itemRidigBody.AddForce(currThrowForce);
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody.LinearVelocity += pc.rb.LinearVelocity;
|
|
|
|
throwItem = false;
|
|
|
|
ResetItemObject();
|
|
|
|
}
|
2022-11-24 14:05:02 +08:00
|
|
|
}
|
|
|
|
|
2023-03-25 15:52:22 +08:00
|
|
|
public void SetItemGravityBack()
|
|
|
|
{
|
|
|
|
if(itemRidigBody)
|
|
|
|
itemRidigBody.IsGravityEnabled = true;
|
|
|
|
if(itemCollider)
|
|
|
|
itemCollider.GetCollisionShape(0).IsTrigger = false;
|
|
|
|
}
|
|
|
|
|
2023-03-05 15:35:57 +08:00
|
|
|
public void ResetItemObject()
|
2022-11-10 13:06:37 +08:00
|
|
|
{
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody = null;
|
2022-11-10 13:06:37 +08:00
|
|
|
itemTransform = null;
|
2022-11-25 14:45:19 +08:00
|
|
|
itemCollider = null;
|
2022-11-23 20:26:53 +08:00
|
|
|
itemScript = null;
|
2022-11-10 13:06:37 +08:00
|
|
|
item = new GameObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void RetrieveItemComponets()
|
|
|
|
{
|
|
|
|
//get the transform of the given item
|
2022-11-25 16:23:26 +08:00
|
|
|
if (item.GetScript<Item>() && !itemTransform && !itemRidigBody)
|
2022-11-10 13:06:37 +08:00
|
|
|
{
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody = item.GetComponent<RigidBody>();
|
|
|
|
if (!itemRidigBody)
|
2022-11-20 16:27:39 +08:00
|
|
|
Debug.Log("Item rb EMPTY");
|
|
|
|
else
|
|
|
|
{
|
2023-03-21 17:55:19 +08:00
|
|
|
currentItemMass = itemRidigBody.Mass;
|
2022-11-25 16:23:26 +08:00
|
|
|
itemRidigBody.IsGravityEnabled = false;
|
2022-11-20 16:27:39 +08:00
|
|
|
}
|
|
|
|
|
2022-11-10 13:06:37 +08:00
|
|
|
itemTransform = item.GetComponent<Transform>();
|
2022-11-25 14:45:19 +08:00
|
|
|
if (!itemTransform)
|
2022-11-10 13:06:37 +08:00
|
|
|
Debug.Log("Item transform EMPTY");
|
2022-11-20 16:27:39 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
itemTransform.LocalEulerAngles = Vector3.Zero;
|
|
|
|
}
|
2022-11-10 13:06:37 +08:00
|
|
|
|
2022-11-25 14:45:19 +08:00
|
|
|
itemCollider = item.GetComponent<Collider>();
|
|
|
|
if (!itemCollider)
|
|
|
|
Debug.Log("Item collider EMPTY");
|
|
|
|
else
|
|
|
|
{
|
2022-11-25 16:23:26 +08:00
|
|
|
itemCollider.GetCollisionShape(0).IsTrigger = true;
|
2022-11-25 14:45:19 +08:00
|
|
|
}
|
|
|
|
|
2022-11-23 20:26:53 +08:00
|
|
|
itemScript = item.GetScript<Item>();
|
|
|
|
if(!itemScript)
|
|
|
|
Debug.Log("Item script EMPTY");
|
2022-11-10 13:06:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-13 21:56:28 +08:00
|
|
|
private void CalculateDir()
|
|
|
|
{
|
2022-11-25 14:45:19 +08:00
|
|
|
if (pc && pc.cam)
|
2022-11-13 21:56:28 +08:00
|
|
|
{
|
2022-11-25 14:45:19 +08:00
|
|
|
Vector3 camerAixs = pc.cam.GetForward();
|
2022-11-13 21:56:28 +08:00
|
|
|
camerAixs.y = 0;
|
|
|
|
camerAixs.Normalise();
|
|
|
|
lastXDir = camerAixs.x;
|
|
|
|
lastZDir = camerAixs.z;
|
|
|
|
}
|
|
|
|
}
|
2022-11-10 13:06:37 +08:00
|
|
|
|
2022-11-24 14:05:02 +08:00
|
|
|
private void CastRay()
|
2022-11-21 00:12:09 +08:00
|
|
|
{
|
2022-11-25 00:54:45 +08:00
|
|
|
if (pc != null)
|
2022-11-24 14:05:02 +08:00
|
|
|
{
|
2023-02-03 21:28:50 +08:00
|
|
|
Vector3 dirNor = pc.tranform.Forward;
|
|
|
|
Vector3 playerRayPos = pc.tranform.GlobalPosition;
|
2023-02-04 16:02:59 +08:00
|
|
|
playerRayPos.y += rayHeight;
|
2023-02-03 21:28:50 +08:00
|
|
|
dirNor.Normalise();
|
2023-03-15 19:39:12 +08:00
|
|
|
List<RaycastHit> rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(25.0f))), rayDistance, false, (ushort)65535);
|
|
|
|
List<RaycastHit> rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-25.0f))), rayDistance, false, (ushort)65535);
|
|
|
|
List<RaycastHit> rayList3 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(12.5f))), rayDistance, false, (ushort)65535);
|
|
|
|
List<RaycastHit> rayList4 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-12.5f))), rayDistance, false, (ushort)65535);
|
|
|
|
List<RaycastHit> rayList5 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance , false, (ushort)65535);
|
2023-02-03 21:28:50 +08:00
|
|
|
|
|
|
|
if (rayList1.Count > 0)
|
|
|
|
{
|
|
|
|
RaycastHit ray1 = rayList1[0];
|
|
|
|
inRange = CheckForItem(ray1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (rayList2.Count > 0)
|
|
|
|
{
|
|
|
|
RaycastHit ray2 = rayList2[0];
|
|
|
|
inRange = CheckForItem(ray2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (rayList3.Count > 0)
|
|
|
|
{
|
|
|
|
RaycastHit ray3 = rayList3[0];
|
|
|
|
inRange = CheckForItem(ray3);
|
|
|
|
return;
|
|
|
|
}
|
2023-03-15 19:39:12 +08:00
|
|
|
else if (rayList4.Count > 0)
|
|
|
|
{
|
|
|
|
RaycastHit ray4 = rayList4[0];
|
|
|
|
inRange = CheckForItem(ray4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (rayList5.Count > 0)
|
|
|
|
{
|
|
|
|
RaycastHit ray5 = rayList5[0];
|
|
|
|
inRange = CheckForItem(ray5);
|
|
|
|
return;
|
|
|
|
}
|
2023-02-03 21:28:50 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
inRange = false;
|
|
|
|
}
|
2022-11-24 14:05:02 +08:00
|
|
|
}
|
2022-11-21 00:12:09 +08:00
|
|
|
}
|
|
|
|
|
2022-11-25 00:54:45 +08:00
|
|
|
private bool CheckForItem(RaycastHit ray)
|
2022-11-02 17:31:57 +08:00
|
|
|
{
|
2022-11-25 00:54:45 +08:00
|
|
|
if (ray.Hit)
|
2022-11-02 17:31:57 +08:00
|
|
|
{
|
2022-11-25 00:54:45 +08:00
|
|
|
if (ray.Other.Value.GetScript<Item>() && !pc.holdItem)
|
|
|
|
{
|
|
|
|
item = ray.Other.Value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
2022-11-02 17:31:57 +08:00
|
|
|
}
|
2022-11-25 00:54:45 +08:00
|
|
|
return false;
|
2022-11-02 17:31:57 +08:00
|
|
|
}
|
|
|
|
|
2023-02-20 19:53:22 +08:00
|
|
|
private float GetPitchRatioRange()
|
|
|
|
{
|
|
|
|
return (pc.camArm.Pitch - tpc.pitchUpperClamp) / (tpc.pitchLowerClamp - tpc.pitchUpperClamp);
|
|
|
|
}
|
|
|
|
|
2023-03-14 17:18:52 +08:00
|
|
|
private void PlayPickUpAnimation()
|
|
|
|
{
|
|
|
|
if (PlayerAnimations.Instance)
|
|
|
|
{
|
|
|
|
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerPickUpClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerCarryIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void PlayThrowAnimation()
|
|
|
|
{
|
|
|
|
if (PlayerAnimations.Instance)
|
|
|
|
{
|
|
|
|
PlayerAnimations.Instance.playerAnimator.PlayOneShot(PlayerAnimations.Instance.playerThrowClip);
|
|
|
|
PlayerAnimations.Instance.playerAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.playerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.BagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.BagAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.BagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.silhoPlayerAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.PlayOneShot(PlayerAnimations.Instance.playerPickUpClip);
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.OnClipFinished.RegisterAction((x) =>
|
|
|
|
{
|
|
|
|
if (x.FinishedClip == PlayerAnimations.Instance.playerThrowClip)
|
|
|
|
{
|
|
|
|
if (pc.isMoveKeyPress)
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerWalkClip);
|
|
|
|
else
|
|
|
|
PlayerAnimations.Instance.silhoBagAnimator.Play(PlayerAnimations.Instance.playerIdleClip);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2022-11-25 00:54:45 +08:00
|
|
|
|
2023-03-15 19:39:12 +08:00
|
|
|
private void TweenFood()
|
|
|
|
{
|
|
|
|
|
2023-03-17 00:31:30 +08:00
|
|
|
if (!foodHoldReach)
|
|
|
|
{
|
|
|
|
pickUptimer += Time.DeltaTimeF;
|
|
|
|
itemTransform.LocalPosition = Vector3.Lerp(itemTransform.LocalPosition, raccoonHoldLocation.GlobalPosition, pickUptimer / lerpPickUpDuration);
|
|
|
|
}
|
|
|
|
else
|
2023-03-15 19:39:12 +08:00
|
|
|
itemTransform.LocalPosition = raccoonHoldLocation.GlobalPosition;
|
|
|
|
|
2023-03-17 00:31:30 +08:00
|
|
|
if (pickUptimer >= lerpPickUpDuration)
|
|
|
|
{
|
|
|
|
foodHoldReach = true;
|
|
|
|
pickUptimer = 0.0f;
|
|
|
|
}
|
2023-03-15 19:39:12 +08:00
|
|
|
}
|
|
|
|
|
2023-03-26 18:10:58 +08:00
|
|
|
public void TweenAimCamArm(bool aim)
|
2023-03-15 19:39:12 +08:00
|
|
|
{
|
2023-03-17 00:31:30 +08:00
|
|
|
|
|
|
|
if (aim)
|
2023-03-15 19:39:12 +08:00
|
|
|
{
|
|
|
|
offSetCamTween = TweenManager.CreateTweenThreadVec3(tweenAimDuration, pc.camArm.TargetOffset, cameraArmOffSet, EASING_METHOD.EASE_IN_SINE);
|
2023-03-17 00:31:30 +08:00
|
|
|
camArmTween = TweenManager.CreateTweenThread(tweenAimDuration, pc.camArm.ArmLength, aimingLength, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
FOVTween = TweenManager.CreateTweenThread(tweenAimDuration, pc.cam.FOV, Settings.cameraFOV + aimingFOV, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offSetCamTween = TweenManager.CreateTweenThreadVec3(tweenAimDuration, pc.camArm.TargetOffset, prevTargetOffSet, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
camArmTween = TweenManager.CreateTweenThread(tweenAimDuration, pc.camArm.ArmLength, tpc.armLength, EASING_METHOD.EASE_IN_SINE);
|
|
|
|
FOVTween = TweenManager.CreateTweenThread(tweenAimDuration, pc.cam.FOV, Settings.cameraFOV , EASING_METHOD.EASE_IN_SINE);
|
2023-03-15 19:39:12 +08:00
|
|
|
}
|
2023-03-17 00:31:30 +08:00
|
|
|
camTweenUpdate = true;
|
2023-03-15 19:39:12 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-02 00:25:43 +08:00
|
|
|
}
|