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


C# GameObject.AddBehaviour方法代码示例

本文整理汇总了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);
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:7,代码来源:SellContainer.cs

示例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());
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:8,代码来源:CartContainer.cs

示例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);
		} 
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:11,代码来源:CraftingSlot.cs

示例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);
			}
		}
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:14,代码来源:TeleporterSlot.cs

示例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);
			}
		}
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:18,代码来源:UsableSlot.cs

示例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;
	}
开发者ID:AlexGam,项目名称:TowerIsland,代码行数:22,代码来源:EquipmentContainer.cs


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