public void Init(int ID, string inputIndex, Color color, Health health) { this.ID = ID; this.inputIndex = inputIndex; ledsIn.color = ledsOut.color = color; this.health = health; if (inputIndex.StartsWith("Key")) { inputDelegate = KeyboardInputs; rotationDelegate = AxisSpin; } else if (inputIndex.StartsWith("Mou")) { inputDelegate = KeyboardInputs; rotationDelegate = MouseSpin; } else { inputDelegate = JoystickInputs; rotationDelegate = AxisSpin; } //só pra funcionar em testes rápidos sem menu movementUpgrade.Initiate(ID, rb); attackUpgrade.Initiate(ID, rb); originalGravity = rb.gravityScale; rb.gravityScale = 0; }
static void Main(string[] args) { Console.WriteLine($"Введите {size} случайных int-числа"); InputDelegate[] arrayDel = new InputDelegate[size]; // массив делегатов // наполняем методами ввода с клавиатуры // если бы не условия задачи, можно было "натолкать" и через += (без массива) for (int i = 0; i < size; i++) { arrayDel[i] = GetDataFromConsole; } /* анонимный метод вычисления сренего значения */ AverDelegate aver = delegate(InputDelegate[] del) { double result = 0; foreach (InputDelegate item in del) { result += item(); // а вот в этом месте мы их (методы) запускаем на выполнение и суммируем значения } return((double)result / size); // и вычисляем среднее арифметическое }; Console.WriteLine($"Среднее арифметическое: {aver(arrayDel) :##.##}"); // вызов анонимного метода (так саказать - старт) // ждем Console.ReadKey(); }
public IEnumerator Die() { inputDelegate = Empty; rotationDelegate = Empty; ledsIn.color = ledsOut.color = Color.black; GetComponent <Breakable>().Break(true); movementUpgradeObject.GetComponent <Breakable>().Break(); attackUpgradeObject.GetComponent <Breakable>().Break(); aim.gameObject.SetActive(false); CameraEffects cam = Camera.main.GetComponent <CameraEffects>(); if (cam) { cam.StopAllCoroutines(); cam.StartCoroutine(cam.Shake()); } Time.timeScale = .01f; yield return(new WaitForSecondsRealtime(.3f)); Time.timeScale = 1f; }
protected Node(InputDelegate userInput, OutputDelegate userOutput) { input = userInput; output = userOutput; numberIncomingConnections = 0; Ip = GetIpAdress(); }
public static void proc(InputDelegate d) { if (Application.platform == RuntimePlatform.Android) { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); d(touch.phase, touch.position); } } else if (Application.platform == RuntimePlatform.IPhonePlayer) { } else // mac { if (true == Input.GetMouseButtonDown(0)) { d(TouchPhase.Began, Input.mousePosition); } else if (true == Input.GetMouseButtonUp(0)) { d(TouchPhase.Ended, Input.mousePosition); } else if (true == Input.GetMouseButton(0)) { d(TouchPhase.Moved, Input.mousePosition); } else { } } }
static void Main(string[] args) { MyDelegate [] del1 = new MyDelegate[5]; // Массив делегатов for (int i = 0; i < del1.Length; i++) // Рандомные числа функций делегата { del1[i] = Rand; } InputDelegate average = (x) => { int result = 0; for (int i = 0; i < x.Length; i++) { int number = x[i](); // Чтоб при очередном вызове x[i]() не создавалось другое рандомное число Console.WriteLine($"Delegate №{i+1}: {number}"); Console.WriteLine(new string('*', 25)); result += number; } Console.WriteLine($"Sum of Delegate: {result}"); Console.WriteLine(new string('*', 25)); result /= x.Length; return(result); }; ; Console.WriteLine($"Result of average {average(del1)}"); }
public static void Unbind(KeyCode key, bool isDown, InputDelegate handler) { if (HasInstance()) { Instance.RemoveKeyBind(key, isDown, handler); } }
public Client(InputDelegate userInput, OutputDelegate userOutput, int checkLostTime) : base(userInput, userOutput) { timeCheckingLost = checkLostTime; sendingAvailable = true; sendingInProcess = false; checkingInProcess = false; eventPacketSequenceAdded += TrySendNewPackets; }
public PressureMeasurementBTControl() { InitializeComponent(); this.InputMethod = new InputDelegate(this.Input); this.Line.Stroke = Brushes.Blue; this.Line.Description = "Pressure ADC value"; this.Line.StrokeThickness = 1; this.Lines.Children.Add(Line); }
public IntcodeComputer(string memoryString, long phase, InputDelegate onInput = null) { _memory = new long[5000]; memoryString.Split(',').Select(long.Parse).ToArray().CopyTo(_memory, 0); _phase = phase; _onInput = onInput; }
public WeightMeasurementBTControl() { InitializeComponent(); this.InputMethod = new InputDelegate(this.Input); this.Line.Stroke = Brushes.Blue; this.Line.Description = "Weight in Gram"; this.Line.StrokeThickness = 1; this.Lines.Children.Add(this.Line); }
public TimeMeasurementBTControl() { InitializeComponent(); this.InputMethod = new InputDelegate(this.Input); this.Line.Stroke = Brushes.Blue; this.Line.Description = "dt=Probe Time - Master Time"; this.Line.StrokeThickness = 1; this.Lines.Children.Add(this.Line); this.CommandTimer.Tick += Timer_Tick; this.CommandTimer.Interval = TimeSpan.FromMilliseconds(this._TimeSliceValue); this.CommandTimer.Start(); }
public void RemoveInputEvent(InputDelegate del) { LinkedListNode <InputEvent> node = m_InputEvent.First; while (node != null) { if (node.Value.Delegate == del) { m_InputEvent.Remove(node); break; } node = node.Next; } }
public static void RegisterInputEvent(string name, InputPhase phase, InputDelegate method) { if (inputEventList == null) { inputEventList = new List <InputEvent>(); } InputEvent inputEvent = new InputEvent(); inputEvent.name = name; inputEvent.phase = phase; inputEvent.method += method; inputEventList.Add(inputEvent); }
public void UpdateLstChat(string input) { if (this.lstChat.InvokeRequired) { InputDelegate inputDelegate = new InputDelegate(UpdateLstChat); this.Invoke(inputDelegate, new object[] { input }); } else { this.lstChat.Items.Add(input); this.lstChat.SelectedIndex = this.lstChat.Items.Count - 1; this.TxtMessage.Text = ""; this.TxtMessage.Focus(); } }
public void Awake() { rb = GetComponent <Rigidbody2D>(); if (movementUpgrade) { movementUpgradeObject = movementUpgrade.gameObject; } if (attackUpgrade) { attackUpgradeObject = attackUpgrade.gameObject; } inputDelegate = Empty; rotationDelegate = Empty; }
public void Deinitialize() { //Mouse & Keyboard RawInput.Mouse_0_Down -= () => ReceiveInput(BA_InputType.MOUSE_0_DOWN); RawInput.Mouse_0_Up -= () => ReceiveInput(BA_InputType.MOUSE_0_UP); RawInput.Mouse_Position -= (v) => ReceiveInputVector2(v, BA_InputType.MOUSE_0_POS); RawInput.Keyboard_0_Down -= () => ReceiveInput(BA_InputType.KEYBOARD_0_DOWN); RawInput.Keyboard_0_Up -= () => ReceiveInput(BA_InputType.KEYBOARD_0_UP); RawInput.Keyboard_1_Down -= () => ReceiveInput(BA_InputType.KEYBOARD_1_DOWN); RawInput.Keyboard_1_Up -= () => ReceiveInput(BA_InputType.KEYBOARD_1_UP); //Touch RawInput.Touch_0_Down -= () => ReceiveInput(BA_InputType.TOUCH_0_DOWN); RawInput.Touch_0_Up -= () => ReceiveInput(BA_InputType.TOUCH_0_UP); RawInput.Touch_0 -= (t) => ReceiveInputTouch(t, BA_InputType.TOUCH_0); RawInput.Swipe_0 -= (s, e) => ReceiveInputSwipe(s, e, BA_InputType.TOUCH_0_SWIPE); //Gamepad RawInput.Gamepad_0_Down -= () => ReceiveInput(BA_InputType.GAMEPAD_0_DOWN); RawInput.Gamepad_0_Up -= () => ReceiveInput(BA_InputType.GAMEPAD_0_UP); RawInput.Gamepad_1_Down -= () => ReceiveInput(BA_InputType.GAMEPAD_1_DOWN); RawInput.Gamepad_1_Up -= () => ReceiveInput(BA_InputType.GAMEPAD_1_UP); RawInput.Gamepad_Axis_Left_X -= (f) => ReceiveInputFloat(f, BA_InputType.GAMEPAD_AXIS_LEFT_X); RawInput.Gamepad_Axis_Left_Y -= (f) => ReceiveInputFloat(f, BA_InputType.GAMEPAD_AXIS_LEFT_Y); RawInput.Gamepad_Axis_Right_X -= (f) => ReceiveInputFloat(f, BA_InputType.GAMEPAD_AXIS_RIGHT_X); RawInput.Gamepad_Axis_Right_Y -= (f) => ReceiveInputFloat(f, BA_InputType.GAMEPAD_AXIS_RIGHT_Y); //Raycasting _raycastResults.Clear(); MoveInputVector2 = null; MoveInputVector3 = null; MouseInputUI = null; TouchInputUI = null; ActionKey = null; ActionKey_2 = null; DirectionalInputRightStick = null; DirectionalInputMousePos = null; }
public static void RegisterKeyEvent(InputPhase phase, KeyCode key, InputDelegate method) { if (keyEventList == null) { keyEventList = new List <KeyEvent>(); } KeyEvent existing = GetKeyEventFromList(phase, key); if (existing == null) { existing = CreateKeyEvent(phase, key); keyEventList.Add(existing); } existing.method += method; }
public static void RegisterButtonEvent(InputPhase phase, string name, InputDelegate method) { if (buttonEventList == null) { buttonEventList = new List <ButtonEvent>(); } ButtonEvent existingEvent = GetButtonEventFromList(phase, name); if (existingEvent == null) { existingEvent = CreateButtonEvent(phase, name); buttonEventList.Add(existingEvent); } existingEvent.method += method; }
public static void RegisterAxisEvent(string name, InputDelegate method) { if (axisEventList == null) { axisEventList = new List <AxisEvent>(); } AxisEvent existingEvent = GetAxisEventFromList(name); if (existingEvent == null) { existingEvent = CreateAxisEvent(name); axisEventList.Add(existingEvent); } existingEvent.method += method; }
public void RemoveKeyBind(KeyCode key, bool isDown, InputDelegate handler) { InputDelegate deleg; var inputTable = isDown ? keyDownTable : keyUpTable; if (inputTable.TryGetValue(key, out deleg)) { deleg = Delegate.Remove(deleg, handler) as InputDelegate; inputTable[key] = deleg; if (inputTable[key] == null) { inputTable.Remove(key); } bindCount--; //unbindString+= key.ToString(); } }
public void AddKeyBind(KeyCode key, bool isDown, InputDelegate handler) { InputDelegate deleg; var inputTable = isDown ? keyDownTable : keyUpTable; if (inputTable.TryGetValue(key, out deleg)) { inputTable[key] = Delegate.Combine(deleg, handler) as InputDelegate; //UnityEngine.Debug.LogError(key+" leaking invok list"+inputTable[key].GetInvocationList().Length); } else { inputTable[key] = handler; } bindCount++; //bindString+= key.ToString(); }
public void AddInputEvent(InputDelegate del, int priority) { LinkedListNode <InputEvent> node = m_InputEvent.First; InputEvent input = new InputEvent(del, priority); while (node != null) { if (priority < node.Value.Priority) { node = node.Next; } else { m_InputEvent.AddBefore(node, input); return; } } m_InputEvent.AddLast(input); }
void Start() // BallScript ballScript = target.GetComponent<BallScript>() as BallScript; { thisTransform = transform; controller = GetComponent <CharacterController>(); properties = GetComponent <PlayerProperties>(); animPlay = GetComponent <AnimSprite>(); animPlay.PlayFrames(2, 0, 1, orientation); Physics.IgnoreCollision(controller.collider, transform.GetComponentInChildren <BoxCollider>()); Collider = transform.GetComponentInChildren <BoxCollider>(); if (Managers.Register.PlayerAutoRunning) { UpdateInput = new InputDelegate(ControlAuto); } else { UpdateInput = new InputDelegate(ControlClassic); } }
private void FireDelegate(bool fire, InputDelegate handle ) { if (fire && handle != null) { handle(this); } }
public void AddTouchDragDownInputDelegate(InputDelegate del) { this.touchDragDownInputDelegate = (InputDelegate)Delegate.Combine(this.touchDragDownInputDelegate, del); }
public void AddTwoTouchTapInputDelegate(InputDelegate del) { this.twoTouchTapInputDelegate = (InputDelegate)Delegate.Combine(this.twoTouchTapInputDelegate, del); }
public void AddRotationInputDelegate(InputDelegate del) { this.rotationInputDelegate = (InputDelegate)Delegate.Combine(this.rotationInputDelegate, del); }
public void AddLongTapInputDelegate(InputDelegate del) { this.longTapInputDelegate = (InputDelegate)Delegate.Combine(this.longTapInputDelegate, del); }
public void SetInputTarget(InputDelegate callback) { OnEvent = callback; }
// Use this for initialization void Start() { RootSystemTest.SetSystem(MainController.GetUnitSystem()); InputDelegate.SetInputSystem(MainController.GetInputSystem()); }
public void setInputDelegate(InputDelegate command) { _inputDelegate = command; }