// ----------------- ---------------- ---------------- ---------------- ---------------- ---------------- // // Manages All Necessiary Attributes And Qualities On Awake void Awake () { // ---------- ---------- ---------- ---------- // // Checks Whether A Suitable Animation Has Been Selected animation = this.gameObject.GetComponent <AntAnimation> (); movement = this.gameObject.GetComponent <MoveObject> (); }
// ----------------- ---------------- ---------------- ---------------- ---------------- ---------------- // // Defines All Attributes And Instances That'll Be Run On Awake void Start () { // ---------- ---------- ---------- ---------- // // Attaches The Specified Creature To The 'Creature Management' Creature List CreatureManagement.Heirachy (this.gameObject); // ---------- ---------- ---------- ---------- // // Defines All Necessiary Attributes if (this.gameObject.GetComponent <AnimationManagement> () != null) animation = this.gameObject.GetComponent <AnimationManagement> (); // ---------- ---------- ---------- ---------- // if (this.gameObject.GetComponent <AntAnimation> () != null) acronophobia = this.gameObject.GetComponent <AntAnimation> (); }
public void SwitchAnimation(string aAnimationName) { if (aAnimationName != _currentAnimation.name) { bool animationFound = false; for (int i = 0, n = animations.Length; i < n; i++) { if (animations [i].name == aAnimationName) { animationFound = true; _currentAnimation = animations [i]; _currentFrame = 1.0f; _prevFrame = -1; break; } } if (!animationFound) { Debug.LogWarning(string.Format("Can't find animation \"{0}\".", aAnimationName)); } } }
// ----------------- ---------------- ---------------- ---------------- ---------------- ---------------- // // Connects With This Creatures Registered Spline And Calculates All Necessiary Spline Animations public void Move (Vector3 position, Spline spline) { // ---------- ---------- ---------- ---------- // // Calculates The Direction Between The Creature And The Spline Point Position Vector3 direction = position - this.transform.position; float magnitude = direction.magnitude; // ---------- ---------- ---------- ---------- // direction = direction.normalized; // ---------- ---------- ---------- ---------- // // Determines Certain Attribute Values On Awake if (!awake) { // ---------- ---------- ---------- ---------- // rotation = transform.rotation; axis = Quaternion.LookRotation (direction, motion); // ---------- ---------- ---------- ---------- // point = position; creature = transform.position; // ---------- ---------- ---------- ---------- // velocity = speed; // ---------- ---------- ---------- ---------- // animation = this.gameObject.GetComponent <AntAnimation> (); // ---------- ---------- ---------- ---------- // awake = true; } // ---------- ---------- ---------- ---------- // // Determines The Creature Orientation Along The Spline if (transistor >= moment) { rotation = transform.rotation; // ---------- ---------- ---------- ---------- // if (direction != Vector3.zero) axis = Quaternion.LookRotation (direction, motion); // ---------- ---------- ---------- ---------- // transistor = zero; // ---------- ---------- ---------- ---------- // // Mathematics.Logged ("Spline Rotation Reached"); } // ---------- ---------- ---------- ---------- // // Clamps The Creature Rotation Between Certain Parameters if (direction != Vector3.zero) contempory = Quaternion.LookRotation (direction, motion); // ---------- ---------- ---------- ---------- // if (Quaternion.Angle (history, contempory) >= clamp) { moment = zero; // ---------- ---------- ---------- ---------- // // Mathematics.Logged ( "Spline Rotation Exceeded Clamp" + Quaternion.Angle (rotation, axis) ); } else moment = 0.2f; // ---------- ---------- ---------- ---------- // // Manuevers The Selected Creature Rotation Along The Spline Over An Interval Of Time transistor += Time.deltaTime; transform.rotation = Quaternion.Lerp (rotation, axis, transistor * orientation); // ---------- ---------- ---------- ---------- // // Dictates The Creature Position Along The Spline if (transform.position - point == Vector3.zero) { point = position; creature = transform.position; // ---------- ---------- ---------- ---------- // transistion = zero; // ---------- ---------- ---------- ---------- // // Mathematics.Logged ("Spline Point Reached"); } // ---------- ---------- ---------- ---------- // // Manuevers The Selected Creature Position Along The Spline Over An Interval Of Time transistion += Time.deltaTime; // ---------- ---------- ---------- ---------- // if (velocity > zero) transform.position = Vector3.Lerp (creature, point, transistion * speed); // ---------- ---------- ---------- ---------- // // Traces The Former Rotational Quaternion Of The Spline Position if (direction != Vector3.zero) history = Quaternion.LookRotation (direction, motion); // ---------- ---------- ---------- ---------- // // Draws A Representative Symbol On The Spline For Each Defined Animation Trigger // Sets The Selected Animation That's Attributed To The Discovered Spline foreach (Transistion transit in node) { // ---------- ---------- ---------- ---------- // // Determines All Necessiary Attributes Needed float percentage = transit.percentage / 100.00f; int place = (int) Mathematics.limitation (transit.point, zero, sploot.spline.Length - 1); int branch = (int) Mathematics.limitation (transit.branch, zero, sploot.spline.GetSubwaysLength (place) - 1); // ---------- ---------- ---------- ---------- // Vector3 note = sploot.spline.GetPointAtTime (percentage, place, branch); // ---------- ---------- ---------- ---------- // Vector3 maximum = Vector3.zero + (Vector3.one / approximate); Vector3 minimum = Vector3.zero - (Vector3.one / approximate); float distance = Vector3.Distance (transform.position, note); // ---------- ---------- ---------- ---------- // // Determines Certain Distance Approxizations Between The Creature And The Animation Trigger // Determines The Set Motion Of The Animation, As Determined By The Current Creature Animation Behaviour if (distance >= minimum.x && distance <= maximum.x) if (distance >= minimum.y && distance <= maximum.y) if (distance >= minimum.z && distance <= maximum.z) animation.motion = transit.animation; // ---------- ---------- ---------- ---------- // // Determines The Speed Of The Animation if (transit.pause > zero) if (animation.motion == transit.animation) if (animation.behaviour == transit.animation.ToString () ) { pause.speed = transit.speed; pause.pause = transit.pause; // ---------- ---------- ---------- ---------- // pause.animation = transit.animation; } } // ----------------- ---------------- ---------------- ---------------- ---------------- ---------------- // // Deciphers The Momentum Of Certain Animations As They're Concievably Triggered // ---------- ---------- ---------- ---------- // // Deciphers Whether The Momentum Is In Dire Wish Of Some Change if (pause.animation != null ) if (animation.motion == pause.animation) { time += Time.deltaTime; // ---------- ---------- ---------- ---------- // if (time < pause.pause) velocity = Mathf.Lerp (speed, pause.speed, time * 2.00f); // ---------- ---------- ---------- ---------- // else { time = zero; animation.motion = AntAnimation.Motion.walk; } } // ---------- ---------- ---------- ---------- // // Transistions Back Into A Pre-Determined Motion if (pause.animation != null ) if (animation.behaviour != pause.animation.ToString () ) { sand += Time.deltaTime; velocity = Mathf.Lerp (pause.speed, speed, sand * 3.00f); } // ---------- ---------- ---------- ---------- // else sand = zero; }
private void Awake() { antAnimation = GetComponent <AntAnimation>(); }
private void Awake() { selectedGameObject = transform.Find("Selected").gameObject; antAnimation = GetComponent <AntAnimation>(); SetSelectedVisible(false); }