public void ReleaseMouse(float time, int id = 0) { Slicer2DInputEvent e = new Slicer2DInputEvent(); e.eventType = Slicer2DInputEvent.EventType.Release; e.time = time; input[id].eventsBank.Add(e); }
public void MoveMouse(Vector2 position, float time, int id = 0) { Slicer2DInputEvent e = new Slicer2DInputEvent(); e.eventType = Slicer2DInputEvent.EventType.Move; e.position = position; e.time = time; input[id].eventsBank.Add(e); }
public void Update_AI(int id = 0) { Slicer2DInput inp = input[id]; if (inp.playing == false) { return; } inp.released = false; if (inp.currentEvent == null) { if (inp.eventsPlaying.Count > 0) { Slicer2DInputEvent e = inp.eventsPlaying.First(); switch (e.eventType) { case Slicer2DInputEvent.EventType.SetPosition: inp.position = e.position; break; case Slicer2DInputEvent.EventType.Move: break; case Slicer2DInputEvent.EventType.Press: inp.pressed = true; inp.clicked = true; break; case Slicer2DInputEvent.EventType.Release: inp.pressed = false; inp.released = true; break; } inp.timer = TimerHelper.Create(); inp.currentEvent = e; inp.eventsPlaying.Remove(e); } } else { switch (inp.currentEvent.eventType) { case Slicer2DInputEvent.EventType.Move: inp.position.x = Mathf.Lerp((float)inp.position.x, inp.currentEvent.position.x, inp.timer.Get() / inp.currentEvent.time); inp.position.y = Mathf.Lerp((float)inp.position.y, inp.currentEvent.position.y, inp.timer.Get() / inp.currentEvent.time); break; } if (inp.timer.Get() > inp.currentEvent.time) { inp.currentEvent = null; if (inp.eventsPlaying.Count < 1) { inp.EventsCompleted(); } } } if (inp.eventsPlaying.Count < 1) { if (inp.currentEvent == null) { if (inp.loop) { Play(); } inp.playing = false; } } }