Fixed DriveInterface and added a new exciting item!
This commit is contained in:
parent
9acd9f638f
commit
43eb01e9de
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
using Cyber.Items;
|
using Cyber.Items;
|
||||||
using Cyber.Networking;
|
using Cyber.Networking;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace Cyber.Entities.SyncBases {
|
namespace Cyber.Entities.SyncBases {
|
||||||
@ -21,6 +22,7 @@ namespace Cyber.Entities.SyncBases {
|
|||||||
public Inventory() {
|
public Inventory() {
|
||||||
Drive = new Drive(10f);
|
Drive = new Drive(10f);
|
||||||
Drive.AddItem(ItemDB.Singleton.Get(0));
|
Drive.AddItem(ItemDB.Singleton.Get(0));
|
||||||
|
Drive.AddItem(ItemDB.Singleton.Get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -11,14 +11,14 @@ namespace Cyber.Items {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Width of the interface.
|
/// Width of the interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int Width = 8;
|
public const int Width = 7;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimun height of the interface.
|
/// Minimun height of the interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int MinHeight = 4;
|
public const int MinHeight = 4;
|
||||||
|
|
||||||
private int[,] ItemGrid = new int[4, Width];
|
private int[,] ItemGrid;
|
||||||
|
|
||||||
private Drive Drive;
|
private Drive Drive;
|
||||||
|
|
||||||
@ -28,6 +28,7 @@ namespace Cyber.Items {
|
|||||||
/// <param name="drive"></param>
|
/// <param name="drive"></param>
|
||||||
public DriveInterface(Drive drive) {
|
public DriveInterface(Drive drive) {
|
||||||
Drive = drive;
|
Drive = drive;
|
||||||
|
ItemGrid = CreateEmptyGrid(Width, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -37,7 +38,7 @@ namespace Cyber.Items {
|
|||||||
/// <param name="y">The y-coordinate</param>
|
/// <param name="y">The y-coordinate</param>
|
||||||
/// <returns>The item or null</returns>
|
/// <returns>The item or null</returns>
|
||||||
public Item GetItemAt(int x, int y) {
|
public Item GetItemAt(int x, int y) {
|
||||||
if (ItemGrid[y, x] == 0) {
|
if (ItemGrid[y, x] == -1) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return Drive.GetItem(ItemGrid[y, x]);
|
return Drive.GetItem(ItemGrid[y, x]);
|
||||||
@ -73,7 +74,7 @@ namespace Cyber.Items {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[,] Temp = new int[RequiredHeight + 1, Width];
|
int[,] Temp = CreateEmptyGrid(Width, RequiredHeight + 1);
|
||||||
for (int y = 0; y < RequiredHeight - 1; y++) {
|
for (int y = 0; y < RequiredHeight - 1; y++) {
|
||||||
for (int x = 0; x < Width; x++) {
|
for (int x = 0; x < Width; x++) {
|
||||||
if (GetItemAt(x, y) != null) {
|
if (GetItemAt(x, y) != null) {
|
||||||
@ -95,9 +96,20 @@ namespace Cyber.Items {
|
|||||||
for (int x = 0; x < Width; x++) {
|
for (int x = 0; x < Width; x++) {
|
||||||
if (GetItemAt(x, y) == null) {
|
if (GetItemAt(x, y) == null) {
|
||||||
ItemGrid[y, x] = idx;
|
ItemGrid[y, x] = idx;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int[,] CreateEmptyGrid(int width, int height) {
|
||||||
|
int[,] Grid = new int[height, width];
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
Grid[y, x] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Grid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ namespace Cyber.Items {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemDB() {
|
public ItemDB() {
|
||||||
AddItem(new Item(Counter++, 0, "Very Long Item Name", 1.5f, "This item is a rare piece of the \"way too long of a name\" technology, invented by space goblins in ancient times."));
|
AddItem(new Item(Counter++, 0, "Very Long Item Name", 1.5f, "This item is a rare piece of the \"way too long of a name\" technology, invented by space goblins in ancient times."));
|
||||||
|
AddItem(new Item(Counter++, 1, "Outworldly spherical tube", .5f, "It's so spherical and smooth that it seems like it's not even from this world!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user