Ejemplo n.º 1
0
    void SetShopMaterial()
    {
        if (File.Exists(Application.persistentDataPath + "/SaveData/" + "skinInfo.sv"))
        {
            string[] info = new string[2];
            info = File.ReadAllLines(Application.persistentDataPath + "/SaveData/" + "skinInfo.sv");
            Skin.Rarity _rarity = (Skin.Rarity)(System.Convert.ToInt32(info[0]));
            string      _name   = info[1];

            if (_name == "Stone")
            {
                material.SetTexture("_MainTex", Resources.Load <Skin>("Prefabs/Stone").sprite.texture);
                material.SetTexture("_BumpMap", Resources.Load <Skin>("Prefabs/Stone").normalSprite);
                return;
            }

            Skin skin = TakeSkinFromPacks(_rarity, _name);
            material.SetTexture("_MainTex", skin.sprite.texture);
            if (skin.normalSprite)
            {
                material.SetTexture("_BumpMap", skin.normalSprite);
            }
        }
        else
        {
            material.SetTexture("_MainTex", Resources.Load <Skin>("Prefabs/Stone").sprite.texture);
            material.SetTexture("_BumpMap", Resources.Load <Skin>("Prefabs/Stone").normalSprite);
        }
    }
Ejemplo n.º 2
0
    Skin TakeSkinFromPacks(Skin.Rarity rarity, string name)
    {
        Skin skin;

        switch (rarity)
        {
        case Skin.Rarity.Common:
            skin = skinsHolder.skinPacks[0].skins.Find(x => x.name == name);
            return(skin);

        case Skin.Rarity.Uncommon:
            skin = skinsHolder.skinPacks[1].skins.Find(x => x.name == name);
            return(skin);

        case Skin.Rarity.Golden:
            skin = skinsHolder.skinPacks[2].skins.Find(x => x.name == name);
            return(skin);
        }

        return(null);
    }
Ejemplo n.º 3
0
 void InventoryLoad()
 {
     if (File.Exists(Application.persistentDataPath + "/SaveData/Inventory.json"))
     {
         string[] jasonTex = File.ReadAllLines(Application.persistentDataPath + "/SaveData/Inventory.json");
         for (int i = 0; i < jasonTex.Length;)
         {
             Skin.Rarity _rarity = (Skin.Rarity)(System.Convert.ToInt32(jasonTex[i++]));
             string      _name   = jasonTex[i++];
             if (_name == "Stone")
             {
                 inventory.skins.Add(Resources.Load <Skin>("Prefabs/Stone"));
                 continue;
             }
             inventory.skins.Add(TakeSkinFromPacks(_rarity, _name));
         }
     }
     else
     {
         inventory.skins.Add(Resources.Load <Skin>("Prefabs/Stone"));
         InventorySave();
     }
 }