Example #1
0
 void Update()
 {
     if (state == FSState.idle) return;
     float u = (Time.time - timeStart)/timeDuration;
     float uC = Easing.Ease (u, easingCurve);
     if (u<0) {
         state = FSState.pre;
         transform.position = bezierPts[0];
     } else {
         if (u>=1) {
             uC = 1;
             state = FSState.post;
             if (reportFinishTo != null) {
                 reportFinishTo.SendMessage("FSCallback", this);
                 Destroy (gameObject);
             } else {
                 state = FSState.idle;
             }
         } else {
             state = FSState.active;
         }
         Vector3 pos = Utils.Bezier(uC, bezierPts);
         transform.position = pos;
         if (fontSizes != null && fontSizes.Count>0) {
             int size = Mathf.RoundToInt( Utils.Bezier(uC, fontSizes) );
             GetComponent<GUIText>().fontSize = size;
         }
     }
 }
Example #2
0
	}//end of FSCallBack

	void Update () {
		if(state == FSState.idle) return;

		float u = (Time.time - timeStart);
		float uC = Easing.Ease (u, easingCurve);
		if (u < 0) {
			state = FSState.pre;
			transform.position = bezierPts [0];
		}//end of if
		else {
			if (u >= 1) {
				uC = 1;
				state = FSState.post;
				if (reportFinishTo != null) {
					reportFinishTo.SendMessage ("FSCallback", this);
					Destroy (gameObject);
				}//end of second nested if
				else {
					state = FSState.idle;
				}//end of second nested else
			}//end of nested if
			else {
				state = FSState.active;
			}//end of nested else
		}//end of else
		Vector3 pos = Utils.Bezier(uC, bezierPts);
		transform.position = pos;
		if (fontSizes != null && fontSizes.Count > 0) {
			int size = Mathf.RoundToInt (Utils.Bezier (uC, fontSizes));
			GetComponent<GUIText> ().fontSize = size;
		}//end of if
	}//end of Update
    protected string Pop(string newName)
    {
        FSState lastState = mStateStack.Peek();
        string  newState  = null;

        if (newName == null && mStateStack.Count > 1)
        {
            int index = 0;
            foreach (FSState item in mStateStack)
            {
                if (index++ == mStateStack.Count - 2)
                {
                    newState = item.StateName;
                }
            }
        }
        else
        {
            newState = newName;
        }
        string lastStateName = null;

        if (lastState != null)
        {
            lastStateName = lastState.StateName;
            lastState.StateObject.OnExit(newState);
        }
        mStateStack.Pop();
        return(lastStateName);
    }
Example #4
0
 public override void AddCanChangeToState(FSState <GameCore> state)
 {
     if (!_canChangeToStateList.Contains(state))
     {
         _canChangeToStateList.Add(state);
     }
 }
Example #5
0
 public void ChangeState(System.Type stateType, object param = null)
 {
     try {
         if (_stateDic.ContainsKey(stateType))
         {
             FSState <T> newState = null;
             if (_stateDic.TryGetValue(stateType, out newState))
             {
                 if (_currentState.CanChangeState(newState) && newState.PreCheck(param))
                 {
                     InternalChangeState(newState, param);
                 }
                 else
                 {
                     Debug.LogWarning("state[" + _currentState.GetType() + "]change to state[" + stateType + "]failed");
                 }
             }
             else
             {
                 if (newState.PreCheck(param))
                 {
                     InternalChangeState(newState, param);
                 }
             }
         }
         else
         {
             Debug.LogError("The state [" + stateType + "] have not be registed");
         }
     } catch (System.Exception e) {
         Debug.LogError(e.ToString());
     }
 }
Example #6
0
    /// <summary>
    /// 执行出栈,出栈事件会传出准备入栈的状态名
    /// </summary>
    /// <param name="nextState">下一个状态,可以为空</param>
    /// <returns></returns>
    protected T?ExcutePop(T?nextState)
    {
        //Fixing
        FSState lastState = mStateStack.Peek();
        T?      newState  = null;

        if (nextState == null && mStateStack.Count > 1)
        {
            int index = 0;
            foreach (FSState item in mStateStack)
            {
                if (index++ == mStateStack.Count - 2)
                {
                    newState = item.StateName;
                }
            }
        }
        else
        {
            newState = nextState;
        }

        T?lastStateName = null;

        if (lastState != null)
        {
            lastStateName = lastState.StateName;
            lastState.StateObject.OnExit(newState);
        }
        mStateStack.Pop();
        return(lastStateName);
    }
Example #7
0
    void UpdateState(bool chase, bool up, bool down, bool left, bool right)
    {
        currentState = chase ? FSState.CHASING : FSState.RESTING;

        //if (currentState == FSState.RESTING) flapTimer = 0f;

        SetAnimatorState(currentState, up, down, left, right);
    }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        // If this is not moving, just return
        if (state == FSState.idle)
        {
            return;
        }

        // Get u from the current time and duration
        // u ranges from 0 to 1 (usually)
        float u = (Time.time - timeStart) / timeDuration;
        // Use Easing class from Utils to curve the u value
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)         // If u<0, then we shouldn't move yet.
        {
            state = FSState.pre;
            // Move to the initial point
            transform.position = bezierPts[0];
        }
        else
        {
            if (u >= 1)                     // If u>=1, we're done moving
            {
                uC    = 1;                  // Set uC=1 so we don't overshoot
                state = FSState.post;
                if (reportFinishTo != null) //If there's a callback GameObject
                // Use SendMessage to call the FSCallback method
                //  with this as the parameter.
                {
                    reportFinishTo.SendMessage("FSCallback", this);
                    // Now that the message has been sent,
                    //  Destroy this gameObject
                    Destroy(gameObject);
                }
                else                     // If there is nothing to callback
                                         // ...then don't destroy this. Just let it stay still.
                {
                    state = FSState.idle;
                }
            }
            else
            {
                // 0<=u<1, which means that this is active and moving
                state = FSState.active;
            }
            // Use Bezier curve to move this to the right point
            Vector3 pos = Utils.Bezier(uC, bezierPts);
            transform.position = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                // If fontSizes has values in it
                // ...then adjust the fontSize of this GUIText
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <GUIText>().fontSize = size;
            }
        }
    }
Example #9
0
    void Update()
    {
        //If not moving
        if (state == FSState.idle)
        {
            return;
        }

        //u ranges between 0 and 1
        float u = (Time.time - timeStart) / timeDuration;
        //The Easing class from Utils curves the u value
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)           //If u < 0, we shouldn't move yet
        {
            state = FSState.pre;
            //transform.position = bezierPts [0];
            setPos(bezierPts[0]);
        }
        else
        {
            if (u >= 1)                     //u >=1 means we're done moving
            {
                uC    = 1;                  //To avoid overshooting
                state = FSState.post;
                if (reportFinishTo != null) //If we have a callback gameObject
                //SendMessage to call FSCallback
                {
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(gameObject);
                }
                else                     //If there is nothing to callback
                                         //Just let it remain still
                {
                    state = FSState.idle;
                }
            }
            else
            {
                //0 <= u < 1 so we are active and moving
                state = FSState.active;
            }
            //Use Bezier curves to move
            Vector3 pos = Utils.Bezier(uC, bezierPts);
            //transform.position = pos;
            setPos(pos);
            if (fontSizes != null && fontSizes.Count > 0)
            {
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                //GetComponent<GUIText>().fontSize = size;
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Example #10
0
 public FSEvent(string mEventName, string mTargetState, FSState mStateOwner, FiniteStateMachine mOwner, FiniteStateMachine.EnterState mEnterDelegate, FiniteStateMachine.PushState mPushDelegate, FiniteStateMachine.PopState mPopDelegate)
 {
     this.mEventName = mEventName;
     this.mTargetState = mTargetState;
     this.mStateOwner = mStateOwner;
     this.mOwner = mOwner;
     this.mEnterDelegate = mEnterDelegate;
     this.mPushDelegate = mPushDelegate;
     this.mPopDelegate = mPopDelegate;
     this.eType = EventType.NONE;
 }
    void Update()
    {
        //如果没有移动,则返回
        if (state == FSState.idle)
        {
            return;
        }

        //从当前时间和持续时间计算u,u范围为0到1(通常)
        float u = (Time.time - timeStart) / timeDuration;
        //使用Utils的Easing类描绘u值曲线图
        float uC = Easing.Ease(u, easingCuve);

        if (u < 0)//如果u<0,那么还不能移动
        {
            state = FSState.pre;
            //移动到初始坐标
            transform.position = bezierPts[0];
        }
        else
        {
            if (u >= 1)                     //如果u>=1,已完成移动
            {
                uC    = 1;                  //设置uC = 1避免越界溢出
                state = FSState.post;
                if (reportFinishTo != null) //如果有回调GameObject
                {
                    //使用SendMessage调用FSCallback方法,并带this参数
                    reportFinishTo.SendMessage("FSCallback", this);
                    //消息发送后,销毁当前gameObject
                    Destroy(gameObject);
                }
                else//如果没有回调
                {
                    //不销毁当前对象,仅保存
                    state = FSState.idle;
                }
            }
            else
            {
                //0<=u<1代表当前对象有效且正在移动
                state = FSState.active;
            }
            //使用Bezier曲线将当前对象移动到正确坐标
            Vector3 pos = Utils.Bezier(uC, bezierPts);
            transform.position = pos;
            if (fontSizes != null && fontSizes.Count > 0)//如果fontSizes有值
            {
                //那么调整GUIText的fontSize
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <GUIText>().fontSize = size;
            }
        }
    }
Example #12
0
 public FSEvent(string name, string target, FSState state, FiniteStateMachine owner, FiniteStateMachine.EnterState e, FiniteStateMachine.PushState pu, FiniteStateMachine.PopState po)
 {
     mStateOwner    = state;
     mEventName     = name;
     mTargetState   = target;
     mOwner         = owner;
     eType          = EventType.NONE;
     mEnterDelegate = e;
     mPushDelegate  = pu;
     mPopDelegate   = po;
 }
Example #13
0
    private void Update()
    {
        // Если он не двигается, просто возвращаем
        if (state == FSState.idle)
        {
            return;
        }

        // Вычисляем u из текущего времени и длинны
        float u = (Time.time - timeStart) / timeDuration;
        // Используем Easing класс из Utils чтобы изменить u
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)    // Мы ещё не должны начать передвигаться
        {
            state = FSState.pre;
            // Двигаем к стартовой точке
            transform.position = bezierPts[0];
        }
        else
        {
            if (u >= 1)                     // Если у больше единицы значит мы закончили движение
            {
                uC    = 1;                  // Задаём уЦе = 1 чтобы мы не перестарались
                state = FSState.post;
                if (reportFinishTo != null) // Если есть ио для фидбека
                // Используем SendMessage чтобы вызвать FSCallback метод
                {
                    reportFinishTo.SendMessage("FSCallback", this);
                    // Когда сообщение отправлено уничтожаем ио
                    Destroy(gameObject);
                }
                else
                {
                    // Если некому вернуть
                    // Просто оставляем в покое
                    state = FSState.idle;
                }
            }
            else        // 0<=u<1, что означает что счёт всё ещё движется
            {
                state = FSState.active;
            }
            // Используем бизеровую кривую чтобы двигаться к правильно точке
            Vector3 pos = Utils.Bezier(uC, bezierPts);
            transform.position = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                // Если есть различные размеры шрифта, то приравниваем так же
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <Text>().fontSize = size;
            }
        }
    }
Example #14
0
 public bool CanChangeState(FSState <T> state)
 {
     if (CanChangeStateTo(state))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #15
0
 public FSEvent(string name, string target, FSState state, FiniteStateMachine owner, FiniteStateMachine.EnterState e, FiniteStateMachine.PushState pu, FiniteStateMachine.PopState po)
 {
     mStateOwner = state;
     mEventName = name;
     mTargetState = target;
     mOwner = owner;
     eType = EventType.NONE;
     mEnterDelegate = e;
     mPushDelegate = pu;
     mPopDelegate = po;
 }
Example #16
0
 public void Init(List<Vector3> ePts, float eTimeS = 0, float eTimeD = 1)
 {
     bezierPts = new List<Vector3>(ePts);
     if (ePts.Count == 1) {
         transform.position = ePts[0];
         return;
     }
     if (eTimeS == 0) eTimeS = Time.time;
     timeStart = eTimeS;
     timeDuration = eTimeD;
     state = FSState.pre;
 }
Example #17
0
 public void RegistState(FSState <T> state)
 {
     state.Setup(_owner, this);
     if (_stateDic.ContainsKey(state.GetType()))
     {
         _stateDic [state.GetType()] = state;
     }
     else
     {
         _stateDic.Add(state.GetType(), state);
     }
 }
	// Set up the FloatingScore and movement
	// Note the use of parameter defaults for eTimeS & eTimeD
	public void Init(List<Vector3> ePts, float eTimeS = 0, float eTimeD = 1) {
		bezierPts = new List<Vector3>(ePts);
		if (ePts.Count == 1) { // If there's only one point
			// ...then just go there.
			transform.position = ePts[0];
			return;
		}
		// If eTimeS is the default, just start at the current time
		if (eTimeS == 0) eTimeS = Time.time;
		timeStart = eTimeS;
		timeDuration = eTimeD;
		state = FSState.pre; // Set it to the pre state, ready to start moving
	}
Example #19
0
 protected void InternalChangeState(FSState <T> newState, object param)
 {
     _previousState = _currentState;
     _currentState  = newState;
     if (_previousState != null)
     {
         _previousState.Exit(param);
     }
     if (_currentState != null)
     {
         _currentState.Enter(param);
     }
 }
Example #20
0
	public void Init(List<Vector3> ePts, float eTimeS = 0, float eTimeD = 1){
		bezierPts = new List<Vector3> (ePts);
		if (ePts.Count == 1) {
			transform.position = ePts [0];
			return;
		}//end of if

		if (eTimeS == 0) eTimeS = Time.time;
		timeStart = eTimeS;
		timeDuration = eTimeD;

		state = FSState.pre;
	}//end of Init
Example #21
0
 public bool isInState(FSState <T> state)
 {
     if (!_stateDic.ContainsKey(state.GetType()))
     {
         return(false);
     }
     if (_currentState.GetType() == state.GetType())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #22
0
 public FSEvent(E eventEnum, T?target, FSState state,
                FiniteStateMachine <T, E, P> owner,
                EnterStateHandle e,
                PushStateHandle pu,
                PopStateHandle po)
 {
     mStateOwner    = state;
     eventEnumName  = eventEnum;
     mTargetState   = target;
     mOwner         = owner;
     eType          = EventType.NONE;
     mEnterDelegate = e;
     mPushDelegate  = pu;
     mPopDelegate   = po;
 }
Example #23
0
 public void RegistTransition(FSState <T> source, FSState <T> dest, bool isTwoWay = false)
 {
     if (!_stateDic.ContainsKey(source.GetType()))
     {
         return;
     }
     if (!_stateDic.ContainsKey(dest.GetType()))
     {
         return;
     }
     source.AddCanChangeToState(dest);
     if (isTwoWay)
     {
         dest.AddCanChangeToState(source);
     }
 }
    void Update()
    {
        if (state == FSState.idle)
        {
            return;
        }

        float u = (Time.time - timeStart) / timeDuration;

        float uC = Easing.Ease(u, easingCurve);

        if (u < 0)
        {
            state = FSState.pre;
            transform.position = bezierPts[0];
        }
        else
        {
            if (u >= 1)
            {
                uC    = 1;
                state = FSState.post;
                if (reportFinishTo != null)
                {
                    Debug.Log("meow");
                    reportFinishTo.SendMessage("FSCallback", this);
                    Destroy(this.gameObject);
                }
                else
                {
                    state = FSState.idle;
                }
            }
            else
            {
                state = FSState.active;
            }
            Vector3 pos = Utils.Bezier(uC, bezierPts);
            transform.position = pos;
            if (fontSizes != null && fontSizes.Count > 0)
            {
                int size = Mathf.RoundToInt(Utils.Bezier(uC, fontSizes));
                GetComponent <GUIText>().fontSize = size;
            }
        }
    }
Example #25
0
 // Set up the FloatingScore and movement
 // Note the use of parameter defaults for eTimeS & eTimeD
 public void Init(List <Vector3> ePts, float eTimeS = 0, float eTimeD = 1)
 {
     bezierPts = new List <Vector3>(ePts);
     if (ePts.Count == 1)
     { // If there's only one point
         // ...then just go there.
         transform.position = ePts[0];
         return;
     }
     // If eTimeS is the default, just start at the current time
     if (eTimeS == 0)
     {
         eTimeS = Time.time;
     }
     timeStart    = eTimeS;
     timeDuration = eTimeD;
     state        = FSState.pre; // Set it to the pre state, ready to start moving
 }
	// Update is called once per frame
	void Update () {
		// If this is not moving, just return
		if (state == FSState.idle) return;

		// Get u from the current time and duration
		// u ranges from 0 to 1 (usually)
		float u = (Time.time - timeStart)/timeDuration;
		// Use Easing class from Utils to curve the u value
		float uC = Easing.Ease (u, easingCurve);
		if (u<0) { // If u<0, then we shouldn't move yet.
			state = FSState.pre;
			// Move to the initial point
			transform.position = bezierPts[0];
		} else {
			if (u>=1) { // If u>=1, we're done moving
				uC = 1; // Set uC=1 so we don't overshoot
				state = FSState.post;
				if (reportFinishTo != null) { //If there's a callback GameObject
					// Use SendMessage to call the FSCallback method
					// with this as the parameter.
					reportFinishTo.SendMessage("FSCallback", this);
					// Now that the message has been sent,
					// Destroy this gameObject
					Destroy (gameObject);
				} else { // If there is nothing to callback
					// ...then don't destroy this. Just let it stay still.
					state = FSState.idle;
				}
			} else {
				// 0<=u<1, which means that this is active and moving
				state = FSState.active;
			}
			// Use Bezier curve to move this to the right point
			Vector3 pos = Utils.Bezier(uC, bezierPts);
			transform.position = pos;
			if (fontSizes != null && fontSizes.Count>0) {
				// If fontSizes has values in it
				// ...then adjust the fontSize of this GUIText
				int size = Mathf.RoundToInt( Utils.Bezier(uC, fontSizes) );
				GetComponent<GUIText>().fontSize = size;
			}
		}
	}
Example #27
0
    // Задаём FloatingScore и движение
    // Заметим использование базового параметра для eTimeS и eTimeD
    public void Init(List <Vector3> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        bezierPts = new List <Vector3>(ePts);

        if (ePts.Count == 1)   // Там только одна точка
        // просто идём туда
        {
            transform.position = ePts[0];
            return;
        }

        // Если eTimeS им. базовое значение, начинаем сразу же
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = FSState.pre;    // Готов к началу движения
    }
Example #28
0
    //These parameters have default values
    public void Init(List <Vector3> ePts, float eTimeS = 0.0f, float eTimeD = 1.0f)
    {
        bezierPts = new List <Vector3> (ePts);

        if (ePts.Count == 1)           //only one point?
        //just go to that point then
        {
            transform.position = ePts[0];
            return;
        }

        //If eTimeS is the default value, just set it to the current time
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = FSState.pre;         //ready to move
    }
    /// <summary>
    /// 设置FloatingScore和移动
    /// </summary>
    /// <param name="ePts"></param>
    /// <param name="eTimeS"></param>
    /// <param name="eTimeD"></param>
    public void Init(List <Vector3> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        bezierPts = new List <Vector3>(ePts);

        if (ePts.Count == 1)//如果只有一个坐标
        {
            //只运行至此
            transform.position = ePts[0];
            return;
        }

        //如果eTimeS为缺省值,就从当前时间开始
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;

        state = FSState.pre;//设置为pre state,准备好开始移动
    }
    // Set up the FloatingScore and movement
    // Note the use of parameter defaults for eTimeS & eTimeD
    public void Init(List <Vector2> ePts, float eTimeS = 0, float eTimeD = 1)
    {
        rectTrans = GetComponent <RectTransform>();
        rectTrans.anchoredPosition = Vector2.zero;

        txt = GetComponent <Text>();

        bezierPts = new List <Vector2>(ePts);
        if (ePts.Count == 1)
        { // If there's only one point
            // ...then just go there.
            transform.position = ePts[0];
            return;
        }
        // If eTimeS is the default, just start at the current time
        if (eTimeS == 0)
        {
            eTimeS = Time.time;
        }
        timeStart    = eTimeS;
        timeDuration = eTimeD;
        state        = FSState.pre; // Set it to the pre state, ready to start moving
    }
    // Update is called once per frame
    // SXC: Update is used to deal with the active and post states
    void Update()
    {
        // If this is not moving, just return
        if (state == FSState.idle)
        {
            return;
        }

        // Get u from the current time and duration
        // u rages from 0 to 1 (usually)
        float u = (Time.time - timeStart) / timeDuration;

        // Use Easing class from utils to curve the u value
        float uC = Easing.Ease(u, easingCurve);

        if (u < 0) // if u <0, then we should not move yet
        {
            state = FSState.pre;
            // Set the position to the starting point
            transform.position = bezierPts[0];
        }
        else if (u >= 1) // It should be stopped
        {
            // Set the state to post, since it shall not be moving
            state = FSState.post;
            // Set uC = 1 so we dont overshoot
            uC = 1;

            // If the callback object exist, send the message to adding up the score
            if (reportFinishTo != null)
            {
                reportFinishTo.SendMessage("FSCallback", this);
                // Call the callback method to add up the score

                // Destory this gameobject since the message is sent
                Destroy(gameObject);
            }
            else
            {
                // If there is nothing to callback
                // ... Then dont destroy this, just let it stay still
                state = FSState.idle;
            }
        }
        else
        {
            // if 0<= u <1, use the bezier pts and algorithm to update the position since it is moving
            state = FSState.active;

            // Use Bezier curve to move this to the right point
            Vector3 tPos = Utils.Bezier(uC, bezierPts);
            transform.position = tPos;

            // If font size has values in it
            if (fontSize.Count != 0)
            {
                // Then adjust the fontSize of this GUIText
                int tSize = Mathf.RoundToInt(Utils.Bezier(uC, fontSize));
                fsText.fontSize = tSize;
            }
        }
    }
Example #32
0
    void SetAnimatorState(FSState chaseState, bool up, bool down, bool left, bool right)
    {
        if (chaseState == FSState.CHASING)
        {
            animator.SetBool("Top", false);
            animator.SetBool("Bottom", false);
            animator.SetBool("Fly", true);
            animator.SetBool("Side", false);

            currentlyFlying = true;
        }
        else
        {
            if (!up && !down && !left && !right)
            {
                animator.SetBool("Top", false);
                animator.SetBool("Bottom", false);
                animator.SetBool("Fly", true);
                animator.SetBool("Side", false);

                currentlyFlying = true;
            }
            else if (left)
            {
                animator.SetBool("Top", false);
                animator.SetBool("Bottom", false);
                animator.SetBool("Fly", false);
                animator.SetBool("Side", true);
                renderer.flipX = false;

                currentlyFlying = false;
                speedX          = -0.2f;
                speedY          = 0;
            }
            else if (right)
            {
                animator.SetBool("Top", false);
                animator.SetBool("Bottom", false);
                animator.SetBool("Fly", false);
                animator.SetBool("Side", true);
                renderer.flipX = true;

                currentlyFlying = false;
                speedX          = 0.2f;
                speedY          = 0;
            }
            else if (up)
            {
                animator.SetBool("Top", true);
                animator.SetBool("Bottom", false);
                animator.SetBool("Fly", false);
                animator.SetBool("Side", false);

                currentlyFlying = false;
                speedX          = 0;
                speedY          = 0.2f;
            }
            else if (down)
            {
                animator.SetBool("Top", false);
                animator.SetBool("Bottom", true);
                animator.SetBool("Fly", false);
                animator.SetBool("Side", false);

                currentlyFlying = false;
                speedX          = 0;
                speedY          = -0.2f;
            }
        }
    }
Example #33
0
 public StateMachine(T owner)
 {
     _owner         = owner;
     _currentState  = null;
     _previousState = null;
 }
Example #34
0
 protected abstract bool CanChangeStateTo(FSState <T> state);
Example #35
0
 public abstract void AddCanChangeToState(FSState <T> state);
Example #36
0
 protected override bool CanChangeStateTo(FSState <GameCore> state)
 {
     return(_canChangeToStateList.Contains(state));
 }