예제 #1
0
 //---------------------------------------------------------------------------	HOTSPOT ANIMATION PLAYBACK / RECORD
 void Update()
 {
     if (_eAnimMode == EAnimMode.Play) {
         if (Input.GetKeyDown(KeyCode.Escape)) {
             _eAnimMode = EAnimMode.Stopped;
             //CGame.INSTANCE._sGuiString_Dev_DEBUG = "";
         } else {
             float nAnimTime = (Time.time - _nAnimStartPlay) * CGame.INSTANCE._nAnimMult_Time * _nTimeRatioToMatchOtherBody;
             if (nAnimTime >= _nAnimClipLength) {
                 nAnimTime = 0;
                 _nAnimStartPlay = Time.time;
             }
             _vecPos = new Vector3();
             _vecPos.y = _oCurveAnimY.Evaluate(nAnimTime);		// Obtain the independent Y,Z hotspot positions from the pre-recorded animation curve.
             _vecPos.z = _oCurveAnimZ.Evaluate(nAnimTime);
             transform.localPosition = _vecPosStart + _vecPos * CGame.INSTANCE._nAnimMult_Pos;
             //CGame.INSTANCE._sGuiString_Dev_DEBUG = string.Format("Play {0:F1} / {1:F1}", nAnimTime, _nAnimClipLength);
         }
     }
 }
예제 #2
0
    public override void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp)
    {
        if (eEditMode != EEditMode.Move)				//###DESIGN!!!!: Can rotate?
            return;

        base.OnHotspotChanged(oGizmo, eEditMode, eHotSpotOp);		// Will set our position, properties and script record.
        Vector3 vecPosHotspotG = oGizmo.transform.position;
        Vector3 vecPosHotspotL = transform.parent.worldToLocalMatrix.MultiplyPoint(vecPosHotspotG);		// Convert the global hotspot position to the position relative to our parent (ActorEmpty) (Done so our animation is stored relative to our parent so user can drag parent while animating)

        if (oGizmo._bMiddleClickOp) {				// Left mouse button editing moves sex, middle mouse button animates

            switch (eHotSpotOp) {
                case EHotSpotOp.First:
                    _oCurveAnimY = new AnimationCurve();				// Create the animation curves to store the (independant) Y & Z coordinates
                    _oCurveAnimZ = new AnimationCurve();
                    _nAnimStartRec = Time.time;							// Store the time of clip recording so we can determine clip length for 0-based curves.
                    _vecPosStart = _vecPosLast = vecPosHotspotL;
                    _nDistTravelled = 0;
                    CGame.INSTANCE._nAnimMult_Pos = 1;				//###CHECK
                    CGame.INSTANCE._nAnimMult_Time = 1;
                    _eAnimMode = EAnimMode.Record;
                    break;

                case EHotSpotOp.Middle:
                    float nAnimTime = Time.time - _nAnimStartRec;
                    Vector3 vecPosFromStart = vecPosHotspotL - _vecPosStart;
                    _oCurveAnimY.AddKey(nAnimTime, vecPosFromStart.y);
                    _oCurveAnimZ.AddKey(nAnimTime, vecPosFromStart.z);
                    _nDistTravelled += (vecPosHotspotL - _vecPosLast).magnitude;		// Add the distance travelled this last frame
                    _vecPosLast = vecPosHotspotL;									// Remember where we are now for next distance travelled adder
                    //CGame.INSTANCE._sGuiString_Dev_DEBUG = string.Format("Rec {0:F1}  Dist: {1:F2}", nAnimTime, _nDistTravelled);
                    break;

                case EHotSpotOp.Last:		// End recording by adding one last data point to return to start position at an appropriately calculated time.
                    _nAnimStartPlay = Time.time;
                    _nAnimClipLength = _nAnimStartPlay - _nAnimStartRec;
                    _nAnimStartRec = 0;
                    float nVelocityAvg = _nDistTravelled / _nAnimClipLength;				// The average velocity of travel for this curve
                    float nDistStartPtToEndPt = (vecPosHotspotL - _vecPosStart).magnitude;	// The distance between the start and end point we must travel to to close the loop
                    float nTimeToReturnToStartPt = nDistStartPtToEndPt / nVelocityAvg;		// The time needed to return to starting point at average velocity
                    _nAnimStartPlay = Time.time - _nAnimClipLength;							// Set the current pointer to play to where we are at now in the curve.  (This will make us return to starting point smoothly)
                    _nAnimClipLength += nTimeToReturnToStartPt;								// Add the time to travel to the last point to the total clip time.
                    _oCurveAnimY.AddKey(_nAnimClipLength, 0);								// Add the starting point position at the end-of-clip time.
                    _oCurveAnimZ.AddKey(_nAnimClipLength, 0);

                    //=== Find the other body (if it exists) and slow-down or speed up our clip if our clip time is nearby the cliptime of the other body
                    //###BROKEN#11
                    //CBody oBodyOther = null;
                    //foreach (CBody oBody in CGame.INSTANCE._aBodyBases) {
                    //	if (oBody != _oBody) {
                    //		oBodyOther = oBody;
                    //		break;
                    //	}
                    //}
                    //if (oBodyOther != null && oBodyOther._oActor_Pelvis != null) {			// If another body with a sex actor exists...
                    //	if ((_nAnimClipLength <= oBodyOther._oActor_Pelvis._nAnimClipLength * 1.2f) && (_nAnimClipLength >= oBodyOther._oActor_Pelvis._nAnimClipLength * 0.8f)) {		//... and has nearly the same lenght as ours...	###TUNE
                    //		oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody = oBodyOther._oActor_Pelvis._nAnimClipLength / _nAnimClipLength;	// We set the other body's time because we could be facing a long return to first position as inserted above
                    //		//Debug.Log("Anim: _nTimeRatioToMatchOtherBody = " + oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody);
                    //	}
                    //}
                    _nTimeRatioToMatchOtherBody = 1;
                    //CGame.INSTANCE._sGuiString_Dev_DEBUG = "";
                    _eAnimMode = EAnimMode.Play;
                    break;

            }
        } else {
            _eAnimMode = EAnimMode.Stopped;				// If user moves with left mouse button we stop previously recorded animation
        }
    }
예제 #3
0
	public void ScheduleSwitch(EAnimMode animMode, EScreen nextScreen)
	{
		stage = 1;
		sharedTimer = 0;
		this.nextScreen = nextScreen;

		foreach(GameObject c in Clouds)
		{
			c.GetComponent<Animator>().Play(c.name + "_in");
		}
	}