Example #1
0
    void CheckDragEnd()
    {
        if (currentstate != UIstate.InventoryDragging)
        {
            return;
        }

        bool endDragInput = false;
        Ray  ray          = new Ray();

        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            endDragInput = true;
            ray          = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
        {
            endDragInput = true;
            ray          = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
        }
        if (!endDragInput)
        {
            return;
        }
        RaycastHit hot;

        if (Physics.Raycast(ray, out hot, Mathf.Infinity, intObjects))
        {
            var co = hot.transform.GetComponent <clickableObject>();
            TryUseItem(inventorySelected, co);
        }
        currentstate   = UIstate.Normal;
        Cursor.visible = true;
        dragIcon.SetActive(false);
    }
Example #2
0
 public void StartDrag()
 {
     //var DISprite = transform.FindDeepChild("InvItemImage").GetComponent<Image>().sprite;
     currentstate = UIstate.InventoryDragging;
     dragIcon.GetComponent <Image>().sprite = inventorySelected.itemSprite; //DISprite;
     dragIcon.SetActive(true);
     Cursor.visible = false;
 }
Example #3
0
 public void AllUIoff()
 {
     for (int i = 0; i < UIs.Length; i++)
     {
         UIs[i].gameObject.SetActive(false);
     }
     currentState = UIstate.None;
 }
Example #4
0
 public void InventoryItemSelected(inventoryItem item)
 {
     currentstate = UIstate.InventoryUsing;
     CharAnim.Play("Idle");
     inventorySelected = item;
     print(item.gameObject.name);
     UseText.text = ("Use " + item.gameObject.name + " on what?");
 }
Example #5
0
 public void InventoryAction()
 {
     InventoryElements.SetActive(!InventoryElements.activeSelf);
     //Fabric.EventManager.Instance.PostEvent("Invopen");
     UIelements.SetActive(false);
     UseText.text = "";
     if (!InventoryElements.activeSelf)
     {
         currentstate = UIstate.Normal;
     }
 }
Example #6
0
 public IEnumerator UIon(UIstate uistate)
 {
     currentState = uistate;
     UIs[(int)UIstate.UIbackground].gameObject.SetActive(true);
     UIs[(int)uistate].gameObject.SetActive(true);
     for (int i = 0; i < 5; i++)
     {
         UIs[(int)uistate].rectTransform.localScale = new Vector3((float)(0.95 + i * 0.01), (float)(0.95 + i * 0.01), (float)(0.95 + i * 0.01));
         yield return(0);
     }
 }
Example #7
0
 public void ShowDamage()
 {
     this.gameObject.transform.GetComponent <Text>().text  = info;
     this.gameObject.transform.GetComponent <Text>().color = new Color(color.r, color.g, color.b, 1.0f);
     timeTem -= Time.deltaTime;
     if (timeTem < 0.0f)
     {
         state   = UIstate.hide;
         timeTem = timer;
     }
 }
Example #8
0
    public void HideDamage()
    {
        timeTem -= Time.deltaTime;
        float a = timeTem / timer;

        this.gameObject.transform.GetComponent <Text>().color = new Color(color.r, color.g, color.b, a);

        if (timeTem < 0.0f)
        {
            state   = UIstate.still;
            timeTem = timer;
        }
    }
Example #9
0
    //UI 창 오픈하는 코드와 이펙트
    public IEnumerator UI_On(UIstate uistate, bool AutoUIOff = false, float seconds = 2f)
    {
        AllUIoff();
        currentState = uistate;
        yield return(new WaitForSeconds(0.1f));

        UIs[(int)UIstate.UIbackground].gameObject.SetActive(true);
        UIs[(int)uistate].gameObject.SetActive(true);
        for (int i = 0; i < 5; i++)
        {
            UIs[(int)uistate].rectTransform.localScale = new Vector3((float)(0.95 + i * 0.01), (float)(0.95 + i * 0.01), (float)(0.95 + i * 0.01));
            yield return(0);
        }
        if (AutoUIOff)
        {
            yield return(new WaitForSeconds(seconds));

            //AllUIoff();
            UIoff(uistate);
        }
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        if (currentstate == UIstate.Normal)
        {
            CharAnim.Play("Idle");
            player.transform.rotation = Quaternion.RotateTowards(player.transform.rotation, normalLookRotation, Time.deltaTime * 200);
        }

        if (currentstate == UIstate.Walking)
        {
            CharAnim.Play("Walk");
            if (Vector3.Distance(player.destination, player.transform.position) <= 1)
            {
                normalLookRotation = player.transform.rotation;
                currentstate       = UIstate.Normal;
            }
        }

        if (currentstate == UIstate.InventoryUsing)
        {
            CharAnim.Play("Idle");
        }

        if (currentstate == UIstate.InventoryDragging)
        {
            if (Input.touchCount > 0)
            {
                dragIcon.transform.position = Input.GetTouch(0).position;
            }
            else
            {
                dragIcon.transform.position = Input.mousePosition;
            }
        }
        CheckDragEnd();
        Ray ray = new Ray();

        bool poke = false;

        if (Input.GetKeyDown(KeyCode.Mouse0) && !IsPointerOverUIObject(Input.mousePosition))
        {
            poke = true;
            ray  = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && !IsPointerOverUIObject(Input.GetTouch(0).position))
        {
            poke = true;
            ray  = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
        }
        if (!poke)
        {
            return;
        }



        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, intObjects))
        {
            var co = hit.transform.GetComponent <clickableObject>();
            //Fabric.EventManager.Instance.PostEvent("StopPiano");
            //Fabric.EventManager.Instance.PostEvent("Unpause");
            //print("Osui");
            if (co)
            {
                player.enabled = false;
                var target = co.transform.position;
                target.y = player.transform.position.y;
                //player.transform.LookAt(target, Vector3.up);
                normalLookRotation = Quaternion.LookRotation(target - player.transform.position, Vector3.up);

                if (currentstate == UIstate.InventoryUsing)
                {
                    TryUseItem(inventorySelected, co);
                }
                else
                {
                    // player.enabled = true;
                    OpenClickableCanvas(co);
                }
                currentstate = UIstate.Normal;
            }
        }
        else if (Physics.Raycast(ray, out hit, Mathf.Infinity, ground | teleport | blocker))
        {
            player.enabled     = true;
            currentstate       = UIstate.Walking;
            player.destination = hit.point;
            //Fabric.EventManager.Instance.PostEvent("StopPiano");
            //Fabric.EventManager.Instance.PostEvent("Unpause");
            //currentstate = UIstate.Normal;
            UIelements.SetActive(false);
            InventoryElements.SetActive(false);
        }
        //if (canv.enabled || InventoryElements) {
        //}
    }
Example #11
0
 public void UIoff(UIstate index)
 {
     UIs[(int)index].gameObject.SetActive(false);
     currentState = UIstate.None;
 }
Example #12
0
 public void UIoff(UIstate index)
 {
     UIs[(int)index].gameObject.SetActive(false);
     // 여기선 current UI State를 어떻게 지정해야할지...?
 }
Example #13
0
 public void Show(string info, Color color)
 {
     this.info  = info;
     this.color = color;
     this.state = UIstate.show;
 }