コード例 #1
0
 public void Cancel(bool OnComplete, CancelCondition cancelCondition)
 {
     this.cancelCondition = cancelCondition;
     isCanceled           = true;
     isCycled             = false;
     onComplete           = OnComplete;
 }
コード例 #2
0
 public int FindCommand(int[] inputs, bool facingRight, CancelCondition cond)
 {
     for (int i = 0; i < moveList.Length; i++)
     {
         //checks if the move can be cancelled into
         if ((cond & moveList[i].condition) == moveList[i].condition)
         {
             int ret = moveList[i].CheckCommand(inputs, facingRight);
             if (ret > -1)
             {
                 return(ret);
             }
         }
     }
     return(-1);
 }
コード例 #3
0
ファイル: SimpleTween.cs プロジェクト: dqchess/Tap-Match
            public void Cancel(bool OnComplete, CancelCondition cancelCondition)
            {
                if (IsFree)
                {
                    return;
                }
                IsFree   = true;
                IsCycled = false;

                switch (cancelCondition)
                {
                case CancelCondition.SetStartValue:
                    currValue    = startValue;
                    currPosition = startPosition;
                    break;

                case CancelCondition.SetEndValue:
                    currValue    = endValue;
                    currPosition = endPosition;
                    break;
                }

                switch (stt)
                {
                case STT.FloatTween:
                    UpdateCallBack?.Invoke(currValue);
                    break;

                case STT.Vector3Tween:
                    UpdateCallBackV3?.Invoke(currPosition);
                    break;

                case STT.Vector3TweenMove:
                    if (gameObject)
                    {
                        gameObject.transform.position = currPosition;
                    }
                    UpdateCallBackV3?.Invoke(currPosition);
                    break;
                }
                if (OnComplete)
                {
                    completeCallBack?.Invoke();
                }
            }
コード例 #4
0
ファイル: SimpleTween.cs プロジェクト: dqchess/Tap-Match
        /// <summary>
        /// Cancel tween id
        /// </summary>
        /// <param name="id"></param>
        /// <param name="OnComplete"></param>
        public static void Cancel(int id, bool OnComplete, CancelCondition cancelCondition)
        {
            if (tweenObjects == null)
            {
                return;
            }
            SimpleTweenObject sTO;
            int length = tweenObjects.Count;

            for (int i = 0; i < length; i++)
            {
                sTO = tweenObjects[i];
                if (sTO.ID == id)
                {
                    sTO.Cancel(OnComplete, cancelCondition);
                }
            }
        }
コード例 #5
0
            private bool onComplete = false; // it(true) run completeCallBack after cancel

            public SimpleTweenObject(GameObject gameObject, float startValue, float endValue, float tweenTime)
            {
                this.gameObject = gameObject;
                this.tweenTime  = tweenTime;
                this.startValue = startValue;
                this.endValue   = endValue;
                lastID++;
                id              = lastID;
                maxValue        = (endValue >= startValue) ? endValue : startValue;
                minValue        = (endValue <= startValue) ? endValue : startValue;
                currValue       = startValue;
                dValue          = endValue - startValue;
                EaseFunc        = EaseLinear;
                stt             = STT.FloatTween;
                isFree          = false;
                isCycled        = false;
                cancelCondition = CancelCondition.AsIs;
                isCanceled      = false;
                onComplete      = false;
            }
コード例 #6
0
            public SimpleTweenObject(GameObject gameObject, Vector3 startPosition, Vector3 endPosition, float tweenTime, bool move)
            {
                this.gameObject = gameObject;
                this.tweenTime  = tweenTime;

                this.startPosition = startPosition;
                this.endPosition   = endPosition;
                currPosition       = startPosition;
                dPosition          = endPosition - startPosition;

                lastID++;
                id = lastID;


                EaseFunc        = EaseLinear;
                stt             = (!move)? STT.Vector3Tween : STT.Vector3TweenMove;
                isFree          = false;
                isCycled        = false;
                cancelCondition = CancelCondition.AsIs;
                isCanceled      = false;
                onComplete      = false;
            }
コード例 #7
0
ファイル: SimpleTween.cs プロジェクト: dqchess/Tap-Match
        /// <summary>
        /// Cancel all tweens for gameObject
        /// </summary>
        /// <param name="gO"></param>
        /// <param name="OnComplete"></param>
        public static void Cancel(GameObject gO, bool OnComplete, CancelCondition cancelCondition)
        {
            if (gO == null || tweenObjects == null)
            {
                return;
            }
            List <SimpleTweenObject> sTOL = new List <SimpleTweenObject>();
            int length = tweenObjects.Count;
            SimpleTweenObject sTO;

            for (int i = 0; i < length; i++)
            {
                sTO = tweenObjects[i];
                if (sTO.gameObject == gO)
                {
                    sTOL.Add(sTO);
                }
            }
            length = sTOL.Count;
            for (int i = 0; i < length; i++)
            {
                sTOL[i].Cancel(OnComplete, cancelCondition);
            }
        }
コード例 #8
0
            internal void Rebuild(GameObject gameObject, Vector3 startPosition, Vector3 endPosition, float tweenTime, bool move)
            {
                this.gameObject = gameObject;
                this.tweenTime  = tweenTime;
                lastID++;
                id = lastID;

                this.startPosition = startPosition;
                this.endPosition   = endPosition;
                currPosition       = startPosition;
                dPosition          = endPosition - startPosition;

                EaseFunc         = EaseLinear;
                currTime         = 0.0f;
                delay            = 0.0f;
                stt              = (move) ? STT.Vector3TweenMove : STT.Vector3Tween;
                isFree           = false;
                isCycled         = false;
                completeCallBack = null;
                UpdateCallBack   = null;
                cancelCondition  = CancelCondition.AsIs;
                isCanceled       = false;
                onComplete       = false;
            }
コード例 #9
0
 internal void Rebuild(GameObject gameObject, float startValue, float endValue, float tweenTime)
 {
     this.gameObject = gameObject;
     this.tweenTime  = tweenTime;
     this.startValue = startValue;
     this.endValue   = endValue;
     lastID++;
     id               = lastID;
     maxValue         = (endValue >= startValue) ? endValue : startValue;
     minValue         = (endValue <= startValue) ? endValue : startValue;
     currValue        = startValue;
     dValue           = endValue - startValue;
     EaseFunc         = EaseLinear;
     currTime         = 0.0f;
     delay            = 0.0f;
     stt              = STT.FloatTween;
     isFree           = false;
     isCycled         = false;
     completeCallBack = null;
     UpdateCallBack   = null;
     cancelCondition  = CancelCondition.AsIs;
     isCanceled       = false;
     onComplete       = false;
 }
コード例 #10
0
 //edits the cancel condition on hit
 public void AddCancelCondition(CancelCondition cond)
 {
     this.cancelCondition |= cond;
 }
コード例 #11
0
 //sets and returns the new state to current state
 private StateFrameData AssignNewCurState(StateFrameData newState)
 {
     currentState         = newState;
     this.cancelCondition = newState.cancelCondition;
     return(currentState);
 }
コード例 #12
0
        //this transition algorithm feels very bad, rewrite and organize
        private StateFrameData CheckTransitionState(bool timerIsDone, SpaxInput input, StateFrameData srcState)
        {
            int len = srcState._transitions.Count;

            //gets current transition conditions
            TransitionCondition curConditions = GetTransitionCondition();

            //if the timer is done
            if (timerIsDone)
            {
                curConditions |= TransitionCondition.ON_END;
            }

            for (int i = 0; i < len; i++)
            {
                StateFrameData      potenState = srcState._transitions[i].Target;
                TransitionCondition compare    = srcState._transitions[i].GetConditions();
                InputCodeFlags      inputCond  = srcState._transitions[i].inputConditions;
                CancelCondition     cancelCond = srcState._transitions[i].cancelCondition;
                if ((compare & (TransitionCondition.FULL_METER | TransitionCondition.HALF_METER | TransitionCondition.QUART_METER)) == 0)
                {
                    //if all the conditions are met
                    if ((compare & curConditions) == compare && (cancelCond & this.cancelCondition) == cancelCond)
                    {
                        //get the last input change
                        int fromInput = (int)inputRecorder.GetLatestCode();
                        //flip 6 and 4 direction, if needed
                        if (!moveCondition.facingRight)
                        {
                            fromInput = InputCode.FlipBackForth(fromInput);
                        }

                        bool initialCheck = ((inputCond & (InputCodeFlags)fromInput) == inputCond);
                        bool freePass     = false;

                        if (!initialCheck && (inputCond & InputCodeFlags.CURRENTLY_HELD) > 0)
                        {
                            inputCond ^= InputCodeFlags.CURRENTLY_HELD;
                            int codeFromInput   = (((int)input.direction & 510) << 2) | ((int)input.buttons << 11);
                            int inputCondSimple = ((int)inputCond >> 3) << 3;
                            if (!moveCondition.facingRight)
                            {
                                codeFromInput = InputCode.FlipBackForth(codeFromInput);
                            }

                            freePass = ((codeFromInput & inputCondSimple) == inputCondSimple);
                        }



                        //check it
                        if (inputCond == 0 || initialCheck || freePass)
                        {
                            //Debug.Log(compare);
                            return(AssignNewCurState(potenState));
                        }
                    }
                }
            }

            //only really reached if state to transition to isn't found
            if (((srcState.stateConditions & StateConditions.NO_PARENT_TRANS) == 0) && (srcState.parentState != null))
            {
                return(CheckTransitionState(timerIsDone, input, srcState.parentState));
            }

            return(null);
        }