示例#1
0
        /// <summary>
        ///     Save the updated information locally and online
        /// </summary>
        public void SaveChanges()
        {
            var parameters = DataParams.Build();

            var handshake = new InformationProtocol(Protocol.Data)
                            .SetHandler("finderProfileUpdate", InformationProtocol.HandlerType.Update)
                            .AddParameter("action", "update")
                            .AddParameter("name", PlayerPrefs.GetString("name"))
                            .AddParameter("uid", PlayerPrefs.GetString("uid"));

            foreach (var field in _fields)
            {
                var key   = field.name;
                var value = field.GetComponentInChildren <InputField>().text;

                if (string.IsNullOrEmpty(value))
                {
                    Warning.SetActive(true);
                    return;
                }

                if (field)
                {
                    parameters.Append(key, value);
                }
                handshake.AddParameter(key, value);
            }

            _profileTable.Update(parameters, "");
            handshake.Send();
            FindObjectOfType <ProfileManagement>().OpenView();
        }
示例#2
0
        /// <summary>
        ///     Event for the final button of the profile setup:
        ///     - Inserts the user's information into the database
        ///     - Creates a table for liked profiles
        ///     - Opens the finder screen and closes the profile setup screen
        /// </summary>
        public void Finish()
        {
            var profileSetup  = GetComponentInParent <ProfileSetup>();
            var finderProfile = new DataTable(FinderController.ProfileTable);

            finderProfile.AddProperty(new DataProperty("Name", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("Age", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("City", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("PhoneNumber", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavMovie", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavMusic", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavFood", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavSport", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavGame", DataProperty.DataPropertyType.VARCHAR));
            finderProfile.AddProperty(new DataProperty("FavVacation", DataProperty.DataPropertyType.VARCHAR));
            AppData.Instance().Registry.Register(finderProfile);

            var fields = FormContent.GetComponentsInChildren <Text>().Where(x => x.tag == "InputName");

            var handshake = new InformationProtocol(Protocol.Data)
                            .SetHandler("finderProfileUpdate", InformationProtocol.HandlerType.Update)
                            .AddParameter("action", "insert")
                            .AddParameter("name", PlayerPrefs.GetString("name"))
                            .AddParameter("uid", PlayerPrefs.GetString("uid"));

            var parameters = DataParams.Build();

            foreach (var field in fields)
            {
                var key   = field.name;
                var value = field.GetComponentInChildren <InputField>().text;

                if (string.IsNullOrEmpty(value))
                {
                    Warning.SetActive(true);
                    return;
                }

                parameters.Append(key, value);
                handshake.AddParameter(key, value);
            }

            finderProfile.Insert(parameters);
            handshake.Send(request => {
                var likeTable = new DataTable(FinderController.LikeTable);
                likeTable.AddProperty(new DataProperty("ProfileID", DataProperty.DataPropertyType.VARCHAR));
                AppData.Instance().Registry.Register(likeTable);

                profileSetup.gameObject.SetActive(false);
                profileSetup.FinderController.gameObject.SetActive(true);
            });
        }
示例#3
0
        /// <summary>
        ///     OnClick event for the hasLiked/pass buttons
        /// </summary>
        /// <param name="hasLiked"></param>
        public void NextProfile(bool hasLiked)
        {
            var likedProfiles  = FinderProfileController.LikedProfiles;
            var currentProfile = FinderProfileController.GetCurrentProfile();

            if (hasLiked && !likedProfiles.Contains(currentProfile))
            {
                likedProfiles.Add(currentProfile);
                AppData.Instance().Registry.Fetch(LikeTable)
                .Insert(DataParams.Build("ProfileID", currentProfile.ProfileInfo.PlayerUID));
            }
            FinderProfileController.NextProfile();
            UpdateUI();
        }
        private void AddRewards()
        {
            DataSource.Create();

            AppData.Instance().MannyAttribute.IncrementAttribute(Attribute.Coins, _prizeController.CurrentPrize);
            AppData.Instance().MannyAttribute.IncrementAttribute(Attribute.Experience, _experience);
            AppData.Instance().MannyAttribute.Save();

            DataSource.Insert(DataParams.Build("Won", _won ? 1 : 0)
                              .Append("CorrectAnswers", _questionController.CurrentQuestionIndex)
                              .Append("Prize", _prizeController.CurrentPrize).Append("Experience", _experience)
                              .Append("TimePlayedSeconds", Time.time));
            Tracking.RequestSend();
        }
示例#5
0
        /// <summary>
        ///     shuts down game and returns to menu
        /// </summary>
        public override void OnUnload()
        {
            var coins = Mathf.RoundToInt(GameScore * 36 / 1080f);

            coins = coins <= 0 ? 0 : coins;

            AppData.Instance().MannyAttribute.IncrementAttribute(Attribute.Coins, coins);

            var experience = GameScore * 30 / 1080;

            experience = experience <= 0 ? 0 : experience;

            AppData.Instance().MannyAttribute.IncrementAttribute(Attribute.Experience, experience);
            AppData.Instance().MannyAttribute.Save();

            DataSource.Insert(DataParams.Build("Points", GameScore).Append("ExperienceGained", experience)
                              .Append("Coins", coins).Append("LogosCaught", LogosCaught).Append("FakeLogosCaught", FakeLogosCaught)
                              .Append("TimePlayedSeconds", Time.time));
            Tracking.RequestSend();
        }