//Method used to send user back to shop by 'travelling' public void TravelButton() { Travel.Towns currentTownSelected = CurrentTownObject(townHit.transform.gameObject); SFX.Play("Traveling_chimes", 1f, 1f, 0f, false, 0f); Travel.ChangeCurrentTown(currentTownSelected); SaveManager.SaveInventory(); Initiate.Fade("Shop", Color.black, 2f); }
//Method to travel to unlocked town by button public void TravelButton() { Travel.ChangeCurrentTown(currentTownSelected); helperText.enabled = false; lastTownClicked = null; SaveManager.SaveInventory(); Initiate.Fade("Shop", Color.black, 2f); }
//Method used when attempting to buy a new town through button. Also handles UI at same time public void PurchaseButton() { bool completeTransaction = Travel.UnlockNewTown(currentTownSelected); //If this was the first town unlocked, make it the current Debug.Log(Inventory.Instance.GetUnlockedTowns().Count + " unlocked towns"); Debug.Log("Complete transaction " + completeTransaction); if (Inventory.Instance.GetUnlockedTowns().Count == 1 && completeTransaction) { //SFX.Play("sound"); player.SetActive(false); player.transform.position = ReturnTownPosition(currentTownSelected); helperText.text = "Welcome to " + currentTownSelected; Travel.ChangeCurrentTown(currentTownSelected); SaveManager.SaveInventory(); PlayerPrefs.SetInt("FirstStart", 1); if (GameManager.Instance.InMap) { GameManager.Instance.InMap = false; GameManager.Instance.BarterTutorial = true; } Initiate.Fade("Shop", Color.black, 2f); } //Else if it was a subsequent town, check the purchase was successful else { if (completeTransaction) { //SFX.Play("sound"); SFX.Play("location_purchase", 1f, 1f, 0f, false, 0f); if (GameManager.Instance.InMap) { GameManager.Instance.InMap = false; GameManager.Instance.BarterTutorial = true; } helperText.text = currentTownSelected + " can now be travelled to"; Travel.ChangeCurrentTown(currentTownSelected); Initiate.Fade("Shop", Color.black, 2f); SaveManager.SaveInventory(); } else { helperText.text = "Insufficent gold to travel to next town"; //SFX.Play("sound"); SFX.Play("Fail_Tap", 1f, 1f, 0f, false, 0f); } } lastTownClicked = null; //CheckUnlockedTowns(); }
//Method used when attempting to buy a new town through button. Also handles UI at same time public void PurchaseTown() { Travel.Towns currentTownSelected = CurrentTownObject(townHit.transform.gameObject); bool completeTransaction = Travel.UnlockNewTown(currentTownSelected); //If this was the first town unlocked, make it the current Debug.Log(Inventory.Instance.GetUnlockedTowns().Count + " unlocked towns"); Debug.Log("Complete transaction " + completeTransaction); if (Inventory.Instance.GetUnlockedTowns().Count == 1 && completeTransaction) { Travel.ChangeCurrentTown(currentTownSelected); SFX.Play("Location_query_purchase", 1f, 1f, 0f, false, 0f); SaveManager.SaveInventory(); PlayerPrefs.SetInt("ExistingSave", 1); if (GameManager.Instance.InMap) { GameManager.Instance.InMap = false; GameManager.Instance.BarterTutorial = true; } Travel.ChangeCurrentTown(currentTownSelected); SaveManager.SaveInventory(); GameManager.Instance.firstTownSelect = false; Initiate.Fade("Shop", Color.black, 2f); } //Else if it was a subsequent town, check the purchase was successful else { if (completeTransaction) { PlayerPrefs.SetInt("ExistingSave", 1); SFX.Play("location_purchase", 1f, 1f, 0f, false, 0f); if (GameManager.Instance.InMap) { GameManager.Instance.InMap = false; GameManager.Instance.BarterTutorial = true; } Travel.ChangeCurrentTown(currentTownSelected); SaveManager.SaveInventory(); GameManager.Instance.firstTownSelect = false; Initiate.Fade("Shop", Color.black, 2f); } else { SFX.Play("Fail_Tap", 1f, 1f, 0f, false, 0f); } } }
//Used when the player clicks on the same town object a second time private void SecondClick(RaycastHit hit) { Travel.Towns selectedTown = CurrentTownObject(lastTownClicked); //If not unlocked, attempt to buy if (!Travel.unlockedTowns.Contains(selectedTown)) { AttemptToBuyTown(selectedTown); } //If the town has been unlocked, move to selected town else { //SFX.Play("sound"); //movementFinished = false; //StartCoroutine(MovePlayerToNewTown(selectedTown)); Travel.ChangeCurrentTown(selectedTown); helperText.enabled = false; lastTownClicked = null; SaveManager.SaveInventory(); Initiate.Fade("Shop", Color.black, 2f); } }