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 Character Manager component. characterManager = Character_Helper.GetPlayerManager().GetComponent <Character_Manager> (); // Get the characters stats as we use that to potentially alter movement. charStats = characterManager.GetComponentInChildren <Character_Stats> (); // Get the Rigidbody2D Component. rb = GetComponent <Rigidbody2D> (); }
void Start() { // Get the Character Manager. characterManager = GetComponent <Character_Manager> (); // Get the Character Stats component. charStats = characterManager.GetComponentInChildren <Character_Stats> (); // Get the Transform componenet. _transform = characterManager.GetComponent <Transform> (); }
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() { // Get the Character component. character = GetComponentInParent <Character> (); // Get the Character Stats component. charStats = character.GetComponentInChildren <Character_Stats> (); if (charStats != null) { Speed = charStats.CurrentMoveSpeed; //some npcs have char defined in parent } if (AggroDistance == 0) { AggroDistance = float.PositiveInfinity; } }
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); } }
private void CollideDamage(GameObject coll) { // IF YOU HAVE ANOTHER SCRIPT IN WHICH YOU DO NOT CARE ABOUT USING CHARACTER_MANAGER // THEN MAKE SURE TO LOOK FOR THE SCRIPT HERE AND MAKE A CHECK IF IT HAS IT. // Grab the Character_Manager Component from the colliding object. Character_Manager otherChar = coll.GetComponentInParent <Character_Manager> (); // IF there is NOT a Character_Manager component. if (otherChar == null) { // We return because we only care about damaging a gameobject that has the Character_Manager // Component. return; } // IF the colliding GameObject's Character_Manager characterEntity is NOT the same as the // GameObject we are colliding with. if (!otherChar.characterEntity.Equals(coll.gameObject)) { // We leave as we are damaging something that isn't a piece of the Entity. // Example would be 2 people clashing swords, Yes both swords are part of the Entity and // children of that entity BUT it ISN'T the Entity so we do not care. return; } // Since we have a Character_Manager lets get the Character_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; } // Play a sound. Grid_Helper.soundManager.PlaySound(collisionSound); // Lets go into our loop and see if we can damage anything. Grid_Helper.helper.DamageCharacterTypeLoop(transform, otherChar, damageTheseTypes, damage, joltAmount); }
private IEnumerator Fight() { while (than.transform.position != thanAlterLocation.transform.position) { than.transform.position = Vector2.MoveTowards(than.transform.position, thanAlterLocation.transform.position, thanWalkSpeed * Time.deltaTime); yield return(null); } while (than.transform.position != flipThan.transform.position) { than.transform.position = Vector2.MoveTowards(than.transform.position, flipThan.transform.position, thanWalkSpeed * Time.deltaTime); yield return(null); } yield return(new WaitForSeconds(2f)); minion.GetComponentInChildren <Immunity_Time>().flashIntervalTime = 0f; minion.SetActive(true); laser1.SetActive(true); laser2.SetActive(true); minionTargetControl = minion.GetComponentInChildren <Follow_Closest_Type>(); minionTargetControl.AggroDistance = 0; Vector3 temp = minion.transform.localScale; Vector3 maxSize = new Vector3(minionMaxSize, minionMaxSize); while (minion.transform.localScale.x <= maxSize.x) { temp.x += minionGrowthRate; temp.y += minionGrowthRate; minion.transform.localScale = temp; yield return(null); } yield return(new WaitForSeconds(1f)); minionTargetControl.AggroDistance = 25; oblisk1.GetComponent <NPC_Manager>().characterType = CharacterType.Enemy; oblisk2.GetComponent <NPC_Manager>().characterType = CharacterType.Enemy; minion.GetComponentInChildren <Immunity_Time>().flashIntervalTime = 0.05f; thanDialogue.SetActive(false); Character_Stats character_stats = minion.GetComponentInChildren <Character_Stats>(); maxSize.x = minionHalfMaxSize; maxSize.y = minionHalfMaxSize; while (laser1 != null || laser2 != null) { if (laser1 == null || laser2 == null) { minion.transform.localScale = maxSize; } if (character_stats.GetCurrentHealth() != character_stats.GetMaxHealth()) { character_stats.CurrentHealth = character_stats.GetMaxHealth(); } yield return(null); } while (!isMinionDead) { yield return(null); } yield return(new WaitForSeconds(1f)); than.GetComponent <NPC_Manager>().characterType = CharacterType.Enemy; than.GetComponentInChildren <Follow_Closest_Type>().enabled = true; }
void Awake() { // Assign the Animator Component. CharacterAnimator = characterEntity.GetComponent <Animator>(); charStats = GetComponentInChildren <Character_Stats> (); }
private void CollideDamage(GameObject coll) { // Grab the Character_Manager Component from the colliding object. Character_Manager otherChar = coll.GetComponentInParent <Character_Manager> (); // IF there is NOT a Character_Manager component. if (otherChar == null) { // We return because we only care about damaging a gameobject that has the Character_Manager Component. return; } // IF the Character_Managers characterEntity is NOT the same as the GameObject we are colliding with. if (!otherChar.characterEntity.Equals(coll.gameObject)) { // We leave as we are damaging something that isn't a piece of the Entity. // Example would be 2 people clashing swords, Yes both swords are part of the Entity and // children of that entity BUT it ISN'T the Entity so we do not care. return; } // Since we have a Character_Manager lets get the Character_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 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; } } }
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; } } }