示例#1
0
    public async void StoryPracticeMode()
    {
        var text  = Resources.Load <TextAsset>("Stories/PracticeMode");
        var story = new Story(text.text);

        Resources.UnloadAsset(text);
        await DialogueOverlay.Show(story);
    }
示例#2
0
    public async void StoryIntro()
    {
        var intro = Resources.Load <TextAsset>("Stories/Intro");

        LevelSelectionScreen.HighlightedLevelId = BuiltInData.TutorialLevelId;
        var story = new Story(intro.text);

        story.variablesState["IsBeginner"] = true;
        await DialogueOverlay.Show(story);

        LevelSelectionScreen.HighlightedLevelId = null;
    }
示例#3
0
 public void SetModel(Badge badge)
 {
     this.badge = badge;
     LoadImage();
     graphicRaycaster.enabled = interactable;
     if (interactable)
     {
         onPointerClick.SetListener(_ =>
         {
             DialogueOverlay.CurrentBadge = badge;
             var story = new Story(Resources.Load <TextAsset>("Stories/Badge").text);
             DialogueOverlay.Show(story);
         });
     }
 }
示例#4
0
 public async void StoryBadge()
 {
     DialogueOverlay.CurrentBadge = new Badge
     {
         title       = "夏祭:一段",
         description = "测试\n你好\n贵阳!\n11111111111",
         type        = BadgeType.Event,
         metadata    = new Dictionary <string, object>
         {
             { "imageUrl", "http://artifacts.cytoid.io/badges/sora1.jpg" }
         }
     };
     var badge = Resources.Load <TextAsset>("Stories/Badge");
     var story = new Story(badge.text);
     await DialogueOverlay.Show(story);
 }
    public async UniTask ShowTrainingDialogue(bool isFirstMet)
    {
        var text  = Resources.Load <TextAsset>("Stories/Training");
        var story = new Story(text.text);

        Resources.UnloadAsset(text);
        story.variablesState["IsFirstMet"] = isFirstMet;
        var shouldIntroduceMechanisms = Context.Player.ShouldOneShot("Training Mode: Should Introduce Mechanisms");

        story.variablesState["ShouldIntroduceMechanisms"] = shouldIntroduceMechanisms;
        story.variablesState["SignedIn"] = Context.OnlinePlayer.IsAuthenticated;
        story.variablesState["Rating"]   = Context.OnlinePlayer.LastProfile?.Rating ?? 0;
        await DialogueOverlay.Show(story);

        if (shouldIntroduceMechanisms && (int)story.variablesState["IntroducedMechanisms"] == 0)
        {
            Context.Player.ClearOneShot("Training Mode: Should Introduce Mechanisms");
        }
    }
示例#6
0
    public async void StoryTrainingIntro()
    {
        if (running)
        {
            DialogueOverlay.TerminateCurrentStory = true;
        }
        var compiler = new Ink.Compiler(File.ReadAllText("Assets/Resources/Stories/Training.ink"));
        var story    = compiler.Compile();

        story.variablesState["IsFirstMet"] = isFirstMet;
        var shouldIntroduceMechanisms = Context.Player.ShouldOneShot("Training Mode: Should Introduce Mechanisms");

        story.variablesState["ShouldIntroduceMechanisms"] = shouldIntroduceMechanisms;
        story.variablesState["SignedIn"] = signedIn;
        story.variablesState["Rating"]   = rating;
        running = true;
        await DialogueOverlay.Show(story);

        running = false;
        if (shouldIntroduceMechanisms && (int)story.variablesState["IntroducedMechanisms"] == 0)
        {
            Context.Player.ClearOneShot("Training Mode: Should Introduce Mechanisms");
        }
    }
示例#7
0
    void OnDestroy()
    {
        if (_instance == this)
        {
            // Unflag the NPC as talking.
            if (character != null)
            {
                character.is_talking = false;
                Debug.Log("== NPC '" + character.name + "' stopped talking. ==");
            }

            _instance = null;

            is_open = false;
            strFilePath_Dialogue = null;
            arrAudioClips = null;
            character = null;
            lstEntries_Function.Clear();
            lstEntries_IfGoto.Clear();
            dictEntries_Label.Clear();
            lstEntries_Label.Clear();
            _iParseCallCount = 0;
            _bInitialized = false;
            _audioSource = null;
            _bNodeSoundPlayed = false;
            _strFilePath_Folder = null;
        }
    }
示例#8
0
    void Awake()
    {
        Debug.Log("DialogueOverlay Created");

        _instance = this;

        _bInitialized = true;
        is_open = true;

        _audioSource = gameObject.GetComponent<AudioSource>();
    }
示例#9
0
    public override async void OnScreenBecameActive()
    {
        base.OnScreenBecameActive();

        //WebViewOverlay.Show();
        if (StartupLogger.Instance != null)
        {
            StartupLogger.Instance.Dispose();
        }

        upperLeftOverlayImage.SetAlpha(Context.CharacterManager.GetActiveCharacterAsset().mainMenuUpperLeftOverlayAlpha);
        overlayImage.SetAlpha(Context.CharacterManager.GetActiveCharacterAsset().mainMenuRightOverlayAlpha);

        var levelCount = Context.LevelManager.LoadedLocalLevels.Count(it =>
                                                                      (it.Value.Type == LevelType.User || it.Value.Type == LevelType.BuiltIn) && !BuiltInData.TrainingModeLevelIds.Contains(it.Value.Id));

        freePlayText.text = "MAIN_LEVELS_LOADED".Get(levelCount);
        freePlayText.transform.RebuildLayout();

        ProfileWidget.Instance.Enter();

        if (Context.CharacterManager.GetActiveCharacterAsset().mirrorLayout)
        {
            layout.anchorMin        = new Vector2(0, 0.5f);
            layout.anchorMax        = new Vector2(0, 0.5f);
            layout.pivot            = new Vector2(0, 0.5f);
            layout.anchoredPosition = new Vector2(96, -90);
            overlayHolder.SetLeft(280);
            overlayHolder.SetRight(840);
            overlayHolder.SetLocalScaleX(-2);
        }
        else
        {
            layout.anchorMin        = new Vector2(1, 0.5f);
            layout.anchorMax        = new Vector2(1, 0.5f);
            layout.pivot            = new Vector2(1, 0.5f);
            layout.anchoredPosition = new Vector2(-96, -90);
            overlayHolder.SetLeft(840);
            overlayHolder.SetRight(280);
            overlayHolder.SetLocalScaleX(2);
        }

        // Check new events
        if (Context.IsOnline() && Context.OnlinePlayer.IsAuthenticated)
        {
            RestClient.GetArray <EventMeta>(new RequestHelper
            {
                Uri         = $"{Context.ApiUrl}/events",
                Headers     = Context.OnlinePlayer.GetRequestHeaders(),
                EnableDebug = true
            }).AbortOnScreenBecameInactive(this).Then(events =>
            {
                var hasUnseenEvent = false;
                foreach (var meta in events)
                {
                    if (Context.Player.Settings.SeenEvents.Contains(meta.uid))
                    {
                        continue;
                    }
                    hasUnseenEvent = true;
                }
                if (hasUnseenEvent)
                {
                    eventNotification.Show();
                }
            }).CatchRequestError(Debug.LogWarning);
        }

        if (Context.InitializationState.IsAfterFirstLaunch() && !LaunchedFirstLaunchDialogue)
        {
            LaunchedFirstLaunchDialogue = true;

            var text = Resources.Load <TextAsset>("Stories/Intro");
            LevelSelectionScreen.HighlightedLevelId = BuiltInData.TutorialLevelId;
            var story = new Story(text.text);
            Resources.UnloadAsset(text);
            story.variablesState["IsBeginner"] = levelCount < 10;
            await DialogueOverlay.Show(story);

            LevelSelectionScreen.HighlightedLevelId = null;
        }
        else
        {
            if (DialogueOverlay.IsShown())
            {
                await UniTask.WaitUntil(() => !DialogueOverlay.IsShown());
            }

            if (PromptCachedCharacterDataCleared)
            {
                PromptCachedCharacterDataCleared = false;
                Dialog.PromptAlert("DIALOG_CACHED_CHARACTER_DATA_CLEARED".Get());
            }

            // Check announcement
            if (!CheckedAnnouncement && Context.IsOnline())
            {
                RestClient.Get <Announcement>(new RequestHelper
                {
                    Uri         = $"{Context.ApiUrl}/announcements",
                    Headers     = Context.OnlinePlayer.GetRequestHeaders(),
                    EnableDebug = true
                }).Then(it =>
                {
                    CheckedAnnouncement = true;
                    if (it.message != null)
                    {
                        Dialog.PromptAlert(it.message);
                    }

                    var localVersion        = new Version(Context.VersionString);
                    var currentVersion      = new Version(it.currentVersion);
                    var minSupportedVersion = new Version(it.minSupportedVersion);
                    if (localVersion < minSupportedVersion)
                    {
                        Dialog.PromptUnclosable("DIALOG_UPDATE_REQUIRED".Get(),
                                                () => Application.OpenURL(Context.StoreUrl));
                        return;
                    }

                    if (localVersion < currentVersion)
                    {
                        Dialog.Prompt("DIALOG_UPDATE_AVAILABLE_X_Y".Get(currentVersion, localVersion),
                                      () => Application.OpenURL(Context.StoreUrl));
                    }
                }).CatchRequestError(Debug.LogError);
            }
        }
    }