Hello , this is Mahsa
I have script that controls upgrading weapon , the point is I have two factory for weapons one of em is axe another one is pickaxe.
I have index that these two share in script when I’m saving the index to player prefs and load it
it will effect two script even I didn’t press the upgrade button
can some tell me how can i seperatly save index in a single script ?
public int index = 0;
public void OnClickToUpgrade()
{
if(WeaponScriptable.Count == 0) return;
StartCoroutine(SpawnResource(player, player.playerSpawnPoint));
}
private IEnumerator SpawnResource(PlayerTileCollector player, Transform playerSpawnPoint)
{
if (index > 6)
{
yield break;
}
chosenWeapon = WeaponScriptable[index];
var list = chosenWeapon.RequiredResourceList;
for (int j = 0; j < list.Count; j++)
{
StartCoroutine(GetResourceToSpawn(player, playerSpawnPoint,list[j]));
}
weaponMeshManager.UpgradeWeapon();
WeaponInfoCanvas.gameObject.SetActive(false);
yield return new WaitForSeconds(8f);
if (list.All(x => x.ResourceAmount == 0))
{
index++;
PlayerPrefs.SetInt("Index", index);
Debug.Log("Index has saved");
}
}