本文整理汇总了C#中StateMachine.state方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.state方法的具体用法?C# StateMachine.state怎么用?C# StateMachine.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake () {
instance = this;
fsm = StateMachine.GetMachine(gameObject, fsm);
fsm.state("root").on_entry(new StateEvent((Automata a)=>{
InitializeLeaf(a.gameObject);
}));
loaded_prefab = Resources.Load(prefab);
}
示例2: Awake
void Awake () {
main = this;
fsm = gameObject.AddComponent<StateMachine>();
fsm.state ("root")
.add_child (
fsm.state ("field")
.initial_function(()=>{
return StrawberryRowState.random_row();
})
.on_entry(new StateEvent((Automata a)=>{
StrawberryComponent sb = a.gameObject.GetComponent<StrawberryComponent>();
sb.Initialize();
}))
, true
).add_child (
fsm.state ("drag")
.on_entry(new StateEvent(()=>{
GameMessages.Log(LanguageController.controller.load_text("tutorial_pick_scroll"));
}).Limit(1))
).add_child (
fsm.state ("fall")
.on_entry(new StateEvent((Automata a)=>{
Rigidbody body = a.GetComponent<Rigidbody>();
if (body != null){
body.useGravity = true;
body.isKinematic = false;
}
}))
).add_child (
fsm.state ("hand")
.on_entry(new StateEvent((Automata a)=>{
Rigidbody body = a.GetComponent<Rigidbody>();
if (body != null){
body.useGravity = false;
body.isKinematic = true;
}
}))
).add_child (
fsm.state ("basket")
);
fsm.new_transition("field_drag", (t)=>{
t.chain_from(fsm.state("field"))
.chain_to (fsm.state("drag"))
.add_test(new TransitionTest(()=>{
return player_state.can_pick();
}))
.on_exit(new TransitionEvent(()=>{
GenerateStrawberries(1);
}))
.on_failure(new TransitionEvent(()=>{
GameMessages.Log(LanguageController.controller.load_text("tutorial_bend_to_pick_up"));
}))
.chain_auto_run(false)
;
}).new_transition("fall_drag", (t)=>{
t.chain_from(fsm.state("fall"))
.chain_to (fsm.state("drag"))
.chain_auto_run(false)
.add_test(new TransitionTest(()=>{
return player_state.can_drag();
}))
;
}).new_transition("hand_drag", (t)=>{
t.chain_from(fsm.state("hand"))
.chain_to (fsm.state("drag"))
.chain_auto_run(false)
.add_test(new TransitionTest(()=>{
return player_state.can_drag();
}))
;
}).new_transition("basket_fall", (t)=>{
t.chain_from(fsm.state("basket"))
.chain_to (fsm.state("fall"))
.chain_auto_run(false)
;
}).new_transition("drag_fall", (t)=>{
t.chain_from(fsm.state("drag"))
.chain_to (fsm.state("fall"))
.chain_auto_run(false)
;
}).new_transition("spawn_direct", (t)=>{
t.chain_from(fsm.state("root"))
.chain_to (fsm.state("fall"))
.chain_auto_run(false)
.on_exit(new TransitionEvent((Automata a)=>{
a.GetComponent<StrawberryComponent>().Initialize();
a.GetComponent<ObjectVisibility>().visible = true;
}))
;
});
loaded_prefab = Resources.Load(prefab);
}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:92,代码来源:StrawberryStateMachine.cs