Ejemplo n.º 1
0
        void RandomizeAppearance()
        {
            float rnd0 = UnityEngine.Random.value;
            float rnd1 = UnityEngine.Random.value;
            float rnd2 = UnityEngine.Random.value;
            float rnd3 = UnityEngine.Random.value;
            var   rndPlayerIconData = new PlayerIconData(Uuid = "",
                                                         UnityEngine.Random.Range(0, 7),
                                                         PlayerTint.Blue,
                                                         PlayerGender.M,
                                                         UnityEngine.Random.ColorHSV(),
                                                         UnityEngine.Random.ColorHSV(),
                                                         UnityEngine.Random.ColorHSV(),
                                                         rnd0 <= 0.5f,
                                                         rnd1 <= 0.5f,
                                                         rnd2 <= 0.5f,
                                                         rnd3 <= 0.5f,
                                                         new JourneyPosition(UnityEngine.Random.Range(1, 6), UnityEngine.Random.Range(1, 15), 1),
                                                         AppEditions.LearnEnglish,
                                                         "TEST");

            SetAppearance(rndPlayerIconData,
                          rnd2 < 0.33f ? EndgameState.Unfinished : rnd2 < 0.66f ? EndgameState.Finished : EndgameState.FinishedWAllStars
                          );
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deletes the player profile.
        /// </summary>
        /// <param name="playerUUID">The player UUID.</param>
        /// <returns></returns>
        public PlayerProfile DeletePlayerProfile(string playerUUID)
        {
            PlayerProfile returnProfile = new PlayerProfile();

            // it prevents errors if rewards unlock coroutine is still running
            AppManager.I.StopAllCoroutines();
            // TODO: check if is necessary to hard delete DB
            PlayerIconData playerIconData = GetPlayersIconData().Find(p => p.Uuid == playerUUID);

            if (playerIconData.Uuid == string.Empty)
            {
                return(null);
            }
            // if setted as active player in gamesettings remove from it
            if (playerIconData.Uuid == AppManager.I.AppSettings.LastActivePlayerUUID)
            {
                // if possible set the first available player...
                PlayerIconData newActivePlayerIcon = GetPlayersIconData().Find(p => p.Uuid != playerUUID);
                if (newActivePlayerIcon.Uuid != null)
                {
                    AppManager.I.PlayerProfileManager.SetPlayerAsCurrentByUUID(newActivePlayerIcon.Uuid);
                }
                else
                {
                    // ...else set to null
                    AppManager.I.PlayerProfileManager._currentPlayer = null;
                }
            }
            AppManager.I.AppSettings.SavedPlayers.Remove(playerIconData);

            AppManager.I.AppSettingsManager.SaveSettings();
            return(returnProfile);
        }
Ejemplo n.º 3
0
        public PlayerIconData GetPlayerIconData()
        {
            PlayerIconData returnIconData = new PlayerIconData()
            {
                Uuid                             = this.Uuid,
                AvatarId                         = this.AvatarId,
                Gender                           = this.Gender,
                Tint                             = this.Tint,
                IsDemoUser                       = this.IsDemoUser,
                HasFinishedTheGame               = this.HasFinishedTheGame,
                HasFinishedTheGameWithAllStars   = this.HasFinishedTheGameWithAllStars,
                HasMaxStarsInCurrentPlaySessions = this.HasMaxStarsInCurrentPlaySessions,
                MaxJourneyPosition               = this.MaxJourneyPosition
            };

            return(returnIconData);
        }
Ejemplo n.º 4
0
        public void Init(PlayerIconData playerIconData)
        {
            if (levelLabelRT == null)
            {
                levelLabelRT         = LevelLabel.GetComponent <RectTransform>();
                orLevelLabelPosition = levelLabelRT.anchoredPosition;
            }
            Uuid = playerIconData.Uuid;
            //Debug.Log("playerIconData " + playerIconData.Uuid + " " + playerIconData.Gender + " " + playerIconData.AvatarId + " " + playerIconData.Tint + " " + playerIconData.IsDemoUser + " > " + playerIconData.HasFinishedTheGame + "/" + playerIconData.HasFinishedTheGameWithAllStars);
            EndgameState endgameState = playerIconData.HasFinishedTheGameWithAllStars
                ? EndgameState.FinishedWAllStars
                : playerIconData.HasFinishedTheGame
                    ? EndgameState.Finished
                    : EndgameState.Unfinished;

            SetAppearance(playerIconData, endgameState);
        }
Ejemplo n.º 5
0
        void RandomizeAppearance()
        {
            float rnd0 = UnityEngine.Random.value;
            float rnd1 = UnityEngine.Random.value;
            float rnd2 = UnityEngine.Random.value;
            float rnd3 = UnityEngine.Random.value;
            var   rndPlayerIconData = new PlayerIconData(Uuid = "",
                                                         UnityEngine.Random.Range(1, 5),
                                                         rnd0 <= 0.5f ? PlayerGender.F : PlayerGender.M,
                                                         (PlayerTint)UnityEngine.Random.Range(1, 8),
                                                         rnd1 <= 0.2f,
                                                         rnd3 <= 0.5f,
                                                         rnd3 <= 0.5f,
                                                         rnd3 <= 0.5f,
                                                         new JourneyPosition(UnityEngine.Random.Range(1, 6), UnityEngine.Random.Range(1, 15), 1));

            SetAppearance(rndPlayerIconData,
                          rnd2 < 0.33f ? EndgameState.Unfinished : rnd2 < 0.66f ? EndgameState.Finished : EndgameState.FinishedWAllStars
                          );
        }
Ejemplo n.º 6
0
        void SetAppearance(PlayerIconData playerIconData, EndgameState endgameState)
        {
            if (playerIconData.Gender == PlayerGender.None)
            {
                Debug.LogWarning("Player gender set to NONE");
            }
            Color color = playerIconData.IsDemoUser ? new Color(0.4117647f, 0.9254903f, 1f, 1f) : PlayerTintConverter.ToColor(playerIconData.Tint);

            UIButton.Ico = IconImage;   // forced icon
            UIButton.ChangeDefaultColors(color, color.SetAlpha(0.5f));
            UIButton.Ico.sprite = playerIconData.IsDemoUser
                ? Resources.Load <Sprite>(AppConfig.RESOURCES_DIR_AVATARS + "god")
                : Resources.Load <Sprite>(AppConfig.RESOURCES_DIR_AVATARS + (playerIconData.Gender == PlayerGender.None ? "M" : playerIconData.Gender.ToString()) +
                                          playerIconData.AvatarId);
            bool hasHat = endgameState != EndgameState.Unfinished;

            HatImage.gameObject.SetActive(hasHat);
            levelLabelRT.anchoredPosition = hasHat ? orLevelLabelPosition + new Vector2(0, LevelLabelHatShift) : orLevelLabelPosition;

            switch (endgameState)
            {
            case EndgameState.Finished:
                HatImage.sprite = EndgameHat;
                break;

            case EndgameState.FinishedWAllStars:
                HatImage.sprite = EndgameHatWStars;
                break;
            }
            if (HideLevel || hasHat)
            {
                LevelLabel.text = "";
            }
            else
            {
                LevelLabel.text = playerIconData.MaxJourneyPosition.Stage.ToString() + "-" + playerIconData.MaxJourneyPosition.LearningBlock.ToString();
            }

            // Debug.Log("hasMaxStarsInCurrentPlaySessions: " + hasMaxStarsInCurrentPlaySessions);
            HighlightImage.SetActive(playerIconData.HasMaxStarsInCurrentPlaySessions);
        }
Ejemplo n.º 7
0
        void SetAppearance(PlayerIconData playerIconData, EndgameState endgameState)
        {
//            if (playerIconData.Gender == PlayerGender.None) {
//                Debug.LogWarning("Player gender set to NONE");
//            }
            isDemoUser = playerIconData.IsDemoUser;
            Color color = isDemoUser ? new Color(0.4117647f, 0.9254903f, 1f, 1f) : playerIconData.BgColor;

//            UIButton.Ico = FaceImg;   // forced icon
//            UIButton.ChangeDefaultColors(color, color.SetAlpha(0.5f));

            if (isDemoUser)
            {
                FaceImg.sprite = Resources.Load <Sprite>($"{AppConfig.RESOURCES_DIR_AVATARS}god");
                HairImg.sprite = null;
            }
            else
            {
                if (playerIconData.IsOldAvatar)
                {
                    color          = PlayerTintConverter.ToColor(playerIconData.Tint);
                    FaceImg.sprite = Resources.Load <Sprite>(AppConfig.RESOURCES_DIR_AVATARS + (playerIconData.Gender == PlayerGender.None ? "M" : playerIconData.Gender.ToString()) + playerIconData.AvatarId);
                }
                else
                {
                    FaceImg.sprite = Resources.Load <Sprite>($"{AppConfig.RESOURCES_DIR_AVATARS}AvatarV2_{(playerIconData.NewAvatarId + 1)}_face");
                    HairImg.sprite = Resources.Load <Sprite>($"{AppConfig.RESOURCES_DIR_AVATARS}AvatarV2_{(playerIconData.NewAvatarId + 1)}_hair");
                }
            }

            UIButton.ChangeDefaultColors(color, color.ChangeSaturation(0.35f));

            defFaceColor = FaceImg.color = (isDemoUser || playerIconData.IsOldAvatar) ? Color.white : playerIconData.SkinColor;
            if (HairImg.sprite != null)
            {
                defHairColor = HairImg.color = playerIconData.HairColor;
            }
            HairImg.gameObject.SetActive(!isDemoUser && !playerIconData.IsOldAvatar);
            bool hasHat = endgameState != EndgameState.Unfinished;

            HatImage.gameObject.SetActive(hasHat);
            HatImage.color = HatImage.color.SetAlpha(1);
            levelLabelRT.anchoredPosition = hasHat ? orLevelLabelPosition + new Vector2(0, LevelLabelHatShift) : orLevelLabelPosition;

            switch (endgameState)
            {
            case EndgameState.Finished:
                HatImage.sprite = EndgameHat;
                break;

            case EndgameState.FinishedWAllStars:
                HatImage.sprite = EndgameHatWStars;
                break;
            }
            if (HideLevel || hasHat)
            {
                LevelLabel.text = "";
            }
            else
            {
                LevelLabel.text = $"{playerIconData.MaxJourneyPosition.Stage}-{playerIconData.MaxJourneyPosition.LearningBlock}";
            }

            // Debug.Log("hasMaxStarsInCurrentPlaySessions: " + hasMaxStarsInCurrentPlaySessions);
            HighlightImage.SetActive(playerIconData.HasMaxStarsInCurrentPlaySessions);

            //            if (playerIconData.Gender == PlayerGender.None) {
            //                Debug.LogWarning("Player gender set to NONE");
            //            }
            //            Color color = isDemoUser ? new Color(0.4117647f, 0.9254903f, 1f, 1f) : PlayerTintConverter.ToColor(playerIconData.Tint);
            //            UIButton.Ico = IconImage;   // forced icon
            //            UIButton.ChangeDefaultColors(color, color.SetAlpha(0.5f));
            //            UIButton.Ico.sprite = isDemoUser
            //                ? Resources.Load<Sprite>(AppConfig.RESOURCES_DIR_AVATARS + "god")
            //                : Resources.Load<Sprite>(AppConfig.RESOURCES_DIR_AVATARS + (playerIconData.Gender == PlayerGender.None ? "M" : playerIconData.Gender.ToString()) +
            //                                         playerIconData.AvatarId);
            //            bool hasHat = endgameState != EndgameState.Unfinished;
            //            HatImage.gameObject.SetActive(hasHat);
            //            levelLabelRT.anchoredPosition = hasHat ? orLevelLabelPosition + new Vector2(0, LevelLabelHatShift) : orLevelLabelPosition;
            //
            //            switch (endgameState) {
            //                case EndgameState.Finished:
            //                    HatImage.sprite = EndgameHat;
            //                    break;
            //                case EndgameState.FinishedWAllStars:
            //                    HatImage.sprite = EndgameHatWStars;
            //                    break;
            //            }
            //            if (HideLevel || hasHat) {
            //                LevelLabel.text = "";
            //            } else {
            //                LevelLabel.text = playerIconData.MaxJourneyPosition.Stage.ToString() + "-" + playerIconData.MaxJourneyPosition.LearningBlock.ToString();
            //            }
            //
            //            // Debug.Log("hasMaxStarsInCurrentPlaySessions: " + hasMaxStarsInCurrentPlaySessions);
            //            HighlightImage.SetActive(playerIconData.HasMaxStarsInCurrentPlaySessions);
        }