本文整理汇总了C#中GameObject.AddBehaviour方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.AddBehaviour方法的具体用法?C# GameObject.AddBehaviour怎么用?C# GameObject.AddBehaviour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.AddBehaviour方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSell
public void ProcessSell(){
int total = GetTotalPrice ();
GameObject go = new GameObject ("ProcessPurchase");
ICodeBehaviour behaviour = go.AddBehaviour(processSell);
behaviour.stateMachine.SetVariable ("Price", -total);
behaviour.stateMachine.SetVariable ("Container", gameObject);
}
示例2: ProcessPurchase
public void ProcessPurchase(){
int total = GetTotalPrice ();
GameObject go = new GameObject ("ProcessPurchase");
ICodeBehaviour behaviour = go.AddBehaviour(processPurchase);
behaviour.stateMachine.SetVariable ("Price", total);
behaviour.stateMachine.SetVariable ("Container", this.gameObject);
behaviour.stateMachine.SetVariable ("Items", Items.FindAll(x=>x!= null).ToArray());
}
示例3: StartCrafting
public void StartCrafting(){
if (mItem == null) {
return;
}
if (mItem.onCraft != null) {
GameObject go = new GameObject ("ProcessCrafting");
ICodeBehaviour behaviour = go.AddBehaviour (mItem.onCraft);
behaviour.stateMachine.SetVariable ("Item", mItem);
}
}
示例4: OnDoubleClick
public override void OnDoubleClick ()
{
if (!IsCoolDown && observedItem != null) {
Teleporter teleporter=observedItem as Teleporter;
if (teleporter.onUse != null) {
GameObject go = new GameObject ("UseItem");
ICodeBehaviour behaviour = go.AddBehaviour (teleporter.onUse);
behaviour.stateMachine.SetVariable ("Item", teleporter);
behaviour.stateMachine.SetVariable ("Slot", gameObject);
CoolDown (teleporter.coolDown, teleporter.containerCoolDown);
}
}
}
示例5: OnDoubleClick
public override void OnDoubleClick ()
{
if (!IsCoolDown && observedItem != null && (observedItem as UsableItem).onUse != null) {
GameObject go = new GameObject ("UseItem");
ICodeBehaviour behaviour = go.AddBehaviour((observedItem as UsableItem).onUse);
behaviour.stateMachine.SetVariable ("Item", observedItem);
behaviour.stateMachine.SetVariable ("Slot", gameObject);
FsmVariable coolDown= (observedItem as UsableItem).onUse.GetVariable("CoolDown");
if(coolDown != null){
if(coolDown is FsmBool && (coolDown as FsmBool).Value){
CoolDown((observedItem as UsableItem).coolDown,(observedItem as UsableItem).containerCoolDown);
}
}else {
CoolDown((observedItem as UsableItem).coolDown,(observedItem as UsableItem).containerCoolDown);
}
}
}
示例6: Replace
public override BaseItem Replace (int id, BaseItem item)
{
if (id < slots.Length){
BaseItem prev = Items[id];
if(prev != null && unEquip != null){
//Un equip
GameObject go=new GameObject("UnEquip");
ICodeBehaviour behaviour=go.AddBehaviour(unEquip);
behaviour.stateMachine.SetVariable("Item",prev);
}
if(item != null && equip != null){
//Equip
GameObject go=new GameObject("Equip");
ICodeBehaviour behaviour=go.AddBehaviour(equip);
behaviour.stateMachine.SetVariable("Item",item);
}
Items[id] = item;
return prev;
}
return item;
}