Trying to figure stuff out
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class FurnitureMiniature : FurnitureObject {
|
public class FurnitureMiniature : MonoBehaviour {
|
||||||
public override void Grab(Transform attachment) {
|
public void Grab(Transform attachment) {
|
||||||
transform.parent = null;
|
transform.parent = null;
|
||||||
foreach (var collider in GetComponentsInChildren<Collider>()) {
|
foreach (var collider in GetComponentsInChildren<Collider>()) {
|
||||||
collider.enabled = false;
|
collider.enabled = false;
|
||||||
@@ -14,7 +14,7 @@ public class FurnitureMiniature : FurnitureObject {
|
|||||||
mini.Duration = 0.33f;
|
mini.Duration = 0.33f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Release() {
|
public void Release() {
|
||||||
var mini = gameObject.GetComponent<WarehouseMiniatureAnim>();
|
var mini = gameObject.GetComponent<WarehouseMiniatureAnim>();
|
||||||
if (mini) {
|
if (mini) {
|
||||||
mini.End();
|
mini.End();
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
public class FurnitureObject : MonoBehaviour {
|
|
||||||
public virtual void Grab(Transform attachment) { }
|
|
||||||
public virtual void Release() { }
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 44b6e16155f118a40b4c700c55978f9d
|
|
||||||
timeCreated: 1464233125
|
|
||||||
licenseType: Free
|
|
||||||
MonoImporter:
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5199afd07a1d6704f9f637d2c69589ef
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 72f984ea83bdc9448af562fb6aae58f5
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c26ef51d558cbfd4ea5aefd315c6bce2
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
Executable
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ad48742d936eb5f4d9712328a2fa4b78
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3ed07849ee4a36e4bb43884947ad9d0b
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 042e68e76d707f64d87ad81b1553689b
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0a1e038fe41be8e46943649e975a4388
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a6c72dd2f75ee0047aee409ee24fcc50
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 268472f8b4d3fd544b30cbf900577455
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Executable
BIN
Binary file not shown.
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 93beb8d361d6fa74783fe650a8ac8345
|
||||||
|
timeCreated: 1464283623
|
||||||
|
licenseType: Free
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+43
-12
@@ -9,7 +9,7 @@ public class RightController : MonoBehaviour {
|
|||||||
SteamVR_ControllerEvents controllerEvents;
|
SteamVR_ControllerEvents controllerEvents;
|
||||||
WarehouseColumn warehouse;
|
WarehouseColumn warehouse;
|
||||||
|
|
||||||
FurnitureObject heldItem;
|
GameObject heldItem;
|
||||||
|
|
||||||
WarehouseRow whRow = null;
|
WarehouseRow whRow = null;
|
||||||
Vector3? whScrollStartPos = null;
|
Vector3? whScrollStartPos = null;
|
||||||
@@ -61,31 +61,62 @@ public class RightController : MonoBehaviour {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ray = new Ray(transform.position, transform.forward);
|
if (grabByProximity()) {
|
||||||
RaycastHit result;
|
|
||||||
bool hit = Physics.Raycast(ray, out result);
|
|
||||||
|
|
||||||
if (!hit) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = result.transform.GetComponentInParent<FurnitureObject>();
|
if (grabByLaser()) {
|
||||||
if (!item) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Grab(MiniatureAttachmentPoint);
|
|
||||||
heldItem = item;
|
|
||||||
}
|
}
|
||||||
void triggerUnclicked(object sender, ControllerClickedEventArgs e) {
|
void triggerUnclicked(object sender, ControllerClickedEventArgs e) {
|
||||||
if (heldItem == null) {
|
if (heldItem == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
heldItem.Release();
|
var furnitureMini = heldItem.GetComponent<FurnitureMiniature>();
|
||||||
|
if (furnitureMini) {
|
||||||
|
furnitureMini.Release();
|
||||||
|
}
|
||||||
heldItem = null;
|
heldItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool grabByProximity() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool grabByLaser() {
|
||||||
|
var ray = new Ray(transform.position, transform.forward);
|
||||||
|
RaycastHit result;
|
||||||
|
bool hit = Physics.Raycast(ray, out result);
|
||||||
|
|
||||||
|
if (!hit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warehouse shelf grabbing
|
||||||
|
var warehouseItem = result.rigidbody.GetComponent<WarehouseItem>();
|
||||||
|
if (warehouseItem) {
|
||||||
|
var mini = warehouseItem.Pick();
|
||||||
|
mini.Grab(MiniatureAttachmentPoint);
|
||||||
|
var anim = mini.GetComponent<WarehouseMiniatureAnim>();
|
||||||
|
anim.OriginItem = warehouseItem;
|
||||||
|
anim.GoalScale = new Vector3(0.05f, 0.05f, 0.05f);
|
||||||
|
heldItem = mini.gameObject;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warehouse miniature grabbing remotely
|
||||||
|
var furnitureMini = result.rigidbody.GetComponent<FurnitureMiniature>();
|
||||||
|
if (furnitureMini) {
|
||||||
|
furnitureMini.Grab(MiniatureAttachmentPoint);
|
||||||
|
heldItem = furnitureMini.gameObject;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Furniture scrolling by drag
|
// Furniture scrolling by drag
|
||||||
void touchpadClicked(object sender, ControllerClickedEventArgs e) {
|
void touchpadClicked(object sender, ControllerClickedEventArgs e) {
|
||||||
var ray = new Ray(transform.position, transform.forward);
|
var ray = new Ray(transform.position, transform.forward);
|
||||||
|
|||||||
Binary file not shown.
+9
-28
@@ -1,40 +1,21 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
public class WarehouseItem : FurnitureObject {
|
public class WarehouseItem : MonoBehaviour {
|
||||||
|
|
||||||
public override void Grab(Transform attachment) {
|
public FurnitureMiniature Pick() {
|
||||||
var replacement = GameObject.Instantiate(this);
|
var clone = GameObject.Instantiate(this);
|
||||||
replacement.transform.parent = transform.parent;
|
|
||||||
replacement.transform.SetSiblingIndex(transform.GetSiblingIndex());
|
|
||||||
|
|
||||||
transform.parent = null;
|
foreach (var collider in clone.GetComponentsInChildren<Collider>()) {
|
||||||
foreach (var collider in GetComponentsInChildren<Collider>()) {
|
|
||||||
collider.enabled = false;
|
collider.enabled = false;
|
||||||
}
|
}
|
||||||
GetComponent<Rigidbody>().isKinematic = true;
|
clone.GetComponent<Rigidbody>().isKinematic = true;
|
||||||
|
|
||||||
var mini = gameObject.AddComponent<WarehouseMiniatureAnim>();
|
// Convert into a miniature
|
||||||
mini.OriginItem = replacement;
|
Destroy(clone.GetComponent<WarehouseItem>());
|
||||||
mini.DestinationAttachment = attachment;
|
var mini = clone.gameObject.AddComponent<FurnitureMiniature>();
|
||||||
mini.Duration = 0.33f;
|
|
||||||
mini.GoalScale = new Vector3(0.05f, 0.05f, 0.05f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Release() {
|
return mini;
|
||||||
var mini = gameObject.GetComponent<WarehouseMiniatureAnim>();
|
|
||||||
if (mini) {
|
|
||||||
mini.End();
|
|
||||||
}
|
|
||||||
|
|
||||||
transform.parent = null;
|
|
||||||
foreach (var collider in GetComponentsInChildren<Collider>()) {
|
|
||||||
collider.enabled = true;
|
|
||||||
}
|
|
||||||
GetComponent<Rigidbody>().isKinematic = false;
|
|
||||||
|
|
||||||
gameObject.AddComponent<FurnitureMiniature>();
|
|
||||||
Destroy(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
|
|||||||
Reference in New Issue
Block a user