Cone Event System Idea
using UnityEngine; using System.Collections; using ProceduralToolkit; using System.Collections.Generic; using System.IO; public class Fibo_Rider : MonoBehaviour { StreamWriter sWrite; public ArgosMeshDraft_Fibonacci AMD_Base; List<GameObject> gO_List = new List<GameObject>(); GameObject goMyPivot; GameObject goTweenFollower; Quaternion qStart; Quaternion qEnd; int m_startLoc; int m_toLoc; int m_deltLoc; int m_numPoints; float m_pathTime; public void initFromSpawner(int FibLoc, int delt, int numPoints, float pathTime ) { //sWrite = new StreamWriter("Fibo_Rider4.csv"); m_startLoc = FibLoc; m_deltLoc = delt; m_toLoc = FibLoc + delt; m_pathTime = pathTime; m_numPoints = numPoints; GameObject gFibSphere = GameObject.Find("Fibonacci_Sphere"); ArgosFibonacci aF = gFibSphere.GetComponent<ArgosFibonacci>(); AMD_Base = aF.aMF_Base; Quaternion q0, q1; q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_startLoc].vPos.normalized); q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized); transform.rotation = q0; transform.position = AMD_Base.funcVerts[FibLoc].vPos; goTweenFollower = transform.Find("TweenFollower").gameObject; goMyPivot = new GameObject(); goMyPivot.transform.position = new Vector3(0, 0, 0); goMyPivot.transform.rotation = Quaternion.identity; transform.SetParent(goMyPivot.transform); goTweenFollower.transform.SetParent(transform);//this goTweenFollower.transform.position = Vector3.zero; qEnd = q1 * Quaternion.Inverse(q0); qStart = Quaternion.identity; iTween.MoveTo(goTweenFollower, iTween.Hash("x", 1, "time", m_pathTime, "easetype", "easeInOutBack", "onstart", "fibTweenStarted", "onstartparams", "FIB Rider Started...", "onupdate", "fibTweenUpdate", "onupdateparams", FibLoc.ToString(), "oncomplete", "fibTweenComplete", "oncompleteparams", "fib Tween DONE", "onCompleteTarget", gameObject, "onStartTarget", gameObject, "onUpdateTarget", gameObject)); m_numPoints--; } void fibTweenStarted(string textToDisplay) { print("fibTween on Start " + textToDisplay); } int CBcount = 0; float fAccumTime = 0.0f; void fibTweenUpdate(string textToDisplay) { //print("fibTweenUpdate " + textToDisplay + " call count = " + CBcount.ToString() + " pos = " + goTweenFollower.transform.position.x.ToString("F3") + " deltaTime = " + Time.deltaTime.ToString("F3")); float sTime = goTweenFollower.transform.position.x; goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, sTime); CBcount++; } void fibTweenComplete(string textToDisplay) { Quaternion q0, q1; goMyPivot.transform.rotation = Quaternion.LerpUnclamped(qStart, qEnd, 1.0f); if (--m_numPoints > 0) { q0 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized); m_toLoc += m_deltLoc; q1 = Quaternion.LookRotation(AMD_Base.funcVerts[m_toLoc].vPos.normalized); qEnd = q1 * Quaternion.Inverse(q0) * goMyPivot.transform.rotation; qStart = goMyPivot.transform.rotation; goTweenFollower.transform.position = Vector3.zero; iTween.MoveTo(goTweenFollower, iTween.Hash("x", 1, "time", m_pathTime, "easetype", "easeInOutBack", "onstart", "fibTweenStarted", "onstartparams", "FIB Rider Started...", "onupdate", "fibTweenUpdate", "onupdateparams", m_toLoc.ToString(), "oncomplete", "fibTweenComplete", "oncompleteparams", "fib Tween DONE", "onCompleteTarget", gameObject, "onStartTarget", gameObject, "onUpdateTarget", gameObject)); } } void Update () { } } //public enum EaseType //{ // easeInQuad, // easeOutQuad, // easeInOutQuad, // easeInCubic, // easeOutCubic, // easeInOutCubic, // easeInQuart, // easeOutQuart, // easeInOutQuart, // easeInQuint, // easeOutQuint, // easeInOutQuint, // easeInSine, // easeOutSine, // easeInOutSine, // easeInExpo, // easeOutExpo, // easeInOutExpo, // easeInCirc, // easeOutCirc, // easeInOutCirc, // linear, // spring, // /* GFX47 MOD START */ // //bounce, // easeInBounce, // easeOutBounce, // easeInOutBounce, // /* GFX47 MOD END */ // easeInBack, // easeOutBack, // easeInOutBack, // /* GFX47 MOD START */ // //elastic, // easeInElastic, // easeOutElastic, // easeInOutElastic, // /* GFX47 MOD END */ // punch //}