/// <summary> /// Run this instance to the next base. /// </summary> public void Run() { // TODO: Might want to put the bases in an array in the Start method to make everything quicker. // Also adding them to a layer in the editor will make finding them easier since Unity caches // the objects per layer. switch (runnerPosition) { case runnerPositions.Null: // run to first base runnerPosition = runnerPositions.First; break; case runnerPositions.First: // run to second base runnerPosition = runnerPositions.Second; break; case runnerPositions.Second: // run to third base runnerPosition = runnerPositions.Third; break; case runnerPositions.Third: // run home runnerPosition = runnerPositions.Home; break; default: break; } targetPosition = bases[(int)runnerPosition - 1].transform.position; Hashtable animParams = iTween.Hash("position", targetPosition, "time", 1.25f, "easetype", "easeInOutCubic", "looktarget", targetPosition); if (runnerPosition == runnerPositions.Home) { //animParams.Add( "oncompletetarget", gameController ); //animParams.Add( "oncomplete", "IncrementScore" ); //animParams.Add( "oncompleteparams", this.gameObject ); animParams.Add("oncomplete", "FireCrossedHomeEvent"); } else { animParams.Add("oncomplete", "lookAtNextBase"); } iTween.MoveTo(gameObject, animParams); }
/// <summary> /// Run this instance to the next base. /// </summary> public void Run() { // TODO: Might want to put the bases in an array in the Start method to make everything quicker. // Also adding them to a layer in the editor will make finding them easier since Unity caches // the objects per layer. switch ( runnerPosition ) { case runnerPositions.Null: // run to first base runnerPosition = runnerPositions.First; break; case runnerPositions.First: // run to second base runnerPosition = runnerPositions.Second; break; case runnerPositions.Second: // run to third base runnerPosition = runnerPositions.Third; break; case runnerPositions.Third: // run home runnerPosition = runnerPositions.Home; break; default: break; } targetPosition = bases[ (int)runnerPosition - 1].transform.position; Hashtable animParams = iTween.Hash( "position", targetPosition, "time", 1.25f, "easetype", "easeInOutCubic", "looktarget", targetPosition ); if( runnerPosition == runnerPositions.Home ) { //animParams.Add( "oncompletetarget", gameController ); //animParams.Add( "oncomplete", "IncrementScore" ); //animParams.Add( "oncompleteparams", this.gameObject ); animParams.Add( "oncomplete", "FireCrossedHomeEvent" ); } else { animParams.Add( "oncomplete", "lookAtNextBase" ); } iTween.MoveTo( gameObject, animParams ); }