Exemplo n.º 1
0
    // 初始化装备
    private void InitEquipment()
    {
        //PlayerPrefs.SetInt("Weapon1", 3);
        // 衣服

        // 武器
        weaponList = PlayerManager.instance.getWeaponsPossess();
        if (PlayerPrefs.HasKey("Weapon1"))
        {
            Weapon weapon1 = WeaponsStore.getWeaponFromStoreId(weaponList, PlayerPrefs.GetInt("Weapon1"));
            //print(weapon1 == null);
            if (weapon1 != null)
            {
                //print(WeaponsStore.getWeaponItemPath(weapon1.ItemPath));
                //print(Resources.Load(WeaponsStore.getWeaponItemPath(weapon1.ItemPath)) as Texture);
                weaponTexture1.mainTexture = Resources.Load(weapon1.ItemPath) as Texture;
            }
        }
        if (PlayerPrefs.HasKey("Weapon2"))
        {
            Weapon weapon2 = WeaponsStore.getWeaponFromStoreId(weaponList, PlayerPrefs.GetInt("Weapon2"));
            if (weapon2 != null)
            {
                weaponTexture2.mainTexture = Resources.Load(weapon2.ItemPath) as Texture;
            }
        }
        if (PlayerPrefs.HasKey("Weapon3"))
        {
            Weapon weapon3 = WeaponsStore.getWeaponFromStoreId(weaponList, PlayerPrefs.GetInt("Weapon3"));
            if (weapon3 != null)
            {
                weaponTexture3.mainTexture = Resources.Load(weapon3.ItemPath) as Texture;
            }
        }

        // 技能
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // 添加武器
        List <Weapon> list = PlayerManager.instance.getWeaponsPossess();

        //print(PlayerPrefs.GetInt(PlayerManager.Key_Weapon1) + "  " + PlayerPrefs.GetInt(PlayerManager.Key_Weapon2) + "  " + PlayerPrefs.HasKey(PlayerManager.Key_Weapon3));

        if (PlayerPrefs.HasKey(PlayerManager.Key_Weapon1))
        {
            weapon1.setWeapon(WeaponsStore.getWeaponFromStoreId(list, PlayerPrefs.GetInt(PlayerManager.Key_Weapon1)));
        }

        if (PlayerPrefs.HasKey(PlayerManager.Key_Weapon2))
        {
            weapon2.setWeapon(WeaponsStore.getWeaponFromStoreId(list, PlayerPrefs.GetInt(PlayerManager.Key_Weapon2)));
        }

        if (PlayerPrefs.HasKey(PlayerManager.Key_Weapon3))
        {
            weapon3.setWeapon(WeaponsStore.getWeaponFromStoreId(list, PlayerPrefs.GetInt(PlayerManager.Key_Weapon3)));
        }

        RegisterEvent();
    }