|
|
|
@ -19,6 +19,7 @@ public class HandController : MonoBehaviour
|
|
|
|
|
public float PlantMoveSpeed = 2; |
|
|
|
|
float timer; |
|
|
|
|
private Transform SettingPanel; |
|
|
|
|
private Transform OriPlantPos; |
|
|
|
|
/// <summary> |
|
|
|
|
/// 当前交互物体,交互该物体时不可移动,比如水炮 |
|
|
|
|
/// </summary> |
|
|
|
@ -26,6 +27,7 @@ public class HandController : MonoBehaviour
|
|
|
|
|
// Use this for initialization |
|
|
|
|
protected virtual void Awake() |
|
|
|
|
{ |
|
|
|
|
OriPlantPos = GameObject.Find("OriPlantPos").transform; |
|
|
|
|
moveController = GetComponentInParent<MoveController>(); |
|
|
|
|
cte = GetComponent<VRTK_ControllerEvents>(); |
|
|
|
|
|
|
|
|
@ -59,6 +61,7 @@ public class HandController : MonoBehaviour
|
|
|
|
|
private void PlantStateChange(IMessage obj) |
|
|
|
|
{ |
|
|
|
|
IsOnPlant = (bool)obj.Data; |
|
|
|
|
OriPlantPos.position = Vector3.zero; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,6 +120,11 @@ public class HandController : MonoBehaviour
|
|
|
|
|
/// <param name="e"></param> |
|
|
|
|
private void Cte_ApplicationMenuPressed(object sender, ControllerInteractionEventArgs e) |
|
|
|
|
{ |
|
|
|
|
//在拆解观测平台上不能打开菜单按钮 |
|
|
|
|
if (IsOnPlant) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (!SettingPanel.gameObject.activeInHierarchy) |
|
|
|
|
{ |
|
|
|
|
ControllerSetting.Instace.SetMenuPanel(true); |
|
|
|
@ -166,18 +174,31 @@ public class HandController : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
if (axis.x > 0) |
|
|
|
|
{//右移动 |
|
|
|
|
|
|
|
|
|
if (Plant.transform.localPosition.x > -50) |
|
|
|
|
if (OriPlantPos.position.x < -50) |
|
|
|
|
{ |
|
|
|
|
OriPlantPos.position = new Vector3(-50, OriPlantPos.position.y, OriPlantPos.position.z); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (OriPlantPos.position.x > -50) |
|
|
|
|
{ |
|
|
|
|
Plant.transform.Translate(Vector3.left * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
OriPlantPos.Translate(Vector3.left * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (Plant.transform.localPosition.x < 50) |
|
|
|
|
if (OriPlantPos.position.x > 50) |
|
|
|
|
{ |
|
|
|
|
OriPlantPos.position = new Vector3(50, OriPlantPos.position.y, OriPlantPos.position.z); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (OriPlantPos.position.x < 50) |
|
|
|
|
{ |
|
|
|
|
Plant.transform.Translate(Vector3.right * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
OriPlantPos.Translate(Vector3.right * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
@ -186,18 +207,32 @@ public class HandController : MonoBehaviour
|
|
|
|
|
if (axis.y > 0) |
|
|
|
|
{//上移动 |
|
|
|
|
|
|
|
|
|
if (Plant.transform.localPosition.y < 120) |
|
|
|
|
if (OriPlantPos.position.y > 100) |
|
|
|
|
{ |
|
|
|
|
OriPlantPos.position = new Vector3(OriPlantPos.position.x, 100, OriPlantPos.position.z); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (OriPlantPos.position.y < 100) |
|
|
|
|
{ |
|
|
|
|
Plant.transform.Translate(Vector3.up * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
OriPlantPos.transform.Translate(Vector3.up * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{//下移动 |
|
|
|
|
|
|
|
|
|
if (Plant.transform.localPosition.y > 0) |
|
|
|
|
if (OriPlantPos.position.y < 0.5) |
|
|
|
|
{ |
|
|
|
|
OriPlantPos.position = new Vector3(OriPlantPos.position.x, 0.5f, OriPlantPos.position.z); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (OriPlantPos.position.y > 0.5) |
|
|
|
|
{ |
|
|
|
|
Plant.transform.Translate(Vector3.down * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
OriPlantPos.transform.Translate(Vector3.down * Time.deltaTime * PlantMoveSpeed); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|