//runs when elemental is instantiated via MeteorManager void Start() { player = GameObject.FindGameObjectWithTag("Player"); elementManager = player.GetComponent <ElementManager>(); playerAnimCtrls = player.GetComponent <PlayerAnimCtrls>(); elementalAnimsCtrl = GetComponent <ElementalAnimsCtrl>(); so_Elemental = GetComponent <ElementalController> ().so_Elemental; rend = GetComponent <Renderer> (); }
public void TakeDamage(int _dam, int _kBForce, SO_Elemental.elementType damElement, Vector3 _dir) //takes the damage, knockback force, element, and force direction { SO_Elemental _so_Elemental = elementManager.currentElemental.GetComponent <ElementalData>().so_Elemental; //if the damager's element is not NEUTRAL if ((int)damElement != 0) { //if the damager's element is weak against the damager's element, apply double damage if (_so_Elemental.elementStrengthOne == damElement || _so_Elemental.elementStrengthTwo == damElement) { currentHealth += _dam / 2; } //if the damager's element is strong against the damager's element, apply double damage if (_so_Elemental.elementWeakness == damElement) { currentHealth += _dam * 2; } } else { currentHealth += _dam; } //if there are no elements just apply damage normally print(currentHealth); //_dir = calculateForce (_dir, currentHealth * .01f , _kBForce *.05f); //calculates the force to be applied to the object _dir = calculateForce(_dir, currentHealth, .01f) + calculateForce(_dir, _kBForce, .05f); //trying different ways of calculating the force if (isMoveable) { //determines if the object can be moved if (usesNav) { // StartCoroutine(ApplyForceNav(_dir)); NR.Push(_dir); } else { if (usesCC) { //if it has a character controller StartCoroutine(ApplyForceCC(_dir)); //use the character controller mehtod of adding force } else { AddForce(_dir, RB); } //else, ie if it has a RB, add force using the RB method } } }