Esempio n. 1
0
        private void AnimateCardToHand(BaseCard card, FlipState flipState, bool preview = true)
        {
            var cardPosition = GetTargetPositionForCard(card);

            if (preview)
            {
                var previewTween = new MoveTween
                {
                    Target             = card.gameObject,
                    Position           = _handPreviewPosition,
                    Time               = 0.5f,
                    Flip               = flipState,
                    Rotate             = TweenRotationType.NoRotate,
                    OnCompleteCallback = () => card.State = State.InHand
                };
                GameManager.TweenQueue.AddTweenToQueue(previewTween);
            }

            var finalTween = new MoveTween
            {
                Target             = card.gameObject,
                Position           = cardPosition,
                Time               = 0.3f,
                Delay              = 0.1f,
                Flip               = flipState,
                Rotate             = TweenRotationType.NoRotate,
                OnCompleteCallback = () => card.State = State.InHand
            };

            GameManager.TweenQueue.AddTweenToQueue(finalTween);
        }
Esempio n. 2
0
        private float getCurTime(ISyncScenarioItem item)
        {
            float curTime = 0.0f;

            if (item is MoveTween)
            {
                MoveTween tSh = (item as MoveTween);
                if (tSh != null)
                {
                    curTime = tSh.CurTime;
                }
            }

            if (item is AlphaTween)
            {
                AlphaTween tF = (item as AlphaTween);

                if (tF != null)
                {
                    curTime = tF.CurTime;
                }
            }

            if (item is ScaleTween)
            {
                ScaleTween tF = (item as ScaleTween);

                if (tF != null)
                {
                    curTime = tF.CurTime;
                }
            }

            return(curTime);
        }
Esempio n. 3
0
 private Vector3 addTweenAction(int i, Vector3 position, float?leftTime)
 {
     if (tweens[i] is MoveTween)
     {
         MoveTween             shiftTween     = tweens[i] as MoveTween;
         Vector3TweenSimulator tweenSimulator = shiftTween.Simulator as Vector3TweenSimulator;
         //MoveTween.sim
         if (!leftTime.HasValue)
         {
             position += shiftTween.EndValue;
         }
         else
         {
             //Vector3TweenSimulator simulator = new Vector3TweenSimulator(shiftTween.;
             if (tweenSimulator != null)
             {
                 position += new Vector3(
                     tweenSimulator.SimulateFunction.Invoke(leftTime.Value, 0, shiftTween.EndValue.x, shiftTween.Duration),
                     tweenSimulator.SimulateFunction.Invoke(leftTime.Value, 0, shiftTween.EndValue.y, shiftTween.Duration),
                     tweenSimulator.SimulateFunction.Invoke(leftTime.Value, 0, shiftTween.EndValue.z, shiftTween.Duration)
                     );
             }
         }
     }
     return(position);
 }
Esempio n. 4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        MoveTween moveTween = (MoveTween)target;

        if (GUILayout.Button("Set target position"))
        {
            moveTween.SetTargetPosition();
        }
    }
Esempio n. 5
0
        public SimulateScenarioItem ShiftBy(List <GameObject> goList, Vector3 shift, float duration, EaseType ease, TweenSpace space, Callback callback)
        {
            SimulateScenarioItem tweenObj = null;

            if (goList != null && goList.Count > 0)
            {
                tweenObj = new MoveTween(convertToObjects(goList), shift, duration, Ease[ease], space, TweenEndValueType.Shift, callback);
                tweenObj.Play();
            }
            return(tweenObj);
        }
Esempio n. 6
0
        private void TweenCardToPosition(BaseCard card)
        {
            var tween = new MoveTween
            {
                Target             = card.gameObject,
                Position           = GetTargetPositionForCard(card),
                Time               = 0.3f,
                Flip               = FlipState.FaceUp,
                Rotate             = TweenRotationType.Rotate90,
                OnCompleteCallback = () => card.State = State.InPlay
            };

            GameManager.TweenQueue.AddTweenToQueue(tween);
        }
Esempio n. 7
0
        private void PreviewSpell()
        {
            State = State.Discarded;
            var rotateType = Player.OppositePlayer.IsLocalPlayer ? TweenRotationType.Rotate180 : TweenRotationType.NoRotate;

            var tween = new MoveTween
            {
                Target             = gameObject,
                Position           = _spellOffset,
                Time               = 0.5f,
                Flip               = FlipState.FaceUp,
                Rotate             = rotateType,
                TimeUntilNextTween = 0.6f
            };

            GameManager.TweenQueue.AddTweenToQueue(tween);
        }
Esempio n. 8
0
        internal static MoveTween GetMoveTween(Transform obj, Transform to, float t)
        {
            MoveTween tween;

            if (TryGetTween(moveTweens, out tween))
            {
                tween.Init(obj, to, t);
            }
            else
            {
                tween         = new MoveTween(obj, to, t, GenerateId());
                tween.Recycle = FinishTween;
            }

            _activeTweens.Add(tween);
            return(tween);
        }
        private void PreviewSpell()
        {
            //TODO: Why is the State set here and in the callback?

            //TODO: Probably do not need to set the state in the callback, remove callback and see what happens
            State = State.Discarded;
            var rotateType = Player.OppositePlayer.IsLocalPlayer ? TweenRotationType.Rotate180 : TweenRotationType.NoRotate;

            var tween = new MoveTween
            {
                Target             = gameObject,
                Position           = _spellOffset,
                Time               = 0.5f,
                Flip               = FlipState.FaceUp,
                Rotate             = rotateType,
                OnCompleteCallback = () => State = State.Discarded,
                TimeUntilNextTween = 0.6f
            };

            GameManager.TweenQueue.AddTweenToQueue(tween);
        }
Esempio n. 10
0
        public override void Add(BaseCard card)
        {
            this.Cards.Add(card);
            card.Enable();

            card.transform.parent = this.transform;

            var cardPos = this.GetTargetPositionForCard(card);

            Vector3 cardPreviewPos = cardPos;

            cardPreviewPos.z -= 20f;

            var previewTween = new MoveTween
            {
                Target             = card.gameObject,
                Position           = cardPreviewPos,
                Time               = 0.35f,
                Flip               = FlipState.FaceUp,
                Rotate             = TweenRotationType.NoRotate,
                OnCompleteCallback = () => card.State = State.Discarded
            };

            var finalTween = new MoveTween
            {
                Target             = card.gameObject,
                Position           = cardPos,
                Time               = 0.25f,
                Flip               = FlipState.FaceUp,
                Rotate             = TweenRotationType.NoRotate,
                OnCompleteCallback = () => card.State = State.Discarded
            };

            GameManager.TweenQueue.AddTweenToQueue(previewTween);
            GameManager.TweenQueue.AddTweenToQueue(finalTween);

            this.MoveToThisCollection(card);
        }
Esempio n. 11
0
        /// <summary>
        /// Adds a card to the bottom of the deck
        /// </summary>
        public override void Add(BaseCard card)
        {
            MoveToThisCollection(card);

            Cards.Insert(0, card);

            card.transform.parent = transform;

            var cardPos = new Vector3(_deckPositionOffset.x, _deckPositionOffset.y, 16f);

            cardPos.z -= Cards.IndexOf(card) * 0.2f;

            var tween = new MoveTween
            {
                Target             = card.gameObject,
                Position           = cardPos,
                Time               = 0.25f,
                Flip               = FlipState.FaceDown,
                Rotate             = TweenRotationType.NoRotate,
                OnCompleteCallback = () => card.State = State.InDeck
            };

            GameManager.TweenQueue.AddTweenToQueue(tween);
        }
Esempio n. 12
0
        public BaseTween Move(Transform obj, Transform to, float t)
        {
            MoveTween tween = TweenPool.GetMoveTween(obj, to, t);

            return(ProcessTween(tween));
        }
Esempio n. 13
0
 public void AddValue(MoveTween tween)
 {
     positions.Add(tween.EndValue);
     durations.Add(tween.Duration);
     tweens.Add(tween);
 }