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


C# StateMachine.Set方法代码示例

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


在下文中一共展示了StateMachine.Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。