void OnApplicationQuit() { if (Master.getInstance().multiplayer) { AppWarp.deleteCurrentRoom(); AppWarp.exit(); } }
void OnDestroy() { AppWarp.connectionStatusEvent -= connectionStatusHandler; AppWarp.oppLeftEvent -= opponentLeftHandler; AppWarp.oppPauseEvent -= opponentPauseHandler; AppWarp.oppResumeEvent -= opponentResumeHandler; AppWarp.exit(); }
void connectionErrorChoice(bool b) { AppWarp.exit(); Application.LoadLevel("Menu"); }
void Update() { int choice = 0; if (Input.GetKeyDown(KeyCode.Alpha1)) { choice = 1; } else if (Input.GetKeyDown(KeyCode.Alpha2)) { choice = 2; } else if (Input.GetKeyDown(KeyCode.Alpha3)) { choice = 3; } switch (mode) { case MenuMode.SP_SETUP: switch (choice) { case 1: debugSettings1 = new Dictionary <string, object>() { { "Lives", 5 }, { "First player first facility", (int)(WorldData.Facility.REDIRECTOR) }, { "Second player first facility", (int)(WorldData.Facility.SEISMOMETER) } }; matchParameters = debugSettings1; oppUsername = "******"; matchParameters.Add("First player", "true"); startGame(); break; case 2: debugSettings2 = new Dictionary <string, object>() { { "Lives", 10 }, { "First player first facility", (int)(WorldData.Facility.REDIRECTOR) }, { "Second player first facility", (int)(WorldData.Facility.SEISMOMETER) } }; matchParameters = debugSettings2; oppUsername = "******"; matchParameters.Add("First player", "false"); startGame(); break; case 3: Application.LoadLevel("Menu"); break; } break; case MenuMode.MP_INIT: switch (choice) { case 1: matchUp = false; mode = MenuMode.MP_INPUTROOMNAME; break; case 2: matchUp = true; AppWarp.roomFoundEvent += roomFoundEventHandler; roomName = AppWarp.MATCHUP_ROOM_NAME; AppWarp.getRoom(roomName); mode = MenuMode.MP_WAITING; break; case 3: AppWarp.exit(); Application.LoadLevel("Menu"); break; } break; case MenuMode.MP_INPUTROOMNAME: switch (choice) { case 1: roomName = "debugRoom1"; AppWarp.roomFoundEvent += roomFoundEventHandler; AppWarp.getRoom(roomName); mode = MenuMode.MP_WAITING; break; case 2: roomName = "debugRoom2"; AppWarp.roomFoundEvent += roomFoundEventHandler; AppWarp.getRoom(roomName); mode = MenuMode.MP_WAITING; break; case 3: mode = MenuMode.MP_INIT; break; } break; case MenuMode.MP_CREATEROOM: switch (choice) { case 1: debugSettings1 = new Dictionary <string, object>() { { "Lives", "5" } }; matchParameters = debugSettings1; AppWarp.oppJoinedEvent += oppJoinedEventHandler; AppWarp.createRoom(roomName, matchParameters); customChoice.message = "Room created, waiting for opponent"; customChoice.firstOption = "Cancel"; customChoice.onChoice = cancelRoomWaitChoice; mode = MenuMode.MP_MONO_CHOICE; break; case 2: debugSettings2 = new Dictionary <string, object>() { { "Lives", "10" } }; matchParameters = debugSettings2; AppWarp.oppJoinedEvent += oppJoinedEventHandler; AppWarp.createRoom(roomName, matchParameters); customChoice.message = "Room created, waiting for opponent"; customChoice.firstOption = "Cancel"; customChoice.onChoice = cancelRoomWaitChoice; mode = MenuMode.MP_MONO_CHOICE; break; case 3: mode = MenuMode.MP_INIT; break; } break; case MenuMode.MP_BIN_CHOICE: if (customChoice.onChoice != null) { switch (choice) { case 1: customChoice.onChoice(true); break; case 2: customChoice.onChoice(false); break; } } break; case MenuMode.MP_MONO_CHOICE: if (customChoice.onChoice != null) { switch (choice) { case 1: customChoice.onChoice(true); break; } } break; } }