void OnApplicationQuit()
 {
     if (Master.getInstance().multiplayer)
     {
         AppWarp.deleteCurrentRoom();
         AppWarp.exit();
     }
 }
Example #2
0
 public void onChatReceived(ChatEvent eventObj)
 {
     Log(eventObj.getSender() + " sent " + eventObj.getMessage());
     if (eventObj.getSender() != Master.getInstance().username)
     {
         AppWarp.receiveMove(eventObj.getMessage());
     }
 }
Example #3
0
 void OnDestroy()
 {
     AppWarp.connectionStatusEvent -= connectionStatusHandler;
     AppWarp.oppLeftEvent          -= opponentLeftHandler;
     AppWarp.oppPauseEvent         -= opponentPauseHandler;
     AppWarp.oppResumeEvent        -= opponentResumeHandler;
     AppWarp.exit();
 }
 void onPause(bool paused)
 {
     this.gameObject.SetActive(!paused);
     if (!paused && Master.getInstance().multiplayer&& resendBackupMove != null)
     {
         Master.getInstance().Log("Move resent");
         AppWarp.reSubmitMove(resendBackupMove);
     }
 }
Example #5
0
 void endGame(bool winner)
 {
     if (winner)
     {
         status = StatusCode.GAME_END_VICTORY;
     }
     else
     {
         status = StatusCode.GAME_END_DEFEAT;
         AppWarp.deleteCurrentRoom();
     }
 }
 void moveMadeEventHandler(MoveData move)
 {
     Master.getInstance().Log("Make move method called");
     if (playerMove == null)
     {
         resendBackupMove = move;
         playerMove       = move;
         if (Master.getInstance().multiplayer)
         {
             AppWarp.submitMove(move);
         }
         if (oppMove != null)
         {
             finalizeMoves();
         }
     }
 }
    public GameObject roundOverviewObj;     // Set via inspector

    // Use this for initialization
    void Start()
    {
        Master.getInstance().Log("Level select scene starts");
        if (Master.getInstance().multiplayer)
        {
            AppWarp.connectionStatusEvent += connectionStatusHandler;
            AppWarp.initialize();
            status = StatusCode.CONNECTING;
            mode   = MenuMode.MP_WAITING;
        }
        else
        {
            status = StatusCode.CONNECTED;
            mode   = MenuMode.SP_SETUP;
        }
        customChoice = new MenuChoice();
    }
 void roomsFoundChoice(bool choice)
 {
     if (choice)
     {
         AppWarp.roomJoinedEvent += roomJoinedEventHandler;
         AppWarp.joinFoundRoom();
     }
     else
     {
         if (matchUp)
         {
             mode = MenuMode.MP_CREATEROOM;
         }
         else
         {
             mode = MenuMode.MP_INIT;
         }
     }
 }
    void connectionStatusHandler(AppWarp.ResultCode result)
    {
        switch (result)
        {
        case AppWarp.ResultCode.SUCCESS:
            status = StatusCode.CONNECTED;
            mode   = MenuMode.MP_INIT;
            AppWarp.associateUserName();
            break;

        default:
            customChoice.message     = "Disconnected from server";
            customChoice.firstOption = "Return to main menu";
            customChoice.onChoice    = connectionErrorChoice;
            mode   = MenuMode.MP_MONO_CHOICE;
            status = StatusCode.DISCONNECTED;
            break;
        }
    }
 void cancelRoomWaitChoice(bool b)
 {
     AppWarp.deleteCurrentRoom();
     mode = MenuMode.MP_INIT;
 }
 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;
        }
    }
Example #13
0
 void opponentLeftHandler()
 {
     pauseGame(true);
     AppWarp.deleteCurrentRoom();
     status = StatusCode.OPP_LEFT;
 }
Example #14
0
 void reconnect()
 {
     AppWarp.reconnect();
 }