示例#1
0
    void LoopEnabel(Selectable currentSelect, Vector3 inputVec)
    {
        var nextSelect = currentSelect.FindSelectable(Vector3.right * inputVec.x);

        if (nextSelect == null)
        {
            pastTime   = 0.0f;
            nextSelect = currentSelect;
            while (nextSelect.FindSelectable(Vector3.left * inputVec.x))
            {
                nextSelect = nextSelect.FindSelectable(Vector3.left * inputVec.x);
            }
        }
        currentSelect = nextSelect;
        nextSelect    = currentSelect.FindSelectable(Vector3.up * inputVec.y);

        if (nextSelect == null)
        {
            pastTime   = 0.0f;
            nextSelect = currentSelect;

            while (nextSelect.FindSelectable(Vector3.down * inputVec.y))
            {
                nextSelect = nextSelect.FindSelectable(Vector3.down * inputVec.y);
            }
        }
        EventSystem.current.SetSelectedGameObject(nextSelect.gameObject);
    }
示例#2
0
    public static void MoveCursor(this UFEScreen screen, Vector3 direction, AudioClip moveCursorSound = null)
    {
        GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject;
        GameObject nextGameObject    = null;

        if (currentGameObject != null && currentGameObject.activeInHierarchy)
        {
            Selectable currentSelectableObject = currentGameObject.GetComponent <Selectable>();

            if (currentSelectableObject != null && currentSelectableObject.IsInteractable())
            {
                Selectable nextSelectableObject = currentSelectableObject.FindSelectable(direction);

                if (nextSelectableObject != null)
                {
                    nextGameObject = nextSelectableObject.gameObject;
                }
            }
        }

        if (nextGameObject == null)
        {
            nextGameObject = screen.FindFirstSelectableGameObject();
        }

        if (currentGameObject != nextGameObject)
        {
            if (moveCursorSound != null)
            {
                UFE.PlaySound(moveCursorSound);
            }
            screen.HighlightOption(nextGameObject);
        }
    }
示例#3
0
    static int FindSelectable(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        Selectable obj  = LuaScriptMgr.GetUnityObject <Selectable>(L, 1);
        Vector3    arg0 = LuaScriptMgr.GetVector3(L, 2);
        Selectable o    = obj.FindSelectable(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
示例#4
0
    public static Selectable FindLoopSelectable(this Selectable current, Vector3 dir)
    {
        Selectable first = current.FindSelectable(dir);

        if (first != null)
        {
            current = first.FindLoopSelectable(dir);
        }
        return(current);
    }
示例#5
0
    private static Selectable GetNextSelectable(Selectable current, Vector3 dir)
    {
        Selectable next = current.FindSelectable(dir);

        if (next == null)
        {
            next = current.FindLoopSelectable(-dir);
        }
        return(next);
    }
示例#6
0
    /// </summary>
    /// 循环寻找下一个UI组件
    /// <param name="current"></param>
    /// <param name="dir"></param>
    /// <returns></returns>
    public static Selectable FindLoopSelectable(this Selectable current, Vector3 dir)
    {
        Selectable first = current.FindSelectable(dir); //用一个向量Vector3去寻找第一个Selectable

        if (first != null)                              //如果下一个为null,用递归方法循环继续寻找第一个
        {
            current = first.FindLoopSelectable(dir);
        }
        return(current);
    }
    void MoveSelected(Vector2 dir)
    {
        Selectable nextSelected = currentSelected.FindSelectable(dir);

        if (nextSelected != null)
        {
            currentSelected.OnPointerExit(null);
            currentSelected = nextSelected;
            currentSelected.OnPointerEnter(null);
            moveTime = Time.time;
        }
    }
    private static int FindSelectable(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            Selectable selectable = (Selectable)ToLua.CheckObject(L, 1, typeof(Selectable));
            Vector3    dir        = ToLua.ToVector3(L, 2);
            Selectable obj        = selectable.FindSelectable(dir);
            ToLua.Push(L, obj);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    public static int FindSelectable(IntPtr l)
    {
        int result;

        try
        {
            Selectable selectable = (Selectable)LuaObject.checkSelf(l);
            Vector3    dir;
            LuaObject.checkType(l, 2, out dir);
            Selectable o = selectable.FindSelectable(dir);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, o);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
示例#10
0
    private static Selectable FindSelectable(Selectable s, Vector3 dir, IList <Selectable> whiteList)
    {
        if (whiteList == null || whiteList.Count == 0)
        {
            return(s.FindSelectable(dir));
        }
        else
        {
            dir = dir.normalized;
            Vector3    vector  = Quaternion.Inverse(s.transform.rotation) * dir;
            Vector3    vector2 = s.transform.TransformPoint(UFEScreenExtensions.GetPointOnRectEdge(s.transform as RectTransform, vector));
            float      num     = float.NegativeInfinity;
            Selectable result  = null;

            for (int i = 0; i < Selectable.allSelectables.Count; i++)
            {
                Selectable selectable = Selectable.allSelectables[i];
                if (selectable != s && selectable != null && whiteList.Contains(selectable))
                {
                    if (selectable.IsInteractable() && selectable.navigation.mode != Navigation.Mode.None)
                    {
                        RectTransform rectTransform = selectable.transform as RectTransform;
                        Vector3       vector3       = (!(rectTransform != null)) ? Vector3.zero : new Vector3(rectTransform.rect.center.x, rectTransform.rect.center.y, 0f);
                        Vector3       vector4       = selectable.transform.TransformPoint(vector3) - vector2;
                        float         num2          = Vector3.Dot(dir, vector4);
                        if (num2 > 0)
                        {
                            float num3 = num2 / vector4.sqrMagnitude;
                            if (num3 > num)
                            {
                                num    = num3;
                                result = selectable;
                            }
                        }
                    }
                }
            }
            return(result);
        }
    }
    void Update()
    {
        if (!toFightScene)
        {
            if (!p1Ready)
            {
                // Get Input p1
                float   p1Hori = Input.GetAxisRaw("Horizontal");
                float   p1Vert = Input.GetAxisRaw("Vertical");
                Vector2 p1Dir  = new Vector2(p1Hori, p1Vert);

                newSelection1 = p1.FindSelectable(p1Dir);

                if (newSelection1 != p1 && newSelection1 != null)
                {
                    p1 = newSelection1;
                    Debug.Log("Moved To The P1 Spot.");
                }

                if (newSelection1 != null)
                {
                    p1Indicator.transform.position = newSelection1.transform.position;
                }

                CheckSelectionChange();

                if (Input.GetButton("AButton"))
                {
                    p1ReadyUI.gameObject.SetActive(true);
                    // Gray out p2Indicator;
                    CharacterInfo p1Info = p1.GetComponent <CharacterInfo>();
                    p1CharName.text   = p1Info.characterInfo.characterName;
                    p1MugShot.texture = p1Info.characterInfo.mugShot.texture;
                    Debug.Log("I'm Selecting YO!");
                    p1Ready = true;
                }
            }
            else if (Input.GetButton("BackButton") && p1Ready)
            {
                p1Ready = false;
                p1ReadyUI.gameObject.SetActive(false);
                // Color p1Indicator;
                Debug.Log("I do exist!");
            }

            //---------------------------------------------------------------------------------

            if (!p2Ready)
            {
                // Get Input p2
                float   p2Hori = Input.GetAxisRaw("Horizontal2");
                float   p2Vert = Input.GetAxisRaw("Vertical2");
                Vector2 p2Dir  = new Vector2(p2Hori, p2Vert);

                newSelection2 = p2.FindSelectable(p2Dir);

                if (newSelection2 != p2 && newSelection2 != null)
                {
                    p2 = newSelection2;
                    Debug.Log("Moved To The P2 Spot.");
                }

                if (newSelection2 != null)
                {
                    p2Indicator.transform.position = newSelection2.transform.position;
                }

                CheckSelectionChange();

                if (Input.GetButton("AButton2") && !p2Ready)
                {
                    p2ReadyUI.gameObject.SetActive(true);
                    // Gray out p2Indicator;
                    CharacterInfo p2Info = p2.GetComponent <CharacterInfo>();
                    p2CharName.text   = p2Info.characterInfo.characterName;
                    p2MugShot.texture = p2Info.characterInfo.mugShot.texture;
                    p2Ready           = true;
                }
            }
            else if (Input.GetButton("BackButton2") && p2Ready)
            {
                p2Ready = false;
                p2ReadyUI.gameObject.SetActive(false);
                // Color p2Indicator;
            }
            TransitionCheck();
        }
        else
        {
            test.ChangeScene();
        }
    }