Exemplo n.º 1
0
 private void Update()
 {
     if (IsDragging)
     {
         Vector3 mousePosition = GameManager.UICamera.ScreenToWorldPoint(Input.mousePosition);
         mousePosition.z = ItemRtf.position.z;
         SelectedItem.GetComponent <RectTransform>().position = mousePosition;
         Debug.Log(mousePosition);
     }
 }
    IEnumerator SetSelectedItem(List <RectTransform> StageListing)
    {
        Debug.Log("StageSlider : We've reached Step 2");

        yield return(new WaitForEndOfFrame());

        string CurrentSceneName = FindObjectOfType <GameManager>().StageMan.CurrentSceneName();

        foreach (RectTransform item in StageListing)
        {
            //So then we check the rects for a button component
            //Within that button component we have stage Data in that data is a name
            //If that name matches what our GM's Current Stage name is we've found the item we're looking for
            if (item.GetComponent <StageSelectBtn>().Data.SceneName == CurrentSceneName)
            {
                //.Data.SceneName == CurrentStageName
                Debug.Log("StageSlider : Setting Selected item to " + CurrentSceneName);//+ item.GetComponent<StageSelectBtn>().Data);
                //Then we our selected item to be the item we found
                SelectedItem = item;
                //Also tell the menu Manager what we're supposed to be focusing
                FindObjectOfType <GameManager>().MenuMan.SetFocus(SelectedItem.gameObject);
                break;
            }
        }

        Debug.Log("StageSlider : We've reached Step 3");

        if (SelectedItem.GetComponent <StageSelectBtn>().Edge == SlideToEdge.NONE)
        {
            CheckPosition(SelectedItem);
        }
        else
        {
            PressToEdge(SelectedItem.GetComponent <StageSelectBtn>().Edge, SelectedItem);
        }
    }
Exemplo n.º 3
0
    public bool DropSelectedItem()
    {
        if (SelectedItem != null)
        {
            // !!! TODO implement properly
            SelectedItem.transform.parent   = null;
            SelectedItem.transform.position = Vector3.zero; // !!! TODO drop on ground
            SelectedItem.transform.rotation = Quaternion.identity;

            // enable gameobject and item interact collider
            SelectedItem.gameObject.SetActive(true);
            Collider c = SelectedItem.GetComponent <Collider>();
            if (c != null)
            {
                c.enabled = true;
            }

            SelectedItem = null; // remove reference to item

            return(true);
        }

        return(false);
    }