public void Curve(ActionData actionData, System.Action onComplete) { Vector3 P0 = moveGameObject.transform.position; Vector3 P2 = new Vector3(P0.x + actionData.width, P0.y, P0.z); Vector3 P1 = new Vector3(P0.x + actionData.width / 2, P0.y + actionData.height, P0.z); if (MoveFlip) { P2 = new Vector3(P0.x - actionData.width, P0.y, P0.z); P1 = new Vector3(P0.x - actionData.width / 2, P0.y + actionData.height, P0.z); } Tweener tweener = moveGameObject.Dobezier(P0, P1, P2, actionData.t, actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo)).OnComplete(() => { onComplete(); }); _tweeners.Add(tweener); }
public virtual void FadeTo(ActionData actionData, System.Action onComplete) { gameObject.RecursiveComponent <Renderer>((Renderer rd, int depth) => { // if (rd.gameObject.GetComponent<Spine.Unity.SkeletonRenderer>() == null) // { // rd.gameObject.DOFade(actionData.alpha, actionData.duration, actionData.ease).OnComplete(() => // { // onComplete(); // }); // } // else // { rd.DOFadeWithMaterialPropertyBlock(actionData.alpha, actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo), actionData.ease).OnComplete(() => { onComplete(); }); // } }, 1, 999); }
public void Dopath(ActionData actionData, System.Action onComplete) { Vector3[] vector3s = actionData.vector3List.ToArray(); for (int intsd = 0; intsd < vector3s.Length; intsd++) { Vector3 nw = actionData.vector3List[intsd]; if (MoveFlip) { nw.x = -nw.x; } vector3s[intsd] = nw + moveGameObject.transform.localPosition; } Tweener tweener = moveGameObject.transform.DOLocalPath(vector3s, actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo), actionData.pathType, actionData.pathMode, actionData.resolution).OnComplete(() => { onComplete(); }); _tweeners.Add(tweener); }
public void MoveBy(ActionData actionData, System.Action onComplete) { Vector3 randomPos; if (actionData.isNormalizedrandom) { randomPos = actionData.randomPosFrom + (actionData.randomPosTo - actionData.randomPosFrom).normalized * UnityEngine.Random.Range(0, (actionData.randomPosTo - actionData.randomPosFrom).magnitude); } else { randomPos = new Vector3(UnityEngine.Random.Range(actionData.randomPosFrom.x, actionData.randomPosTo.x) , UnityEngine.Random.Range(actionData.randomPosFrom.y, actionData.randomPosTo.y) , UnityEngine.Random.Range(actionData.randomPosFrom.z, actionData.randomPosTo.z)); } Tweener tweener = moveGameObject.transform.DoLocalMove(moveGameObject.transform.localPosition + (actionData.pos + randomPos).RotateFrontTo(Orientation).Flip(MoveFlip), actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo), actionData.ease).OnComplete(() => { onComplete(); }); _tweeners.Add(tweener); }
public virtual void RunAction(ActionData actionData, System.Action onComplete) { switch (actionData.actionType) { case ActionType.MoveBy: Vector3 randomPos; if (actionData.isNormalizedrandom) { randomPos = actionData.randomPosFrom + (actionData.randomPosTo - actionData.randomPosFrom).normalized * UnityEngine.Random.Range(0, (actionData.randomPosTo - actionData.randomPosFrom).magnitude); } else { randomPos = new Vector3(UnityEngine.Random.Range(actionData.randomPosFrom.x, actionData.randomPosTo.x) , UnityEngine.Random.Range(actionData.randomPosFrom.y, actionData.randomPosTo.y) , UnityEngine.Random.Range(actionData.randomPosFrom.z, actionData.randomPosTo.z)); } transform.DoLocalMove(transform.localPosition + (actionData.pos + randomPos).RotateFrontTo(Orientation).Flip(Flip), actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo), actionData.ease).OnComplete(() => { if (onComplete != null) { onComplete(); } }); break; case ActionType.AddForce: { var bloodRigidbody = gameObject.GetComponentInChildren <Rigidbody>(); if (bloodRigidbody != null) { if (actionData.RandomType == RandomType.Fix) { bloodRigidbody.AddForce(actionData.Force.RotateFrontTo(Orientation).Flip(Flip), actionData.ForceMode); } else { Vector3 force = new Vector3( Random.Range(actionData.randomForceMin.x, actionData.randomForceMax.x), Random.Range(actionData.randomForceMin.y, actionData.randomForceMax.y), Random.Range(actionData.randomForceMin.z, actionData.randomForceMax.z)); bloodRigidbody.AddForce(force.RotateFrontTo(Orientation).Flip(Flip), actionData.ForceMode); } } gameObject.DoDelay(actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo)).OnComplete(() => { onComplete(); }); } break; case ActionType.AddRotation: { AddRotation(actionData, onComplete); } break; case ActionType.AddTorque: { var bloodRigidbody = gameObject.GetComponentInChildren <Rigidbody>(); if (bloodRigidbody != null) { if (actionData.RandomType == RandomType.Fix) { bloodRigidbody.AddTorque(actionData.Force.RotateFrontTo(Orientation).Flip(Flip), actionData.ForceMode); } else { Vector3 force = new Vector3( Random.Range(actionData.randomForceMin.x, actionData.randomForceMax.x), Random.Range(actionData.randomForceMin.y, actionData.randomForceMax.y), Random.Range(actionData.randomForceMin.z, actionData.randomForceMax.z)); bloodRigidbody.AddTorque(force.RotateFrontTo(Orientation).Flip(Flip), actionData.ForceMode); } } gameObject.DoDelay(actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo)).OnComplete(() => { onComplete(); }); } break; case ActionType.FadeTo: FadeTo(actionData, onComplete); break; case ActionType.ScaleTo: Vector3 randomScale; if (actionData.isNormalizedrandom) { randomScale = actionData.randomScaleFrom + (actionData.randomScaleTo - actionData.randomScaleFrom).normalized * UnityEngine.Random.Range(0, (actionData.randomScaleTo - actionData.randomScaleFrom).magnitude); } else { randomScale = new Vector3(UnityEngine.Random.Range(actionData.randomScaleFrom.x, actionData.randomScaleTo.x) , UnityEngine.Random.Range(actionData.randomScaleFrom.y, actionData.randomScaleTo.y) , UnityEngine.Random.Range(actionData.randomScaleFrom.z, actionData.randomScaleTo.z)); } Vector3 toScale = actionData.scale + randomScale; toScale.x = toScale.x * animEffectData.scale.x; toScale.y = toScale.y * animEffectData.scale.y; toScale.z = toScale.z * animEffectData.scale.z; transform.DOScale(toScale, actionData.duration + Random.Range(actionData.randomDurationFrom, actionData.randomDurationTo)).SetEase(actionData.ease).OnComplete(() => { onComplete(); }); break; case ActionType.Curve: { var bloodRigidbody = gameObject.GetComponentInChildren <Rigidbody>(); if (bloodRigidbody != null && bloodRigidbody.useGravity) { onComplete(); } else { Curve(actionData, onComplete); } } break; case ActionType.Path: { var bloodRigidbody = gameObject.GetComponentInChildren <Rigidbody>(); if (bloodRigidbody != null && bloodRigidbody.useGravity) { onComplete(); } else { Dopath(actionData, onComplete); } } break; case ActionType.AddColorTo: AddColorTo(actionData, onComplete); break; case ActionType.MulColorTo: MulColorTo(actionData, onComplete); break; case ActionType.Sequence: RunSequence(actionData.actionList, onComplete, 0); break; case ActionType.Parallel: RunParallel(actionData.actionList, onComplete); break; default: onComplete(); break; } }