Пример #1
0
 public GameSessionInfo(string gameId, params Player[] players) : this(gameId)
 {
     foreach (var player in players)
     {
         PlayerIds.Add(player.ConnectionId, player);
     }
 }
        private async void Signup_Clicked(object sender, EventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    Alogin.IsRunning = true;
                    Alogin.IsVisible = true;

                    PlayerIds deviceId = await OneSignal.Current.IdsAvailableAsync();

                    string deviceid = deviceId.PlayerId;

                    string Inputs = "deviceId=" + deviceid.ToString();
                    string resp   = await RestService.VerificationCode(Inputs);

                    var result = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(resp);

                    string userUniqueId = result;

                    if (result == "Yes")
                    {
                        await DisplayAlert("Alert", "You are already registered", "Ok");

                        Alogin.IsRunning = false;
                        Alogin.IsVisible = false;
                    }
                    else if (result == "0")
                    {
                        //  await Navigation.PushAsync(new Signup1(), false);

                        await Navigation.PushAsync(new Signup("Yes", "Yes"), false);

                        Alogin.IsRunning = false;
                        Alogin.IsVisible = false;
                    }
                    else if (result == "-1")
                    {
                        await Navigation.PushAsync(new ForgotPassword());
                    }
                    else
                    {
                        // await Navigation.PushAsync(new SignupVerification(userUniqueId), false);
                        Alogin.IsRunning = false;
                        Alogin.IsVisible = false;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                    Alogin.IsRunning = false;
                    Alogin.IsVisible = false;
                }
            }
            else
            {
                await DisplayAlert("Alert", "Please check your Internet Connection", "Ok");
            }
        }
Пример #3
0
 public Player(PlayerIds pId, PlayerTypes pType, string pPadName, AIs pAI = AIs.Easy)
 {
     m_id      = pId;
     m_type    = pType;
     m_padName = pPadName;
     m_AI      = pAI;
     InitPad();
 }
Пример #4
0
        public Game(IEnumerable <Int32> playerIds, ITurnFactory turnFactory)
        {
            this.PlayerIds   = playerIds.ToList();
            this.turnFactory = turnFactory;
            this.Rounds      = 0;

            PlayerIds = PlayerIds.Shuffle();
            SetUpPlayerTurns();
        }
        public void ProcessHandshakeRequest(TPeer source, ref PacketReader reader)
        {
            //Parse packet
            string        name;
            CodecSettings codecSettings;

            reader.ReadHandshakeRequest(out name, out codecSettings);

            // Validate that we have a player name, and ignore if not
            if (name == null)
            {
                Log.Warn("Ignoring a handshake with a null player name");
                return;
            }

            // Check if this client is already in the session but with a different connection to the current one.
            // We'll assume name collisions never happen, so this is probably a client reconnecting before the server has cleaned up after a very recent disconnection
            ClientInfo <TPeer> currentInfoByName;
            ClientInfo <TPeer> currentInfoByConn;

            if (TryGetClientInfoByName(name, out currentInfoByName) | TryFindClientByConnection(source, out currentInfoByConn))
            {
                //We got the client by name and by current connection. If they are different then the client is in the session with a different connection
                if (!EqualityComparer <ClientInfo <TPeer> > .Default.Equals(currentInfoByName, currentInfoByConn))
                {
                    //Remove clients who were already connected
                    if (currentInfoByConn != null && currentInfoByConn.IsConnected)
                    {
                        RemoveClient(currentInfoByConn);
                    }
                    if (currentInfoByName != null && currentInfoByName.IsConnected)
                    {
                        RemoveClient(currentInfoByName);
                    }

                    Log.Debug("Client '{0}' handshake received but client is already connected! Disconnecting client '{1}' & '{2}', connecting '{3}'",
                              name,
                              currentInfoByConn,
                              currentInfoByName,
                              source
                              );
                }
            }

            //Get or register the ID for this client
            var id   = PlayerIds.GetId(name) ?? PlayerIds.Register(name);
            var info = GetOrCreateClientInfo(id, name, codecSettings, source);

            //Send back handshake response
            _tmpClientBufferHandshake.Clear();
            GetClients(_tmpClientBufferHandshake);

            var writer = new PacketWriter(_tmpSendBuffer);

            writer.WriteHandshakeResponse(_server.SessionId, info.PlayerId, _tmpClientBufferHandshake, ClientsInRooms.ByName);
            _server.SendReliable(source, writer.Written);
        }
Пример #6
0
 public void Add1PointToScore(PlayerIds id)
 {
     m_players[id].Score1Point();
     UpdateScoreDisplay();
     if (m_players[id].CurrentScore == m_roundsLength)
     {
         m_gameSequencer.EndRound();
         m_uIManager.OpenStartScreen();
     }
 }
Пример #7
0
        public void ReceiveHandshakeResponseBody(ref PacketReader reader)
        {
            // Allocation here is ok (and unavoidable). This doesn't happen very often (just once in normal circumstances) and
            // we're creating lists of peers - so at the very least we need to allocate the lists.
            var clientsByRooms = new Dictionary <string, List <ushort> >();
            var clients        = new List <ClientInfo>();

            reader.ReadHandshakeResponseBody(clients, clientsByRooms);

            // Load player IDs
            PlayerIds.Load(clients);

            //Remove all player objects who are not in the handshake response
            //Normally we would only receive one handshake response, but it's still valid to receive more
            var currentClients = new List <ClientInfo <TPeer?> >();

            GetClients(currentClients);
            for (var i = 0; i < currentClients.Count; i++)
            {
                if (PlayerIds.GetName(currentClients[i].PlayerId) != currentClients[i].PlayerName)
                {
                    RemoveClient(currentClients[i]);
                }
            }

            //Create a client object for every player which does not already exist
            foreach (var client in clients)
            {
                GetOrCreateClientInfo(client.PlayerId, client.PlayerName, client.CodecSettings, null);
            }

            //Clear all rooms
            ClearRooms();

            //Add remote clients into rooms according to `clientsByRooms` which we deserialized from packet
            foreach (var item in clientsByRooms)
            {
                foreach (var client in item.Value)
                {
                    ClientInfo <TPeer?> info;
                    if (!TryGetClientInfoById(client, out info))
                    {
                        Log.Warn("Attempted to add an unknown client '{0}' into room '{1}'", client, item.Key);
                    }
                    else
                    {
                        JoinRoom(item.Key, info);
                    }
                }
            }

            //Send back a response with the complete current state of this client and follow up with deltas every time the state changes
            SendClientState();
        }
Пример #8
0
    virtual public void Init(PlayerIds playerId)
    {
        //Debug.Log("[PadController] Init Game");

        SetComponentsEnabled(true);

        m_playerId = playerId;
        m_padMover.SetController(this);
        m_ballStriker.SetController(this);
        m_smashChargeFeedback.SetController(this);
        m_smashTriggerFeedback.SetController(this);
    }
Пример #9
0
    public void ResetPosition(PlayerIds player)
    {
        Debug.Log(GameManager.Instance.RightBound);
        Debug.Log(GameManager.Instance.TouchAreaWidth);
        Debug.Log(transform.lossyScale.x / 2.0f);
        float xPosition = GameManager.Instance.RightBound - GameManager.Instance.TouchAreaWidth + (transform.lossyScale.x / 2.0f);

        if (player == PlayerIds.P1)
        {
            xPosition *= -1;
        }
        transform.position = new Vector3(xPosition, transform.position.y, transform.position.z);
    }
Пример #10
0
    public void StartNewPoint(PlayerIds engagingPlayer)
    {
        Vector3 engagementDirection;

        if (engagingPlayer == PlayerIds.P1)
        {
            engagementDirection = Vector3.left;
        }
        else
        {
            engagementDirection = Vector3.right;
        }
        StartNewPoint(engagementDirection);
    }
Пример #11
0
    void Start()
    {
        m_gameSequencer = GameObject.Find("GameSequencer").GetComponent <GameSequencer>();

        if (transform.position.x < 0)
        {
            m_defendingPlayer = PlayerIds.P1;
            m_scoringPlayer   = PlayerIds.P2;
        }
        else
        {
            m_defendingPlayer = PlayerIds.P2;
            m_scoringPlayer   = PlayerIds.P1;
        }
    }
Пример #12
0
    public IEnumerator EndPoint(PlayerIds pointWinner, PlayerIds pointLoser)
    {
        m_ball.Disable();
        if (m_isSmashAction)
        {
            yield return(StartCoroutine(m_uiManager.DisplayBoom()));
        }
        else
        {
            yield return(null);
        }

        m_ball.Disable();
        m_gameManager.Add1PointToScore(pointWinner);

        if (m_isRoundInProgress)
        {
            StartNewPoint(pointLoser);
        }
    }
Пример #13
0
        public async void GetSignUpDetails()
        {
            try
            {
                PlayerIds deviceId = await OneSignal.Current.IdsAvailableAsync();

                string deviceid = deviceId.PlayerId;
                string Inputs   = "ScreenName=" + "State" + "&StateId=" + "";
                string resp     = await RestService.GetStateCity(Inputs);

                var result = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(resp);
                if (result != "")
                {
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Unable to find signup data");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
Пример #14
0
 public bool HasTouch(PlayerIds id)
 {
     return(m_players[id].TouchFound);
 }
Пример #15
0
        private async void CreateAccount(object sender, EventArgs e)
        {
            var isMobileValid = App.Current.Properties.ContainsKey("IsMobileValid") ? (bool)App.Current.Properties["IsMobileValid"] : false;

            try
            {
                Boolean boolisValid = await IsValid();

                if (boolisValid && isMobileValid)
                {
                    IsBusy = true;
                    uploadImage();
                    string MobileNumber = mobilenumber.Text;
                    string Storename    = storename.Text;
                    string StoreAddress = storeaddress.Text;

                    if (StoreAddress.Contains("&"))
                    {
                        StoreAddress = StoreAddress.Replace("&", "");
                    }

                    string storeAddress2 = storeaddress2.Text;
                    string StoreCity     = storestate.Items[storestate.SelectedIndex].ToString() + ":" + othercity.Text;
                    if (StoreCity.Contains("&"))
                    {
                        StoreCity = StoreCity.Replace("&", "");
                    }
                    string StoreState = storecity.Items[storecity.SelectedIndex].ToString();
                    if (StoreState.Contains("&"))
                    {
                        StoreState = StoreState.Replace("&", "");
                    }
                    string StoreZip         = storezip.Text;
                    string StorePhone       = storephone.Text;
                    string StoreEmail       = storeemail.Text;
                    string StoreWebsite     = storewebsite.Text;
                    string StoreArea        = storearea.Text;
                    string Businesscategory = businesscategory.Text;
                    string SubCategory      = subcategory.Text;
                    string openingHour      = openingTime.Time.ToString();
                    string ClosingTime      = closingTime.Time.ToString();

                    string StoreImageAll = "Store" + ":" + StoreImageName + "`" + StoreImageName2 + "`" + StoreImageName3;
                    //  string StoreImageAll = "Store:" + StoreImageName;
                    string StoreLogoAll = "Logo:" + LogoImageName;
                    string StoreProfile = "Profile:" + ProfileImageName;
                    //  string Verificationcode = verificationcode.Text;

                    // Navigation.PushAsync(new SetPassword());
                    PlayerIds deviceId = await OneSignal.Current.IdsAvailableAsync();

                    string deviceid = deviceId.PlayerId;
                    MobileNumber = mobilenumber.Text;

                    //if (SendData.Contains("&"))
                    //{
                    //    SendData = SendData.Replace("&", "_");
                    //}

                    //  string Inputs = "Mobile=" + MobileNumber + "&UserType=" + "Retailer" + "&DeviceID=" + deviceid;
                    string Inputs = "StoreName=" + Storename + "&StoreAddress=" + StoreAddress + "&City=" + StoreCity + "&State=" + StoreState + "&MainArea=" + StoreArea +
                                    "&ZipCode=" + StoreZip + "&Phone=" + StorePhone + "&Mobile=" + MobileNumber + "&Email=" + StoreEmail + "&Website=" + StoreWebsite + "&Latitude=" + lat + "&Longitude=" + lng +
                                    "&StoreImage=" + StoreImageAll.ToString() + "&StoreAddress2=" + storeAddress2 + "&BusinessCategory=" + SendData +
                                    "&StoreLogo=" + StoreLogoAll + "&UserProfilePhoto=" + StoreProfile.ToString() + "&IsGoogleBusinessAccount=" + GoogleAccount + "&IsWebsite=" + Website + "&DeviceId=" + deviceid.ToString()
                                    + "&BusinessSubCategory=" + "SubCategory" + "&StoreOpeningTime=" + openingHour + "&StoreClosingTime=" + ClosingTime.ToString();

                    string resp = await RestService.PostRegistration(Inputs);

                    var result = Newtonsoft.Json.JsonConvert.DeserializeObject <string>(resp);

                    if (result != "0")
                    {
                        UserID = result;
                    }

                    if (UserID != "0" && UserID != "")
                    {
                        await DisplayAlert("Alert", "Submit successfully...!", "Ok");

                        // var _Popupspec = new PopupOTPDialog(pagename, UserID, MobileNumber);
                        if (GoogleAccount == "Yes")
                        {
                            string pageName   = "setpassword";
                            var    _Popupspec = new PopupOTPDialog(UserID, pageName);
                            await Navigation.PushPopupAsync(_Popupspec);
                        }
                        else if (GoogleAccount == "No")
                        {
                            await Navigation.PopToRootAsync();
                        }
                    }
                    else if (UserID == "0" || UserID == "")
                    {
                        await DisplayAlert("Alert", "Mobile number already exist", "Ok");
                    }

                    else
                    {
                        await DisplayAlert("Alert", "Network Issue", "Ok");
                    }


                    IsBusy = false;
                }
                else
                {
                    //   await DisplayAlert("Alert", "Invalid Mobile Number", "Ok");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                Alogin.IsRunning = false;
                Alogin.IsVisible = false;
                IsBusy           = false;
            }
        }
Пример #16
0
    public float m_maxOffset = 1;                                   // maximum offset to pad center when striking ball

    #endregion

    #region PUBLIC METHODS

    override public void Init(PlayerIds player)
    {
        base.Init(player); //reference the pad owner
        DetermineOpponentDirection();
    }
Пример #17
0
        public void ProcessHandshakeRequest(TPeer source, ref PacketReader reader)
        {
            //Parse packet
            string        name;
            CodecSettings codecSettings;

            reader.ReadHandshakeRequest(out name, out codecSettings);

            // Validate that we have a player name, and ignore if not
            if (name == null)
            {
                Log.Warn("Ignoring a handshake with a null player name");
                return;
            }

            // Check if this client is already in the session but with a different connection to the current one.
            // We'll assume name collisions never happen, so this is probably a client reconnecting before the server has cleaned up after a very recent disconnection
            ClientInfo <TPeer> currentInfoByName;
            ClientInfo <TPeer> currentInfoByConn;

            if (TryGetClientInfoByName(name, out currentInfoByName) | TryFindClientByConnection(source, out currentInfoByConn))
            {
                //We got the client by name and by current connection. If they are different then the client is in the session with a different connection
                if (!EqualityComparer <ClientInfo <TPeer> > .Default.Equals(currentInfoByName, currentInfoByConn))
                {
                    //Remove clients who were already connected
                    if (currentInfoByConn != null && currentInfoByConn.IsConnected)
                    {
                        RemoveClient(currentInfoByConn);
                    }
                    if (currentInfoByName != null && currentInfoByName.IsConnected)
                    {
                        RemoveClient(currentInfoByName);
                    }

                    Log.Debug("Client '{0}' handshake received but client is already connected! Disconnecting client '{1}' & '{2}', connecting '{3}'",
                              name,
                              currentInfoByConn,
                              currentInfoByName,
                              source
                              );
                }
            }

            //Get or register the ID for this client
            var id   = PlayerIds.GetId(name) ?? PlayerIds.Register(name);
            var info = GetOrCreateClientInfo(id, name, codecSettings, source);

            // Send the handshake response - but with _no_ clients in the list, as if the session has no one in it. The handshake packet previously listed everyone in the session and what rooms they're in. However,
            // this could cause the packet to become very large and eventually it would overflow a buffers. Rather than expand all the buffers (which could break network integrations) we're not going to send any of
            // that data in the handshake (as if it's an empty session) and then we'll immediately send all the client data in separate packets.
            var writer = new PacketWriter(_tmpSendBuffer);

            _tmpClientBufferHandshake.Clear();
            writer.WriteHandshakeResponse(_server.SessionId, info.PlayerId, _tmpClientBufferHandshake, _tmpClientByRoomsBufferHandshake);
            _server.SendReliable(source, writer.Written);

            //Send individual client state messages for all clients in the session
            GetClients(_tmpClientBufferHandshake);
            for (var i = 0; i < _tmpClientBufferHandshake.Count; i++)
            {
                SendFakeClientState(source, _tmpClientBufferHandshake[i]);
            }
        }
Пример #18
0
 public int GetTapCount(PlayerIds id)
 {
     return(m_players[id].TapCount);
 }
Пример #19
0
 public Vector2 GetTouchPosition(PlayerIds id)
 {
     return(m_players[id].Touch.position);
 }