public void ReturnDuelVictoryCardToSlot(Card card, bool isCardChangeSlotBeforeAttack, bool isAttackCard, ActionDelegate onFinish) { Transform oldParent = card.transform.parent; card.transform.parent = null; Vector3 oldPosition = card.transform.position; Quaternion oldRotation = card.transform.rotation; card.transform.parent = oldParent; MoveCardIntoThisSlotImmediately(card); card.transform.parent = null; Vector3 targetPosition = card.transform.position; card.transform.position = oldPosition; card.transform.rotation = oldRotation; Vector3 subPoint = targetPosition + (targetPosition-oldPosition)*1f - card.transform.forward*2f; Vector3 distanceDir = oldPosition-targetPosition; float sign = -Mathf.Sign(distanceDir.z); ActionDelegate FinishAnimation = delegate() { MoveCardIntoThisSlotImmediately(card); onFinish(); }; float animationTime = 1f; MathFunction2D bezier1 = new BezierIntepolation2D(new Vector2(0f, 0f), new Vector2(0.746506f, -0.01541233f), new Vector2(-0.008380715f, 1.051112f), new Vector2(1f, 1f)); ITransform waitTranform = new ST.Wait(animationTime*0.2f); ITransform rotationTransform = new ST.TimeRotationTransform(Axis.X,true, animationTime*0.6f, sign*2*Mathf.PI); ITransform positionTransform1 = new ST.LinearPositionTransformParam(subPoint, animationTime*0.5f, false, false, delegate(float t) { return bezier1.GetValue(t).y; }); ITransform positionTransform2 = new ST.LinearPositionTransformParam(targetPosition, 0.5f*animationTime, false, delegate(float t) { return t; }); if(isCardChangeSlotBeforeAttack) { GameGuiSlot oldSlot = GameGui.Instance.GetSlotWithCard(card); DuelAnimationHelper.ReturnCardToSlot(card, oldSlot, onFinish); } else{ if(isAttackCard){ MainAnimationHelper.RunAnimationsConcurrent(card.gameObject, null, FinishAnimation, new ITransform[] { positionTransform1, positionTransform2 }, new ITransform[] {waitTranform, rotationTransform}); }else{ FinishAnimation(); } } }
public void MoveCardIntoThisSlot(Card card, int position, ST.UnitFunction function, float avarageVelocity, ActionDelegate onFinish) { Transform oldParent = card.transform.parent; card.transform.parent = null; Vector3 oldPosition = card.transform.position; Quaternion oldRotation = card.transform.rotation; card.transform.parent = oldParent; MoveCardIntoThisSlotImmediately(card, position); card.transform.parent = null; Vector3 targetPosition = card.transform.position; Quaternion targetRotation = card.transform.rotation; card.transform.position = oldPosition; card.transform.rotation = oldRotation; float time = (targetPosition-card.transform.position).magnitude/avarageVelocity; ST.LinearPositionTransformParam positionTransform = new ST.LinearPositionTransformParam(targetPosition, time, false, function); TransformManager.Instance.AddTransform(card.gameObject, delegate(int id, GameObject obj, ITransform transform, TransformEventType t) { if(t == TransformEventType.OnListFinished) { card.transform.parent = gameObject.transform; if(IsCementarySlot) card.Reinitialize(); if(onFinish != null) onFinish(); } }, positionTransform); ST.LinearRotationTransformParam rotationTransform = new ST.LinearRotationTransformParam(targetRotation, 0.92f*time, false, function); TransformManager.Instance.AddTransform(card.gameObject, rotationTransform); }