示例#1
0
        public void Init(BookPanel _manager, WordInfo _info)
        {
            info    = _info;
            manager = _manager;

            if (info.unlocked || AppManager.I.GameSettings.CheatSuperDogMode)
            {
                LockIcon.enabled = false;
            }
            else
            {
                LockIcon.enabled = true;
            }

            Title.text    = info.data.Arabic;
            SubTitle.text = info.data.Id;

            if (info.data.Drawing != "")
            {
                Drawing.text = AppManager.I.Teacher.wordHelper.GetWordDrawing(info.data);
                if (info.data.Category == Db.WordDataCategory.Color)
                {
                    Drawing.SetColor(GenericUtilities.GetColorFromString(info.data.Value));
                }
                //GetComponent<Image>().color = Color.green;
            }
            else
            {
                Drawing.text = "";
            }
        }
 /// <summary>
 /// Prepares the string for display (say from Arabic into TMPro Text
 /// </summary>
 /// <returns>The string for display.</returns>
 /// <param name="">.</param>
 public static string PrepareArabicStringForDisplay(string str, bool reversed = true)
 {
     if (reversed)
     {
         // needed to be set in a TMPro RTL text
         return(GenericUtilities.ReverseText(ArabicFixer.Fix(str, true, true)));
     }
     return(ArabicFixer.Fix(str, true, true));
 }
示例#3
0
        public void Init(ILivingLetterData _data, string text, DropContainer _dropContainer)
        {
            DropContain = _dropContainer;
            Data        = _data;

            LetterLable.font = normalFont;
            LetterLable.text = GenericUtilities.ReverseText(text);
            DrawText.gameObject.SetActive(false);

            AreaState = State.disabled;
        }
示例#4
0
        void WordsPanel(WordDataCategory _category = WordDataCategory.None)
        {
            ListPanel.SetActive(true);
            Submenu.SetActive(true);
            ListWidePanel.SetActive(false);
            currentWordCategory = _category;

            List <WordData> list;

            switch (currentWordCategory)
            {
            case WordDataCategory.None:
                //list = AppManager.I.DB.GetAllWordData();
                list = new List <WordData>();
                break;

            default:
                list = AppManager.I.DB.FindWordData((x) => (x.Category == currentWordCategory && x.Article == WordDataArticle.None && x.Kind == WordDataKind.Noun));
                break;
            }
            emptyListContainers();

            List <WordInfo> info_list = AppManager.I.Teacher.scoreHelper.GetAllWordInfo();

            foreach (var info_item in info_list)
            {
                if (list.Contains(info_item.data))
                {
                    btnGO = Instantiate(WordItemPrefab);
                    btnGO.transform.SetParent(ElementsContainer.transform, false);
                    btnGO.GetComponent <ItemWord>().Init(this, info_item);
                }
            }
            Drawing.text = "";

            //btnGO = Instantiate(CategoryItemPrefab);
            //btnGO.transform.SetParent(SubmenuContainer.transform, false);
            //btnGO.GetComponent<MenuItemCategory>().Init(this, new GenericCategoryData { Id = WordDataCategory.None.ToString(), Title = "All" });

            foreach (WordDataCategory cat in GenericUtilities.SortEnums <WordDataCategory>())
            {
                btnGO = Instantiate(CategoryItemPrefab);
                btnGO.transform.SetParent(SubmenuContainer.transform, false);
                btnGO.GetComponent <MenuItemCategory>().Init(
                    this,
                    new GenericCategoryData {
                    area         = PlayerBookPanel.BookWords,
                    wordCategory = cat,
                    Id           = cat.ToString(),
                    Title        = LocalizationManager.GetWordCategoryTitle(cat)
                });
            }
        }
 void SetRewardsGos()
 {
     for (int i = 0; i < RewardsGos.Length; ++i)
     {
         GameObject go = RewardsGos[i];
         if (go.transform.childCount == 0)
         {
             continue;
         }
         go.SetLayerRecursive(GenericUtilities.LayerMaskToIndex(RewardsGosLayer));
         CameraHelper.FitRewardToUICamera(go.transform.GetChild(0), RewardsCams[i], true);
     }
 }
示例#6
0
        string FormatCredits(string _txt)
        {
            // Format
            string lv0 = "<size=" + Level0FontPerc + "%><color=#" + GenericUtilities.ColorToHex(Level0Color) + ">";
            string lv1 = "<size=" + Level1FontPerc + "%><color=#" + GenericUtilities.ColorToHex(Level1Color) + ">";

            _txt = _txt.Replace("[0]", lv0);
            _txt = _txt.Replace("[0E]", "</color></size>");
            _txt = _txt.Replace("[1]", lv1);
            _txt = _txt.Replace("[1E]", "</color></size>");
            // Fix missing characters
            _txt = _txt.Replace("ö", "o");

            return(_txt);
        }
        void InitUI()
        {
            GameObject btnGO;

            //// MUSIC
            foreach (Transform t in PanelMusic.transform)
            {
                Destroy(t.gameObject);
            }

            btnGO = Instantiate(PlayButtonPrefab);
            btnGO.transform.SetParent(PanelMusic.transform, false);
            btnGO.GetComponentInChildren <Text>().text = "Stop Music";
            btnGO.GetComponent <Button>().onClick.AddListener(StopMusic);

            foreach (Music mus in GenericUtilities.SortEnums <Music>())
            {
                //Debug.Log(mus.ToString());
                btnGO = Instantiate(PlayButtonPrefab);
                btnGO.transform.SetParent(PanelMusic.transform, false);
                btnGO.GetComponentInChildren <Text>().text = mus.ToString();
                AddListenerMusic(btnGO.GetComponent <Button>(), mus);
            }

            ///// SFX

            foreach (Transform t in PanelSfx.transform)
            {
                Destroy(t.gameObject);
            }

            btnGO = Instantiate(PlayButtonPrefab);
            btnGO.transform.SetParent(PanelSfx.transform, false);
            btnGO.GetComponentInChildren <Text>().text = "Stop Sfx";
            btnGO.GetComponent <Button>().onClick.AddListener(StopCurrentSfx);

            foreach (Sfx sfx in GenericUtilities.SortEnums <Sfx>())
            {
                //Debug.Log(sfx.ToString());
                btnGO = Instantiate(PlayButtonPrefab);
                btnGO.transform.SetParent(PanelSfx.transform, false);
                btnGO.GetComponentInChildren <Text>().text = sfx.ToString();
                AddListenerSfx(btnGO.GetComponent <Button>(), sfx);
            }

            ///// DIALOG

            foreach (Transform t in PanelLocalization.transform)
            {
                Destroy(t.gameObject);
            }

            btnGO = Instantiate(PlayButtonPrefab);
            btnGO.transform.SetParent(PanelLocalization.transform, false);
            btnGO.GetComponentInChildren <Text>().text = "Stop Dialog";
            btnGO.GetComponent <Button>().onClick.AddListener(StopCurrentLocalization);

            foreach (var loc in AppManager.I.DB.GetAllLocalizationData())
            {
                //Debug.Log(sfx.ToString());
                btnGO = Instantiate(PlayButtonPrefab);
                btnGO.transform.SetParent(PanelLocalization.transform, false);
                btnGO.GetComponentInChildren <Text>().text = loc.GetId();
                AddListenerLocalization(btnGO.GetComponent <Button>(), loc.GetId());
            }
        }
示例#8
0
        void OnEnable()
        {
            InfoTable.Reset();
            InfoTable.AddRow("لاعب", AppManager.I.Player.Id.ToString(), "player id");
            InfoTable.AddRow("لاعب", AppManager.I.Player.CurrentJourneyPosition.ToString(), "current LB");

            //var str = "";

            //str = "hello player (ID: " + AppManager.I.Player.Id + ")\n";
            //str += "you're now in LB " + AppManager.I.Player.CurrentJourneyPosition + "\n";
            //str += "your max LB is " + AppManager.I.Player.MaxJourneyPosition + "\n";
            //str += "Mood " + AppManager.I.Player.MainMood + "\n";

            //if (AppManager.I.Player.Precision != 0f) { str += "Precision " + AppManager.I.Player.Precision + "\n"; }
            //if (AppManager.I.Player.Reaction != 0f) { str += "Reaction " + AppManager.I.Player.Reaction + "\n"; }
            //if (AppManager.I.Player.Memory != 0f) { str += "Memory " + AppManager.I.Player.Memory + "\n"; }
            //if (AppManager.I.Player.Logic != 0f) { str += "Logic " + AppManager.I.Player.Logic + "\n"; }
            //if (AppManager.I.Player.Rhythm != 0f) { str += "Rhythm " + AppManager.I.Player.Rhythm + "\n"; }
            //if (AppManager.I.Player.Musicality != 0f) { str += "Musicality " + AppManager.I.Player.Musicality + "\n"; }
            //if (AppManager.I.Player.Sight != 0f) { str += "Sight " + AppManager.I.Player.Sight + "\n"; }

            // Number of play sessions
            var allPlaySessionInfos      = AppManager.I.Teacher.scoreHelper.GetAllPlaySessionInfo();
            var unlockedPlaySessionInfos = allPlaySessionInfos.FindAll(x => x.unlocked);

            //str += "Play sessions unlocked: " + unlockedPlaySessionInfos.Count + "\n";
            InfoTable.AddRow("لاعب", unlockedPlaySessionInfos.Count.ToString(), "Play sessions unlocked");

            // Total elapsed time
            var                db        = AppManager.I.DB;
            var                tableName = db.GetTableName <LogInfoData>();
            string             query     = "select * from \"" + tableName + "\"";
            List <LogInfoData> list      = db.FindLogInfoDataByQuery(query);

            System.TimeSpan totalTimespan  = new System.TimeSpan(0);
            bool            foundStart     = false;
            int             startTimestamp = 0;
            int             endTimestamp   = 0;

            foreach (var infoData in list)
            {
                if (!foundStart && infoData.Event == InfoEvent.AppStarted)
                {
                    startTimestamp = infoData.Timestamp;
                    foundStart     = true;
                }
                else if (foundStart && infoData.Event == InfoEvent.AppClosed)
                {
                    endTimestamp = infoData.Timestamp;
                    foundStart   = false;

                    var deltaTimespan = GenericUtilities.FromTimestamp(endTimestamp) - GenericUtilities.FromTimestamp(startTimestamp);
                    totalTimespan += deltaTimespan;
                    //Debug.Log("TIME FOUND:"  + deltaTimespan.Days + " days " + deltaTimespan.Hours + " hours " + deltaTimespan.Minutes + " minutes " + deltaTimespan.Seconds + " seconds");
                }
            }
            var timeElapsed = totalTimespan.Days + "d " + totalTimespan.Hours + "h " + totalTimespan.Minutes + "m " + totalTimespan.Seconds + "s";

            InfoTable.AddRow("لاعب", timeElapsed, "Total time elapsed");


            //AppManager.I.DB.GetLocalizationDataById("Game_Title").Arabic;
            //output.text += "\n" + AppManager.I.DB.GetLocalizationDataById("Game_Title2").Arabic;

            journeyGraph.Show(allPlaySessionInfos, unlockedPlaySessionInfos);

            playerAvatar.sprite = AppManager.I.Player.GetAvatar();
        }
        /// <summary>
        /// Called when [model changed].
        /// </summary>
        void OnModelChanged()
        {
            if (Data == null)
            {
                ImageSprite.enabled = false;
                Drawing.enabled     = false;
                Label.enabled       = false;
            }
            else
            {
                if (Data.DataType == LivingLetterDataType.Image)
                {
                    Drawing.text    = Data.DrawingCharForLivingLetter;
                    Drawing.enabled = true;

                    LL_ImageData data = (LL_ImageData)Data;
                    if (data.Data.Category == Db.WordDataCategory.Color)
                    {
                        Drawing.color = GenericUtilities.GetColorFromString(data.Data.Value);
                    }
                    else
                    {
                        Drawing.color = Color.black;
                    }

                    //ImageSprite.sprite = Data.DrawForLivingLetter;
                    //ImageSprite.enabled = true;
                    Label.enabled = false;
                }
                else
                {
                    ImageSprite.enabled = false;
                    Drawing.enabled     = false;
                    Label.enabled       = true;

                    // Scale modification
                    switch (data.DataType)
                    {
                    case LivingLetterDataType.Word:
                        Label.text = Data.TextForLivingLetter;
                        Scale      = 1.3f;
                        break;

                    case LivingLetterDataType.Phrase:
                        Label.text = Data.TextForLivingLetter;
                        Scale      = 2f;
                        break;

                    case LivingLetterDataType.Letter:
                        Label.text = Data.TextForLivingLetter;
                        Scale      = 1f;
                        break;

                    default:
                        Label.text = Data.TextForLivingLetter;
                        Scale      = 1f;
                        break;
                    }
                }
            }
        }
        void SelectReward(RewardItem _rewardData)
        {
            showSwatchesTween.Rewind();
            bool isTextureOrDecal = currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Texture ||
                                    currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Decal;

            BTRemoveMods.gameObject.SetActive(!isTextureOrDecal && _rewardData != null);
            if (_rewardData == null)
            {
                foreach (AnturaSpaceItemButton item in btsItems)
                {
                    item.Toggle(false);
                }
                if (currCategory == AnturaSpaceCategoryButton.AnturaSpaceCategory.Ears)
                {
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory("EAR_L");
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory("EAR_R");
                }
                else
                {
                    AnturaModelManager.Instance.ClearLoadedRewardInCategory(currCategory.ToString());
                }
                return;
            }

            foreach (AnturaSpaceItemButton item in btsItems)
            {
                item.Toggle(item.Data == _rewardData);
            }
            currSwatchesDatas = RewardSystemManager.SelectRewardItem(_rewardData.ID, currRewardType);
            if (currSwatchesDatas.Count == 0)
            {
                Debug.Log("No color swatches for the selected reward!");
                return;
            }

            // Hide non-existent swatches
            for (int i = currSwatchesDatas.Count - 1; i < btsSwatches.Length; ++i)
            {
                btsSwatches[i].gameObject.SetActive(false);
            }
            // Setup and show swatches
            RewardColorItem selectedSwatchData = null;

            for (int i = 0; i < currSwatchesDatas.Count; ++i)
            {
                RewardColorItem         swatchData = currSwatchesDatas[i];
                AnturaSpaceSwatchButton swatch     = btsSwatches[i];
                swatch.gameObject.SetActive(true);
                swatch.Data = swatchData;
                if (swatchData != null)
                {
                    swatch.SetAsNew(swatchData.IsNew);
                    swatch.Toggle(swatchData.IsSelected);
                    swatch.SetColors(GenericUtilities.HexToColor(swatchData.Color1RGB), GenericUtilities.HexToColor(swatchData.Color2RGB));
                    if (swatchData.IsSelected)
                    {
                        selectedSwatchData = swatchData;
                    }
                }
                else
                {
                    swatch.Toggle(false);
                }
                swatch.Lock(swatchData == null);
            }

            SwatchesContainer.gameObject.SetActive(true);
            showSwatchesTween.PlayForward();

            // Select eventual color
            if (selectedSwatchData != null)
            {
                SelectSwatch(selectedSwatchData);
            }
        }
        IEnumerator CO_SelectCategory(AnturaSpaceCategoryButton.AnturaSpaceCategory _category)
        {
            BTRemoveMods.gameObject.SetActive(false);

            // Get rewards list
            currCategory   = _category;
            currRewardType = CategoryToRewardType(_category);
            bool useImages = _category == AnturaSpaceCategoryButton.AnturaSpaceCategory.Texture || _category == AnturaSpaceCategoryButton.AnturaSpaceCategory.Decal;

            foreach (AnturaSpaceItemButton item in btsItems)
            {
                item.SetImage(!useImages);
            }
            if (_category == AnturaSpaceCategoryButton.AnturaSpaceCategory.Ears)
            {
                currRewardDatas = RewardSystemManager.GetRewardItemsByRewardType(currRewardType, rewardsContainers, "EAR_L");
                List <Transform> altRewardContainers = new List <Transform>(rewardsContainers);
                altRewardContainers.RemoveRange(0, currRewardDatas.Count);
                currRewardDatas.AddRange(RewardSystemManager.GetRewardItemsByRewardType(currRewardType, altRewardContainers, "EAR_R"));
            }
            else
            {
                currRewardDatas = RewardSystemManager.GetRewardItemsByRewardType(currRewardType, useImages ? rewardsImagesContainers : rewardsContainers, _category.ToString());
            }
            yield return(null);

            // Hide non-existent items
            for (int i = currRewardDatas.Count - 1; i < btsItems.Length; ++i)
            {
                btsItems[i].gameObject.SetActive(false);
            }
            // Setup and show items
            RewardItem selectedRewardData = null;

            for (int i = 0; i < currRewardDatas.Count; ++i)
            {
                RewardItem            rewardData = currRewardDatas[i];
                AnturaSpaceItemButton item       = btsItems[i];
                item.gameObject.SetActive(true);
                item.Data = rewardData;
                if (rewardData != null)
                {
                    if (!useImages)
                    {
                        item.RewardContainer.gameObject.SetLayerRecursive(GenericUtilities.LayerMaskToIndex(RewardsLayer));
                        CameraHelper.FitRewardToUICamera(item.RewardContainer.GetChild(0), item.RewardCamera, FlipRewards);
                    }
                    item.SetAsNew(rewardData.IsNew);
                    item.Toggle(rewardData.IsSelected);
                    if (rewardData.IsSelected)
                    {
                        selectedRewardData = rewardData;
                    }
                }
                else
                {
                    item.Toggle(false);
                }
                item.Lock(rewardData == null);
            }

            ItemsContainer.gameObject.SetActive(true);
            showItemsTween.PlayForward();

            // Select eventual reward
            if (selectedRewardData != null)
            {
                SelectReward(selectedRewardData);
            }
            else
            {
                showSwatchesTween.Rewind();
            }
        }