Пример #1
0
        private void Create(int itemCount, float radius)
        {
            const float radStart = Mathf.PI / 2f;

            float radianIncr = Mathf.PI * 2 / itemCount;

            for (int i = 0; i < itemCount; i++)
            {
                FanMenuItem fmi = GameObject.Instantiate <FanMenuItem>(fanMenuItemTemplate, transform);

                float   radians   = radianIncr * i;
                Vector3 circleVec = new Vector3(Mathf.Cos(radStart + radians), Mathf.Sin(radStart + radians), 0f);
                Vector3 spritePos = circleVec * radius;
                Vector3 textPos   = circleVec * radius * 1.1f;
                fmi.transform.localPosition         = spritePos;
                fmi.tmpText.transform.localPosition = textPos;
                fmi.Create(menuItems[i].tmpText, menuItems[i].spriteImage, menuItems[i].response);
                fmi.gameObject.SetActive(false);
                fmi.GetComponent <BoxCollider>().enabled = false;
                createdItems.Add(fmi);
            }
        }
Пример #2
0
        public bool Create(ConversationNode node, System.Action <int> onSelect)
        {
            if (node.Options.Length == 0)
            {
                return(false);
            }

            const float radStart = Mathf.PI / 2f;

            float radianIncr = Mathf.PI * 2 / node.Options.Length;

            if (createdItems.Count > 0)
            {
                Debug.Log("Items not cleared: " + createdItems.Count);

                ClearItems(false);
            }

            for (int i = 0; i < node.Options.Length; i++)
            {
                FanMenuItem fmi = GameObject.Instantiate <FanMenuItem>(fanMenuItemTemplate, transform);

                float   radians   = radianIncr * i;
                Vector3 circleVec = new Vector3(Mathf.Cos(radStart + radians), Mathf.Sin(radStart + radians), 0f);
                Vector3 spritePos = circleVec * radius;
                Vector3 textPos   = circleVec * radius * 1.1f;
                fmi.transform.localPosition         = spritePos;
                fmi.tmpText.transform.localPosition = textPos;
                fmi.Create(node.Options[i].Text, i, onSelect);
                fmi.gameObject.SetActive(false);
                fmi.GetComponent <BoxCollider>().enabled = false;
                createdItems.Add(fmi);
            }

            Debug.Log("Created items, size: " + createdItems.Count);

            return(true);
        }