Exemple #1
0
        public void UI_OpenSelectMenu(int typeID)
        {
            SelectMenuType type = (SelectMenuType)Mathf.Clamp(typeID, 0, 4);

            GunInfo.GunType gunType = (GunInfo.GunType)Mathf.Clamp(typeID, 0, 3);

            currentSelectMenu = type;

            if (type == SelectMenuType.Primary)
            {
                currentSelected = primary;
            }
            else if (type == SelectMenuType.Secondary)
            {
                currentSelected = secondary;
            }
            else if (type == SelectMenuType.Melee)
            {
                currentSelected = melee;
            }
            else if (type == SelectMenuType.Item1)
            {
                currentSelected = item1;
            }
            else
            {
                currentSelected = item2;
            }

            for (int i = 0; i < items.Length; i++)
            {
                ClassItem classItem = items[i];
                classItem.gameObject.SetActive(classItem.info.type == gunType);
            }

            scrollRect.verticalNormalizedPosition = 1f;
            UpdateItems();

            main.SetActive(false);
            selectMenu.SetActive(true);
        }
Exemple #2
0
        void Start()
        {
            UpdateItems();
            OnInitializeGamemode();

            GunInfo[] allGuns = GameController.GetAllGuns();
            items = new ClassItem[allGuns.Length];

            for (int i = 0; i < allGuns.Length; i++)
            {
                GunInfo gun = allGuns[i];

                GameObject go = Instantiate(classItemPrefab) as GameObject;
                go.transform.SetParent(classItemParent);
                go.transform.localScale = Vector3.one;

                ClassItem classItem = go.GetComponent <ClassItem>();
                classItem.Refresh(gun);
                classItem.classCreation = this;

                items[i] = classItem;
            }
        }