void Start() { // Get the Character component. character = GetComponentInParent <Character> (); // Get the Character Stats component. charStats = character.GetComponentInChildren <Character_Stats> (); }
void Awake() { // Get the Player State in the parent. _playerManager = GetComponentInParent <Player_Manager>(); // Get the Players Stats as we use that to potentially alter movement. charStats = _playerManager.GetComponentInChildren <Character_Stats> (); // Get the Rigidbody2D Component. rb = GetComponent <Rigidbody2D>(); }
void Awake() { // Get the Player State. _playerManager = GetComponentInParent <Player_Manager>(); // Get the Players Stats as we use that to potentially alter movement. charStats = _playerManager.GetComponentInChildren <Character_Stats> (); // Get the Rigidbody2D Component. rb = GetComponent <Rigidbody2D>(); // Set the horizontalFirst to false as nothing is being pressed. firstKeyPressed = false; horizontalFirst = false; verticalFirst = false; }
void Awake() { // Get the players Collider2D. playerCollider = characterEntity.GetComponent <Collider2D> (); // Assign the Animator Component. CharacterAnimator = characterEntity.GetComponent <Animator> (); // Get the Equipment Script. equipment = GetComponentInChildren <Equipment> (); // Get the Character Stats script. charStats = GetComponentInChildren <Character_Stats> (); // Load the Inventory. Grid.inventory.LoadInventory(); }
void Start() { // Set the index to 0 for the start. _locationIndex = 0; // Grab the transform for more efficiency. _transform = gameObject.transform; // Grab the manager of this gameobject. _character = GetComponentInParent <Character>(); // IF there is a Character to this Entity. if (_character != null) { // Grab the stats of this Entity. charStats = _character.GetComponentInChildren <Character_Stats>(); } // Lets start moving! StartCoroutine(GoToNextLocation()); }
void Update() { // IF there isn't a player manager active on the scene. if (pm == null) { // Get the Player Manager GameObject. pm = Character_Manager.GetPlayerManager().GetComponent <Player_Manager>(); return; } // IF there isn't a Character_Stats (or any script you want that holds your characters data) for your characters data. if (charStats == null) { // Get your Character_Stats. charStats = pm.GetComponentInChildren <Character_Stats> (); return; } // Display your hearts. DisplayHearts(); }
private void HandleTypes(Player_Manager playerManager) { // IF we pick up a Key, // ELSE IF we pick up a Bomb, // ELSE IF we pick up a type of Currency, // ELSE IF we pick up a stat increase Item, // ELSE IF *tbc* if (type == "Key") { // Get the Key script. Key key = playerManager.GetComponentInChildren <Key> (); // Add to the keys. key.AddSubtractKeys(title, amount); } else if (type == "Bomb") { // Get the Drop_Bombs script. Bombs playerDB = playerManager.GetComponentInChildren <Bombs> (); // Add to the keys. playerDB.AddSubtractBomb(amount); } else if (type == "Currency") { // Get the Money script. Money money = playerManager.GetComponentInChildren <Money> (); // IF we have a Crystal Currency. if (title == "Green Crystal" || title == "Blue Crystal") { // Add to the currency. money.AddSubtractMoney("Crystal", amount); } } else if (type == "Stat Increase") { // Get the Character Stats (or any data structure if you choose to make your own or use another Asset), Character_Stats charStats = playerManager.GetComponentInChildren <Character_Stats> (); // Then Add to the stats. charStats.IncreaseMaxHealth(bonusHealth); // charStats.IncreaseMaxMana (bonusMana); // charStats.IncreaseBaseDamage (bonusDamage); // charStats.IncreaseBaseMoveSpeed (bonusMoveSpeed); } }
void Awake() { // Assign the Animator Component. CharacterAnimator = characterEntity.GetComponent <Animator>(); charStats = GetComponentInChildren <Character_Stats> (); }
private void CollideDamage(GameObject coll) { // IF we are colliding with another gameobject that does damage. if (coll.GetComponent <Damage_OnCollision>() != null) { return; } // Grab the Character Component from the colliding object. Character otherChar = coll.GetComponentInParent <Character> (); // IF there is not a Character component. if (otherChar == null) { // We return because we only care about damaging a gameobject that has the Character Component. return; } // Since we have a character lets get the stats script. Character_Stats charStats = otherChar.GetComponentInChildren <Character_Stats> (); // IF there is not a script to hold the stats of this Character. if (charStats == null) { // Then there is nothing we can damage we are attacking a Character but this character is statless so its like a town friendly NPC. return; } // Loop through all the Character Types this GameObject collides with to see if we are allowed to damage them. for (int i = 0; i < DamageTheseTypes.Length; i++) { // IF the colliding objects characterType matches one of the types that can take damage or if the selection is an ALL choice. if (otherChar.characterType == DamageTheseTypes [i] || DamageTheseTypes[i] == CharacterType.All) { // Check for Immunity. Immunity_Time _ITS = coll.GetComponentInParent <Immunity_Time> (); // IF the colliding object has the Immunity_Time script. // ELSE just damage the target. if (_ITS != null) { // IF we are Vulnerable. if (_ITS.GetVulnerability()) { // We passed the prerequisites to do damage... Yay! DamageCharacter(otherChar); // IF the player dies while taking damage. if (charStats.CurrentHealth <= 0f) { // We just leave as there is no need to alter the Change Vulnerability. return; } // Since there is a Immunity_Time script on the colliding object we need to make sure we set the vulnerability of the colliding gameobject to false; _ITS.ChangeVulnerability(false); } } else { // We passed the prerequisites to do damage... Yay!. DamageCharacter(otherChar); } // Found 1 so we return. return; } } }