Пример #1
0
        public void SetWeaponIcon(ItemSlot item)
        {
            if (CurrentWeaponContainer == null)
            {
                return;
            }

            if (CurrentWeaponContainer.childCount > 0)
            {
                for (var i = 0; i < CurrentWeaponContainer.childCount; i++)
                {
                    Destroy(CurrentWeaponContainer.GetChild(i).gameObject);
                }
            }

            if (item == null)
            {
                return;
            }

            var prefabName = string.Empty;

            var type = HeroHelper.GetActiveItemType(item);

            switch (type)
            {
            case WeaponType.Anh:
                prefabName = "Prefabs\\Anh";
                break;

            case WeaponType.Sword:
                prefabName = "Prefabs\\Sword";
                break;

            case WeaponType.Banana:
                prefabName = "Prefabs\\Banana";
                break;
            }

            var weaponTamplate = Resources.Load <GameObject>(prefabName);
            var weaponObj      = Instantiate <GameObject>(weaponTamplate, CurrentWeaponContainer);

            weaponObj.transform.localPosition = Vector3.zero;
        }