Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    public static InventoryPosition MaterialSelector(int materialId)
    {
        InventoryPosition pos = new InventoryPosition();

        pos.type       = InventoryPositionType.MaterialSelector;
        pos.MaterialId = materialId;
        return(pos);
    }
Exemplo n.º 3
0
    public static InventoryPosition MainArea(Point point)
    {
        InventoryPosition pos = new InventoryPosition();

        pos.type  = InventoryPositionType.MainArea;
        pos.AreaX = point.X;
        pos.AreaY = point.Y;
        return(pos);
    }
Exemplo n.º 4
0
    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();
        }
    }
Exemplo n.º 5
0
		/// <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;
		}
Exemplo n.º 6
0
		/// <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];
		}
Exemplo n.º 7
0
 public InventorySlotHandler(GameObject window, InventoryPosition inventoryPosition, GameObject[,] inventory) : base(window)
 {
     this.inventoryPosition = inventoryPosition;
     this.inventory         = inventory;
 }
Exemplo n.º 8
0
 public static InventoryPosition MaterialSelector(int materialId)
 {
     InventoryPosition pos = new InventoryPosition();
     pos.type = InventoryPositionType.MaterialSelector;
     pos.MaterialId = materialId;
     return pos;
 }
Exemplo n.º 9
0
 public static InventoryPosition MainArea(Point point)
 {
     InventoryPosition pos = new InventoryPosition();
     pos.type = InventoryPositionType.MainArea;
     pos.AreaX = point.X;
     pos.AreaY = point.Y;
     return pos;
 }
Exemplo n.º 10
0
 public InventoryDraggableHandler(GameObject window, InventoryPosition inventoryPosition, GameObject[,] inventory, InventoryItem item) : base(window)
 {
     this.inventoryPosition = inventoryPosition;
     this.inventory         = inventory;
     this.item = item;
 }
Exemplo n.º 11
0
 public void MoveToInventory(InventoryPosition from)
 {
     PacketClientInventoryAction p = new PacketClientInventoryAction();
     p.A = from;
     p.Action = InventoryActionType.MoveToInventory;
     SendPacketClient(new PacketClient() { PacketId = ClientPacketId.InventoryAction, InventoryAction = p });
 }
Exemplo n.º 12
0
 public void InventoryClick(InventoryPosition pos)
 {
     PacketClientInventoryAction p = new PacketClientInventoryAction();
     p.A = pos;
     p.Action = InventoryActionType.Click;
     SendPacketClient(new PacketClient() { PacketId = ClientPacketId.InventoryAction, InventoryAction = p });
 }
Exemplo n.º 13
0
 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 });
 }