门式起重机scene更新
This commit is contained in:
parent
3a06291848
commit
9ab41d4c92
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 48f91517c7cf6824c9770be0c3079c59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!84 &8400000
|
||||
RenderTexture:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: "\u95E8\u5F0F\u8D77\u91CD\u673Aall"
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_ForcedFallbackFormat: 4
|
||||
m_DownscaleFallback: 0
|
||||
m_IsAlphaChannelOptional: 0
|
||||
serializedVersion: 5
|
||||
m_Width: 1920
|
||||
m_Height: 1080
|
||||
m_AntiAliasing: 1
|
||||
m_MipCount: -1
|
||||
m_DepthStencilFormat: 94
|
||||
m_ColorFormat: 8
|
||||
m_MipMap: 0
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_BindMS: 0
|
||||
m_EnableCompatibleFormat: 1
|
||||
m_EnableRandomWrite: 0
|
||||
m_TextureSettings:
|
||||
serializedVersion: 2
|
||||
m_FilterMode: 1
|
||||
m_Aniso: 0
|
||||
m_MipBias: 0
|
||||
m_WrapU: 1
|
||||
m_WrapV: 1
|
||||
m_WrapW: 1
|
||||
m_Dimension: 2
|
||||
m_VolumeDepth: 1
|
||||
m_ShadowSamplingMode: 2
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b301338939bf34c489fa5de79f62f75f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 8400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,18 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 88c0b673c32c6eb46a0d500e50461234
|
||||
VideoClipImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
frameRange: 0
|
||||
startFrame: -1
|
||||
endFrame: -1
|
||||
colorSpace: 0
|
||||
deinterlace: 0
|
||||
encodeAlpha: 0
|
||||
flipVertical: 0
|
||||
flipHorizontal: 0
|
||||
importAudio: 1
|
||||
targetSettings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f6f85c465e3a044481dcd83864e6806
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 98d161d5ab1012b4da672c48c9bd6e80
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MenShiHook : MonoBehaviour
|
||||
{
|
||||
private GameObject candidateCargo; // 当前可被吸附的货物
|
||||
private GameObject grabbedCargo; // 已吸附的货物
|
||||
|
||||
public bool _isCanGet=false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//如果钩子被放到最底下了
|
||||
if (MenShiManager.Instance.currentBlendValue > 99)
|
||||
{
|
||||
|
||||
_isCanGet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isCanGet = false;
|
||||
}
|
||||
|
||||
if(grabbedCargo != null)
|
||||
{
|
||||
float zValue = -0.16f + ((100-MenShiManager.Instance.currentBlendValue) / 100) * 0.142f;
|
||||
|
||||
grabbedCargo.transform.localPosition = new Vector3(grabbedCargo.transform.localPosition.x, grabbedCargo.transform.localPosition.y, zValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Debug.Log("触碰了");
|
||||
|
||||
if (other.CompareTag("货物"))
|
||||
{
|
||||
candidateCargo = other.gameObject;
|
||||
Debug.Log("检测到货物:" + candidateCargo.name);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
Debug.Log("离开了");
|
||||
|
||||
// 离开触发区后,如果没吸附,就清空候选
|
||||
if (candidateCargo != null && other.gameObject == candidateCargo && grabbedCargo == null)
|
||||
{
|
||||
candidateCargo = null;
|
||||
Debug.Log("货物离开触发范围");
|
||||
}
|
||||
}
|
||||
|
||||
public void GrabCargo()
|
||||
{
|
||||
if (candidateCargo != null && grabbedCargo == null && _isCanGet)
|
||||
{
|
||||
grabbedCargo = candidateCargo;
|
||||
grabbedCargo.transform.SetParent(transform);
|
||||
// grabbedCargo.transform.position = attachPoint.position + (SizeZ/2);
|
||||
|
||||
Debug.Log("吸附到货物:" + grabbedCargo.name);
|
||||
}
|
||||
}
|
||||
|
||||
// 释放货物 (对应 M 键)
|
||||
public void ReleaseCargo()
|
||||
{
|
||||
if (grabbedCargo != null && _isCanGet)
|
||||
{
|
||||
grabbedCargo.transform.SetParent(null);
|
||||
grabbedCargo = null;
|
||||
Debug.Log("货物已分离");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8da4a88686253e440a26bce41377dd27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MenShiManager : MonoBehaviour
|
||||
{
|
||||
public static MenShiManager Instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
[Header("物体")]
|
||||
public Transform bridge; // 起重机
|
||||
public Transform jia; // 驾驶室
|
||||
public SkinnedMeshRenderer hookRenderer;//吊钩
|
||||
|
||||
public Transform[] YaoGan; //3个摇杆
|
||||
|
||||
[Header("移动速度")]
|
||||
[Range(1, 10)]
|
||||
public float bridgeSpeed = 0.1f; // 起重机移动速度
|
||||
[Range(1, 10)]
|
||||
public float hookSpeed = 0.1f; // 驾驶室移动速度
|
||||
|
||||
public float blendShapeSpeed = 30f;
|
||||
|
||||
[Header("移动范围限制 (X轴)")]
|
||||
[Range(-0.35f, 0.25f)]
|
||||
public float bridgeMinX = -0.35f;
|
||||
[Range(-0.35f, 0.25f)]
|
||||
public float bridgeMaxX = 0.25f;
|
||||
[Range(-0.19f, 0.04f)]
|
||||
public float jiaMinY = -0.19f;
|
||||
[Range(-0.19f, 0.04f)]
|
||||
public float jiaMaxY = 0.04f;
|
||||
|
||||
[Header("BlendShape设置")]
|
||||
public int hookBlendShapeIndex = 0; // BlendShape索引(通常是0)
|
||||
public float minBlendShapeValue = 0f; // 吊钩收起
|
||||
public float maxBlendShapeValue = 100f; // 吊钩放下
|
||||
|
||||
public float currentBlendValue = 0f;
|
||||
|
||||
private float baseColliderZ;
|
||||
|
||||
private float Max = 0f;
|
||||
private float Min = 0f;
|
||||
|
||||
public BoxCollider hookCollider; //钩子的碰撞
|
||||
|
||||
// 按钮控制标志
|
||||
private bool isBridgeLeft = false;
|
||||
private bool isBridgeRight = false;
|
||||
private bool isHookForward = false; // 对应 J 键 (input=1, 向 -x 移动)
|
||||
private bool isHookBackward = false; // 对应 L 键 (input=-1, 向 +x 移动)
|
||||
private bool isHookUp = false; // 对应 U 键 (上升)
|
||||
private bool isHookDown = false; // 对应 O 键 (下降)
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Max = -(2.49513f - 0.5113189f) / 100;
|
||||
Min = (6.295807f - 0.3099952f) / 100;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
HandleBridgeMovement();
|
||||
HandleHookMovement();
|
||||
HandleHookLift();
|
||||
}
|
||||
|
||||
|
||||
void HandleBridgeMovement()
|
||||
{
|
||||
// I/K 或按钮控制横杆前后
|
||||
float input = 0f;
|
||||
|
||||
// 键盘输入
|
||||
if (Input.GetKey(KeyCode.I))
|
||||
input += 1f;
|
||||
if (Input.GetKey(KeyCode.K))
|
||||
input -= 1f;
|
||||
|
||||
// 按钮输入
|
||||
if (isBridgeLeft)
|
||||
input += 1f;
|
||||
if (isBridgeRight)
|
||||
input -= 1f;
|
||||
|
||||
// 限制输入范围,避免超速
|
||||
input = Mathf.Clamp(input, -1f, 1f);
|
||||
|
||||
Vector3 newbrigePos = bridge.localPosition + Vector3.right * input * bridgeSpeed * Time.deltaTime;
|
||||
newbrigePos.x = Mathf.Clamp(newbrigePos.x, bridgeMinX, bridgeMaxX);
|
||||
bridge.localPosition = newbrigePos;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void HandleHookMovement()
|
||||
{
|
||||
// J/L 或按钮控制滑轮前后
|
||||
float input = 0f;
|
||||
|
||||
// 键盘输入
|
||||
if (Input.GetKey(KeyCode.J))
|
||||
input += 1f; // input=1,向 -x 移动
|
||||
if (Input.GetKey(KeyCode.L))
|
||||
input -= 1f; // input=-1,向 +x 移动
|
||||
|
||||
// 按钮输入
|
||||
if (isHookForward)
|
||||
input += 1f;
|
||||
if (isHookBackward)
|
||||
input -= 1f;
|
||||
|
||||
// 限制输入范围,避免超速
|
||||
input = Mathf.Clamp(input, -1f, 1f);
|
||||
|
||||
Vector3 newjiaPos = jia.localPosition + Vector3.up * input * hookSpeed * Time.deltaTime;
|
||||
newjiaPos.y = Mathf.Clamp(newjiaPos.y, jiaMinY, jiaMaxY);
|
||||
jia.localPosition = newjiaPos;
|
||||
}
|
||||
|
||||
void HandleHookLift()
|
||||
{
|
||||
if (hookRenderer == null)
|
||||
return;
|
||||
|
||||
float input = 0f;
|
||||
|
||||
// 键盘输入
|
||||
if (Input.GetKey(KeyCode.U))
|
||||
input += 1f; // 上升
|
||||
if (Input.GetKey(KeyCode.O))
|
||||
input -= 1f; // 下降
|
||||
|
||||
// 按钮输入
|
||||
if (isHookUp)
|
||||
input -= 1f;
|
||||
if (isHookDown)
|
||||
input += 1f;
|
||||
|
||||
// 限制输入范围,避免超速
|
||||
input = Mathf.Clamp(input, -1f, 1f);
|
||||
|
||||
currentBlendValue += input * blendShapeSpeed * Time.deltaTime;
|
||||
currentBlendValue = Mathf.Clamp(currentBlendValue, minBlendShapeValue, maxBlendShapeValue);
|
||||
|
||||
hookRenderer.SetBlendShapeWeight(hookBlendShapeIndex, currentBlendValue);
|
||||
}
|
||||
|
||||
//public void SethookColliderPos(bool isDi)
|
||||
//{
|
||||
// if (isDi)
|
||||
// {
|
||||
// hookCollider.center = new Vector3(hookCollider.center.x, hookCollider.center.y, -0.15f);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
// ========== 按钮控制公共方法 ==========
|
||||
// 桥前进 (对应 I 键)
|
||||
public void StartBridgeLeft()
|
||||
{
|
||||
isBridgeLeft = true;
|
||||
}
|
||||
|
||||
public void StopBridgeLeft()
|
||||
{
|
||||
isBridgeLeft = false;
|
||||
}
|
||||
|
||||
// 桥后退 (对应 K 键)
|
||||
public void StartBridgeRight()
|
||||
{
|
||||
isBridgeRight = true;
|
||||
}
|
||||
|
||||
public void StopBridgeRight()
|
||||
{
|
||||
isBridgeRight = false;
|
||||
}
|
||||
|
||||
// 钩子左移 (对应 J 键,向 -x)
|
||||
public void StartHookForward()
|
||||
{
|
||||
isHookForward = true;
|
||||
}
|
||||
|
||||
public void StopHookForward()
|
||||
{
|
||||
isHookForward = false;
|
||||
}
|
||||
|
||||
// 钩子右移 (对应 L 键,向 +x)
|
||||
public void StartHookBackward()
|
||||
{
|
||||
isHookBackward = true;
|
||||
}
|
||||
|
||||
public void StopHookBackward()
|
||||
{
|
||||
isHookBackward = false;
|
||||
}
|
||||
|
||||
// 钩子上? (对应 U 键)
|
||||
public void StartHookUp()
|
||||
{
|
||||
isHookUp = true;
|
||||
}
|
||||
|
||||
public void StopHookUp()
|
||||
{
|
||||
isHookUp = false;
|
||||
}
|
||||
|
||||
// 钩子下降 (对应 O 键)
|
||||
public void StartHookDown()
|
||||
{
|
||||
isHookDown = true;
|
||||
}
|
||||
|
||||
public void StopHookDown()
|
||||
{
|
||||
isHookDown = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c280d1d603e004b418ea06319902f53d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ¶à¸öÊÓÆµÂÖ²¥
|
||||
/// </summary>
|
||||
public class VideoCtrl : MonoBehaviour
|
||||
{
|
||||
public string[] AllVideoNames;
|
||||
|
||||
private string[] _allVideoPath;
|
||||
private int _nowVideoNum = 0;
|
||||
private VideoPlayer _player;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
_player = GetComponent<VideoPlayer>();
|
||||
|
||||
_allVideoPath=new string[AllVideoNames.Length];
|
||||
for (int i = 0; i < AllVideoNames.Length; i++)
|
||||
{
|
||||
_allVideoPath[i]= Path.Combine(Application.streamingAssetsPath, AllVideoNames[i] + ".mp4");
|
||||
}
|
||||
|
||||
StartCoroutine(WaitTimeToLoadNextVideo());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IEnumerator WaitTimeToLoadNextVideo()
|
||||
{
|
||||
_player.url = _allVideoPath[0];
|
||||
_player.Play();
|
||||
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
if (_player.time > (_player.length - 1))
|
||||
{
|
||||
if (_nowVideoNum < AllVideoNames.Length - 1)
|
||||
{
|
||||
_nowVideoNum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nowVideoNum = 0; ;
|
||||
}
|
||||
|
||||
_player.url = _allVideoPath[_nowVideoNum];
|
||||
_player.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2a1c50846fa73646b5a565446f51781
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b4bffe9e0556f545afe4fa566238f34
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cd2229c0a672712429b514dac15ffe1d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2caa585238f8abf4493cbceb9f3b6f72
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue