示例#1
0
    public void AddOption(PieMenu.MenuOption option)
    {
        List <PieMenu.MenuOption> list = ((IEnumerable <PieMenu.MenuOption>) this.options).ToList <PieMenu.MenuOption>();

        list.Add(option);
        this.options = list.ToArray();
    }
示例#2
0
    public void AddOption(PieMenu.MenuOption option)
    {
        List <PieMenu.MenuOption> list = this.options.ToList <PieMenu.MenuOption>();

        list.Add(option);
        this.options = list.ToArray();
    }
示例#3
0
    public void Rebuild()
    {
        this.options = (
            from x in (IEnumerable <PieMenu.MenuOption>) this.options
            orderby x.order
            select x).ToArray <PieMenu.MenuOption>();
        while (this.optionsCanvas.transform.childCount > 0)
        {
            if (!UnityEngine.Application.isPlaying)
            {
                UnityEngine.Object.DestroyImmediate(this.optionsCanvas.transform.GetChild(0).gameObject);
            }
            else
            {
                GameManager.DestroyImmediate(this.optionsCanvas.transform.GetChild(0).gameObject, true);
            }
        }
        float length = this.radiusSize / (float)((int)this.options.Length);

        for (int i = 0; i < (int)this.options.Length; i++)
        {
            GameObject gameObject = Instantiate.GameObject(this.pieOptionPrefab, null);
            gameObject.transform.SetParent(this.optionsCanvas.transform, false);
            this.options[i].option = gameObject.GetComponent <PieOption>();
            this.options[i].option.UpdateOption(this.startRadius + (float)i * length - length * 0.25f, length, this.sliceGaps, this.options[i].name, this.outerSize, this.innerSize, this.iconSize, this.options[i].sprite);
        }
        this.selectedOption = null;
    }
示例#4
0
    public void UpdateInteraction(bool allowLerp = true)
    {
        if (this.isClosing)
        {
            return;
        }
        Vector3 vector3 = Vector3.op_Subtraction(Input.get_mousePosition(), new Vector3((float)Screen.get_width() / 2f, (float)Screen.get_height() / 2f, 0.0f));
        float   num1    = Mathf.Atan2((float)vector3.x, (float)vector3.y) * 57.29578f;

        if ((double)num1 < 0.0)
        {
            num1 += 360f;
        }
        float num2 = this.radiusSize / (float)this.options.Length;

        for (int index = 0; index < this.options.Length; ++index)
        {
            float num3 = (float)((double)this.startRadius + (double)index * (double)num2 + (double)num2 * 0.5 - (double)num2 * 0.25);
            if ((double)((Vector3) ref vector3).get_magnitude() < 32.0 && this.options[index] == this.defaultOption || (double)((Vector3) ref vector3).get_magnitude() >= 32.0 && (double)Mathf.Abs(Mathf.DeltaAngle(num1, num3)) < (double)num2 * 0.5)
            {
                if (allowLerp)
                {
                    this.pieSelection.startRadius = Mathf.MoveTowardsAngle(this.pieSelection.startRadius, this.options[index].option.background.startRadius, Time.get_deltaTime() * Mathf.Abs((float)((double)Mathf.DeltaAngle(this.pieSelection.startRadius, this.options[index].option.background.startRadius) * 30.0 + 10.0)));
                    this.pieSelection.endRadius   = Mathf.MoveTowardsAngle(this.pieSelection.endRadius, this.options[index].option.background.endRadius, Time.get_deltaTime() * Mathf.Abs((float)((double)Mathf.DeltaAngle(this.pieSelection.endRadius, this.options[index].option.background.endRadius) * 30.0 + 10.0)));
                }
                else
                {
                    this.pieSelection.startRadius = this.options[index].option.background.startRadius;
                    this.pieSelection.endRadius   = this.options[index].option.background.endRadius;
                }
                this.pieSelection.SetVerticesDirty();
                this.middleImage.set_sprite(this.options[index].sprite);
                this.middleTitle.set_text(this.options[index].name);
                this.middleDesc.set_text(this.options[index].desc);
                this.middleRequired.set_text("");
                string requirements = this.options[index].requirements;
                if (requirements != null)
                {
                    this.middleRequired.set_text(requirements.Replace("[e]", "<color=#CD412B>").Replace("[/e]", "</color>"));
                }
                ((Graphic)this.options[index].option.imageIcon).set_color(this.colorIconHovered);
                if (this.selectedOption != this.options[index])
                {
                    if (this.selectedOption != null && !this.options[index].disabled)
                    {
                        this.scaleTarget.get_transform().set_localScale(Vector3.get_one());
                        LeanTween.scale(this.scaleTarget, Vector3.op_Multiply(Vector3.get_one(), 1.03f), 0.2f).setEase(PieMenu.easePunch);
                    }
                    this.selectedOption = this.options[index];
                }
            }
示例#5
0
    public void Rebuild()
    {
        this.options = ((IEnumerable <PieMenu.MenuOption>) this.options).OrderBy <PieMenu.MenuOption, int>((Func <PieMenu.MenuOption, int>)(x => x.order)).ToArray <PieMenu.MenuOption>();
        while (this.optionsCanvas.get_transform().get_childCount() > 0)
        {
            GameManager.DestroyImmediate(((Component)this.optionsCanvas.get_transform().GetChild(0)).get_gameObject(), true);
        }
        float sliceSize = this.radiusSize / (float)this.options.Length;

        for (int index = 0; index < this.options.Length; ++index)
        {
            GameObject gameObject = Instantiate.GameObject(this.pieOptionPrefab, (Transform)null);
            gameObject.get_transform().SetParent(this.optionsCanvas.get_transform(), false);
            this.options[index].option = (PieOption)gameObject.GetComponent <PieOption>();
            this.options[index].option.UpdateOption((float)((double)this.startRadius + (double)index * (double)sliceSize - (double)sliceSize * 0.25), sliceSize, this.sliceGaps, this.options[index].name, this.outerSize, this.innerSize, this.iconSize, this.options[index].sprite);
        }
        this.selectedOption = (PieMenu.MenuOption)null;
    }
示例#6
0
 public void SetDefaultOption()
 {
     this.defaultOption = (PieMenu.MenuOption)null;
     for (int index = 0; index < this.options.Length; ++index)
     {
         if (!this.options[index].disabled)
         {
             if (this.defaultOption == null)
             {
                 this.defaultOption = this.options[index];
             }
             if (this.options[index].selected)
             {
                 this.defaultOption = this.options[index];
                 break;
             }
         }
     }
 }
示例#7
0
 public void SetDefaultOption()
 {
     this.defaultOption = null;
     for (int i = 0; i < (int)this.options.Length; i++)
     {
         if (!this.options[i].disabled)
         {
             if (this.defaultOption == null)
             {
                 this.defaultOption = this.options[i];
             }
             if (this.options[i].selected)
             {
                 this.defaultOption = this.options[i];
                 return;
             }
         }
     }
 }
示例#8
0
    public void UpdateInteraction(bool allowLerp = true)
    {
        if (this.isClosing)
        {
            return;
        }
        Vector3 vector3 = UnityEngine.Input.mousePosition - new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f);
        float   single  = Mathf.Atan2(vector3.x, vector3.y) * 57.29578f;

        if (single < 0f)
        {
            single += 360f;
        }
        float length = this.radiusSize / (float)((int)this.options.Length);

        for (int i = 0; i < (int)this.options.Length; i++)
        {
            float single1 = this.startRadius + (float)i * length + length * 0.5f - length * 0.25f;
            if ((vector3.magnitude >= 32f || this.options[i] != this.defaultOption) && (vector3.magnitude < 32f || Mathf.Abs(Mathf.DeltaAngle(single, single1)) >= length * 0.5f))
            {
                this.options[i].option.imageIcon.color = this.colorIconActive;
            }
            else
            {
                if (!allowLerp)
                {
                    this.pieSelection.startRadius = this.options[i].option.background.startRadius;
                    this.pieSelection.endRadius   = this.options[i].option.background.endRadius;
                }
                else
                {
                    this.pieSelection.startRadius = Mathf.MoveTowardsAngle(this.pieSelection.startRadius, this.options[i].option.background.startRadius, Time.deltaTime * Mathf.Abs(Mathf.DeltaAngle(this.pieSelection.startRadius, this.options[i].option.background.startRadius) * 30f + 10f));
                    this.pieSelection.endRadius   = Mathf.MoveTowardsAngle(this.pieSelection.endRadius, this.options[i].option.background.endRadius, Time.deltaTime * Mathf.Abs(Mathf.DeltaAngle(this.pieSelection.endRadius, this.options[i].option.background.endRadius) * 30f + 10f));
                }
                this.pieSelection.SetVerticesDirty();
                this.middleImage.sprite  = this.options[i].sprite;
                this.middleTitle.text    = this.options[i].name;
                this.middleDesc.text     = this.options[i].desc;
                this.middleRequired.text = "";
                string str = this.options[i].requirements;
                if (str != null)
                {
                    str = str.Replace("[e]", "<color=#CD412B>");
                    str = str.Replace("[/e]", "</color>");
                    this.middleRequired.text = str;
                }
                this.options[i].option.imageIcon.color = this.colorIconHovered;
                if (this.selectedOption != this.options[i])
                {
                    if (this.selectedOption != null && !this.options[i].disabled)
                    {
                        this.scaleTarget.transform.localScale = Vector3.one;
                        LeanTween.scale(this.scaleTarget, Vector3.one * 1.03f, 0.2f).setEase(PieMenu.easePunch);
                    }
                    if (this.selectedOption != null)
                    {
                        this.selectedOption.option.imageIcon.RebuildHackUnity2019();
                    }
                    this.selectedOption = this.options[i];
                    if (this.selectedOption != null)
                    {
                        this.selectedOption.option.imageIcon.RebuildHackUnity2019();
                    }
                }
            }
            if (this.options[i].disabled)
            {
                this.options[i].option.imageIcon.color  = this.colorIconDisabled;
                this.options[i].option.background.color = this.colorBackgroundDisabled;
            }
        }
    }