public GameOverLayer(int score, int remoteScore)
        {
            TouchEnabled = true;

            string scoreMessage = String.Format("Game Over. You collected {0} bananas \r\n Opponent collected {1} bananas!", score, remoteScore);

            var scoreLabel = new CCLabelTTF(scoreMessage, "MarkerFelt", 22)
            {
                Position = new CCPoint(CCDirector.SharedDirector.WinSize.Center.X, CCDirector.SharedDirector.WinSize.Center.Y + 50),
                Color    = new CCColor3B(XNA.Color.Yellow)
            };

            AddChild(scoreLabel);

            var playAgainLabel = new CCLabelTTF("Tap to Play Again", "MarkerFelt", 22)
            {
                Position = CCDirector.SharedDirector.WinSize.Center,
                Color    = new CCColor3B(XNA.Color.Green)
            };

            AddChild(playAgainLabel);

            Color   = new CCColor3B(XNA.Color.Black);
            Opacity = 255;
            // Clean up the room from the server
            if (Context.isRoomCreator)
            {
                WarpClient.GetInstance().DeleteRoom(Context.gameRoomId);
            }
        }
Ejemplo n.º 2
0
    private void Init()
    {
        unityObjects = new Dictionary <string, GameObject>();
        GameObject[] _unityObject = GameObject.FindGameObjectsWithTag("UnityObject");
        foreach (GameObject g in _unityObject)
        {
            unityObjects.Add(g.name, g);
        }
        matchRoomData = new Dictionary <string, object>();
        unityObjects["Text_UserID"].SetActive(false);
        unityObjects["Btn_Logout"].SetActive(false);
        unityObjects["Text_StatusUser"].SetActive(false);
        if (listener == null)
        {
            listener = new Listener();
        }

        WarpClient.initialize(apiKey, sceretKey);
        WarpClient.GetInstance().AddConnectionRequestListener(listener);
        WarpClient.GetInstance().AddChatRequestListener(listener);
        WarpClient.GetInstance().AddRoomRequestListener(listener);
        WarpClient.GetInstance().AddUpdateRequestListener(listener);
        WarpClient.GetInstance().AddLobbyRequestListener(listener);
        WarpClient.GetInstance().AddNotificationListener(listener);
        WarpClient.GetInstance().AddRoomRequestListener(listener);
        WarpClient.GetInstance().AddZoneRequestListener(listener);
        WarpClient.GetInstance().AddTurnBasedRoomRequestListener(listener);

        UpdateStatus("Connecting...");
    }
 public void onJoinLobbyDone(LobbyEvent eventObj)
 {
     if (eventObj.getResult() == 0)
     {
         WarpClient.GetInstance().SubscribeLobby();
     }
 }
Ejemplo n.º 4
0
 public static void getRoom(string name)
 {
     // returns a MatchParameter from roomFoundEvent
     Log("Attempted to join room with name: " + name);
     listen.roomNameFilter = name;
     WarpClient.GetInstance().GetRoomsInRange(1, 1);
 }
Ejemplo n.º 5
0
 private void DoRoomSearchLogic()
 {
     if (roomIds.Count > 0 && roomIds.Count > roomIdx)
     {
         //Get Room information
         UpdateStatus("Getting room Details: " + roomIds[roomIdx]);
         WarpClient.GetInstance().GetLiveRoomInfo(roomIds[roomIdx]);
     }
     else
     {
         //Create Room
         Debug.Log("matchRoomData: " + matchRoomData.Count);
         if (matchRoomData.Count > 0 && !matchRoomData.ContainsKey(""))
         {
             indexRoom++;
             UpdateStatus("Creating as room...");
             WarpClient.GetInstance().CreateTurnRoom(GlobalVariables.userID + indexRoom, GlobalVariables.userID, 2, matchRoomData, GlobalVariables.turnTimer);
         }
         else
         {
             UpdateStatus("Choose Number ...");
             Btn_Go_Out();
         }
     }
 }
Ejemplo n.º 6
0
        private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dInterop == null)
            {
                m_d3dInterop = new Direct3DInterop();

                // Set window bounds in dips
                m_d3dInterop.WindowBounds = new Windows.Foundation.Size((float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight);

                // Set native resolution in pixels
                m_d3dInterop.NativeResolution = new Windows.Foundation.Size((float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f));

                // Set render resolution to the full native resolution
                m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;

                // Hook-up native component to DrawingSurface
                DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider(m_username, false));
                DrawingSurface.SetManipulationHandler(m_d3dInterop);

                m_d3dInterop.setWinRtCallback(new WinRtCallback(ProcessCallback));

                string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + CONNECTING + "}";

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    m_d3dInterop.onChatReceived(preGameUpdate);

                    WarpClient.GetInstance().AddConnectionRequestListener(m_connectionRequestListener);
                    WarpClient.GetInstance().AddNotificationListener(m_notifyListener);

                    WarpClient.GetInstance().Connect(m_username, AppWarpConstants.APPWARP_AUTH_DATA);
                });
            }
        }
Ejemplo n.º 7
0
 public void onGetMatchedRoomsDone(MatchedRoomsEvent eventObj)
 {
     Log("onGetMatchedRooms: ", eventObj.getResult());
     if ((ResultCode)eventObj.getResult() == ResultCode.SUCCESS)
     {
         string     matchedRoomID = null;
         RoomData[] rooms         = eventObj.getRoomsData();
         foreach (RoomData room in rooms)
         {
             Log(room.getName() + " vs. " + roomNameFilter);
             if (room.getName() == (roomNameFilter))
             {
                 Log("Found appropriate room");
                 matchedRoomID = room.getId();
                 break;
             }
         }
         if (string.IsNullOrEmpty(matchedRoomID))
         {
             Log("No appropriate room found");
             if (roomFoundEvent != null)
             {
                 roomFoundEvent(null);
             }
         }
         else
         {
             currentRoom_ID = matchedRoomID;
             WarpClient.GetInstance().GetLiveRoomInfo(matchedRoomID);
         }
     }
 }
Ejemplo n.º 8
0
        private void ProcessCallback(String command, String param)
        {
            if (command.Equals("SEND_CHAT"))
            {
                WarpClient.GetInstance().SendChat(param);
            }
            else if (command.Equals("EXIT"))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    NavigationService.GoBack();
                });
            }
            else if (command.Equals("CONNECTION_ERROR"))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MainPage.isConnectionError = true;
                    NavigationService.GoBack();
                });
            }
            else if (command.Equals("DISPLAY_TOAST"))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    ToastPrompt toast     = new ToastPrompt();
                    toast.FontSize        = 30;
                    toast.Title           = param;
                    toast.TextOrientation = System.Windows.Controls.Orientation.Horizontal;

                    toast.Show();
                });
            }
        }
Ejemplo n.º 9
0
            public void onConnectDone(ConnectEvent eventObj)
            {
                Debug.WriteLine("onConnectDone");

                if (eventObj.getResult() == 0)
                {
                    string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + FINDING_ROOM_TO_JOIN + "}";

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        _page.m_d3dInterop.onChatReceived(preGameUpdate);

                        WarpClient.GetInstance().JoinRoomInRange(0, 7, true);
                    });
                }
                else if (eventObj.getResult() == 2)
                {
                    string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + BATTLE_BOMBS_BETA_CLOSED + "}";

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        _page.m_d3dInterop.onChatReceived(preGameUpdate);
                    });
                }
                else
                {
                    string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + CONNECTION_ERROR + "}";

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        _page.m_d3dInterop.onChatReceived(preGameUpdate);
                    });
                }
            }
Ejemplo n.º 10
0
 public void onJoinRoomDone(RoomEvent eventObj)
 {
     if (eventObj.getResult() == 0)
     {
         appwrapTeenpatti.roomID = eventObj.getData().getId();
         WarpClient.GetInstance().SubscribeRoom(eventObj.getData().getId());
     }
     else
     {
         if (GameControllerTeenPatti.GameType.Equals(TagsTeenpatti.PRIVATE))
         {
             GameControllerTeenPatti.showToast(MessageScriptTeenPatti.INVALID_ROOM_MESSAGE);
         }
         else
         {
             Dictionary <string, object> dic = new Dictionary <string, object>();
             dic.Add(TagsTeenpatti.GAME_TYPE, "" + TagsTeenpatti.PUBLIC_GAME);
             dic.Add(TagsTeenpatti.BOOT_AMOUNT, "" + GameControllerTeenPatti.BootAmount);
             dic.Add(TagsTeenpatti.PORT_LIMIT, "" + GameControllerTeenPatti.PortLimit);
             dic.Add(TagsTeenpatti.MAX_BET_AMOUNT, "" + GameControllerTeenPatti.MaxBetAmt);
             dic.Add(TagsTeenpatti.DOMAIN, "" + TagsTeenpatti.URL);
             dic.Add(TagsTeenpatti.MAX_BLIND, "4");
             if (GameControllerTeenPatti.variation)
             {
                 dic.Add("VARIATION_TYPE", "1");
             }
             dic.Add(TagsTeenpatti.USER_TYPE, "" + PlayerPrefs.GetInt(PlayerDetails.RealMoney));
             WarpClient.GetInstance().CreateRoom("teenPatti", "game", 6, dic);
         }
     }
 }
Ejemplo n.º 11
0
 public void OnClick()
 {
     WarpClient.GetInstance().Connect(username, "");
     //WarpClient.GetInstance ().CreateTurnRoom (roomname, username, 4, null, 10);
     Debug.Log(username);
     Debug.Log(roomname);
 }
Ejemplo n.º 12
0
 public void onCreateRoomDone(RoomEvent eventObj)
 {
     if (eventObj.getResult() == 0)
     {
         WarpClient.GetInstance().JoinRoom(eventObj.getData().getId());
     }
 }
Ejemplo n.º 13
0
    private void OnMoveCompleted(MoveEvent _Move)
    {
        if (_Move.getSender() != GlobalVariables.userId)
        {
            Dictionary <string, object> _data = (Dictionary <string, object>)MiniJSON.Json.Deserialize(_Move.getMoveData());
            if (_data != null && _data.ContainsKey("Index"))
            {
                string _index = _data["Index"].ToString();
                GlobalEnums.MatchState _currentState = PlacementLogic(_index);
                if (_currentState == GlobalEnums.MatchState.Tie || _currentState == GlobalEnums.MatchState.Winner)
                {
                    WarpClient.GetInstance().stopGame();
                }
            }
        }

        startTime = Time.time;
        if (_Move.getNextTurn() == GlobalVariables.userId)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }
    }
Ejemplo n.º 14
0
    public void SitToTable(int seat, MultiplayerGamersCommunicator multiplayerGamersCommunicator)
    {
        int playersSeat = GetPlayersSeat();

        if (LobbyPlayerStats.RoomData.getRoomOwner() == PlayerName)
        {
            //  INFORM OTHERS
            Dictionary <string, object> tableProperties = new Dictionary <string, object>();
            tableProperties.Add("SEAT" + seat.ToString(), PlayerName);
            List <string> removeProperties = null;
            if (playersSeat != -1)
            {
                gameTable.LeaveTable(playersSeat);
                removeProperties = new List <string>();
                removeProperties.Add("SEAT" + playersSeat.ToString());
            }
            WarpClient.GetInstance().UpdateRoomProperties(LobbyPlayerStats.RoomData.getId(), tableProperties, removeProperties);
        }
        else
        {
            string peerSitUpdate = "SIT-" + seat.ToString() + "-" + PlayerName;
            if (playersSeat != -1)
            {
                gameTable.LeaveTable(playersSeat);
            }
            MultiplayerManager.SendBytes(ByteHelper.GetBytes(peerSitUpdate));
        }
    }
Ejemplo n.º 15
0
    public void OnGetLiveRoomInfo(LiveRoomInfoEvent eventObj)
    {
        Debug.Log("OnGetLiveRoomInfo " + eventObj.getData().getId() + " " + eventObj.getResult() + " " + eventObj.getJoinedUsers().Length);
        Dictionary <string, object> _temp = eventObj.getProperties();

        print("bet = " + SC_DefiendVariables.bet);
        Debug.Log(_temp.Count + " " + _temp["bet"] + " " + SC_DefiendVariables.bet["bet"].ToString());
        if (eventObj.getResult() == 0 && eventObj.getJoinedUsers().Length == 1 &&
            _temp["bet"].ToString() == SC_DefiendVariables.bet["bet"].ToString())
        {
            print("entering the room!");
            currentTurn = SC_DefiendVariables.Turn.RedTurn;
            print("Enemy start the game!");
            WarpClient.GetInstance().JoinRoom(eventObj.getData().getId());
            WarpClient.GetInstance().SubscribeRoom(eventObj.getData().getId());
        }
        else
        {
            currentTurn = SC_DefiendVariables.Turn.blueTurn;
            print("I start the game!");
            isMyTurn = true;
            Debug.Log("No rooms were availible, create a room");
            WarpClient.GetInstance().CreateTurnRoom("Room Name", SC_MultiPlayer_Globals.userName, 2, SC_DefiendVariables.bet, 60);
        }

        if (_temp["bet"].ToString() == SC_DefiendVariables.bet["bet"].ToString())
        {
            roomMatch = true;
        }
    }
Ejemplo n.º 16
0
    public void SendMoveAfterRestarting(SC_MultiPlayer_TileLogic tile)
    {
        print("SendMove");
        Dictionary <string, object> _moveToSend = new Dictionary <string, object>();

        point _to = new point();

        _to.row = tile.Row;
        _to.col = tile.Col;

        SC_MultiPlayer_Globals.SoldierRank strength = currentSelectedPiece.piece.pieceStrengh;

        _moveToSend.Add("toRow", _to.row);
        _moveToSend.Add("toCol", _to.col);
        //_moveToSend.Add("number", currentSelectedPiece.name);

        _moveToSend.Add("strength", strength);
        if (currentSelectedPiece.piece != null)
        {
            int result = Int32.Parse(System.Text.RegularExpressions.Regex.Match(currentSelectedPiece.piece.name, @"\d+").Value);
            _moveToSend.Add("name", result);
        }

        string _jsonToSend = MiniJSON.Json.Serialize(_moveToSend);

        Debug.Log(_jsonToSend);
        WarpClient.GetInstance().sendMove(_jsonToSend);
    }