void Update() { if (newCharacter) { followTarget = characterSelector.GetCharacterObject(); } if (characterSelector != null) { if (characterSelector.GetCharacterActive()) //checks if the character is active { targetPos = new Vector3(followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z); //using the z position of the camera } else { if (playerStartPoint != null) { targetPos = new Vector3(playerStartPoint.GetStartPosition().x, playerStartPoint.GetStartPosition().y, -10); //sets the camera's default position to the position of the player start point game object to prevent camera drag on character spawn } else { targetPos = new Vector3(0, 0, -10); //if there is no player start point present, default the camera to these values } } } transform.position = Vector3.Lerp(transform.position, targetPos, moveSpeed * Time.deltaTime); //current position, new position (target position), amount of movement per frame - Using Time.deltaTime to adjust to computer framerates }
void Update() { if (characterSelector.GetCharacterActive()) //checks if the character is active { playerHealthManager = characterSelector.GetCharacterObject().GetComponent <PlayerHealthManager>(); //get the instantiated (or active) player's PlayerHealthManager script maxHealth = playerHealthManager.GetMaxHealth(); //sets a variable to teh value of the character's max health currentHealth = playerHealthManager.GetCurrentHealth(); //sets a variable to teh value of the character's max health healthBar.maxValue = maxHealth; healthBar.value = currentHealth; //healthText.text = "HP: " + ((currentHealth / maxHealth) * 100).ToString() + "%"; //sets the health text to the player's current health as a percentage healthText.text = "HP: " + (currentHealth.ToString() + " / " + maxHealth.ToString()); //sets the health text to the player's current health over max health //changed to avoid decimal percentages (since the Warrior and Archer's health isn't 100) } }
void Update() { playerController = FindObjectOfType <PlayerController>(); characterSelector = FindObjectOfType <CharacterSelector>(); levelTransitionManager = FindObjectOfType <LevelTransitionManager>(); if (characterSelector != null) //checks if characterSelector is active/not destroyed { if (characterSelector.GetCharacterActive()) //checks if the character is active { playerHealthManager = characterSelector.GetCharacterObject().GetComponent <PlayerHealthManager>(); //gets the current player instance's health manager } } scenesListLength = levelTransitionManager.GetScenesList().Count; chosenScenesListLength = levelTransitionManager.GetChosenScenesList().Count; }
void Update() { characterSelector = FindObjectOfType <CharacterSelector>(); audioManager = FindObjectOfType <AudioManager>(); try //hastily done because a non-gamebreaking error was being thrown once the player is killed { if (characterSelector.GetCharacterActive()) //checks if the character is active { playerHealthManager = characterSelector.GetCharacterObject().GetComponent <PlayerHealthManager>(); //gets the current player instance's health manager maxHealth = playerHealthManager.GetMaxHealth(); currentHealth = playerHealthManager.GetCurrentHealth(); } } catch { //pass } }
void Update() { characterSelector = FindObjectOfType <CharacterSelector>(); if (characterSelector != null) { if (characterSelector.GetCharacterActive()) //checks if the character is active { playerController = characterSelector.GetCharacterObject().GetComponent <PlayerController>(); //gets the current player instance's health manager if (!startPosSet) { startPosSet = true; playerController.transform.position = transform.position; //setting the player's position to the same position as the start point playerController.lastMove = startDirection; //The Vector2 variable, lastMove, in the PlayerController script was made public so it could be updated here } } } }
void Update() { if (justAttacked) //if the player was just attacked by the enemy, start the counter { nextAttackCounter -= Time.deltaTime; } if (nextAttackCounter <= 0f) //if the counter ends, the enemy did not just attack and the counter is reset { justAttacked = false; nextAttackCounter = storeAttackCounter; } if (characterSelector.GetCharacterActive()) //checks if the character is active { charge = characterSelector.GetCharacterObject().GetComponentInChildren <Charge>(); //retrieved from the player's weapon roll = characterSelector.GetCharacterObject().GetComponentInChildren <Roll>(); chargeInvulnerable = charge.GetInvulnerable(); rollInvulnerable = roll.GetInvulnerable(); } }