コード例 #1
0
ファイル: UnitSelector.cs プロジェクト: Lokan451/CubicCrusade
    public void StopDragging(Vector2 dragAmount, Vector2 dragPos)
    {
        Vector3    pos       = new Vector3(dragPos.x, dragPos.y);
        Ray        cameraRay = Camera.main.ScreenPointToRay(pos);
        LayerMask  uiMask    = 1 << LayerMask.NameToLayer("UI");
        RaycastHit hit;

        if (Physics.Raycast(cameraRay, out hit, 1000, uiMask))
        {
            FormationSlot slot = hit.transform.GetComponent <FormationSlot>();
            if (dragging)
            {
                if (slot)
                {
                    slot.HandoffUnit(dragging.gameObject, dragTarget.GetFormation());
                }
                else
                {
                    Instantiate(cubeSparklePrefab, dragging.transform.position, Quaternion.identity);
                    Destroy(dragging.gameObject);
                }
            }
        }
        else
        {
            if (dragging)
            {
                Instantiate(cubeSparklePrefab, dragging.transform.position, Quaternion.identity);
                Destroy(dragging.gameObject);
            }
        }
        dragTarget     = null;
        dragging       = null;
        isDraggingList = false;
    }
コード例 #2
0
ファイル: UnitSelector.cs プロジェクト: Lokan451/CubicCrusade
 public void StartDragging(Vector2 dragPos, GameObject selected)
 {
     dragTarget     = selected.GetComponent <UnitSelectorSlot>();
     screenSize     = new Vector2(Screen.width, Screen.height);
     dragStartPos   = dragPos;
     pickupReady    = true;
     isDraggingList = true;
 }