/// <summary> /// A method called at this object's instantiation. Gives it the approriate information to animate. /// </summary> public void StartAnimation(Special spc, Entity u, Entity t, float animationTime, bool accurate) { Vector3 start = u.transform.position; destination = t.transform.position; xSpeed = ((destination.x - start.x) * Time.deltaTime) / animationTime; ySpeed = ((destination.y - start.y) * Time.deltaTime) / animationTime; //Spell will miss - flies past target if (!accurate) { //destination = new Vector3(destination.x * 1.5f, destination.y * 1.5f); } //Target is the user if (Vector3.Distance(u.transform.position, t.transform.position) == 0) { targetIsUser = true; destination = new Vector3(start.x + 2.5f, start.y, 0); xSpeed = ((destination.x - start.x) * Time.deltaTime) / animationTime; ySpeed = ((destination.y - start.y) * Time.deltaTime) / animationTime; //If it's a miss, projectile will fly in opposite direction if (!accurate) { destination = new Vector3(start.x - 5f, start.y, 0); xSpeed *= -2; } } user = u; target = t; hit = accurate; //A self-targeting skill that misses will simply whif and not appear at all if (!hit && spc.classification == Special.CLASS.SKILL && spc.type == Special.TYPE.EFFECT) { GetComponent <SpriteRenderer>().sprite = null; } else { GetComponent <SpriteRenderer>().sprite = spc.GetSprite(); } enemyPosition = target.transform.position; SetRotation(); }
/// <summary> /// A method called at this object's instantiation. Gives it the approriate information to animate. /// </summary> public void StartAnimation(Special spc, Entity u, Entity t, float animationTime, bool accurate) { Vector3 start = u.transform.position; destination = t.transform.position; xSpeed = ((destination.x - start.x) * Time.deltaTime) / animationTime; ySpeed = ((destination.y - start.y) * Time.deltaTime) / animationTime; //Spell will miss - flies past target if (!accurate) { destination *= 2; } //Target is same as user if (Vector3.Distance(u.transform.position, t.transform.position) == 0 || spc.hitAll) { destination = new Vector3(start.x + 2.5f, start.y, 0); xSpeed = ((destination.x - start.x) * Time.deltaTime) / animationTime; ySpeed = ((destination.y - start.y) * Time.deltaTime) / animationTime; //If it's a miss, projectile will fly in opposite direction if (!accurate) { destination = new Vector3(start.x - 5f, start.y, 0); xSpeed *= -2; } } user = u; target = t; hit = accurate; GetComponent <SpriteRenderer>().sprite = spc.GetSprite(); SetRotation(); }