Integrate inventory interface with inventory backend
This commit is contained in:
parent
a43b53112d
commit
9acd9f638f
@ -1671,14 +1671,14 @@ Transform:
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1101618282831644}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -0.02, y: 0.6244, z: 0.5199004}
|
||||
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: -0.02, y: 0.6244, z: 0}
|
||||
m_LocalScale: {x: 0.14000012, y: 0.14, z: 0.14000012}
|
||||
m_Children:
|
||||
- {fileID: 4871279644634608}
|
||||
m_Father: {fileID: 4236387573765288}
|
||||
m_RootOrder: 10
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
|
||||
--- !u!4 &4345907313541278
|
||||
Transform:
|
||||
m_ObjectHideFlags: 1
|
||||
@ -2262,13 +2262,13 @@ Transform:
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1733941371029502}
|
||||
m_LocalRotation: {x: -0.5, y: 0.5, z: 0.5, w: 0.5}
|
||||
m_LocalPosition: {x: -0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0.02, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0.8, y: 0.8, z: 0.8}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4334285771407092}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: -90.00001, y: 90, z: 0}
|
||||
m_LocalEulerAnglesHint: {x: -90.00001, y: 0, z: 0}
|
||||
--- !u!4 &4883048021777868
|
||||
Transform:
|
||||
m_ObjectHideFlags: 1
|
||||
@ -4646,6 +4646,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: bb0d2e67bf4cd4c6b97d2572ce00fc41, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Inventory: {fileID: 114702404122310282}
|
||||
Camera: {fileID: 20678872378488080}
|
||||
Hologram: {fileID: 114633016952828368}
|
||||
ItemPreviewMesh: {fileID: 33585471952367662}
|
||||
|
@ -2259,70 +2259,6 @@ Prefab:
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -0.02
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0.02
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 0.8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 0.8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4871279644634608, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 0.8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 90
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4334285771407092, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: e8761b9491a974d1780e60dafbd372a2, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cyber.Util;
|
||||
using Cyber.Console;
|
||||
using Cyber.Entities.SyncBases;
|
||||
using Cyber.Items;
|
||||
|
||||
namespace Cyber.Controls {
|
||||
|
||||
@ -11,6 +13,11 @@ namespace Cyber.Controls {
|
||||
/// </summary>
|
||||
public class InventoryInterface : MonoBehaviour {
|
||||
|
||||
/// <summary>
|
||||
/// The inventory of the player, will be displayed here.
|
||||
/// </summary>
|
||||
public Inventory Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// The camera that is displaying this inventory interface.
|
||||
/// </summary>
|
||||
@ -173,36 +180,45 @@ namespace Cyber.Controls {
|
||||
if (ItemGridSelectedIndex < 0) {
|
||||
SetPreviewMesh(null);
|
||||
}
|
||||
for (int i = 0; i < ItemGridDimensions.x * ItemGridDimensions.y; i++) {
|
||||
ItemGridCellMeshes[i].mesh = MeshDB.Meshes[i % MeshDB.Meshes.Length];
|
||||
float Scale = 0.08f;
|
||||
bool Spinning = false;
|
||||
if (focused == i || ItemGridSelectedIndex == i) {
|
||||
Scale = 0.1f;
|
||||
Spinning = true;
|
||||
}
|
||||
if (ItemGridSelectedIndex == i) {
|
||||
SetPreviewMesh(ItemGridCellMeshes[i].mesh);
|
||||
if ((ItemGridSelector.position - ItemGridCells[i].position).magnitude < 0.01f) {
|
||||
ItemGridSelector.position = ItemGridCells[i].position;
|
||||
} else {
|
||||
ItemGridSelector.position =
|
||||
Vector3.Lerp(ItemGridSelector.position,
|
||||
ItemGridCells[i].position, 20f * Time.deltaTime);
|
||||
for (int y = 0; y < ItemGridDimensions.y; y++) {
|
||||
for (int x = 0; x < ItemGridDimensions.x; x++) {
|
||||
int i = x + y * (int) ItemGridDimensions.x;
|
||||
Item Item = Inventory.Drive.Interface.GetItemAt(x, y);
|
||||
Mesh Mesh = null;
|
||||
if (Item != null) {
|
||||
Mesh = MeshDB.Meshes[Item.ModelID];
|
||||
}
|
||||
ItemGridSelector.LookAt(Camera.transform);
|
||||
Vector3 NewRot = ItemGridSelector.localEulerAngles;
|
||||
NewRot.z = 0;
|
||||
ItemGridSelector.localEulerAngles = NewRot;
|
||||
ItemGridCellMeshes[i].mesh = Mesh;
|
||||
|
||||
float Scale = 0.08f;
|
||||
bool Spinning = false;
|
||||
if (focused == i || ItemGridSelectedIndex == i) {
|
||||
Scale = 0.1f;
|
||||
Spinning = true;
|
||||
}
|
||||
if (ItemGridSelectedIndex == i) {
|
||||
SetPreviewMesh(ItemGridCellMeshes[i].mesh);
|
||||
if ((ItemGridSelector.position - ItemGridCells[i].position).magnitude < 0.01f) {
|
||||
ItemGridSelector.position = ItemGridCells[i].position;
|
||||
} else {
|
||||
ItemGridSelector.position =
|
||||
Vector3.Lerp(ItemGridSelector.position,
|
||||
ItemGridCells[i].position, 20f * Time.deltaTime);
|
||||
}
|
||||
ItemGridSelector.LookAt(Camera.transform);
|
||||
Vector3 NewRot = ItemGridSelector.localEulerAngles;
|
||||
NewRot.z = 0;
|
||||
ItemGridSelector.localEulerAngles = NewRot;
|
||||
}
|
||||
if (!Spinning) {
|
||||
ItemGridCellMeshes[i].transform.LookAt(Camera.transform);
|
||||
Vector3 NewRot = ItemGridCellMeshes[i].transform.localEulerAngles;
|
||||
NewRot.z = 0;
|
||||
ItemGridCellMeshes[i].transform.localEulerAngles = NewRot;
|
||||
}
|
||||
ItemGridCells[i].GetComponent<Spinner>().Spinning = Spinning;
|
||||
FixMeshScaling(ItemGridCellMeshes[i], Scale);
|
||||
}
|
||||
if (!Spinning) {
|
||||
ItemGridCellMeshes[i].transform.LookAt(Camera.transform);
|
||||
Vector3 NewRot = ItemGridCellMeshes[i].transform.localEulerAngles;
|
||||
NewRot.z = 0;
|
||||
ItemGridCellMeshes[i].transform.localEulerAngles = NewRot;
|
||||
}
|
||||
ItemGridCells[i].GetComponent<Spinner>().Spinning = Spinning;
|
||||
FixMeshScaling(ItemGridCellMeshes[i], Scale);
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,7 +232,11 @@ namespace Cyber.Controls {
|
||||
}
|
||||
|
||||
private void FixMeshScaling(MeshFilter toFix, float scale) {
|
||||
float HighestExtent = 0f;
|
||||
if (toFix.mesh == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
float HighestExtent = 0.1f;
|
||||
float Height = toFix.mesh.bounds.extents.y * 2f;
|
||||
float Width = Mathf.Sqrt(Mathf.Pow(toFix.mesh.bounds.extents.x * 2f, 2) +
|
||||
Mathf.Pow(toFix.mesh.bounds.extents.y * 2f, 2));
|
||||
|
@ -76,7 +76,7 @@ namespace Cyber.Items {
|
||||
/// <param name="idx">The index of the desired item</param>
|
||||
/// <returns>The item or null if nothing was found.</returns>
|
||||
public Item GetItem(int idx) {
|
||||
if (idx < 0 || idx > Items.Count) {
|
||||
if (idx < 0 || idx >= Items.Count) {
|
||||
return null;
|
||||
}
|
||||
return Items[idx];
|
||||
|
Loading…
Reference in New Issue
Block a user