コード例 #1
0
ファイル: SampleButton.cs プロジェクト: yuheong/HangryOrbital
 private void OnPointerUp()
 {
     // scrollList.closeDescription();
     if (buyMode)
     {
         scrollList.TryTransferItemToOtherShop(item);
     }
     Debug.Log("up");
 }
コード例 #2
0
 public void HandleClick()
 {
     scrollList.TryTransferItemToOtherShop(item); //scrollist needed for button to call transfer item func
 }
コード例 #3
0
 public void HandleClick()
 {
     scrollList.TryTransferItemToOtherShop(item);
 }
コード例 #4
0
    void GetInput()
    {
        //Debug.Log(overlapTile ? "true" : "false");
        if (creating && !EventSystem.current.IsPointerOverGameObject() && overlapTile)
        {
            if (cursor != null && creating && !EventSystem.current.IsPointerOverGameObject() && (Input.GetMouseButtonDown(0) || isDrag))
            {
                foreach (GameObject chk in GameObject.FindGameObjectsWithTag("FloorPlaced"))
                {
                    if (chk.transform.position == cursor.transform.position)
                    {
                        return;
                    }
                }
                Vector3 pos = cursor.transform.position;
                pos.y     = 0;
                tileAdded = (GameObject)Instantiate(cursor, pos, Quaternion.identity);
                tileAdded.gameObject.tag = "FloorPlaced";
                objLoad.PushItem(tileAdded);
                if (scrollList != null)
                {
                    scrollList.TryTransferItemToOtherShop(cartItem);
                }
                //target.transform.position = tileAdded.transform.position;
                isDrag = true;
                tileAdded.transform.parent = GameObject.FindGameObjectWithTag("Manager").transform;
            }
            if (cursor != null && creating && !EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(1))
            {
                float[] numbers = new float[3] {
                    1f, .5f, .25f
                };
                float pick = numbers[Random.Range(0, numbers.Length)];
                cursor.transform.localScale = new Vector3(pick, 0.05f, pick);
                return;
            }
            //else if (Input.GetMouseButtonDown(0))
            //{
            //    creating = true;
            //}
            //else if (Input.GetMouseButtonUp(0))
            //{
            //    creating = false;
            //}
            if (Input.GetKeyDown("1"))
            {
                TilePicked = 0;
                Destroy(cursor);
            }
            if (Input.GetKeyDown("2"))
            {
                TilePicked = 1;
                Destroy(cursor);
            }
            if (Input.GetKeyDown("3"))
            {
                TilePicked = 2;
                Destroy(cursor);
            }

            //else
            //{
            //    if (creating)
            //    {
            //        Adjust();
            //    }
            //}
        }
    }
コード例 #5
0
    void GetInput()
    {
        if (creating && !EventSystem.current.IsPointerOverGameObject())
        {
            if (cursor != null && creating && !EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(0) && !overlapTile)
            {
                foreach (GameObject chk in GameObject.FindGameObjectsWithTag("DoorPlaced"))
                {
                    if (chk.transform.position == cursor.transform.position)
                    {
                        return;
                    }
                }
                Vector3 pos = cursor.transform.position;
                pos.y = 0;
                cursor.GetComponent <DetectCollison>().OnUndo();
                tileAdded = (GameObject)Instantiate(cursor, pos, cursor.transform.rotation);
                tileAdded.gameObject.tag = "DoorPlaced";
                objLoad.PushItem(tileAdded);
                if (scrollList != null)
                {
                    scrollList.TryTransferItemToOtherShop(cartItem);
                }
                creating = false;
                Destroy(cursor);
                cursor = null;
                tileAdded.transform.parent = GameObject.FindGameObjectWithTag("Manager").transform;
            }
            if (cursor != null && creating && !EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(1))
            {
                cursor.transform.Rotate(0, 90, 0);
                return;
            }
            //else if (Input.GetMouseButtonDown(0))
            //{
            //    creating = true;
            //}
            //else if (Input.GetMouseButtonUp(0))
            //{
            //    creating = false;
            //}
            if (Input.GetKeyDown("1"))
            {
                TilePicked = 0;
                Destroy(cursor);
            }
            if (Input.GetKeyDown("2"))
            {
                TilePicked = 1;
                Destroy(cursor);
            }
            if (Input.GetKeyDown("3"))
            {
                TilePicked = 2;
                Destroy(cursor);
            }

            //else
            //{
            //    if (creating)
            //    {
            //        Adjust();
            //    }
            //}
        }
        else if (!creating && Input.GetMouseButtonDown(0))
        {
            Ray        ray = GetComponent <Camera>().ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "DoorPlaced")
                {
                    hit.transform.Rotate(0, 90, 0);
                }
                //else
            }
        }
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (creating && cursor == null)
        {
            if (TilePicked == 0)
            {
                cursor   = (GameObject)Instantiate(tile1, new Vector3(), Quaternion.identity);
                holdX    = true;
                holdZ    = false;
                newStart = true;
                cursor.SetActive(true);
                cursor.GetComponent <BoxCollider>().enabled = false;
                Collison[] col = cursor.GetComponentsInChildren <Collison>();
                for (int i = 0; i < col.Length; i++)
                {
                    if (col[i].tag.Contains("CursorMode"))
                    {
                        col[i].GetComponent <Collison>().enabled = false;
                    }
                }
            }
            else if (TilePicked == 1)
            {
                GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren <ObjectsLoaded>().CamAdjust = true;
                creating = false;
                //cursor = (GameObject)Instantiate(tile2, new Vector3(), Quaternion.identity);
                Vector3 pos = Vector3.zero;
                pos.z = 0.5f;
                pos.x = 0.5f;
                foreach (GameObject chk in GameObject.FindGameObjectsWithTag("WallPlaced"))
                {
                    if (chk.transform.position == pos)
                    {
                        //chk.transform.Rotate(0,90,0);
                        //prevRot.y = chk.transform.rotation.y;
                        return;
                    }
                }
                tileAdded = (GameObject)Instantiate(tile2, pos, tile2.transform.rotation);
                tileAdded.gameObject.tag = "WallPlaced";
                objLoad.PushItem(tileAdded);
                //prevRot.y = tileAdded.transform.rotation.y;
                if (scrollList != null)
                {
                    scrollList.TryTransferItemToOtherShop(cartItem);
                }

                tileAdded.transform.parent = GameObject.FindGameObjectWithTag("Manager").transform;
                WorldCenter.GetComponentInChildren <ObjectsLoaded>().CamAdjust = true;
            }
            else if (TilePicked == 2)
            {
                GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren <ObjectsLoaded>().CamAdjust = true;
                creating = false;
                Vector3 pos = Vector3.zero;
                pos.z = 0.5f;
                pos.x = 0.5f;
                //cursor = (GameObject)Instantiate(tile3, new Vector3(), Quaternion.identity);
                foreach (GameObject chk in GameObject.FindGameObjectsWithTag("WallPlaced"))
                {
                    if (chk.transform.position == pos)
                    {
                        //chk.transform.Rotate(0,90,0);
                        //prevRot.y = chk.transform.rotation.y;
                        return;
                    }
                }
                tileAdded = (GameObject)Instantiate(tile3, pos, tile3.transform.rotation);
                tileAdded.gameObject.tag = "WallPlaced";
                objLoad.PushItem(tileAdded);
                //prevRot.y = tileAdded.transform.rotation.y;
                if (scrollList != null)
                {
                    scrollList.TryTransferItemToOtherShop(cartItem);
                }

                tileAdded.transform.parent = GameObject.FindGameObjectWithTag("Manager").transform;
                WorldCenter.GetComponentInChildren <ObjectsLoaded>().CamAdjust = true;
            }
            if (cursor != null)
            {
                cursor.tag = "Cursor";
            }
            //cursor.transform.rotation = Quaternion.LookRotation(prevRot, Vector3.up);
        }

        if (cursor != null && EventSystem.current.IsPointerOverGameObject())
        {
            cursor.SetActive(false);
        }
        if (Input.GetMouseButtonUp(0))
        {
            isDrag   = false;
            newStart = true;
            return;
        }
        if (cursor != null && !EventSystem.current.IsPointerOverGameObject())
        {
            cursor.SetActive(true);
            cursor.transform.position = snapPosition(GetWorldPoint());
            GetInput();
        }
    }
コード例 #7
0
ファイル: SampleButton.cs プロジェクト: MoongK/Pooling
 private void HandleClick()
 {
     print("clicked!");
     scrollList.TryTransferItemToOtherShop(item);
 }