static void Main() { //This is a test program showcasing a building with 10 floors and two elevators Building.CreateInstance(2, 10); var testBuilding = Building.Instance; //start with some call buttons already pressed testBuilding.GetCallPanelForFloor(5).UpButton.Press(); testBuilding.GetCallPanelForFloor(6).DownButton.Press(); //queue some requests for passengers once they get into an elevator testBuilding.Bank.Controller.ButtonPresses.Add(7); testBuilding.Bank.Controller.ButtonPresses.Add(4); //prepare some callButton presses to be added in real time ButtonPressDelegate newPassenger1 = testBuilding.Bank.Controller.PressOutsideButton; var task = new Task(testBuilding.Bank.Controller.RunAll); task.Start(); Thread.Sleep(50); //Simulate a button press on the fly newPassenger1(new CallRequest(3, Direction.Up)); Console.ReadLine(); }
private void AddButton (Sprite image, ButtonPressDelegate onClick) { GameObject butt = GameObject.Instantiate (buttonPrefab); butt.GetComponent <UnityEngine.UI.Image> ().sprite = image; butt.GetComponent <UnityEngine.UI.Button> ().onClick.AddListener (() => {onClick();}); butt.transform.SetParent (GetComponent <UnityEngine.UI.ScrollRect> ().content); }
/// <summary> Handle the ButtonPress event. </summary> /// <param name="e"> The event data. <see cref="XButtonEvent"/> </param> /// <remarks> Set XawButtonEvent. Set result to nonzero to stop further event processing. </remarks> internal virtual void OnButtonPress(XrwButtonEvent e) { ButtonPressDelegate buttonPress = ButtonPress; if (buttonPress != null) { buttonPress(this, e); } }
private void CheckButtonState(string buttonName, ButtonPressDelegate pressEvent) { string fullButtonName = "J" + controller.ToString() + buttonName; bool pressed = Input.GetButton(fullButtonName); bool changed = false; if (mButtonStates.ContainsKey(buttonName)) { changed = mButtonStates[buttonName] != pressed; mButtonStates[buttonName] = pressed; } else { mButtonStates.Add(buttonName, pressed); } if (changed && pressEvent != null) { pressEvent(pressed); } }
private void CheckDPadStates(string axisName, bool positive, ButtonPressDelegate pressEvent) { string fullAxisName = "J" + controller.ToString() + axisName; bool pressed = positive ? Input.GetAxis(fullAxisName) > 0f : Input.GetAxis(fullAxisName) < 0f; bool changed = false; string axisKey = axisName + (positive ? "Pos" : "Neg"); if (mButtonStates.ContainsKey(axisKey)) { changed = mButtonStates[axisKey] != pressed; mButtonStates[axisKey] = pressed; } else { mButtonStates.Add(axisKey, pressed); } if (changed && pressEvent != null) { pressEvent(pressed); } }