コード例 #1
0
    private void ChangeScreenLogic(MenuScreen newScreen)
    {
        _screens[(int)_currentScreen].SetActive(false);

        if (newScreen == MenuScreen.Multiplayer && GameManager.Instance.UserId == null)
        {
            GameManager.Instance.UserId = System.DateTime.Now.Ticks.ToString();
            Debug.Log(GameManager.Instance.UserId);
            WarpClient.GetInstance().Connect(GameManager.Instance.UserId);
            UpdateStatus("Connecting...");
        }

        if (newScreen == MenuScreen.Loading && _currentScreen == MenuScreen.Multiplayer)
        {
            UpdateStatus("Searching for room...");
            WarpClient.GetInstance().GetRoomsInRange(1, 2);
        }

        if (newScreen == MenuScreen.Loading && _currentScreen == MenuScreen.Singleplayer)
        {
            gameObject.SetActive(false);
            return;
        }
        _screens[(int)newScreen].SetActive(true);
        _currentScreen = newScreen;
        if (_firstButton[(int)newScreen] != null)
        {
            _eventSystem.SetSelectedGameObject(_firstButton[(int)newScreen].gameObject);
        }
    }
コード例 #2
0
ファイル: GamePage.xaml.cs プロジェクト: Katry4/WinRepo
        public GamePage()
        {
            InitializeComponent();
            this.SupportedOrientations = SupportedPageOrientation.Landscape;

            Balls_mas = new Ball[maxUsers];// ініціал масиву шарів
            Ws.InitWorld();
            // initial word dates винести в клас
            //_world = new World(new Vector2(0, 0));
            //ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);
            //width = ConvertUnits.ToSimUnits(800);
            //height = ConvertUnits.ToSimUnits(480);
            //

            WarpClient game = WarpClient.GetInstance();

            game.AddNotificationListener(new GameNotificationListener(this));



            // Get the content manager from the application
            contentManager = (Application.Current as App).Content;

            // Create a timer for this page
            timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update        += OnUpdate;
            timer.Draw          += OnDraw;
        }
コード例 #3
0
    private IEnumerator createRoom(Dictionary <string, object> tableProperties)
    {
        LoadingScreen.Show();
        yield return(null);

        WarpClient.GetInstance().CreateRoom(roomName, Player.GetInternalPlayer().PlayerName, 4, tableProperties);
    }
コード例 #4
0
 public void sendMsg(string msg)
 {
     if (state == 1)
     {
         WarpClient.GetInstance().SendChat(msg);
     }
 }
コード例 #5
0
        public MainPage()
        {
            this.InitializeComponent();

            this.navigationHelper            = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;

            this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;

            // Set the data context to the friendsData global variable
            AppServices.friendsData._page      = this;
            AppServices.friendsData.myUsername = AppServices.localUsername;
            DataContext          = AppServices.friendsData;
            AppServices.mainPage = this;

            WarpClient.initialize(AppServices.apiKey, AppServices.secretKey);
            WarpClient.setRecoveryAllowance(AppServices.appWarpRecoveryTime);
            AppServices.warpClient = WarpClient.GetInstance();

            AppServices.warpClient.AddConnectionRequestListener(AppServices.connListenObj);
            AppServices.warpClient.AddNotificationListener(AppServices.notificationListnerObj);
            AppServices.warpClient.AddUpdateRequestListener(AppServices.updateListenerObj);

            // Connect to Appwarp and update our online friends in the callback
            AppServices.appWarpConnectMode = appWarpConnectModes.sendAllUpdates;
            WarpClient.GetInstance().Connect(AppServices.localUsername);
        }
コード例 #6
0
 public static void Disconnect()
 {
     if (WarpClient.GetInstance() != null)
     {
         WarpClient.GetInstance().Disconnect();
     }
 }
コード例 #7
0
        public void onConnectDone(ConnectEvent eventObj)
        {
            switch (eventObj.getResult())
            {
            case WarpResponseResultCode.SUCCESS:
                Debug.WriteLine("\nConnection Success\n");
                GlobalContext.IsConnectedToAppWarp = true;
                _recoverCounts = 0;
                Deployment.Current.Dispatcher.BeginInvoke(delegate()
                {
                    if (GlobalContext.tableProperties["IsPrivateRoom"].Equals("false"))
                    {
                        WarpClient.GetInstance().JoinRoomWithProperties(GlobalContext.tableProperties);
                    }
                });
                break;

            case WarpResponseResultCode.CONNECTION_ERROR_RECOVERABLE:
                Deployment.Current.Dispatcher.BeginInvoke(delegate(){ RecoverConnection(); });
                break;

            case WarpResponseResultCode.SUCCESS_RECOVERED:
                break;

            default:
                if (App.CurrentPage.Equals("HomePage"))
                {
                    Deployment.Current.Dispatcher.BeginInvoke(delegate() { App.g_HomePageListener.ConnectionFailed(); });
                }
                GlobalContext.IsConnectedToAppWarp = false;
                break;
            }
        }
コード例 #8
0
 void BattlePlayerPhaseThree()
 {
     TotalPower2 = Stats(Opponent).pwr + DiceValue;
     UnityObjects["Battle_Roll"].GetComponent <Text>().text = TotalPower1 + " VS " + TotalPower2;
     if (TotalPower1 > TotalPower2)
     {
         UnityObjects["Battle_Result_Text"].GetComponent <Text>().text = "Player " + GetCurrentPlayer() + " Win!";
     }
     else if (TotalPower1 < TotalPower2)
     {
         UnityObjects["Battle_Result_Text"].GetComponent <Text>().text = "Player " + Opponent + " Win!";
     }
     else
     {
         UnityObjects["Battle_Result_Text"].GetComponent <Text>().text = "Draw!";
     }
     if (PlayingMulti && isMyTurn)
     {
         EnableDice(false);
         isMyTurn = false;
         Dictionary <string, object> _toSend = new Dictionary <string, object>();
         _toSend.Add("Move", "FP3");
         string _jsonToSend = MiniJSON.Json.Serialize(_toSend);
         WarpClient.GetInstance().SendChat(_jsonToSend);
     }
     if (PlayingMulti)
     {
         Invoke("MakeCardShow", 1f);
     }
     else
     {
         MakeCardShow();
     }
 }
コード例 #9
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Hide();
            WarpClient.GetInstance().Disconnect();
            LoginScreen.Show();
        }

        if (Input.touchCount > 0)
        {
            Touch touch = Input.GetTouch(0);
            if (touch.phase == TouchPhase.Began)
            {
                touchPosition = touch.position;
            }
            else if (touch.phase == TouchPhase.Moved)
            {
                scrollPosition.y += touch.position.y - touchPosition.y;
                touchPosition     = Input.mousePosition;
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            touchPosition = Input.mousePosition;
        }
        else if (Input.GetMouseButton(0))
        {
            scrollPosition.y += Input.mousePosition.y - touchPosition.y;
            touchPosition     = Input.mousePosition;
        }
    }
コード例 #10
0
    void ApplyBattleResult()
    {
        if (TotalPower1 > TotalPower2)
        {
            if (IsFightingDragon)
            {
                if (PlayingMulti)
                {
                    WarpClient.GetInstance().stopGame();
                }

                NoWinner = false;
                UnityObjects["Winning_Msg"].SetActive(true);
                UnityObjects["Winning_Text"].GetComponent <Text>().text = "Player " + GetCurrentPlayer() + "\n Victory!";
            }
            else
            {
                Stats(GetCurrentPlayer()).AddXp(Deck_Manager.Instance.GetPower());
            }
        }
        else if (TotalPower1 < TotalPower2)
        {
            if (Stats(GetCurrentPlayer()).TakeAhit())
            {
                RestartPlayerPos(GetCurrentPlayer());
            }
        }
    }
コード例 #11
0
    public void MakeUnanimousDeck()
    {
        Stack <Card> TempBdeck              = new Stack <Card>(Deck_Manager.Instance.BlueDeck);//this reverse the original deck
        Stack <Card> TempRdeck              = new Stack <Card>(Deck_Manager.Instance.RedDeck);
        string       BlueDeckToSend         = string.Empty;
        string       RedDeckToSend          = string.Empty;
        int          Size                   = TempBdeck.Count;
        Dictionary <string, object> _toSend = new Dictionary <string, object>();

        _toSend.Add("Move", "Deck");
        _toSend.Add("Bsize", TempBdeck.Count.ToString());
        for (int i = 0; i < Size; i++)
        {
            BlueDeckToSend += TempBdeck.Peek().Picture.ToString();
            TempBdeck.Pop();
        }
        Size = TempRdeck.Count;
        _toSend.Add("Bdeck", BlueDeckToSend);
        _toSend.Add("Rsize", TempRdeck.Count.ToString());
        for (int i = 0; i < Size; i++)
        {
            RedDeckToSend += TempRdeck.Peek().Picture.ToString();
            TempRdeck.Pop();
        }
        _toSend.Add("Rdeck", RedDeckToSend);
        string _jsonToSend = MiniJSON.Json.Serialize(_toSend);

        WarpClient.GetInstance().SendChat(_jsonToSend);
    }
コード例 #12
0
    public void ReRoll()
    {
        UnityObjects["Continue"].SetActive(false);
        if (isMyTurn)
        {
            UnityObjects["ReRoll"].SetActive(false);
            DiceValue = Random.Range(1, 7);
            Stats(GetCurrentPlayer()).faith--;
            HasReRolled = true;
            coroutine   = RollTheDice();
            StartCoroutine(coroutine);
            if (Stats(GetCurrentPlayer()).Turn_Status == Global_Variables.turn_Status.Moving)
            {
                UpdateTiles(false, Original_TileColor);
            }

            if (PlayingMulti)
            {
                Dictionary <string, object> _toSend = new Dictionary <string, object>();
                _toSend.Add("Move", "ReRoll");
                _toSend.Add("Dval", DiceValue.ToString());
                if (Stats(GetCurrentPlayer()).Turn_Status == Global_Variables.turn_Status.Moving)
                {
                    _toSend.Add("Moving", "Y");
                }
                else
                {
                    _toSend.Add("Moving", "N");
                }
                string _jsonToSend = MiniJSON.Json.Serialize(_toSend);
                WarpClient.GetInstance().SendChat(_jsonToSend);
            }
        }
    }
コード例 #13
0
 public void DealCards(List <Common.Card>[] splittedCards)
 {
     MultiplayerManager.DealCallbackCount = 0;
     for (int k = 0; k < 4; k++)
     {
         string networkMessage = string.Empty;
         for (int i = 0; i < 4; i++)
         {
             if (i != 0)
             {
                 networkMessage += "|";
             }
             else
             {
                 networkMessage = "DEAL:";
             }
             for (int j = 0; j < 13; j++)
             {
                 if (j == 0)
                 {
                     networkMessage += splittedCards[i][j].ToNetworkCardString();
                 }
                 else
                 {
                     networkMessage += "," + splittedCards[i][j].ToNetworkCardString();
                 }
             }
         }
         if (networkPlayers[k].PlayerName != localPlayer.GetInternalPlayer().PlayerName)
         {
             WarpClient.GetInstance().sendPrivateUpdate(networkPlayers[k].PlayerName, ByteHelper.GetBytes(networkMessage));
         }
     }
 }
コード例 #14
0
 public void onCreateRoomDone(RoomEvent eventObj)
 {
     if (eventObj.getResult() == WarpResponseResultCode.SUCCESS)
     {
         WarpClient.GetInstance().SetCustomRoomData(eventObj.getData().getId(), "This is a sample room");
         _page.showResult("name " + eventObj.getData().getName() + " and Id " + eventObj.getData().getId());
     }
 }
コード例 #15
0
 public static void Disconnect()
 {
     if (WarpClient.GetInstance() != null)
     {
         //// Debug.Log ("Disconnect Server!");
         WarpClient.GetInstance().Disconnect();
     }
 }
コード例 #16
0
        private void JoinRoomWithRandomPlayer()
        {
            AddListeners();
            Dictionary <string, object> tableProperties = new Dictionary <string, object>();

            tableProperties.Add("IsPrivateRoom", "false");
            WarpClient.GetInstance().JoinRoomWithProperties(tableProperties);
        }
コード例 #17
0
 public void onSubscribeLobbyDone(LobbyEvent eventObj)
 {
     Log("onSubscribeLobbyDone : " + eventObj.getResult());
     if (eventObj.getResult() == 0)
     {
         WarpClient.GetInstance().JoinLobby();
     }
 }
コード例 #18
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.Quit();
     }
     WarpClient.GetInstance().Update();
 }
コード例 #19
0
 public void onChatReceived(ChatEvent eventObj)
 {
     // Debug.Log(eventObj.getSender() + "  :  " + eventObj.getMessage());
     if (WarpClient.GetInstance() != null)
     {
         RouletteDelegate.chatRecived(eventObj.getSender(), eventObj.getMessage());
     }
 }
コード例 #20
0
    private IEnumerator TryToReconnect()
    {
        WarpClient.GetInstance().RecoverConnection();

        yield return(new WaitForSeconds(2f));

        StartCoroutine("TryToReconnect");
    }
コード例 #21
0
ファイル: MainPage.xaml.cs プロジェクト: Katry4/WinRepo
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            ///JObject jObj = new JObject();
            //jObj.Add("name", "stefan");
            string name = textBox1.Text;

            WarpClient.GetInstance().SendUpdatePeers(System.Text.Encoding.UTF8.GetBytes(name));
        }
コード例 #22
0
 private void OnDestroy()
 {
     WarpClient.GetInstance().Disconnect();
     if (WarpClient.GetInstance())
     {
         Destroy(WarpClient.GetInstance().gameObject);
     }
 }
コード例 #23
0
 private void getWarpInstance()
 {
     try {
         theClient = WarpClient.GetInstance();
     } catch (UnityException ex) {
         Utils.showToastAlert(Constants.ALERT_INIT_EXEC + " " + ex.Message);
     }
 }
コード例 #24
0
 public void onJoinRoomDone(RoomEvent eventObj)
 {
     Log("onJoinRoomDone : ", eventObj.getResult());
     if ((ResultCode)eventObj.getResult() == ResultCode.SUCCESS)
     {
         WarpClient.GetInstance().SubscribeRoom(currentRoom_ID);
     }
 }
コード例 #25
0
ファイル: Listener.cs プロジェクト: JiboStore/AppWarpUnity
 //ConnectionRequestListener
 #region ConnectionRequestListener
 public void onConnectDone(ConnectEvent eventObj)
 {
     Log("onConnectDone : " + eventObj.getResult());
     if (eventObj.getResult() == 0)
     {
         WarpClient.GetInstance().SubscribeRoom(appwarp.roomid);
     }
 }
コード例 #26
0
    public void EnemyBoard_Slot_Click(int _index)
    {
        temp.index   = _index;
        temp.msgSend = "shoot";
        string jsonToSend = JsonUtility.ToJson(temp);

        WarpClient.GetInstance().sendMove(jsonToSend, "");
    }
コード例 #27
0
 public void OnCreateRoom(bool _IsSuccess, string _RoomId)
 {
     Debug.Log("OnCreateRoom " + _IsSuccess + " " + _RoomId);
     if (_IsSuccess)
     {
         WarpClient.GetInstance().JoinRoom(_RoomId);
     }
 }
コード例 #28
0
 //NotifyListener
 public void onRoomCreated(RoomData eventObj)
 {
     Log("onRoomCreated " + eventObj.getId() + " " + eventObj.getRoomOwner());
     if (eventObj != null)
     {
         WarpClient.GetInstance().JoinRoom(eventObj.getId());
     }
 }
コード例 #29
0
ファイル: MainPage.xaml.cs プロジェクト: Katry4/WinRepo
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     //settings винести в окремий клас
     WarpClient.GetInstance().JoinRoom("1995630518");
     WarpClient.GetInstance().SubscribeRoom("1995630518");
     WarpClient.GetInstance().GetLiveRoomInfo("1995630518");
     //WarpClient.GetInstance().SubscribeRoom("1995630518");
 }
コード例 #30
0
 private void OnUserJoinRoom(RoomData eventObj, string _UserId)
 {
     if (userId != _UserId)
     {
         Debug.Log(_UserId + " Have joined the room");
         WarpClient.GetInstance().startGame();
     }
 }
コード例 #31
0
ファイル: AppWarp.cs プロジェクト: 4ONSports/Prototype_2
    public static void InitializeConnection(string _name, string _gameplayScene)
    {
        WarpClient.initialize(apiKey,secretKey);
        DontDestroyOnLoad (WarpClient.GetInstance().gameObject);
        warpClient = WarpClient.GetInstance ();
        WarpClient.GetInstance().AddConnectionRequestListener(conn_listen);
        WarpClient.GetInstance().AddRoomRequestListener(room_listen);

        localusername = _name;
        gameplaySceneStr = _gameplayScene;
        WarpClient.GetInstance().Connect(localusername);
    }
コード例 #32
0
    private void initAppWarp()
    {
        if (theClient != null)
            return;
        WarpClient.initialize(ApiKey,SecretKey);
        WarpClient.setRecoveryAllowance (60);

        WarpClient.GetInstance().AddConnectionRequestListener(this);
        WarpClient.GetInstance().AddChatRequestListener(this);
        WarpClient.GetInstance().AddLobbyRequestListener(this);
        WarpClient.GetInstance().AddNotificationListener(this);
        WarpClient.GetInstance().AddRoomRequestListener(this);
        WarpClient.GetInstance().AddUpdateRequestListener(this);
        WarpClient.GetInstance().AddZoneRequestListener(this);
        theClient = WarpClient.GetInstance ();
    }
コード例 #33
0
ファイル: AppWarp.cs プロジェクト: 4ONSports/Prototype_2
    void Start()
    {
        warpClient = WarpClient.GetInstance (); // WarpClient.GetInstance() returns null until it is initialized

        conn_listen = new ConnectionListener();
        notify_listen = new NotificationListener();
        room_listen = new RoomListener();
    }