本文整理汇总了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");
}
示例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");
}
}