Ejemplo n.º 1
0
    private void Update()
    {
        // 이미 퍼즐있으면 불러오기
        if (Global.loadPuzz_b == true)
        {
            Global.loadPuzz_b = false;

            temp = Global.GetPuzz();

            for (int i = 0; i < temp.Count; i++)
            {
                //UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath("Assets/prefab/puzz/" + temp[i].drum + ".prefab",typeof(GameObject));
                // UnityEngine.Object prefab = Resources.Load("prefab/" + temp[i].drum + ".prefab", typeof(GameObject));
                GameObject prefab = Resources.Load("prefab/" + temp[i].drum) as GameObject;
                //Debug.Log("prefab/" + temp[i].drum + ".prefab");
                //Debug.Log(prefab.name);
                GameObject clone = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
                clone.transform.position = new Vector3(temp[i].pos_x, temp[i].pos_y, 0);
            }
        }

        // Mouse Left Click ON
        if (Input.GetMouseButtonDown(0))
        {
            createFlag = false;
            GetRayObject();
        }
        // Mouse Left Click OFF
        else if (Input.GetMouseButtonUp(0))
        {
            isDrag = false;
            if (null == target)
            {
                return;
            }
            if (target.gameObject.tag.Equals("btnPuzzle"))
            {
                target = null;
                return;
            }

            pc = target.GetComponent <PuzzleController>();

            if (pc.GetIsCol())
            {
                if (pc.GetColTag().Equals("PuzzSub") || pc.GetColTag().Equals("PuzzStart"))
                {
                    target.SendMessage("AttachPuzzle");
                }
                else if (pc.GetColTag().Equals("btnTrash"))
                {
                    PuzzleData pd = puzzleData.GetComponent <PuzzleData>();
                    pd.DeletePuzzle(target);
                    Destroy(target);
                    target = null;
                }
            }
            target = null;
        }
        // Mouse Left Drag
        else if (Input.GetMouseButton(0))
        {
            // 퍼즐 새로 생성
            if (CheckTargetDrag("btnPuzzle", dragTreshold))
            {
                isDrag = true;
                CreatePuzzle();
            }

            // 퍼즐 옮김
            else if (CheckTargetDrag("PuzzSub", 0))
            {
                isDrag = true;
                DragOnPuzzle();
            }

            // 카메라 화면 옮김
            //if (CheckTargetDrag("background", 0))
            else if (EventSystem.current.IsPointerOverGameObject() == false)
            {
                isDrag = true;
                Debug.Log("카메라 옮김");
                CameraZoom();
            }
        }
    }