Fix some docs, fix item use on server, update project settings

This commit is contained in:
excitedneon 2017-05-16 05:34:43 +03:00
parent f231252275
commit 427071c1d3
3 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,9 @@ namespace Cyber.Items {
/// An item, containing itemmy information. /// An item, containing itemmy information.
/// </summary> /// </summary>
public class Item { public class Item {
/// <summary>
/// Delegate for actions that items can do.
/// </summary>
public delegate void ItemAction(Character host); public delegate void ItemAction(Character host);
/// <summary> /// <summary>
@ -52,6 +55,7 @@ namespace Cyber.Items {
/// <param name="weight">The Weight of the item.</param> /// <param name="weight">The Weight of the item.</param>
/// <param name="slot">The equip slot of the item.</param> /// <param name="slot">The equip slot of the item.</param>
/// <param name="description">The description of the item.</param> /// <param name="description">The description of the item.</param>
/// <param name="action">The action which is ran when the item is used.</param>
public Item(int id, int modelId, string name, float weight, EquipSlot slot, string description, ItemAction action = null) { public Item(int id, int modelId, string name, float weight, EquipSlot slot, string description, ItemAction action = null) {
ID = id; ID = id;
ModelID = modelId; ModelID = modelId;

View File

@ -246,7 +246,8 @@ namespace Cyber.Networking.Serverside {
InventoryActionPkt InventoryActionPkt = new InventoryActionPkt(); InventoryActionPkt InventoryActionPkt = new InventoryActionPkt();
InventoryActionPkt.Deserialize(msg.reader); InventoryActionPkt.Deserialize(msg.reader);
Inventory CurrInventory = Players[msg.conn.connectionId].Character.GetComponent<Inventory>(); Character Character = Players[msg.conn.connectionId].Character;
Inventory CurrInventory = Character.GetComponent<Inventory>();
InventoryActionPkt.SyncBaseID = CurrInventory.ID; InventoryActionPkt.SyncBaseID = CurrInventory.ID;
switch (InventoryActionPkt.Action) { switch (InventoryActionPkt.Action) {
@ -258,6 +259,15 @@ namespace Cyber.Networking.Serverside {
EquipSlot Slot = (EquipSlot) InventoryActionPkt.RelatedInt; EquipSlot Slot = (EquipSlot) InventoryActionPkt.RelatedInt;
CurrInventory.Equipped.ClearSlot(Slot); CurrInventory.Equipped.ClearSlot(Slot);
break; break;
case InventoryAction.Use:
EquipSlot UseSlot = (EquipSlot) InventoryActionPkt.RelatedInt;
Item UseItem = CurrInventory.Equipped.GetItem(UseSlot);
if (UseItem != null && UseItem.Action != null && Character != null) {
// Item exists, it has an action, and the character
// isn't controlled by the client (no double-actions).
UseItem.Action(Character);
}
break;
} }
SendToAll(PktType.InventoryAction, InventoryActionPkt); SendToAll(PktType.InventoryAction, InventoryActionPkt);

View File

@ -10,7 +10,7 @@ PlayerSettings:
targetDevice: 2 targetDevice: 2
useOnDemandResources: 0 useOnDemandResources: 0
accelerometerFrequency: 60 accelerometerFrequency: 60
companyName: DefaultCompany companyName: Saltosion
productName: Cyber productName: Cyber
defaultCursor: {fileID: 0} defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0} cursorHotspot: {x: 0, y: 0}
@ -64,7 +64,7 @@ PlayerSettings:
useOSAutorotation: 1 useOSAutorotation: 1
use32BitDisplayBuffer: 1 use32BitDisplayBuffer: 1
disableDepthAndStencilBuffers: 0 disableDepthAndStencilBuffers: 0
defaultIsFullScreen: 1 defaultIsFullScreen: 0
defaultIsNativeResolution: 1 defaultIsNativeResolution: 1
runInBackground: 1 runInBackground: 1
captureSingleScreen: 0 captureSingleScreen: 0