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); }
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()); }
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); } }
private void OnReceive(NetworkMessage message) { FsmVariableMessage mMessage = new FsmVariableMessage(null); message.ReadMessage <FsmVariableMessage>(mMessage); if (execute != null) { GameObject go = new GameObject("Handler"); ICodeBehaviour behaviour = go.AddBehaviour(execute); behaviour.stateMachine.SetVariable("Info", mMessage.variable.GetValue()); } }
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); } } }
private void AddBehaviours(ObjectModel model, GameObject gameObject) { if (model.HasBehaviours()) { for (int i = 0; i < model.BehaviourModels.Length; i++) { gameObject.AddBehaviour(model.BehaviourModels[i].Name); if (model.BehaviourModels[i].Start) { gameObject.StartBehaviour(model.BehaviourModels[i].Name); } } } }
public static ICodeBehaviour AddBehaviour(this GameObject gameObject, StateMachine stateMachine, int group, bool replaceIfExists) { ICodeBehaviour behaviour = gameObject.GetBehaviour(group); if (behaviour != null && replaceIfExists) { behaviour.stateMachine = stateMachine; behaviour.EnableStateMachine(); } else { behaviour = gameObject.AddBehaviour(stateMachine); behaviour.group = group; } return(behaviour); }
private GameObject CreateNode(Vector2 position, GameObject parent, string mapName = "", bool canEnter = true) { GameObject node = new GameObject(Game) { Name = "MapNode" }; node.Position = position; node.AddBehaviour("MapNode", new object[] { mapName, canEnter }); if (parent != null) { parent.AddChild(node); } return(node); }
protected override void OnInitialize() { GameObject map = new GameObject(Game); map.AddBehaviour("Map", new object[] { mapName }); mapBehaviour = map.FirstBehaviourOfType <Map>(); map.StartBehaviours(); Game.AddGameObject(map); player = Game.FindGameObject(p => p.Name == "Player 1"); hud = new HUD(Game); Game.WindowManager.AddWindow(hud); Game.WindowManager.MoveToFront("Main"); Game.WindowManager.Background = null; Game.WindowManager.Show(false); }
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); } } }
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; }