Exemplo n.º 1
0
    private void LoadItemsResources(Dictionary <EItemKey, GameObject[]> resourcesDic, EUnitKey unitKey, UnitModelView unitModelView, EItemKey weaponRKey, EItemKey weaponLKey, EItemKey armorKey)
    {
        if (unitModelView != null)
        {
            GameObject rhWeaponResource  = null;
            GameObject lhWeaponResource  = null;
            GameObject headArmorResource = null;
            GameObject bodyArmorResource = null;

            unitModelView.SetWeaponType(weaponRKey, weaponLKey);

            //right hand weapon
            if (!resourcesDic.ContainsKey(weaponRKey))
            {
                GameObject[] weaponResources = new GameObject[1];
                weaponResources[0] = Resources.Load(string.Format("{0}/{1}", GameConstants.Paths.ITEM_RESOURCES, GetItemResourcePath(weaponRKey))) as GameObject;
                resourcesDic.Add(weaponRKey, weaponResources);

                rhWeaponResource = weaponResources[0];
            }
            else if (weaponRKey != EItemKey.None)
            {
                rhWeaponResource = resourcesDic[weaponRKey][0];
            }

            //left hand weapon
            if (!resourcesDic.ContainsKey(weaponLKey))
            {
                GameObject[] weaponResources = new GameObject[1];
                weaponResources[0] = Resources.Load(string.Format("{0}/{1}", GameConstants.Paths.ITEM_RESOURCES, GetItemResourcePath(weaponLKey))) as GameObject;
                resourcesDic.Add(weaponLKey, weaponResources);

                lhWeaponResource = weaponResources[0];
            }
            else if (weaponLKey != EItemKey.None)
            {
                lhWeaponResource = resourcesDic[weaponLKey][0];
            }

            //armor
            if (armorKey == EItemKey.None)
            {
                //Debug.LogWarning(string.Format("No armor set for {0} unit", unitKey));
            }
            else if (!resourcesDic.ContainsKey(armorKey))
            {
                string armorResourcePath = GetItemResourcePath(armorKey);

                GameObject[] armorResources = new GameObject[2];
                armorResources[0] = Resources.Load(string.Format("{0}/{1}_head", GameConstants.Paths.ITEM_RESOURCES, armorResourcePath)) as GameObject;
                armorResources[1] = Resources.Load(string.Format("{0}/{1}_body", GameConstants.Paths.ITEM_RESOURCES, armorResourcePath)) as GameObject;
                resourcesDic.Add(armorKey, armorResources);

                headArmorResource = armorResources[0];
                bodyArmorResource = armorResources[1];
            }
            else
            {
                headArmorResource = resourcesDic[armorKey][0];
                bodyArmorResource = resourcesDic[armorKey][1];
            }

            unitModelView.SetupGraphics(rhWeaponResource, lhWeaponResource, headArmorResource, bodyArmorResource);
        }
    }