当前位置: 首页>>代码示例>>C#>>正文


C# StateMachine.Add方法代码示例

本文整理汇总了C#中StateMachine.Add方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.Add方法的具体用法?C# StateMachine.Add怎么用?C# StateMachine.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateMachine的用法示例。


在下文中一共展示了StateMachine.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    /// <summary>
    /// Initialize the menu
    /// </summary>
    void Start()
    {
        Player = transform.parent.GetComponent<PlayerController>();
        _stateMachine = new StateMachine<MenuController> ();

        craftingState.Start ();
        var presentationState = new PresentationState (this);

        _stateMachine.Add (craftingState);
        _stateMachine.Add (presentationState);
        _stateMachine.Set ("PresentationState");
    }
开发者ID:MikevanLoe,项目名称:EggshellVR,代码行数:15,代码来源:MenuController.cs

示例2: Run

        protected static void Run()
        {
            gGameMode = new StateMachine();

            // A state for each game mode
            gGameMode.Add(States.MainMenu, new MainMenuState(gGameMode))
                .Add(States.Battle, new BattleState(gGameMode));
            //.Add("localmap",   new LocalMapState(gGameMode))
            //.Add("worldmap",   new WorldMapState(gGameMode))
            //.Add("ingamemenu", new InGameMenuState(gGameMode))

            gGameMode.Change(States.MainMenu);
            while (true)
            {
                Update();
            }
        }
开发者ID:ericbutera,项目名称:goatsharp,代码行数:17,代码来源:Program.cs

示例3: Init

 private void Init()
 {
     _sendTimer = new Timer(100);
     _inactivityTimer = new Timer();
     InitListData();
     _stateMachine = new StateMachine<OspfNeighborState, NeighborEventType>();
     ////++ NBMA
     ////_stateMachine.Add(OspfNeighborState.Down, NeighborEventType.Start, Start);
     ////_stateMachine.Add(OspfNeighborState.Attempt, NeighborEventType.HelloReceived, HelloReceived);
     _stateMachine.Add(OspfNeighborState.Down, NeighborEventType.HelloReceived, HelloReceived, nextState: OspfNeighborState.Init);
     _stateMachine.Add(OspfNeighborState.Init, NeighborEventType.HelloReceived, HelloReceived, StateEntryMode.AtLeast, nextStateMode: NextStateMode.NoAction);
     _stateMachine.Add(OspfNeighborState.Init, NeighborEventType.TwoWayReceived, TwoWayReceived);
     _stateMachine.Add(OspfNeighborState.ExStart, NeighborEventType.NegotiationDone, NegotiationDone);
     _stateMachine.Add(OspfNeighborState.Exchange, NeighborEventType.ExchangeDone, ExchangeDone);
     //_stateMachine.Add(OspfNeighborState.Loading, NeighborEventType.LoadingDone, LoadingDone);
     _stateMachine.Add(OspfNeighborState.TwoWay, NeighborEventType.AdjOK, AdjOK);
     _stateMachine.Add(OspfNeighborState.ExStart, NeighborEventType.AdjOK, AdjOK, StateEntryMode.AtLeast);
     _stateMachine.Add(OspfNeighborState.Exchange, NeighborEventType.SeqNumberMismatch, SeqNumberMismatch, StateEntryMode.AtLeast);
     //_stateMachine.Add(OspfNeighborState.Exchange, NeighborEventType.BadLSReq, BadLSReq, StateEntryMode.AtLeast);
     _stateMachine.Add(NeighborEventType.KillNbr, (s, e, o) =>
     {
         InitListData();
         _inactivityTimer.Stop();
     }, OspfNeighborState.Down);
     _stateMachine.Add(NeighborEventType.LLDown, (s, e, o) =>
     {
         InitListData();
         _inactivityTimer.Stop();
     }, OspfNeighborState.Down);
     _stateMachine.Add(NeighborEventType.InactivityTimer, (s, e, o) => InitListData(), OspfNeighborState.Down);
     _stateMachine.Add(OspfNeighborState.TwoWay, NeighborEventType.OneWayReceived, (s, e, o) => InitListData(), StateEntryMode.AtLeast, OspfNeighborState.Init);
     _stateMachine.Add(OspfNeighborState.TwoWay, NeighborEventType.TwoWayReceived, StateEntryMode.AtLeast, NextStateMode.NoAction);
     _stateMachine.Add(OspfNeighborState.Init, NeighborEventType.OneWayReceived, NextStateMode.NoAction);
     _sendTimer.Elapsed += (s, e) =>
     {
         SendDBDReady();
     };
     _sendTimer.Start();
 }
开发者ID:davidbetz,项目名称:netrouter,代码行数:39,代码来源:Neighbor.cs

示例4: Init

        internal void Init()
        {
            DR = IPAddress.GetDefault();
            BDR = IPAddress.GetDefault();
            _stateMachine = new StateMachine<InterfaceState, InterfaceEventType>();
            _stateMachine.Add(InterfaceState.Down, InterfaceEventType.InterfaceUp, InterfaceUp);
            _stateMachine.Add(InterfaceState.Waiting, InterfaceEventType.BackupSeen, BackupSeen);
            _stateMachine.Add(InterfaceState.Waiting, InterfaceEventType.WaitTimer, WaitTimer);
            _stateMachine.Add(InterfaceState.DROther, InterfaceEventType.NeighborChange, NeighborChange);
            _stateMachine.Add(InterfaceState.DR, InterfaceEventType.NeighborChange, NeighborChange);
            _stateMachine.Add(InterfaceState.Backup, InterfaceEventType.NeighborChange, NeighborChange);
            _stateMachine.Add(InterfaceEventType.InterfaceDown, InterfaceDown);
            _stateMachine.Add(InterfaceEventType.LoopInd, LoopInd, Ospf.InterfaceState.Loopback);
            _stateMachine.Add(InterfaceState.Loopback, InterfaceEventType.UnloopInd, UnloopInd, Ospf.InterfaceState.Down);

            Device device = _controller.DeviceConfigurationMap[DeviceID];
            if (device.IsEnabled && device.InterfaceState == Routing.InterfaceState.L2UpL3Up)
            {
                RaiseEvent(InterfaceEventType.InterfaceUp);
            }
        }
开发者ID:davidbetz,项目名称:netrouter,代码行数:21,代码来源:Interface.cs

示例5: Start

    void Start()
    {
        //Find child object with the name "Neck"
        _neck = FindTransform (transform, "Neck");
        if (_neck == null)
            throw new UnityException ("NPC: " + name + " has no neck attached");
        //Find child object with name "Center"
        _center = FindTransform (transform, "Center");
        if (_center == null)
            throw new UnityException ("NPC: " + name + " has no center attached");

        _NPCAnim = GetComponent<Animation> ();

        _forward = _center.transform.forward;
        _stateMachine = new StateMachine<NPCController> ();

        _stateMachine.Add (new TownState (this, 8));
        _stateMachine.Add (new CrowdState (this));
        _stateMachine.Add (new TravelState (this));
        if (!_stateMachine.Set ("TownState"))
        {
            Debug.Log ("Failed to set state.");
            throw new UnityException();
        }

        Switches = new Dictionary<string, bool> ();
        Variables = new Dictionary<string, float> ();

        _originalPosition = transform.position;

        switch (PersonalityName)
        {
        case "HappyFisher":
            _personality = new HappyFisher(this);
            break;
        case "Smith":
            _personality = new Smith(this);
            break;
        case "Guard":
            _personality = new Guard(this);
            break;
        case "Bland":
            _personality = new Bland(this);
            break;
        default:
            throw new UnityException("Chosen personality for NPC: \"" + name + "\" not found");
        }
    }
开发者ID:MikevanLoe,项目名称:EggshellVR,代码行数:48,代码来源:NPCController.cs


注:本文中的StateMachine.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。