private InventoryPosition GetObject() { //Set up the new Pointer Event m_PointerEventData = new PointerEventData(m_EventSystem); //Set the Pointer Event Position to that of the mouse position m_PointerEventData.position = Input.mousePosition; //Create a list of Raycast Results List <RaycastResult> results = new List <RaycastResult>(12); //Raycast using the Graphics Raycaster and mouse click position m_Raycaster.Raycast(m_PointerEventData, results); //For every result returned, output the name of the GameObject on the Canvas hit by the Ray foreach (RaycastResult result in results) { InventoryPosition ip = result.gameObject.GetComponentInChildren <InventoryPosition>(); if (ip) { return(ip); } } return(null); }
public static InventoryPosition MaterialSelector(int materialId) { InventoryPosition pos = new InventoryPosition(); pos.type = InventoryPositionType.MaterialSelector; pos.MaterialId = materialId; return(pos); }
public static InventoryPosition MainArea(Point point) { InventoryPosition pos = new InventoryPosition(); pos.type = InventoryPositionType.MainArea; pos.AreaX = point.X; pos.AreaY = point.Y; return(pos); }
void Update() { if (Input.GetMouseButtonDown(0)) { from = GetObject(); if (from && from.drag) { transform.position = Input.mousePosition; from.Visible(); setPosition(from.token); } } //Mover el objeto else if (token && Input.GetMouseButton(0)) { transform.position = Input.mousePosition; } //Resolucion else if (token && Input.GetMouseButtonUp(0)) { to = GetObject(); if (InGame(Input.mousePosition)) { from.Clear(); } else if (to && !to.drag) { if (to.setPosition(from.token)) { from.Clear(); } } else if (to && to.drag) { Token ip = to.token; to.setPosition(from.token); from.setPosition(ip); } from.Visible(true); Clear(); } }
/// <summary> /// Sets the item at a given inventory position /// </summary> /// <param name="position">Position in the inventory</param> /// <param name="item">Item to set</param> /// <returns>True if the item can be set at the given inventory location</returns> public bool SetInventoryItem(InventoryPosition position, Item item) { if (item == null) { Inventory[(int)position] = item; return true; } bool res = false; switch (position) { case InventoryPosition.Armor: if ((item.Slot & BodySlot.Torso) == BodySlot.Torso) res = true; break; case InventoryPosition.Wrist: if ((item.Slot & BodySlot.Wrists) == BodySlot.Wrists) res = true; break; case InventoryPosition.Secondary: if ((item.Slot & BodySlot.Secondary) == BodySlot.Secondary) res = true; break; case InventoryPosition.Ring_Left: case InventoryPosition.Ring_Right: if ((item.Slot & BodySlot.Fingers) == BodySlot.Fingers) res = true; break; case InventoryPosition.Feet: if ((item.Slot & BodySlot.Feet) == BodySlot.Feet) res = true; break; case InventoryPosition.Primary: if ((item.Slot & BodySlot.Primary) == BodySlot.Primary) res = true; break; case InventoryPosition.Neck: if ((item.Slot & BodySlot.Neck) == BodySlot.Neck) res = true; break; case InventoryPosition.Helmet: if ((item.Slot & BodySlot.Head) == BodySlot.Head) res = true; break; } if (res) Inventory[(int)position] = item; return res; }
/// <summary> /// Returns the item at a given inventory location /// </summary> /// <param name="position">Inventory position</param> /// <returns>Item or null</returns> public Item GetInventoryItem(InventoryPosition position) { return Inventory[(int)position]; }
public InventorySlotHandler(GameObject window, InventoryPosition inventoryPosition, GameObject[,] inventory) : base(window) { this.inventoryPosition = inventoryPosition; this.inventory = inventory; }
public static InventoryPosition MaterialSelector(int materialId) { InventoryPosition pos = new InventoryPosition(); pos.type = InventoryPositionType.MaterialSelector; pos.MaterialId = materialId; return pos; }
public static InventoryPosition MainArea(Point point) { InventoryPosition pos = new InventoryPosition(); pos.type = InventoryPositionType.MainArea; pos.AreaX = point.X; pos.AreaY = point.Y; return pos; }
public InventoryDraggableHandler(GameObject window, InventoryPosition inventoryPosition, GameObject[,] inventory, InventoryItem item) : base(window) { this.inventoryPosition = inventoryPosition; this.inventory = inventory; this.item = item; }
public void MoveToInventory(InventoryPosition from) { PacketClientInventoryAction p = new PacketClientInventoryAction(); p.A = from; p.Action = InventoryActionType.MoveToInventory; SendPacketClient(new PacketClient() { PacketId = ClientPacketId.InventoryAction, InventoryAction = p }); }
public void InventoryClick(InventoryPosition pos) { PacketClientInventoryAction p = new PacketClientInventoryAction(); p.A = pos; p.Action = InventoryActionType.Click; SendPacketClient(new PacketClient() { PacketId = ClientPacketId.InventoryAction, InventoryAction = p }); }
public void WearItem(InventoryPosition from, InventoryPosition to) { PacketClientInventoryAction p = new PacketClientInventoryAction(); p.A = from; p.B = to; p.Action = InventoryActionType.WearItem; SendPacketClient(new PacketClient() { PacketId = ClientPacketId.InventoryAction, InventoryAction = p }); }