// // Attacking methods // public void StartCharging() { // Spawn and save an instance of our reticule m_reticule = Instantiate( Reticule, transform.position + (Vector3)MuzzleRelative, Quaternion.identity ) as CanonReticule; // Reticule moves relative to us m_reticule.transform.parent = transform; // Setup our reticule m_reticule.Setup(transform.parent.GetComponent <Canons>()); }
public override void Attack() { // Spawn projectile Canonball cball = Instantiate( CanonballToSpawn, transform.position + (Vector3)MuzzleRelative, Quaternion.identity ) as Canonball; // Get parent ; // Tell our cball whats up cball.Setup(GetComponentInParent <Canons>().relativeDistance, m_reticule); // Tell our reticule to stop moving m_reticule.StopMoving(); m_reticule = null; }
// PERCENTCHARGE: From canons.cs, percent charge // of our canons. We'll grab the distance etc from // him too. public void Setup(float distance, CanonReticule reticule) { f_goalposx = transform.position.x + distance; f_startposx = transform.position.x; f_startposy = transform.position.y; f_distance = distance; reticuleToDestroy = reticule; // We need to play the full animation over the entire // course of the canonball. // // Animation finishes in one second float invtime = Canons.CanonballVelocity / distance; GetComponent <Animator>().speed *= invtime; // Figure out our actual max height to use float percentDist = (Mathf.Abs(distance) - Canons.minDistance) / (Canons.maxDistance - Canons.minDistance); f_finalMaxHeight = MaxHeightFunction.Evaluate(percentDist) * MaxHeight; }