// Use this for initialization void Start() { playerGold = FindObjectOfType(typeof(PlayerGold)) as PlayerGold; inventory = FindObjectOfType(typeof(InventoryManager)) as InventoryManager; exit.onClick.AddListener(Exit); startFunction(); }
public void Setup(EnemySpawner enemySpawner, PlayerGold playerGold) { spriteRenderer = GetComponent <SpriteRenderer>(); this.enemySpawner = enemySpawner; this.playerGold = playerGold; if (weaponType == WeaponType.Cannon) { ChangeState(WeaponState.SearchTarget); } }
public static void SavePlayer(PlayerGold playerGold) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/miniLuma.xd"; FileStream stream = new FileStream(path, FileMode.Create); PlayerData data = new PlayerData(playerGold); formatter.Serialize(stream, data); stream.Close(); }
public PlayerData(PlayerGold playerGold) { gold = playerGold.goldAmount; }
/// <summary> /// /// Constructor for copying player resource information /// /// </summary> public PlayerGold(PlayerGold playerGold) { CopyCommonResourceValues(playerGold); BountyGain = playerGold.BountyGain; }
void OnEnable() { playerGold = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerGold> (); shopManager = FindObjectOfType(typeof(ShopManager)) as ShopManager; }
public void buyItem() { playerGold = PlayerPrefs.GetInt("PlayerGold"); //check player gold if (playerGold >= itemPrice && PlayerPrefs.HasKey(itemName + "SkillLvl")) { //play audio GameObject objSfxPurchasing = GameObject.Find("sfxPurchasing"); AudioSource asSfxPuchasing = objSfxPurchasing.GetComponent <AudioSource>(); asSfxPuchasing.Play(); buyNotif.SetActive(true); //check if player has this item already if (itemTime <= 480) { if ((PlayerPrefs.HasKey("endTime" + itemName))) { print("BEFORE: " + itemTime.ToString()); if (tempItemTime == 0) { tempItemTime = itemTime; } itemTime = (Convert.ToDateTime(PlayerPrefs.GetString("endTime" + itemName)) - System.DateTime.Now).TotalMinutes + tempItemTime; print("AFTER: " + itemTime.ToString()); } if (itemName == "boost") { printTimeBoost = printTime.GetComponent <PrintTimeBoost>(); printTimeBoost.itmTime = itemTime; printTimeBoost.itemName = itemName; printTimeBoost.iprintna(); } else if (itemName == "attack") { printTimeAttack = printTime.GetComponent <PrintTimeAttack>(); printTimeAttack.itmTime = itemTime; printTimeAttack.itemName = itemName; printTimeAttack.iprintna(); } else if (itemName == "shield") { printTimeShield = printTime.GetComponent <PrintTimeShield>(); printTimeShield.itmTime = itemTime; printTimeShield.itemName = itemName; printTimeShield.iprintna(); } //decrease price from gold PlayerPrefs.SetInt("PlayerGold", PlayerPrefs.GetInt("PlayerGold") - itemPrice); //curGold.text = PlayerPrefs.GetInt("PlayerGold").ToString(); pGold = GameObject.Find("PlayerGoldMenu").GetComponent <PlayerGold>(); pGold.playerGold = PlayerPrefs.GetInt("PlayerGold"); PlayerPrefs.Save(); } } else { //insufficient print("Insufficient Gold"); //play audio GameObject objSfxInsufficientGold = GameObject.Find("sfxInsufficientGold"); AudioSource asSfxInsufficientGold = objSfxInsufficientGold.GetComponent <AudioSource>(); asSfxInsufficientGold.Play(); } }