Пример #1
0
        public void Init(CompanionState state)
        {
            companionState = state;

            lockedState.sprite   = state.Data.mainScreenImage;
            unlockedState.sprite = state.Data.mainScreenImage;

            mainButton.onClick.AddListener(() =>
            {
                if (!UIManager.Instance.inputAllowed)
                {
                    return;
                }

                UIManager.Instance.GetWidget <CompanionInfoWidget>().ShowForCompanion(companionState, true);

                var ftueState = Inventory.Instance.ftueState.Value;
                if (!ftueState.GetFTUE(FTUEType.COMPANION_SELECTION1) &&
                    ftueState.needShowCompanionSelection)
                {
                    UIManager.Instance.GetWidget <MainScreenWidget>().EnableScroll(true);
                    UIManager.Instance.FTUEWidget.WithdrawFTUE();
                    ftueState.SetFTUE(FTUEType.COMPANION_SELECTION1, true);
                    Inventory.Instance.ftueState.Save();
                }
            });

            ResizeAndReposition();

            RestartNotifAnim();

            UpdateState();
        }
Пример #2
0
        public void ShowForCompanion(CompanionState companionState, bool showTalkBtn)
        {
            this.companionState = companionState;

            CompanionInfoImageTab t1 = (CompanionInfoImageTab)tabController.tabs[0];

            t1.Populate(companionState.Data);

            CompanionInfoInfoTab t2 = (CompanionInfoInfoTab)tabController.tabs[1];

            t2.Populate(companionState.Data);

            talkBtn.gameObject.SetActive(showTalkBtn);

            Show(() =>
            {
                var ftueState = Inventory.Instance.ftueState.Value;
                if (!ftueState.GetFTUE(FTUEType.COMPANION_SELECTION_INFO_TAB) &&
                    ftueState.needShowCompanionSelection)
                {
                    UIManager.Instance.FTUEWidget.Show();
                    UIManager.Instance.FTUEWidget.PresentFTUE(tabController.tabToggles[1].gameObject, FTUEType.COMPANION_SELECTION_INFO_TAB);
                }
                else if (!ftueState.GetFTUE(FTUEType.COMPANION_SELECTION2) &&
                         ftueState.needShowCompanionSelection)
                {
                    UIManager.Instance.FTUEWidget.Show();
                    UIManager.Instance.FTUEWidget.PresentFTUE(talkBtn.gameObject, FTUEType.COMPANION_SELECTION2);
                }
            });
        }
Пример #3
0
        public override void Execute()
        {
            CompanionState companion = Inventory.Instance.worldState.Value.GetCompanion(companionId);

            if (companion == null)
            {
                Debug.LogError($"SetCompanionNameSfStatement: failed to get companion with id {companionId}");
            }
            else
            {
                UIManager.Instance.ChatWidget.SetCompanionName(companion.Data.name);
            }
        }
Пример #4
0
 public void SetEmotion(CompanionState companion, string emotionName)
 {
     if (emotionName != "unexistent")
     {
         var e = companion.Data.GetEmotion(emotionName);
         companionImage.sprite = e.sprite;
         companionImage.color  = Color.white;
     }
     else
     {
         companionImage.sprite = null;
         companionImage.color  = transparentColor;
     }
 }
        protected override void Setup()
        {
            toParse = new List <Passage>();
            // if (!Inventory.Instance.worldState.Value.companionJsonsLoaded)
            // {
            for (int j = 0; j < Inventory.Instance.worldState.Value.companionStates.Count; j++)
            {
                currentCompanion = Inventory.Instance.worldState.Value.companionStates[j];

                if (!currentCompanion.Data.enabled)
                {
                    continue;
                }

                for (int i = 0; i < currentCompanion.Data.dialogueJsons.Count; i++)
                {
                    Debug.Log($"~~~ Parsing {currentCompanion.id.ToString()} dialogue {i}");
                    TwineRoot root = JsonConvert.DeserializeObject <TwineRoot>(currentCompanion.Data.dialogueJsons[i].text);
                    root.PostDeserialize();
                    ConvertToSnowflake(root);
                    currentCompanion.dialogues[i].root = root;
                }
            }

            // Inventory.Instance.worldState.Value.companionJsonsLoaded = true;

            Inventory.Instance.worldState.Value.advicesLoaded = true;
            Inventory.Instance.worldState.Save();
            // }
            // else
            // {
            //     foreach (var compState in Inventory.Instance.worldState.Value.companionStates)
            //     {
            //         if (!compState.Data.enabled)
            //         {
            //             continue;
            //         }
            //
            //         for (int i = 0; i < compState.dialogues.Count; i++)
            //         {
            //             TwineRoot tr = compState.dialogues[i].root;
            //             for (int j = 0; j < tr.passages.Count; j++)
            //             {
            //                 tr.passages[j].RegenerateLinks(tr);
            //             }
            //         }
            //     }
            // }
        }
Пример #6
0
 public void SetEmotionAndName(CompanionState companion, string emotionName)
 {
     SetCompanionName(companion.Data.name);
     SetEmotion(companion, emotionName);
 }
Пример #7
0
        public override void Show(Action onComplete = null)
        {
            base.Show(onComplete);

            if (firstTimeShown)
            {
                StartCoroutine(GradualInit());

                firstTimeShown = false;
            }

            savePath              = true;
            executeStatements     = true;
            soundEnabled          = true;
            currentStatement      = null;
            currentStatementIndex = -1;

            var newCompanion = Inventory.Instance.worldState.Value.GetCompanion(Inventory.Instance.currentCompanion.Value);

            if (currentCompanion == null || newCompanion.Data.id != currentCompanion.Data.id || currentCompanion.lastDialogueTaken != currentCompanion.activeDialogue)
            {
                dialogueIsBuilt = false;
                ResetScreen();
            }

            var lm = LayoutManager.Instance;

            currentCompanion = newCompanion;

            companionNameText.fontSize = 1.25f * lm.esw;

            currentCompanion.lastDialogueTaken = currentCompanion.activeDialogue;
            currentDialog = currentCompanion.activeDialogue;

            // screenWidth = UIManager.Instance.canvasRectTransform.rect.size.x;
            // em = screenWidth / 25f;
            // margins = new Vector4(em, 0.5f * em, em, 0.5f * em);
            typingText.fontSize = 0.75f * lm.esw;

            SFDialogue dialogue = currentCompanion.dialogues[currentCompanion.activeDialogue];
            var        path     = dialogue.path;

            // we either talked to some companion, went back and entered another companion screen
            // or this is the first time we enter companion screen
            if (!dialogueIsBuilt)
            {
                time       = 0;
                timeToWait = 0;

                SetEmotionAndName(currentCompanion, "main");

                BuildPastConversation();

                // dialogue was undergoing before
                if (path.Count != 0)
                {
                    currentPassage = dialogue.root.Find(path[path.Count - 1]);

                    tempNextAvailablePassages.Clear();
                    currentPassage.GetNextAvailablePassages(ref tempNextAvailablePassages);

                    // if it is the end of the dialogue present last passage and do nothing
                    if (tempNextAvailablePassages.Count == 0)
                    {
                        savePath          = false;
                        executeStatements = false;
                        soundEnabled      = false;
                        PresentPassage();
                        savePath          = true;
                        executeStatements = true;
                        soundEnabled      = true;

                        state = State.DIALOGUE_FINISHED;
                    }
                    // if dialogue is continuing then show last line with sound effect
                    else
                    {
                        savePath          = false;
                        executeStatements = false;
                        PresentPassage();
                        savePath          = true;
                        executeStatements = true;

                        ContinueDialogue();
                    }
                }
                // dialogue is undergoing first time
                else
                {
                    currentPassage = dialogue.root.startPassage;
                    SFStatement e = currentPassage.GetStatement(SFStatement.Type.CHANGE_IMAGE);
                    if (e != null)
                    {
                        e.Execute();
                    }

                    e = currentPassage.GetStatement(SFStatement.Type.SET_COMPANION_NAME);
                    if (e != null)
                    {
                        e.Execute();
                    }

                    StartDialogue(); //blocking
                }
            }
            // else
            // {
            //     if (path.Count != 0)
            //     {
            //         StartDialogue();
            //     }
            // }
        }