// Called before the first frame // We use start to start the generation because we have to wait for references to be set in awake private void Start() { // Get the persistant controller script PersistantController persistContScript = FindPersistCont(); // Start the generation of this floor persistContScript.StartGeneration(); }
/// <summary> /// Called from the yes button of the "next floor" scene /// </summary> public void PrepareNextFloorInstigation() { // Get the persistant controller script PersistantController persistContScript = FindPersistCont(); // Prepare the next floor persistContScript.PrepareNextFloor(); }
/// <summary> /// Loads the data for the persistant controller and applies the save data to runtime /// </summary> /// <param name="persistCont">PersistantController that will recieve the data </param> public static void LoadPersistantController(PersistantController persistCont) { // Get the save data PersistantFloorData persistFloorData = SaveSystem.LoadPersistantFloorData(); // Set the values of the PersistantController persistCont.SetNextFloorDifficulty(persistFloorData.GetNextFloorDifficulty()); persistCont.SetNextFloorNum(persistFloorData.GetNextFloor()); PersistantController.SetPotCharges(persistFloorData.GetPotCharges()); }
/// <summary> /// when you click on the potion you pick it up and whoever you click on next recieves it reduces charges by 1 /// if you reclick the potion with a potion in hand it will put it back down increasing the charges by 1 /// </summary> public void HoldingPotion() { //if you aren't holding the potion you will pick it up if (_isHolding == false && PersistantController.GetPotCharges() != 0) { _isHolding = true; } //if you are already holding the potion and reclick the potion icon it puts it back else if (_isHolding == true) { _isHolding = false; } }
/// <summary> /// Finds the Persistant controller and calls PrepareNextFloor /// </summary> public void PrepareNextFloor() { try { GameObject persistObj = GameObject.FindWithTag("PersistantController"); PersistantController persistRef = persistObj.GetComponent <PersistantController>(); persistRef.PrepareNextFloor(); } catch { Debug.LogError("Failed to Prepare Next Floor"); } }
private static PersistantController _instance; // Retain personalised instance, so we don't create more than one of this object. // --------------------------------------------------------------------------------------------------------------------------------------------------------- // // Use this for initialization void Start() { // Make sure we've only got one of this little bugger running. if (!_instance) { _instance = this; } else { Destroy(this.gameObject); } // Make sure this isn't destroyed. I quite like it. DontDestroyOnLoad(gameObject); }
public void GameOverToMenu(string menu) { // Destroy the persistant controller try { GameObject persistObj = GameObject.FindWithTag("PersistantController"); PersistantController persistRef = persistObj.GetComponent <PersistantController>(); persistRef.PrepareForQuit(); } catch { Debug.LogError("No Persistant Controller found"); } // Load the menu scene SceneManager.LoadScene(menu); }
private void LateUpdate() { //updates the charges whenever it is changed _chargesText.text = PersistantController.GetPotCharges().ToString(); //updates potion image to follow mouse if (_isHolding == true) { _potionImage.transform.position = Input.mousePosition; } //returns potion to default position else if (_isHolding == false) { _potionImage.transform.position = _defaultPos; } }
// Gets character selected using the event and changes allyIndex to match the character selected character private void CharacterToHeal(MoveAttack charMA) { if (charMA.WhatAmI == CharacterType.Ally && _isHolding == true) { // reduces the charges PersistantController.SetPotCharges(PersistantController.GetPotCharges() - 1); _allyToHeal = charMA.GetComponent <AllyHealth>(); if (_allyToHeal == null) { Debug.LogError("No AllyHealth attached to " + _allyToHeal.name); } HealCharacter(); _isHolding = false; } }
/// <summary> /// Finds the PersistantController in the scene and returns it /// </summary> /// <returns>PersistantController in the scene</returns> private PersistantController FindPersistCont() { // Get the persistant controller GameObject persistContRef = GameObject.FindWithTag("PersistantController"); if (persistContRef == null) { Debug.Log("Could not find a gameobject with the tag PersistantController"); } // Get the persistant controller script PersistantController persistContScript = persistContRef.GetComponent <PersistantController>(); if (persistContScript == null) { Debug.Log(persistContScript.name + " did not have a PersistantController script attached"); } return(persistContScript); }
// Called before the first frame private void Start() { /// Get stuff we need // Get parents CreateParents(); // Get the persistant controller try { GameObject persistContObj = GameObject.FindWithTag("PersistantController"); _persistCont = persistContObj.GetComponent <PersistantController>(); } catch { Debug.LogError("Error setting persistant controller"); } // Load everything LoadFloor(); // Get the procedural generation controller from the generation controller GameObject genContObj = GameObject.FindWithTag("GenerationController"); if (genContObj != null) { ProceduralGenerationController genContRef = genContObj.GetComponent <ProceduralGenerationController>(); if (genContRef != null) { genContRef.GiveEssentials(_roomParent, _bleedLightParent, _wallParent, _stairsTrans, _tilemap, _enemyParent, _allyParent, _interactableParent); genContRef.GenerateFloor(false, 0, _allyParent); } else { Debug.LogError("No ProceduralGenerationController was attached to " + genContObj.name); } } else { Debug.LogError("No GameObject with the tag GenerationController was found"); } }
public PersistantFloorData(PersistantController persistCont) { _nextFloor = persistCont.GetNextFloorNum(); _nextFloorDiff = persistCont.GetNextFloorDifficulty(); _potCharges = PersistantController.GetPotCharges(); }
//refills potion back to three public void RefillPotion() { PersistantController.SetPotCharges(3); _update = true; Debug.Log("Potions have been refilled"); }