コード例 #1
0
 private void LateUpdate()
 {
     if (Input.GetKey(KeyCode.Escape) && selected)
     {
         Informations.SetInfo(information);
         selected = false;
         GetComponent <Text>().text = PlayerPrefs.GetString(action, "<None>");
     }
 }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        changedThisFrame = false;
        Vector2 pos = transform.position;

        if (titre != null)
        {
            titre.transform.position = new Vector2(pos.x, pos.y + distanceTitre);
        }
        if (enabled)
        {
            GetComponent <Text>().color = new Color(enabledColor.r, enabledColor.g, enabledColor.b, GetComponent <Text>().color.a);
        }
        else
        {
            GetComponent <Text>().color = new Color(disabledColor.r, disabledColor.g, disabledColor.b, GetComponent <Text>().color.a);
        }

        if (selected)
        {
            Informations.SetInfo(instructions);
            GetComponent <Text>().text = "(Enter key)";
            foreach (KeyCode v in Enum.GetValues(typeof(KeyCode)))
            {
                Debug.Log("Key pressed:" + v);
                if (Input.GetKeyDown(v) && !Input.GetButton("Start") && !(Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.Return)))
                {
                    GetComponent <Text>().text = v.ToString();
                    PlayerPrefs.SetString(action, v.ToString());
                    Controls.LoadControls();
                    Debug.Log(v);
                    selected = false;
                    Informations.SetInfo(instructions);
                    changedThisFrame = true;
                }
            }
        }
        if (selected)
        {
            string axis = Controls.GetAxis();
            if (axis != null)
            {
                GetComponent <Text>().text = axis;
                PlayerPrefs.SetString(action, axis);
                selected = false;
            }
            Informations.SetInfo(instructions);
        }
    }
コード例 #3
0
ファイル: OptionList.cs プロジェクト: Inferture/ShmupJin
    // Update is called once per frame
    void Update()
    {
        if (enabled)
        {
            GetComponent <Text>().color = new Color(enabledColor.r, enabledColor.g, enabledColor.b, GetComponent <Text>().color.a);
        }
        else
        {
            GetComponent <Text>().color = new Color(disabledColor.r, disabledColor.g, disabledColor.b, GetComponent <Text>().color.a);
        }
        if (hovering)
        {
            Informations.SetInfo(information + "(currently " + choix[numChoix] + ")");
        }
        GetComponent <Text>().text = choix[numChoix];


        PlayerPrefs.SetString(action, choix[numChoix]);
    }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (active)
        {
            if (alpha < alphaTarget)
            {
                alpha = Mathf.Min(alpha + alphaSpeed, alphaTarget);
            }
            Text[] texts = GetComponentsInChildren <Text>();
            foreach (Text t in texts)
            {
                t.color = new Color(t.color.r, t.color.g, t.color.b, alpha);
            }
            Image[] images = GetComponentsInChildren <Image>();
            foreach (Image im in images)
            {
                im.color = new Color(im.color.r, im.color.g, im.color.b, alpha);
            }


            if (!horizontal)
            {
                if (Controls.DownMenu())
                {
                    cursor = Next(cursor);//cursor = (cursor + 1) % options.Length;
                    selected.transform.position = new Vector2(sx, sy - sep * cursor);
                    Sounds.Play("sound_menu_change");
                }
                if (Controls.UpMenu())
                {
                    cursor = Last(cursor);//cursor = (cursor + options.Length - 1) % options.Length;
                    selected.transform.position = new Vector2(sx, sy - sep * cursor);
                    Sounds.Play("sound_menu_change");
                }
            }
            if (horizontal)
            {
                if (Controls.RightMenu())
                {
                    cursor = Next(cursor);//cursor = (cursor + 1) % options.Length;
                    selected.transform.position = new Vector2(sx + sep * cursor, sy);
                    Sounds.Play("sound_menu_change");
                }
                if (Controls.LeftMenu())
                {
                    cursor = Last(cursor);//cursor = (cursor + options.Length - 1) % options.Length;
                    selected.transform.position = new Vector2(sx + sep * cursor, sy);
                    Sounds.Play("sound_menu_change");
                }
            }
            bool occupied = false;
            foreach (Option op in options)
            {
                Debug.Log(op.GetComponent <Text>().text + op.selected);
                if (op.selected)
                {
                    occupied = true;
                }
            }
            if (Controls.LastMenu() && !occupied)
            {
                Sounds.Play("sound_menu_cancel");
                if (parent != null)
                {
                    Disappear(false);
                    parent.GetComponent <Menu>().Appear();
                }
            }
            if (Controls.Select())
            {
                if (optionsObj[cursor].GetComponent <Option>().menu != null)
                {
                    optionsObj[cursor].GetComponent <Option>().menu.GetComponent <Menu>().parent = gameObject;
                }

                optionsObj[cursor].GetComponent <Option>().parentMenu = gameObject;
                optionsObj[cursor].GetComponent <Option>().Select();
                if (optionsObj[cursor].GetComponent <OptionKey>() != null)
                {
                    optionsObj[cursor].GetComponent <OptionKey>();
                }

                Sounds.Play("sound_menu_select");
            }
        }

        foreach (Option op in options)
        {
            op.hovering = false;
        }
        options[cursor].hovering = true;
        Informations.SetInfo(options[cursor].information);
        selected.transform.SetParent(optionsObj[cursor].transform);

        HandleActivation();


        if (!active)
        {
            if (alpha > alphaTarget)
            {
                alpha = Mathf.Max(alpha - alphaSpeed, alphaTarget);
            }
            else if (alpha == 0)
            {
                gameObject.SetActive(false);
            }
            Text[] texts = GetComponentsInChildren <Text>();
            foreach (Text t in texts)
            {
                t.color = new Color(t.color.r, t.color.g, t.color.b, alpha);
            }
            Image[] images = GetComponentsInChildren <Image>();
            foreach (Image im in images)
            {
                im.color = new Color(im.color.r, im.color.g, im.color.b, alpha);
            }
        }

        if (Mathf.Abs(move) < Mathf.Abs(target))
        {
            float dx;
            if (target < 0)
            {
                dx    = -Mathf.Min(speed, Mathf.Abs(move - target));
                move -= dx;
            }
            else
            {
                dx    = Mathf.Min(speed, Mathf.Abs(move - target));
                move += dx;
            }
            Vector2 pos = transform.position;
            transform.position = new Vector2(pos.x + dx, pos.y);
        }
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (hovering && !selected)
        {
            if (Controls.DownMenu())
            {
                if (alternates.Count > 0)
                {
                    Sounds.Play("sound_menu_change");
                }
                selectedNum = (selectedNum + 1) % (alternates.Count);

                Vector2 localpos = selectedObject.transform.localPosition;
                selectedObject.transform.SetParent(alternates[selectedNum].transform);

                selectedObject.transform.localPosition = localpos;
            }
            if (Controls.UpMenu())
            {
                if (alternates.Count > 0)
                {
                    Sounds.Play("sound_menu_change");
                }
                selectedNum = (selectedNum - 1 + (alternates.Count)) % (alternates.Count);

                Vector2 localpos = selectedObject.transform.localPosition;
                selectedObject.transform.SetParent(alternates[selectedNum].transform);

                selectedObject.transform.localPosition = localpos;
            }
        }



        if (selected && action.keyAble)
        {
            alternates[selectedNum].GetComponent <Text>().text = "(Enter key)";
            if (!Controls.Select())
            {
                endSelect = true;
            }
            if (!Controls.Select() || endSelect)
            {
                foreach (KeyCode v in Enum.GetValues(typeof(KeyCode)))
                {
                    if (Input.GetKeyDown(v))//
                    {
                        alternates[selectedNum].GetComponent <Text>().text = v.ToString();
                        PlayerPrefs.SetString(Controls.PREFIXE_ACTION + action.id + "-" + selectedNum, v.ToString());
                        PlayerPrefs.SetInt(Controls.PREFIXE_ACTION + action.id + "-" + selectedNum + "-" + "type", (int)Action.InputType.Key);
                        selected = false;

                        if (selectedNum == alternates.Count - 1 && action.keys.Count <= selectedNum)
                        {
                            action.AddKey(new ActionKey());
                        }
                        if (alternates.Count < Controls.numAlternates)
                        {
                            AddEmpty();
                        }
                        Controls.LoadControls();
                        endSelect = false;
                    }
                }
            }
            Informations.SetInfo(action.information);
        }
        if (selected && action.axisAble)
        {
            alternates[selectedNum].GetComponent <Text>().text = "(Enter axis)";
            string axis = Controls.GetAxis();
            if (axis != null)
            {
                alternates[selectedNum].GetComponent <Text>().text = axis;
                PlayerPrefs.SetString(Controls.PREFIXE_ACTION + action.id + "-" + selectedNum, axis);
                PlayerPrefs.SetInt(Controls.PREFIXE_ACTION + action.id + "-" + selectedNum + "-" + "type", (int)Action.InputType.Axis);
                selected = false;

                if (selectedNum == alternates.Count - 1 && alternates.Count < Controls.numAlternates)
                {
                    action.AddKey(new ActionKey(Action.InputType.Axis, axis));
                    AddEmpty();
                }
                Controls.LoadControls();
            }
            Informations.SetInfo(action.information);
        }
    }
コード例 #6
0
ファイル: OptionList.cs プロジェクト: Inferture/ShmupJin
 override public void Select()
 {
     numChoix = (numChoix + 1) % choix.Length;
     Informations.SetInfo(information + "(currently " + choix[numChoix] + ")");
     selected = false;
 }