/// <summary> /// Adds a behaviour to the current chain. If addingChain is false, /// then the final FlowBehaviour is sent to the server. /// </summary> /// <param name="fb">The flow behaviour to add to the current chain</param> /// <param name="addingChain">Boolean to determine if another behaviour will be added later</param> public void AddBehaviour(FlowBehaviour fb, Boolean addingChain) { if (headBehaviour == null) { headBehaviour = fb; Debug.Log("Making " + fb.Name + " the head behaviour"); } else { FlowBehaviour head; for (head = headBehaviour; head.BehaviourChain != null; head = head.BehaviourChain) { } head.BehaviourChain = fb; Debug.Log("making " + fb.Name + " the chain behaviour"); } if (!addingChain) { Operations.CreateBehaviour(headBehaviour, projectId, (_, e) => { if (e.message.WasSuccessful == true) { } }); } }
/// <summary> /// Creates an on Disable behaviour /// </summary> /// <param name="addingChain"></param> public void CreateDisable(int addingChain) { int index1 = disableDropdown.value; string object1name = disableDropdown.options[index1].text; objectList.TryGetValue(object1name, out string firstObjectId); FlowBehaviour fb = new FlowBehaviour("Disable", "1", firstObjectId, firstObjectId, null, firstObjectId); AddBehaviour(fb, addingChain == 0 ? false : true); }
/// <summary> /// Creates an on Click behaviour. A chain must always be created /// after an click behaviour is created /// </summary> public void CreateClick() { int index1 = onClickDropdown.value; string object1name = onClickDropdown.options[index1].text; objectList.TryGetValue(object1name, out string firstObjectId); FlowBehaviour fb = new FlowBehaviour("Click", "1", firstObjectId, firstObjectId, null, firstObjectId); AddBehaviour(fb, true); }
/// <summary> /// Creates a teleport behaviour /// </summary> /// <param name="addingChain"></param> public void SendTeleport(int addingChain) { int index1 = teleportDropdown1.value; int index2 = teleportDropdown2.value; string object1name = teleportDropdown1.options[index1].text; string object2name = teleportDropdown1.options[index2].text; objectList.TryGetValue(object1name, out string firstObjectId); objectList.TryGetValue(object2name, out string secondObjectId); FlowBehaviour fb = new FlowBehaviour("Teleport", "1", firstObjectId, secondObjectId, null, firstObjectId); AddBehaviour(fb, addingChain == 0 ? false : true); }