void wakeUp(TweenEvent data) { int i = (int)data.parms[0]; transform.GetChild(i).rigidbody.isKinematic = false; transform.GetChild(i).rigidbody.WakeUp(); }
public void onTweenComplete(TweenEvent evt) { if (waitForEndOfTween) { myPlayer.callBackFromCommand(); } }
/// <summary> /// Performs the given tweeing event on this GameObject /// </summary> public void PerformEvent(TweenEvent tweenEvent, float duration) { // If the tween modifies position if ((tweenEvent.type & TweenType.Position) == TweenType.Position) { // Perform a tween on the GameObject's localPosition, lasting 'duration' seconds LeanTween.moveLocal(gameObject, tweenEvent.targetPosition, duration).setEase(tweenEvent.positionEasingType); } // If the tween modifies scale if ((tweenEvent.type & TweenType.Scale) == TweenType.Scale) { // Perform a tween on the GameObject's scale, lasting 'duration' seconds LeanTween.scaleX(gameObject, tweenEvent.targetScale.x, duration).setEase(tweenEvent.scaleEasingType); LeanTween.scaleY(gameObject, tweenEvent.targetScale.y, duration).setEase(tweenEvent.scaleEasingType); LeanTween.scaleZ(gameObject, tweenEvent.targetScale.z, duration).setEase(tweenEvent.scaleEasingType); } // If the tween modifies rotation if ((tweenEvent.type & TweenType.Rotation) == TweenType.Rotation) { // Perform a tween on the GameObject's scale, lasting 'duration' seconds LeanTween.rotateZ(gameObject, tweenEvent.targetAngle, duration).setEase(tweenEvent.rotationEasingType); } //Debug.Log ("PERFORM THE TWEEN: " + tweenEvent.ToString ()); //Debug.Log ("Duration: " + duration + " seconds"); }
void OnDestroy() { CollisionEvent = null; CollisionEventWithParam = null; EndEvent = null; EndEventWithParam = null; }
private void OnMoveComplete(TweenEvent e) { Vector3 from = (Vector3)e.parms[0]; Vector3 to = (Vector3)e.parms[1]; OnMoveEnd(from, to); Moving = false; }
private void musicCrossFadeComplete(TweenEvent tweenEvent) { debugMusic("Done with crossfade current music is now: " + currentMusicAudioSource.clip.name + " ,vol:" + currentMusicAudioSource.volume); //((AudioSource)tweenEvent.parms[0]).clip.name ); /*if ( musicFadeOutTweener.isComplete && musicFadeInTweener.isComplete ) * { * currentMusicAudioSource = ((AudioSource)tweenEvent.parms[0]); * }*/ }
public void onUndoComplete(TweenEvent evt) { Transform target = sequencerData.targets [lastSelectedWho].target.transform; target.gameObject.SetActive(wasActiveAtStart); if (waitForEndOfTween) { myPlayer.callBackFromCommand(); } }
// Constructor public TweenEventArgs( ITween tween, TweenEvent eventType, string errorDescription = null, TweenCompletedBy completedBy = TweenCompletedBy.Undefined ) { Tween = tween; Event = eventType; CompletedBy = completedBy; Error = errorDescription; }
private void OnShootProjectileComplete(TweenEvent e) { GameObject arrowView = (GameObject)e.parms[0]; GameObject target = (GameObject)e.parms[1]; GameObject.Destroy(arrowView); if (target != null && target.tag == "Enemy") { target.GetComponent <EnemyView>().Die(); } }
void ParabolaGo(Params _params) { this.delayFinished = true; this.worldSpace = _params.worldSpace; fromPos = _params.worldSpace ? transform.position : transform.localPosition; previousPos = fromPos; this.toPos = _params.toPos; this.middlePos = _params.middlePos; this.delta = _params.delta; this.elasticity = _params.elasticity; this.CollisionEvent = _params.OnCollisionEvent; this.CollisionEventWithParam = _params.OnCollisionEventWithParam; this.EndEvent = _params.OnEndEvent; this.EndEventWithParam = _params.OnEndEventWithParam; t = 0f; }
void SwingGo(Params _params) { if (_params.time <= 0f) { return; } this.delayFinished = true; this.r = UnityEngine.Random.Range(0f, Mathf.PI * 2f); this.offsetAngle = _params.offsetAngle / _params.time; this.speed = _params.speed; this.useDamping = _params.useDamping; swingTime = _params.time; this.enabled = true; this.EndEvent = _params.OnEndEvent; this.EndEventWithParam = _params.OnEndEventWithParam; }
public void doneMusicFade(TweenEvent tweenEvent) { AudioSource fadedTargetAudioSource = ((AudioSource)tweenEvent.parms[0]); if (fadedTargetAudioSource.volume < .1f && fadedTargetAudioSource != (musicFadeInTweener.target as AudioSource)) { if (fadedTargetAudioSource.clip != null) { debugMusic("done music fade stoping music: " + fadedTargetAudioSource.clip.name); fadedTargetAudioSource.Stop(); } } else { debugMusic("music Fade is done, but volume is above .1(" + fadedTargetAudioSource.volume + "} so wasnt killed."); } }
// Creates an Event with the same properties as the given event public Event(Event other) { type = other.type; actionToPerform = other.actionToPerform; basicActionToPerform = other.basicActionToPerform; soundEffect = other.soundEffect; cameraMovement = new CameraMovement(other.cameraMovement); slowMotion = other.slowMotion; particleEvent = other.particleEvent; forceEvent = new Force(other.forceEvent, false); colorFlash = other.colorFlash; ghostEffect = other.ghostEffect; screenShake = other.screenShake; tweenEvent = other.tweenEvent; startTime = other.startTime; duration = other.duration; }
private void scale1Complete(TweenEvent e) { if (scaleType == "open") { isOpen = true; if (funcAfterOpen != null) { funcAfterOpen(this.gameObject); } } else { isOpen = false; if (funcAfterClose != null) { funcAfterClose(this.gameObject); } } }
void _OnTweenComplete(TweenEvent te) { if (onComplete != null) { Event e = new Event(); e.number = _number; e.parms = te.parms; try { onComplete(e); } catch (MissingReferenceException) { // When GameObject is destroyed during Tween Update. } catch (Exception ex) { Debug.LogError(ex.ToString()); } } }
private void scale0Complete(TweenEvent e) { if (scaleType == "open") { textureSprite = AssetsManager.getSpriteByFile(image_path); } else { textureSprite = AssetsManager.getSpriteByFile("images/cards/back"); //Debug.Log (textureSprite); } this.gameObject.transform.FindChild("textureSprite").GetComponent <SpriteRenderer> ().sprite = textureSprite; /////////////////////////////////////////////////////////// TweenParms parms = new TweenParms(); parms.Ease(EaseType.Linear); // Easing type parms.Prop("localScale", new Vector3(1f * Game.card_scale, 1f * Game.card_scale, 1f * Game.card_scale)); parms.OnComplete(scale1Complete, this.gameObject); HOTween.To(this.gameObject.transform, 0.1f, parms); /////////////////////////////////////////////////////////// }
private void comp(TweenEvent e) { ((GameObject)(e.parms [1])).transform.FindChild("textureSprite").gameObject.GetComponent <SpriteRenderer>().sortingOrder = 100 * Game.completedCount + comp_depth++; if (((int)(e.parms [0])) == 1) { if (pokerArr.Count > 0) { (pokerArr [pokerArr.Count - 1] as GameObject).GetComponent <Poker> ().open(null, 0); } Game.completeBigK_array.Add(e.parms [1] as GameObject); if (Game.completedCount == 8) { Game.you_win_window.SetActive(true); } Game.isRemoving = false; } else { ((GameObject)(e.parms [1])).GetComponent <Poker> ().fadeOutAlphaAndDistroy(0.3f, 0.3f, false); } }
/// <summary> /// Displays an editor to modify a tweening event. /// Note: This method mutates the tweenEvent. /// </summary> public static void TweenEventEditor(TweenEvent tweenEvent) { tweenEvent.type = (TweenType)EditorGUILayout.EnumMaskField("Property:", tweenEvent.type); if ((tweenEvent.type & TweenType.Position) == TweenType.Position) { tweenEvent.targetPosition = EditorGUILayout.Vector3Field("Target Position", tweenEvent.targetPosition); tweenEvent.positionEasingType = (LeanTweenType)EditorGUILayout.EnumPopup("Position easing Type:", tweenEvent.positionEasingType); tweenEvent.positionRelativeToFacingDirection = EditorGUILayout.Toggle("Relative to facing direction", tweenEvent.positionRelativeToFacingDirection); EditorGUILayout.LabelField("------------------------------------------------"); } if ((tweenEvent.type & TweenType.Scale) == TweenType.Scale) { tweenEvent.targetScale = EditorGUILayout.Vector3Field("Target Scale", tweenEvent.targetScale); tweenEvent.scaleEasingType = (LeanTweenType)EditorGUILayout.EnumPopup("Scale easing Type:", tweenEvent.scaleEasingType); EditorGUILayout.LabelField("------------------------------------------------"); } if ((tweenEvent.type & TweenType.Rotation) == TweenType.Rotation) { tweenEvent.targetAngle = EditorGUILayout.Slider("Target Angle:", tweenEvent.targetAngle, 0.0f, 360.0f); tweenEvent.rotationEasingType = (LeanTweenType)EditorGUILayout.EnumPopup("Rotation easing Type:", tweenEvent.rotationEasingType); tweenEvent.angleRelativeToFacingDirection = EditorGUILayout.Toggle("Relative to facing direction", tweenEvent.angleRelativeToFacingDirection); if (tweenEvent.angleRelativeToFacingDirection) { EditorGUILayout.HelpBox("0 degrees = Upright. If Facing Right: positive angle turns clockwise. If Facing Left: positive angle turns counter-clockwise.", MessageType.Info); } else { EditorGUILayout.HelpBox("0 degrees = Upright. Positive angle turns the GameObject clockwise.", MessageType.Info); } } }
private void OnTweenToGroundComplete(TweenEvent e) { rigidbody.detectCollisions = true; _tweening = false; }
private void OnTweenOffWallComplete(TweenEvent e) { Vector3 groundPos = (Vector3)e.parms[0]; TweenToGround(groundPos); }
private void OnTweenToWallHeightComplete(TweenEvent e) { Vector3 wallPiecePos = (Vector3)e.parms[0]; TweenToWallCenter(wallPiecePos); }
private void RunWayTrail(TweenEvent te) { if (_wayTrail == null) { return; } var currentWaypoint = te != null && te.parms[0] != null ? (Waypoint)te.parms[0] : CurrentWaypoint; if (currentWaypoint.IsControlPoint && currentWaypoint.GetInstanceID() != CurrentWaypoint.GetInstanceID()) { currentWaypoint = CurrentWaypoint; } if (currentWaypoint.NextWaypoint == null || BrushMode == BrushModeType.Autoplay) { _wayTrail.SetActive(false); return; } var currentWpPos = currentWaypoint.transform.localPosition; var initPos = new Vector3(currentWpPos.x, currentWpPos.y, _wayTrail.transform.localPosition.z); _wayTrail.transform.localPosition = initPos; var nextWpPos = currentWaypoint.NextWaypoint.transform.localPosition; var nextPos = new Vector3(nextWpPos.x, nextWpPos.y, initPos.z); #region animator rotatation calculating var sinA = Vector3.Magnitude(Vector3.Project(nextPos - initPos, Vector3.left)) / Vector3.Magnitude(nextPos - initPos); if (nextWpPos.y <= currentWpPos.y) { sinA = (nextWpPos.x < currentWpPos.x) ? -sinA : sinA; } else if (nextWpPos.x > currentWpPos.x) { sinA = -sinA; } var angle = Mathf.Asin(sinA) * 180 / Mathf.PI; if (nextWpPos.y > currentWpPos.y) { angle = angle + 180; } _wayTrail.transform.localRotation = Quaternion.Euler(0, 0, angle); #endregion var distance = Vector3.Distance(new Vector2(currentWpPos.x, currentWpPos.y), new Vector2(nextWpPos.x, nextWpPos.y)); var param = new TweenParms(); param.Prop("localPosition", nextPos); param.Ease(EaseType.Linear); param.OnComplete(RunWayTrail, currentWaypoint.NextWaypoint); _wayTrail.gameObject.SetActive(TapGesture.State == TouchScript.Gestures.Gesture.GestureState.Possible); HOTween.To(_wayTrail.transform, distance / _wayTrailSpeed, param); }
/** Displays a foldout of a list of events */ public Brawler.Event[] Display() { showFoldout = EditorGUILayout.Foldout(showFoldout, title + " (" + events.Length + ")"); if (showFoldout) { EditorGUILayout.BeginVertical(); { EditorGUI.indentLevel++; // Cycle through each event for (int i = 0; i < events.Length; i++) { Brawler.Event e = events[i]; EditorGUILayout.BeginHorizontal(); { e.type = (Brawler.EventType)EditorGUILayout.EnumPopup("Type:", e.type); if (GUILayout.Button("X", GUILayout.Width(40))) { this.events = ArrayUtils.RemoveAt <Brawler.Event> (this.events, i); showStartTimeFoldouts = ArrayUtils.RemoveAt <bool>(showStartTimeFoldouts, i); showDurationFoldouts = ArrayUtils.RemoveAt <bool>(showDurationFoldouts, i); continue; } } EditorGUILayout.EndHorizontal(); if (e.type == Brawler.EventType.PerformAction) { // Select an action e.actionToPerform = (ActionScriptableObject)EditorGUILayout.ObjectField("Action:", e.actionToPerform, typeof(ActionScriptableObject), false); } else if (e.type == Brawler.EventType.PerformBasicAction) { // Select a basic action e.basicActionToPerform = (BasicActionType)EditorGUILayout.EnumPopup("Basic action:", e.basicActionToPerform); } else if (e.type == Brawler.EventType.CameraMovement) { // Set the camera settings e.cameraMovement.target = (TargetPosition)EditorGUILayout.EnumPopup("Target position:", e.cameraMovement.target); if (e.cameraMovement.target == TargetPosition.CustomPosition) { e.cameraMovement.targetPosition = EditorGUILayout.Vector2Field("Position to move to:", e.cameraMovement.targetPosition); } e.cameraMovement.zoom = EditorGUILayout.FloatField("Zoom:", e.cameraMovement.zoom); e.cameraMovement.cameraSpeed = EditorGUILayout.FloatField("Camera speed:", e.cameraMovement.cameraSpeed); } else if (e.type == Brawler.EventType.SoundEffect) { // Select the sound effect to play when the event is triggered e.soundEffect = (AudioClip)EditorGUILayout.ObjectField("Sound effect:", e.soundEffect, typeof(AudioClip), false); } else if (e.type == Brawler.EventType.SlowMotion) { e.slowMotion.timeScale = EditorGUILayout.Slider("Time scale:", e.slowMotion.timeScale, 0.001f, 1.0f); } else if (e.type == Brawler.EventType.ParticleEffect) { // Select a particle effect e.particleEvent.effect = (ParticleEffect)EditorGUILayout.EnumPopup("Particle Effect:", e.particleEvent.effect); e.particleEvent.spawnPoint = (ParticleSpawnPoint)EditorGUILayout.EnumPopup("Spawn Point:", e.particleEvent.spawnPoint); e.particleEvent.offset = EditorGUILayout.Vector3Field("Offset:", e.particleEvent.offset); } else if (e.type == Brawler.EventType.Force) { Force force = e.forceEvent; // Select a force type force.forceType = (ForceType)EditorGUILayout.EnumPopup("Force Type:", force.forceType); switch (force.forceType) { case ForceType.Velocity: force.velocity = EditorGUILayout.Vector2Field("Velocity:", force.velocity); force.relativeToFacingDirection = EditorGUILayout.Toggle("Relative to facing direction?", force.relativeToFacingDirection); break; case ForceType.Position: force.target = (TargetPosition)EditorGUILayout.EnumPopup("Target Position:", force.target); if (force.target == TargetPosition.CustomPosition) { force.customTargetPosition = EditorGUILayout.Vector2Field("Custom Position:", force.customTargetPosition); } force.faceTarget = EditorGUILayout.Toggle("Face target?", force.faceTarget); break; } } else if (e.type == Brawler.EventType.ColorFlash) { ColorFlash colorFlash = e.colorFlash; // Edit the color-flashing event colorFlash.color = EditorGUILayout.ColorField("Color:", colorFlash.color); colorFlash.renderInFront = EditorGUILayout.Toggle("Render in front", colorFlash.renderInFront); } else if (e.type == Brawler.EventType.Ghosting) { GhostEffect ghostEffect = e.ghostEffect; // Edit the ghosting effect ghostEffect.color = EditorGUILayout.ColorField("Color:", ghostEffect.color); ghostEffect.renderInFront = EditorGUILayout.Toggle("Render in front", ghostEffect.renderInFront); } else if (e.type == Brawler.EventType.ScreenShake) { ScreenShake screenShake = e.screenShake; // Modify the screen shake settings screenShake.speed = EditorGUILayout.FloatField("Speed:", screenShake.speed); screenShake.magnitude = EditorGUILayout.FloatField("Magnitude:", screenShake.magnitude); } else if (e.type == Brawler.EventType.Tween) { TweenEvent tweenEvent = e.tweenEvent; TweenEventEditor(tweenEvent); } // Stores true if the event being edited requires a starting time to be specified bool editStartTime = (e.type != Brawler.EventType.None); // If we require to edit the duration if (editStartTime) { // "Starting Time" foldout showStartTimeFoldouts[i] = EditorGUILayout.Foldout(showStartTimeFoldouts[i], "Starting Time"); if (showStartTimeFoldouts[i]) { ActionEditor.StartTimeFoldout(e.startTime); } } // Stores true if the event being edited requires a 'duration' to be specified bool editDuration = (e.type == Brawler.EventType.SlowMotion || e.type == Brawler.EventType.Force || e.type == Brawler.EventType.ColorFlash || e.type == Brawler.EventType.FreezeAnimation || e.type == Brawler.EventType.ScreenShake || e.type == Brawler.EventType.Tween || e.type == Brawler.EventType.Ghosting); // If we require to edit the duration if (editDuration) { // "Duration" foldout showDurationFoldouts[i] = EditorGUILayout.Foldout(showDurationFoldouts[i], "Duration"); if (showDurationFoldouts[i]) { ActionEditor.DurationFoldout(e.duration); } } EditorGUILayout.Space(); } // Add event ("+") button EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(""); // Add new event if (GUILayout.Button("+", GUILayout.Width(40))) { this.events = ArrayUtils.Add <Brawler.Event>(this.events, new Brawler.Event()); showStartTimeFoldouts = ArrayUtils.Add <bool>(showStartTimeFoldouts, false); showDurationFoldouts = ArrayUtils.Add <bool>(showDurationFoldouts, false); } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); } // Return the modified array of events return(events); }
private void _updateCB(TweenEvent data) { FsmResult.Value = Current; }
protected void _stepCompleteCB(TweenEvent data) { OnHOTweenStepComplete(); }
protected void _completeCB(TweenEvent data) { OnHOTweenComplete(); }
public void Register(TweenEvent evt) { tweenEvents.Add(evt); evt.id = tweenEvents.Count.ToString(); }
/// <summary> /// Tween the character for the given amount of time, using the given TweenEvent. /// </summary> public void Tween(TweenEvent tweenEvent, float duration) { // Delegate the call to the tweener, which tweens the character's graphics. tweener.PerformEvent(tweenEvent, duration); }
public override void OnInspectorGUI() { TweenEvent baseEvent = (TweenEvent)target; if (StoryNameManager.instance == null) { GUILayout.Label("No StoryNameManager Singleton found in scene"); return; } if (story == null) { story = DataManager.LoadStory(StoryNameManager.instance.storyName, "0"); } if (story == null) { Debug.LogErrorFormat("Story with the name {0} could not be loaded!", DataManager.currentStoryName); return; } //We get the index based on the name int index = 0; for (int i = 0; i < story.pageObjects.Count; i++) { if (baseEvent.pageName == story.pageObjects[i].name) { index = i; break; } } string[] pageNames = story.GetPageNames(); index = EditorGUILayout.Popup("Page", index, pageNames); baseEvent.pageName = pageNames[index]; PageObject page = story.GetPage(baseEvent.pageName); //We get the index based on the name index = 0; for (int i = 0; i < page.audioObjects.Count; i++) { if (baseEvent.audioName == page.audioObjects[i].name) { index = i; break; } } string[] audioNames = page.GetAudioNames(); index = EditorGUILayout.Popup("Audio", index, audioNames); baseEvent.audioName = audioNames[index]; //This is quite hacky. Every event is a DOTweenAnimation, but things like ActivationEvents simple don't show that. if (baseEvent.GetType() == typeof(TweenEvent)) { base.OnInspectorGUI(); } }
public void Swing(float delay, float offsetAngle, float speed, float time, bool useDamping, Action OnEndEvent, TweenEvent OnEndEventWithParam) { for (int i = 0; i < paramsQueue.Count; i++) { if (delay <= paramsQueue[i].delay) { paramsQueue.RemoveAt(i); } } Params newParams = new Params(); newParams.delay = delay; newParams.offsetAngle = offsetAngle; newParams.speed = speed; newParams.time = time; newParams.useDamping = useDamping; newParams.OnEndEvent = OnEndEvent; newParams.OnEndEventWithParam = OnEndEventWithParam; if (delay > 0f) { paramsQueue.Add(newParams); } else { SwingGo(newParams); } this.enabled = true; }
void OnDestroy() { EndEvent = null; EndEventWithParam = null; }