private void EventButtonDown(ManyMouse mouse, int buttonId) { //Manual "leave game" if (buttonId == 1) { _mouse.EventButtonDown -= EventButtonDown; //destroy self Destroy(gameObject); } }
private void EventButtonDownJoinGame(ManyMouse mouse, int buttonId) { if (buttonId == 0) { mouse.EventButtonDown -= EventButtonDownJoinGame; SpawnACharacterControlledByMouseID((int)mouse.id); mouse.EventButtonDown += EventButtonDownLeaveGame;//listen for another button down } }
public void OpenHand(ManyMouse mouse, int buttonId) { if (buttonId == 0) { if (selected != null) { audioSource.PlayOneShot(release); selected.GetComponent <FruitController>().Deselect(); } selecting = false; spriteRenderer.sprite = handOpen; } }
public void CloseHand(ManyMouse mouse, int buttonId) { if (buttonId == 0) { if (selected != null) { audioSource.PlayOneShot(grab); selected.GetComponent <FruitController>().Select(); selecting = true; } spriteRenderer.sprite = handClosed; } }
static void Main(string[] args) { var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "zbrozonoid.log" }; config.AddRule(LogLevel.Info, LogLevel.Fatal, logfile); config.AddRule(LogLevel.Debug, LogLevel.Debug, logfile); LogManager.Configuration = config; Logger.Info("Zbrozonoid starts"); int number = ManyMouse.Init(); if (number == 0) { return; } /* * ManyMouse manyMouse = new ManyMouse(); * int number = manyMouse.Init(); * if (number == 0) * { * return; * } */ IGameEngine game = new GameEngine(number); Window window = new Window(game /*, manyMouse*/); game.OnChangeLevelEvent += window.OnChangeLevel; game.OnBrickHitEvent += window.OnBrickHit; game.OnLostBallEvent += window.OnLostBalls; game.OnLevelCompletedEvent += window.OnLevelCompleted; game.Initialize(); window.Initialize(); window.Run(); ManyMouse.Quit(); Logger.Info("Zbrozonoid quits"); LogManager.Shutdown(); }
private ManyMouse _mouse; //This is what you'll grab input from. public void Init(int mouseID) { _mouseId = mouseID; if (ManyMouseWrapper.MouseCount > _mouseId) { _mouse = ManyMouseWrapper.GetMouseByID(_mouseId); Debug.Log(gameObject.name + " connected to mouse: " + _mouse.DeviceName); //List to mouse button events _mouse.EventButtonDown += EventButtonDown; } else { Debug.Log("Mouse ID " + _mouseId + " not found. Plug in an extra mouse?"); Destroy(gameObject); } }
private void EventButtonDownLeaveGame(ManyMouse mouse, int buttonId) { if (buttonId == 1) { mouse.EventButtonDown -= EventButtonDownLeaveGame; //listen for another button down mouse.EventButtonDown += EventButtonDownJoinGame; numSpawnedBoxes--; if (numSpawnedBoxes == 0) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } }
void SetUpCursor() { int mouseNumber; if (ManyMouseWrapper.MouseCount < 2) { if (player == Player.PlayerA) { mouseNumber = 0; mouse = ManyMouseWrapper.GetMouseByID(mouseNumber); mouse.EventButtonDown = delegate { }; mouse.EventButtonUp = delegate { }; mouse.EventButtonDown += CloseHand; mouse.EventButtonUp += OpenHand; } else { disabled = true; } } else { if (player == Player.PlayerA) { mouseNumber = PlayerPrefs.GetInt("MouseIdA", 0); } else { mouseNumber = PlayerPrefs.GetInt("MouseIdB", 1); } mouse = ManyMouseWrapper.GetMouseByID(mouseNumber); mouse.EventButtonDown = delegate { }; mouse.EventButtonUp = delegate { }; mouse.EventButtonDown += CloseHand; mouse.EventButtonUp += OpenHand; } }
// Use this for initialization void Awake() { ManyMouse_Quit(); int initCode = ManyMouse_Init(); if (initCode < 0) { Debug.Log("ManyMouse Init Code:" + initCode + " so there must be some error. Trying to close and open again"); ManyMouse_Quit(); initCode = ManyMouse_Init(); if (initCode < 0) { Debug.Log("ManyMouse Init Code:" + initCode + " so there must be some error. Retrying"); return; } } Debug.Log("ManyMouse Init Code:" + initCode); IntPtr mouseDriverNamePtr = ManyMouse_DriverName(); string mouseDriverName = StringFromNativeUtf8(mouseDriverNamePtr); Debug.Log("ManyMouse Driver Name: " + mouseDriverName); _numMice = initCode; _manyMice = _manyMice ?? new List <ManyMouse>(); for (int i = 0; i < _numMice; i++) { ManyMouse mouse = new ManyMouse(i); // todo: check if we already have a mouse in that id. // if it's not the correct id anymore, we have to check by the mouse's name. this might read very generically! _manyMice.Add(mouse); } }
private void EventMouseDisconnected(ManyMouse mouse) { // Keep details of disconnected mouse... then keep looking for it with an init? Debug.Log("Mouse Disconnected: " + mouse.DeviceName); }