Esempio n. 1
0
 protected void SetBool(StateId stateId, Boolean value)
 {
     string enumName = Enum.GetName (typeof(StateId), stateId);
     string stateName = enumName.Replace ("State", "").ToLower ();
     //Debug.Log ("SetBool:" + stateName);
     animator.SetBool (stateName, value);
 }
Esempio n. 2
0
 /// <summary>
 /// 播放一次动画
 /// </summary>
 /// <returns>The one shot.</returns>
 /// <param name="stateId">State identifier.</param>
 protected IEnumerator PlayOneShot(StateId stateId)
 {
     SetBool (stateId, true);
     //yield return null;
     yield return new WaitForSeconds(0.1f);
     SetBool (stateId, false);
 }
Esempio n. 3
0
        public NewGameViewModel(Identity identity, MainNavigationModel mainNavigation, NameNavigationModel nameNavigation)
        {
            _identity = identity;
            _mainNavigation = mainNavigation;
            _nameNavigation = nameNavigation;

            _depState = new Dependent(delegate
            {
                _state =
                    _identity.User != null ? StateId.Challenge :
                    _identity.Claims.Any(claim => !claim.Responses.Any()) ? StateId.PendingUserName :
                    StateId.YourName;
            });
            _depChallenge = new Dependent(delegate
            {
                _depState.OnGet();
                _challenge = _state == StateId.Challenge
                    ? new ChallengeViewModel(_identity.User, _mainNavigation)
                    : null;
            });
            _depYourName = new Dependent(delegate
            {
                _depState.OnGet();
                _yourName = _state == StateId.YourName
                    ? new YourNameViewModel(_identity, _nameNavigation)
                    : null;
            });
            _depPendingUserName = new Dependent(delegate
            {
                _depState.OnGet();
                _pendingUserName = _state == StateId.PendingUserName
                    ? new PendingUserNameViewModel(_identity.Claims.FirstOrDefault(claim => !claim.Responses.Any()))
                    : null;
            });
        }
Esempio n. 4
0
 /// 状態セット
 ///---------------------------------------------------------------------------
 /// 状態の切り替え
 public bool ChangeState( StateId id )
 {
     if( DoChangeState( id ) == true ){
     stateBackPlayId      = stateIsPlayId;
     stateIsPlayId        = id;
     statePlayTask        = 0;
     return true;
     }
     return false;
 }
Esempio n. 5
0
    /// <summary>
    /// 新增子状态
    /// </summary>
    /// <param name="newStateId">New state identifier.</param>
    /// <param name="param">Data.</param>
    public void AddSubState(StateId newStateId, object param)
    {
        BaseState subState = CreateState (newStateId);
        if (subState == null) {
            //addSubStateFail ();
            return;
        }

        subState.OnEnter (param);
        InsertSubState (subState);
    }
Esempio n. 6
0
    /// <summary>
    /// 是否可以切换状态
    /// </summary>
    /// <returns><c>true</c>, if can toggle was ised, <c>false</c> otherwise.</returns>
    /// <param name="currentStateId">当前状态</param>
    /// <param name="newStateId">新状态</param>
    /// <param name="subStateList">角色当前身上的子状态</param>
    public Boolean IsCanToggle(StateId currentStateId, StateId newStateId, List<BaseState> subStateList)
    {
        //是否是相同的主状态
        if (IsSameState (currentStateId, newStateId)) {
            return false;
        }

        //角色身上是否有与主状态互斥的子状态
        if (IsHaveMutexSubState (newStateId, subStateList)) {
            return false;
        }

        return IsCanToggleToNewState (currentStateId, newStateId);
    }
Esempio n. 7
0
    /// <summary>
    /// 创建状态
    /// 后面优化 存放到一个List缓存
    /// </summary>
    /// <returns>The state.</returns>
    /// <param name="stateId">State identifier.</param>
    public BaseState CreateState(StateId stateId)
    {
        string enumName = Enum.GetName (typeof(StateId), stateId) + "State";

        Assembly assembly = Assembly.GetExecutingAssembly();
        BaseState obj = (BaseState)assembly.CreateInstance(enumName);

        if (obj != null) {
            //Debug.Log ("reflect "+obj.ToString());
            return obj;
        }

        //		if (stateId == StateId.Idle) {
        //
        //			return new IdleState ();
        //		}

        return new IdleState ();
    }
Esempio n. 8
0
    /// <summary>
    /// 新状态是否与角色身上的子状态互斥 
    /// </summary>
    /// <returns><c>true</c>, if have mutex sub state was ised, <c>false</c> otherwise.</returns>
    /// <param name="newStateId">New state identifier.</param>
    /// <param name="subStateList">角色当前身上的子状态</param>
    public Boolean IsHaveMutexSubState(StateId newStateId, List<BaseState> subStateList)
    {
        //新状态的互斥子状态
        List<StateId> excludeList = StateRuleConfig.GetInstance.Dict [newStateId].ExcludeSubState;

        if (excludeList == null || excludeList.Count == 0) {
            return false;
        }

        for (int i = 0; i < excludeList.Count; i++) {

            StateId subStateId = excludeList [i];
            //包含互斥状态
            if (IsHaveSubState (subStateList, subStateId)) {
                return true;
            }
        }

        return false;
    }
    public void AddTransition(Transition transition2, StateId id2)
    {
        if (transition2 == Transition.nullTranition)
        {
            return;
        }

        if (id == StateId.nullStateId)
        {
            return;
        }

        if(map.ContainsKey(transition2))
        {
            map.Remove(transition2);
            return;
        }

        map.Add(transition2, id2);
    }
Esempio n. 10
0
    /// <summary>
    /// 能否切换到新状态 
    /// </summary>
    /// <returns><c>true</c>, if can toggle to new state was ised, <c>false</c> otherwise.</returns>
    /// <param name="currentStateId">Current state identifier.</param>
    /// <param name="newStateId">New state identifier.</param>
    private Boolean IsCanToggleToNewState(StateId currentStateId, StateId newStateId)
    {
        List<StateId> rules = StateRuleConfig.GetInstance.Dict [currentStateId].ToggleMajorState;

        if (rules == null || rules.Count == 0) {

            return false;
        }

        if (rules.Contains (newStateId)) {

            return true;
        }

        return false;
    }
Esempio n. 11
0
 /// <summary>
 /// 是否跟当前状态相同
 /// </summary>
 /// <returns><c>true</c>, if same state was ised, <c>false</c> otherwise.</returns>
 /// <param name="currentStateId">Current state identifier.</param>
 /// <param name="newStateId">New state identifier.</param>
 public Boolean IsSameState(StateId currentStateId, StateId newStateId)
 {
     return currentStateId == newStateId;
 }
Esempio n. 12
0
    /// <summary>
    /// 播放状态声音
    /// </summary>
    /// <param name="stateId">State identifier.</param>
    public void PlaySound(StateId stateId)
    {
        //Debug.Log("PlaySound:"+stateId);
        if (!soundDict.ContainsKey (stateId)) {
            Debug.Log ("No Sound:" + stateId);
            return;
        }

        String soundName = soundDict [stateId];

        AudioManager.SharedInstance.PlayOneShot(soundName,4.0f);
    }
Esempio n. 13
0
 public StateMachine(Character character, StateId defaultStateId)
 {
     _defaultStateId = defaultStateId;
     _character      = character;
 }
Esempio n. 14
0
 protected BaseState()
 {
     this.stateId = StateId.NullStateId;
 }
Esempio n. 15
0
 public void RemoveState(StateId stateId)
 {
     States.Remove(stateId);
 }
Esempio n. 16
0
 /// <summary>
 /// 是否是子状态
 /// </summary>
 /// <returns><c>true</c>, if sub state was ised, <c>false</c> otherwise.</returns>
 /// <param name="stateId">Current state identifier.</param>
 public Boolean IsSubState(StateId stateId)
 {
     return(stateId > StateId.SubStateStartId);
 }
Esempio n. 17
0
 /// <summary>
 /// 是否跟当前状态相同
 /// </summary>
 /// <returns><c>true</c>, if same state was ised, <c>false</c> otherwise.</returns>
 /// <param name="currentStateId">Current state identifier.</param>
 /// <param name="newStateId">New state identifier.</param>
 public Boolean IsSameState(StateId currentStateId, StateId newStateId)
 {
     return(currentStateId == newStateId);
 }
Esempio n. 18
0
 public override int GetHashCode()
 {
     return(StateId.GetHashCode());
 }
Esempio n. 19
0
 internal State(Vector2u size, StateId stateId, DirectionType direction, (Texture icon, float delay)[][] icons)
Esempio n. 20
0
 public override string ToString() => "State " + StateId.ToString();
Esempio n. 21
0
 public bool Equals(State <St, Ev> other) => other != null && StateId.Equals(other.StateId);
Esempio n. 22
0
 protected BaseState()
 {
     this.stateId = StateId.NullStateId;
 }
Esempio n. 23
0
 public IStateComponentBuilder To(StateId stateId)
 {
     this.parent.Add(new ResultComponent(stateId));
     return(this.builder);
 }
Esempio n. 24
0
        /// 開始
        public override bool Start()
        {
            stateIsPlayId        = StateId.Stand;
            SetStateStand();

            unitCmnPlay.Start( this, interfereCntr, moveCollMgr );
            EventCntr.Clear();

            Enable = DoStart();
            return( Enable );
        }
Esempio n. 25
0
 public State this[StateId key] => States[key];
Esempio n. 26
0
 public StateMachineCore(StateId initialStateId, IStateComponent component)
 {
     this.InitialStateId = initialStateId;
     this.Component      = component;
 }
Esempio n. 27
0
 public Boolean IsState(StateId stateId)
 {
     return CurrentState.StateId == stateId;
 }
Esempio n. 28
0
 public Boolean IsState(StateId stateId)
 {
     return(CurrentState.StateId == stateId);
 }
Esempio n. 29
0
 protected virtual bool DoChangeState( StateId id )
 {
     return true;
 }
Esempio n. 30
0
    public void RemoveSubState(StateId subStateId)
    {
        for (int i = 0; i < subStateList.Count; i++) {

            if (subStateList [i].StateId == subStateId) {

                subStateList [i].OnExit ();

                subStateList.RemoveAt (i);
            }

        }
    }
Esempio n. 31
0
    /// <summary>
    /// 让BaseSolider 可以加入声音,测试用。
    /// </summary>
    /// <param name="stateId">State identifier.</param>
    /// <param name="soundName">Sound name.</param>
    public void AddSound(StateId stateId, String soundName)
    {
        //		if (soundDict.ContainsKey (stateId)) {
        //			soundDict.Remove (stateId);
        //		}

        soundDict.Add (stateId, soundName);
    }
Esempio n. 32
0
    /// <summary>
    /// 切换主状态
    /// </summary>
    public void ToggleMajorState(StateId newStateId, object param)
    {
        if (!this.StateRule.IsCanToggle (CurrentState.StateId, newStateId, this.subStateList)) {
            return;
        }

        //没有对应的状态,直接返回
        BaseState newState = CreateState (newStateId);
        if (newState == null) {
            //toggleStateFail
            return;
        }

        //Debug.Log("cur:"+CurrentState.StateId+",new :"+newStateId);

        //退出当前状态
        CurrentState.OnExit ();
        this.CurrentState = newState;
        newState.OnEnter (param);

        //		if (currentState.StateId==StateId.Ult) {
        //			Debug.Log("cur:"+CurrentState.StateId);
        //		}
    }
Esempio n. 33
0
 /// <summary>
 /// 动画状态切换
 /// </summary>
 /// <param name="state">State.</param>
 public void ToggleState(StateId stateId)
 {
     //animator.Play("hf_action_attack",0,1.0f);
     //SetBool (stateId, true);
     StartCoroutine (PlayOneShot (stateId));
 }
Esempio n. 34
0
 /// <summary>
 /// 是否是子状态,如果是,则直接加到子状态列表
 /// </summary>
 public void ToggleState(StateId newStateId, object param)
 {
     if (this.StateRule.IsSubState (newStateId)) {
         AddSubState (newStateId, param);
     } else {
         ToggleMajorState (newStateId, param);
     }
 }
Esempio n. 35
0
    /// <summary>
    /// 包含指定子状态
    /// </summary>
    /// <returns><c>true</c>, if have sub state was ised, <c>false</c> otherwise.</returns>
    /// <param name="subStateList">Sub state list.</param>
    /// <param name="subStateId">Sub state identifier.</param>
    public Boolean IsHaveSubState(List<BaseState> subStateList, StateId subStateId)
    {
        for (int i = 0; i < subStateList.Count; i++) {

            if (subStateList [i].StateId == subStateId) {

                return true;

            }

        }

        return false;
    }
Esempio n. 36
0
    /// <summary>
    /// 创建状态
    /// </summary>
    private BaseState CreateState(StateId newStateId)
    {
        BaseState newState = StateCreator.GetInstance.CreateState (newStateId);

        //		if (newState != null) {
        //
        //			newState = this.Soldier;
        //
        //		}

        return newState;
    }
Esempio n. 37
0
 /// <summary>
 /// 是否是子状态
 /// </summary>
 /// <returns><c>true</c>, if sub state was ised, <c>false</c> otherwise.</returns>
 /// <param name="stateId">Current state identifier.</param>
 public Boolean IsSubState(StateId stateId)
 {
     return stateId > StateId.SubStateStartId;
 }
Esempio n. 38
0
 /// private メソッド
 ///---------------------------------------------------------------------------
 /// 状態タスクのセット
 private void setStateTask( StateId stateId )
 {
     this.stateId = stateId;
     taskId      = 0;
 }
Esempio n. 39
0
 /// <summary>
 /// Determines whether this instance is sate the specified stateId.
 /// </summary>
 /// <returns><c>true</c> if this instance is sate the specified stateId; otherwise, <c>false</c>.</returns>
 /// <param name="stateId">State identifier.</param>
 public bool IsState(StateId stateId)
 {
     return stateMachine.IsState (stateId);
 }
Esempio n. 40
0
 /// <summary>
 /// Request the state stack to push the specified state.
 /// </summary>
 /// <param name="stateId">The state to push</param>
 protected void RequestPushState(StateId stateId)
 {
     OnRequestStateChange?.Invoke(new StateChangeInfo(StateChangeCommand.PushState, stateId));
 }
Esempio n. 41
0
 public StateChangeInfo(StateChangeCommand command, StateId stateId = StateId.None)
 {
     Command = command;
     StateId = stateId;
 }
Esempio n. 42
0
 public bool TryGetState(StateId stateId, [NotNullWhen(true)] out State?state)
 {
     return(States.TryGetValue(stateId, out state));
 }
Esempio n. 43
0
 /// <summary>
 /// 切换状态
 /// </summary>
 /// <param name="stateId">State identifier.</param>
 public void ToggleState(StateId stateId)
 {
     stateMachine.ToggleState (stateId, this.attackMessage);
 }
Esempio n. 44
0
 public void NotAllowedToTransitionFromState(StateId id)
 {
     Assert.That(_sut.IsTransitionAllowed(id), Is.False);
 }
Esempio n. 45
0
 public ConfigData(StateId key, List<StateId> toggle, List<StateId> exclude)
 {
     this.keyStateId = key;
     this.toggleMajorState = toggle;
     this.excludeSubState = exclude;
 }
Esempio n. 46
0
 public StateInfo(int trial, StateId id, double elapsedTime)
 {
     Trial       = trial;
     Id          = id;
     ElapsedTime = elapsedTime;
 }