예제 #1
0
    public void Rebuild()
    {
        m_cachedParamIndex = 0;
        m_cachedParams.Clear();

        AddParam("section", StateMachineParamTypes.Long);                    // Current animation section
        AddParam("process", StateMachineParamTypes.Long);                    // Current process
        AddParam("key", StateMachineParamTypes.Long);                        // The first valid input in current state
        AddParam("exit", StateMachineParamTypes.Bool);                       // Current animation can exit ?
        AddParam("moveBreak", StateMachineParamTypes.Bool);                  // Current animation can break by movement ?
        AddParam("moving", StateMachineParamTypes.Bool);                     // Are we in moving state ?
        AddParam("state", StateMachineParamTypes.Long);                      // Current state
        AddParam("groupMask", StateMachineParamTypes.Long);                  // Current state group mask
        AddParam("prevGroupMask", StateMachineParamTypes.Long);              // Prev state group mask
        AddParam("targetGroupMask", StateMachineParamTypes.Long);            // Target group mask after hit (target passive state)
        AddParam("targetHitGroupMask", StateMachineParamTypes.Long);         // Target group mask when hit
        AddParam("configID", StateMachineParamTypes.Long);                   // Config ID (If statemachine is player, configID is player class)
        AddParam("targetConfigID", StateMachineParamTypes.Long);             // Target config ID
        AddParam("forcePassive", StateMachineParamTypes.Long);               // Force translate passive state
        AddParam("isDead", StateMachineParamTypes.Bool);                     // Creature dead (health < 1) ?
        AddParam("realDead", StateMachineParamTypes.Bool);                   // Creature real dead (health < 1 and dead animation ended) ?
        AddParam("hit", StateMachineParamTypes.Bool);                        // Hit target ?
        AddParam("hited", StateMachineParamTypes.Long);                      // Hited by other target ?
        AddParam("frame", StateMachineParamTypes.Long);                      // Current frame
        AddParam("rage", StateMachineParamTypes.Double);                     // Current rage
        AddParam("rageRate", StateMachineParamTypes.Double);                 // Current rage rate
        AddParam("weak", StateMachineParamTypes.Bool);                       // Creature in weak state ?
        AddParam("tough", StateMachineParamTypes.Bool);                      // Creature in tough state ?
        AddParam("fatal", StateMachineParamTypes.Long);                      // Creature in other creature's fatal radius ?
        AddParam("catchState", StateMachineParamTypes.Bool);                 // Creature in catch state ?
        AddParam("passiveCatchState", StateMachineParamTypes.Bool);          // Creature in passive catch state ?
        AddParam("immuneDeath", StateMachineParamTypes.Bool);                // Immune death
        AddParam("speedRun", StateMachineParamTypes.Double);                 // Creature run speed
        AddParam("speedAttack", StateMachineParamTypes.Double);              // Creature attack speed
        AddParam("weaponItemID", StateMachineParamTypes.Long);               // Current weapon item id
        AddParam("offWeaponItemID", StateMachineParamTypes.Long);            // Current off-hand weapon item id
        AddParam("hasLaydownTime", StateMachineParamTypes.Bool);             // Current state has laydown time ?
        AddParam("nextLayDownTime", StateMachineParamTypes.Long);            // Next laydown state time
        AddParam("prevEthreal", StateMachineParamTypes.Long);                // Prev state ethreal count
        AddParam("prevPassiveEthreal", StateMachineParamTypes.Long);         // Prev state passive ethreal count
        AddParam("stateType", StateMachineParamTypes.Long);                  // Current state type   0 = normal  1 = off  2 = passive
        AddParam("loopCount", StateMachineParamTypes.Long);                  // Current loop count, first loop is 0
        AddParam("totalFrame", StateMachineParamTypes.Long);                 // Current frame count
        AddParam("freezing", StateMachineParamTypes.Bool);                   // StateMachine freezing ?
        AddParam("onGround", StateMachineParamTypes.Bool);                   // Creature on ground ?
        AddParam("morph", StateMachineParamTypes.Long);                      // Creature morph, see CreatureMorphs
        AddParam("energy", StateMachineParamTypes.Long);                     // Current energy
        AddParam("energyRate", StateMachineParamTypes.Double);               // Current energy rate

        CollectHitAndDeadEffects();
        CreateStates();
        CreateTransitions();

        currentState = states[0];
        currentState.Enter();

        onEnterState?.Invoke(null, currentState);
        onRebuild?.Invoke();
    }
예제 #2
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (OnEnterState != null)
     {
         OnEnterState.Invoke(stateInfo.shortNameHash);
     }
 }
예제 #3
0
 public virtual void EnterState()
 {
     Debug.Log("Entering State");
     for (int i = 0; i < transform.childCount; i++)
     {
         transform.GetChild(i).gameObject.SetActive(true);
     }
     OnEnterState.Invoke();
 }
예제 #4
0
        private IEnumerator LoadScenesCoroutine(SceneState state)
        {
            OnExitState?.Invoke(currentState, state);

            //Loading to Empty Scene to avoid memory bloat during cross-load
            AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(stateList[SceneState.Empty].SceneName);

            while (!asyncLoad.isDone)
            {
                yield return(null);
            }

            //Actually loading new scene
            asyncLoad = SceneManager.LoadSceneAsync(stateList[state].SceneName, LoadSceneMode.Single);
            while (!asyncLoad.isDone)
            {
                yield return(null);
            }

            OnEnterState?.Invoke(currentState, state);
            currentState = state;
        }
예제 #5
0
 public virtual void EnterState(FiniteStateMachine fsm)
 {
     OnEnterState?.Invoke();
 }