コード例 #1
0
ファイル: Block.cs プロジェクト: myxa42/ldjam43_sacrifice
    public void OnEndDrag(PointerEventData eventData)
    {
        if (icon != null)
        {
            icon.GetComponent <RectTransform>().anchoredPosition = new Vector2(position, 0);
        }

        dragging = false;

        if (buildingUnderMouse != null && type != BlockType.Empty)
        {
            bool found = false;
            foreach (var r in buildingUnderMouse.requiredResources)
            {
                if (r.blockType == type)
                {
                    found = true;
                    break;
                }
            }

            if (found)
            {
                buildingUnderMouse.AddResource(type);
                DestroyIcon();
            }
        }

        if (cannonUnderMouse != null && type == BlockType.Bomb)
        {
            cannonUnderMouse.AddBall();
            DestroyIcon();
        }

        cannonUnderMouse   = null;
        buildingUnderMouse = null;
    }