void OnMouseDown()
 {
     if (StoryScene.OnSpeakWithActor != null)
     {
         StoryScene.OnSpeakWithActor(actorName);
     }
 }
示例#2
0
    public void InitForScene(StoryScene scene, List <string> enabledQuestions)
    {
        List <QuestionKey> responseKeys = new List <QuestionKey>();

        if (enabledQuestions != null)
        {
            foreach (string enabledQuestion in enabledQuestions)
            {
                try
                {
                    responseKeys.Add((QuestionKey)Enum.Parse(typeof(QuestionKey), enabledQuestion, true));
                }
                catch (Exception)
                {
                    Debug.LogWarning("Questionnaire.InitForScene: " + scene.Data.Key + " attempted to enable " + enabledQuestion + ", which does not exist in QuestionKey enum.");
                }
            }
        }

        foreach (Question question in RootQuestions)
        {
            question.InitForScene(scene, responseKeys, true);
        }

        foreach (QuestionnaireResponse response in Responses)
        {
            response.Reset();
        }
    }
示例#3
0
    // Use this for initialization
    public void InitForScene(StoryScene scene, List <QuestionKey> responseKeys, bool questionInitiallyActive)
    {
        if (QuestionButton != null)
        {
            HasResponseInScene = responseKeys.Contains(Key);

            if (HasResponseInScene)
            {
                QuestionButton.onClick.RemoveAllListeners();
                QuestionButton.onClick.AddListener(
                    () =>
                {
                    Questionnaire.Instance.Hide();
                    // StoryManager.Instance.JumpToStitchInKnot(scene.Data.Key, Key.ToString());

                    SetQuestionActive(false);

                    foreach (Question subQuestion in SubQuestions)
                    {
                        if (subQuestion.HasResponseInScene)
                        {
                            subQuestion.SetQuestionActive(true);
                        }
                    }
                });
            }

            foreach (Question subQuestion in SubQuestions)
            {
                subQuestion.InitForScene(scene, responseKeys, HasResponseInScene == false);
            }

            SetQuestionActive(HasResponseInScene && questionInitiallyActive);
        }
    }
        void Start()
        {
            if (DialogueBox)
            {
                DialogueBox.RegisterForOptionClickEvents(this);
                DialogueBox.RegisterForNextClickEvents(this);
            }

            StoryScene firstScene = StartingSceneOverride ? StartingSceneOverride : GameManager.Instance.GetNextScene();

            if (firstScene != null)
            {
                StartNewScene(firstScene);

                if (CharacterController)
                {
                    CharacterController.SetCharacters(LeftCharacter, RightCharacter);
                }

                GameManager.Instance.LoopMusic("background_music");
            }
            else
            {
                GameManager.Instance.StartLevelSelect();
            }
        }
 private void NextScene()
 {
     SceneNumber++;
     CurrentScene   = CurrentStory.StoryScenes[SceneNumber];
     DialogueNumber = 0;
     NextDialogue(DialogueNumber);
     StoryBackground.sprite = CurrentScene.image;
 }
示例#6
0
 protected override void InitSingletonInstance()
 {
     SceneData[] scenes = Resources.LoadAll <SceneData>(ResourcePaths.StoryEngineScenePath);
     foreach (var sceneData in scenes)
     {
         StoryScene scene = new StoryScene(sceneData);
         _sceneDictionary.Add(sceneData.Key, scene);
     }
 }
示例#7
0
            public void It_starts_with_the_first_scene()
            {
                var scene  = new StoryScene();
                var engine = An.Engine().WithScene(scene).Build();

                engine.NextScene();

                Assert.AreEqual(engine.CurrentScene, scene);
            }
示例#8
0
        static void Main(string[] args)
        {
            var playerContext = new PlayerContext();
            var firstScene    = new StoryScene();
            var engine        = new StoryEngine(playerContext, firstScene);

            while (engine.StoryStatus != StoryStatus.Ended)
            {
                var currentScene = engine.NextScene();
                while (currentScene.SceneStatus != SceneStatus.Ended)
                {
                    var currentEvent = currentScene.NextEvent();

                    switch (currentEvent)
                    {
                    case NarrativeEvent _:
                        var narrativeEvent = (NarrativeEvent)currentEvent;
                        foreach (var narrativeResult in narrativeEvent.PlayEvent())
                        {
                            Console.WriteLine(narrativeResult.Text);
                        }

                        break;

                    case ChoiceEvent _:
                        var choiceEvent = (ChoiceEvent)currentEvent;
                        Console.WriteLine("Waiting for player choice");
                        // TODO: have a foreach with index ?
                        for (var i = 0; i < choiceEvent.Choices.Count(); i++)
                        {
                            var choice = choiceEvent.Choices[i];
                            Console.WriteLine("{0}. {1}", i, choice.Text);
                        }

                        var input    = Console.ReadLine();
                        var intInput = short.Parse(input ?? throw new InvalidOperationException());
                        if (intInput > choiceEvent.Choices.Count)
                        {
                            throw new ArgumentOutOfRangeException("Choice not available !");
                        }

                        choiceEvent.Choose(choiceEvent.Choices[intInput], playerContext);
                        break;

                    case EndEvent _:
                        Console.WriteLine("Scene Ended");
                        break;

                    default:
                        throw new InvalidCastException("unexpected child class");
                    }
                }
            }

            Console.WriteLine("Story Ended");
        }
    public void Init(int StoryNumber) // Called by GameManager
    {
        StoryPanel.SetActive(true);
        CurrentStory   = Stories[StoryNumber];
        SceneNumber    = 0;
        DialogueNumber = 0;

        CurrentScene      = CurrentStory.StoryScenes[SceneNumber];
        StoryImage.sprite = CurrentScene.image;
        NextDialogue(DialogueNumber);
    }
    public void Init(int StoryNumber) // Called by GameManager
    {
        StoryCanvas.enabled = true;
        CurrentStory        = Stories[StoryNumber];
        SceneNumber         = 0;
        DialogueNumber      = 0;

        CurrentScene           = CurrentStory.StoryScenes[SceneNumber];
        StoryBackground.sprite = CurrentScene.image;
        NextDialogue(DialogueNumber);
    }
示例#11
0
 protected override void Load()
 {
     if (yirdName == YirdMain)
     {
         LoadStory(newGame);
         curType = StoryScene.MainLand;
     }
     else if (yirdName == "DienShip0")
     {
         LoadYird(newGame, StoryScene.DienShip0);
         curType = StoryScene.DienShip0;
     }
     else if (yirdName == "DienShip1")
     {
         LoadYird(newGame, StoryScene.DienShip1);
         curType = StoryScene.DienShip1;
     }
     else if (yirdName == "DienShip2")
     {
         LoadYird(newGame, StoryScene.DienShip2);
         curType = StoryScene.DienShip2;
     }
     else if (yirdName == "DienShip3")
     {
         LoadYird(newGame, StoryScene.DienShip3);
         curType = StoryScene.DienShip3;
     }
     else if (yirdName == "DienShip4")
     {
         LoadYird(newGame, StoryScene.DienShip4);
         curType = StoryScene.DienShip4;
     }
     else if (yirdName == "DienShip5")
     {
         LoadYird(newGame, StoryScene.DienShip5);
         curType = StoryScene.DienShip5;
     }
     else if (yirdName == "L1Ship")
     {
         LoadYird(newGame, StoryScene.L1Ship);
         curType = StoryScene.L1Ship;
     }
     else if (yirdName == "PajaShip")
     {
         LoadYird(newGame, StoryScene.PajaShip);
         curType = StoryScene.PajaShip;
     }
     else if (yirdName == "LaunchCenter")
     {
         LoadYird(newGame, StoryScene.LaunchCenter);
         curType = StoryScene.LaunchCenter;
     }
 }
示例#12
0
 private void Awake()
 {
     sugarline         = FindObjectOfType <SugarLineController>();
     createRequireBox  = FindObjectOfType <HandleMachine_Create>();
     destoryRequireBox = FindObjectOfType <HandleMachine_Destory>();
     stockpath         = FindObjectOfType <StockPath>();
     handleOrder       = FindObjectOfType <HandleOrder>();
     storyScene        = FindObjectOfType <StoryScene>();
     controller        = FindObjectOfType <GameController>();
     candyFloss        = FindObjectOfType <SpricalCandyFloss>();
     numOfBox          = LevelManager.amountBox;
 }
示例#13
0
 // Appelé lors d'un clic sur un des boutons d'inventaires
 public void OnInventoryItemClicked(InventoryItem item)
 {
     Debug.Log("Clic objet " + item.itemName);
     if (currentNPC != null)
     {
         currentNPC.Show(item.itemName);
     }
     else
     {
         StoryScene scene = (StoryScene)FindObjectOfType(typeof(StoryScene));
         scene.InspectInventoryItem(item);
     }
 }
示例#14
0
    public IEnumerator DisplaySceneName(StoryScene scene)
    {
        Title.text = scene.Data.Name;

        LeanTween.textAlpha(Title.rectTransform, 1.0f, TitleFadeInTime).tweenType = LeanTweenType.easeInOutQuad;

        yield return(new WaitForSeconds(TitleFadeInTime));

        yield return(new WaitForSeconds(TitleShowTime));

        LeanTween.textAlpha(Title.rectTransform, 0.0f, TitleFadeOutTime).tweenType = LeanTweenType.easeInOutQuad;

        yield return(new WaitForSeconds(TitleFadeOutTime));
    }
示例#15
0
    private bool ParseAction(StoryScene scene, string value)
    {
        value = value.Trim('.', '\n', ' ');

        string[] colonSplit = value.Split(':');

        if (string.Compare(colonSplit[0], "sync", StringComparison.OrdinalIgnoreCase) == 0)
        {
            DesiredStitch = colonSplit.Length > 1 ? colonSplit[1] : "";

            Syncing = true;

            return(true);
        }

        return(false);
    }
示例#16
0
    //Subscribe to button click event.
    public void LoadNextPart()
    {
        if (loadLine < storyData.StoryScript.Count)
        {
            //At first, load some data from array.
            storyScene = storyData.StoryScript[loadLine];
            //Do stuff here

            Debug.Log(storyScene.SceneText);

            loadLine++;
        }
        else
        {
            DisplayResult();
        }
    }
示例#17
0
    private void PlayNextScene()
    {
        StoryScene storyScene = StoryManager.Instance.GetScene(Key, _nextSceneIndex);

        _nextSceneIndex++;

        while (storyScene == null)
        {
            storyScene = StoryManager.Instance.GetScene(Key, _nextSceneIndex);
            _nextSceneIndex++;
            if (_nextSceneIndex >= 10)
            {
                Finished = true;
                return;
            }
        }

        StartCoroutine(PlaySceneCoroutine(storyScene));
    }
示例#18
0
    public void InitWithKey(CharacterKey key)
    {
        Key = key;

        StoryFeed[] _storyFeeds = FindObjectsOfType <StoryFeed>();

        foreach (StoryFeed storyFeed in _storyFeeds)
        {
            if (storyFeed.CharacterKey == key)
            {
                _storyFeed = storyFeed;
                break;
            }
        }

        TextAsset inkStoryJson = Resources.Load <TextAsset>(ResourcePaths.StoryEngineInkJsonPath);

        _inkStory = Story.CreateWithJson(inkStoryJson.text);

        StoryScene debugSceneToPlay = StoryManager.Instance.GetScene(DebugSettings.Instance.LoadIntoScene);

        if (debugSceneToPlay == null && string.IsNullOrEmpty(DebugSettings.Instance.LoadIntoScene) == false)
        {
            int i;
            if (int.TryParse(DebugSettings.Instance.LoadIntoScene, out i))
            {
                debugSceneToPlay = StoryManager.Instance.GetScene(Key, i);
                _nextSceneIndex  = i + 1;
            }
        }

        if (debugSceneToPlay != null)
        {
            StartScene(debugSceneToPlay);
        }
        else
        {
            // todo - load the first scene!
            StartScene(StoryManager.Instance.GetScene("intro"));
        }
    }
示例#19
0
 private void Start()
 {
     timeCounter     = FindObjectOfType <TimeCounter>();
     pause           = FindObjectOfType <GamePause>();
     main            = FindObjectOfType <Main>();
     audiosource     = GetComponent <AudioSource>();
     storyScene      = FindObjectOfType <StoryScene>();
     gameRequirement = FindObjectOfType <GameRequirement>();
     if (gameRequirement.isEndless)
     {
         minute = 3;
         second = 0;
         money  = 0;
     }
     else
     {
         minute = LevelManager.minute;
         second = LevelManager.second;
     }
     StartCoroutine(gameStart());
 }
示例#20
0
    //Attach button event or invoke by Mouse input(Update in other script).
    public void LoadNextPart()
    {
        if (tmpLine < storyData.StoryScript.Count)
        {
            storyScene = storyData.StoryScript[tmpLine];
            ChangeText();

            ChangeFieldImage();

            ChangeModelImage();

            if (tmpLine < storyData.StoryScript.Count - 1)
            {
                CheckNextState();
            }
            tmpLine++;
        }
        else
        {
            BackToMenu();
        }
    }
        private void StartNewScene([NotNull] StoryScene scene)
        {
            Debug.Log("Starting Scene: " + scene);
            GameManager.Instance.MarkSceneCompleted(scene);

            if (Background)
            {
                Background.SetBackground(scene.Setting);
            }

            if (CharacterController)
            {
                if (scene.ShowRightCharacter)
                {
                    CharacterController.DoIntro(DialogCharacterController.Character.Right);
                }
                else
                {
                    CharacterController.DoOutro(DialogCharacterController.Character.Right);
                }
            }

            StartNewSequence(scene.StartingDialogue);
        }
示例#22
0
 public void MarkSceneCompleted(StoryScene scene)
 {
     CompletedStoryScenes.Add(scene);
 }
示例#23
0
 public StoryEngineBuilder(StoryScene scene)
 {
     _scene = scene;
 }
示例#24
0
 public StoryEngineBuilder WithScene(StoryScene scene)
 {
     _scene = scene;
     return(this);
 }
示例#25
0
 private void StartScene(StoryScene scene)
 {
     StartCoroutine(PlaySceneCoroutine(scene));
 }
示例#26
0
    private IEnumerator PlaySceneCoroutine(StoryScene scene, float initialDelay = 0.0f)
    {
        CurrentScene = scene;
        // _storyOptionBox.ClearOptions();
        _storyFeed.ClearOptions();

        if (string.IsNullOrEmpty(scene.Data.Name) == false)
        {
            _storyFeed.Clear();
            yield return(StartCoroutine(_storyFeed.DisplaySceneName(scene)));
        }

        _inkStory.ChoosePathString(scene.Data.Key);

        {
            float timer = 0.0f;
            while (timer < initialDelay)
            {
                timer += Time.deltaTime;

                yield return(null);

                if ((StoryManager.Instance.GameplayTextMode == GameplayTextMode.ClickToContinue && Input.GetMouseButtonDown(0)) ||
#if MULTI_TOUCH_SKIP
                    (Input.touchCount > 1 && Input.GetTouch(1).phase == TouchPhase.Began) ||
#endif
                    (Application.isEditor && Input.GetMouseButtonDown(1)))
                {
                    break;
                }
            }
        }

        while (_inkStory.canContinue)
        {
            string inkLine = _inkStory.Continue();

            if (!ParseAction(scene, inkLine))
            {
                float delayTime;
                inkLine = ParseDisplayTime(inkLine, out delayTime);

                delayTime = delayTime < 0.0f ? StoryManager.Instance.DefaultEndDelay : delayTime;

                _storyFeed.DisplayLine(inkLine);

                while (_storyFeed.DisplayingLine)
                {
                    yield return(null);
                }

                float timer = 0.0f;
                while (timer < delayTime)
                {
                    timer += Time.deltaTime;

                    yield return(null);

                    if ((StoryManager.Instance.GameplayTextMode == GameplayTextMode.ClickToContinue && Input.GetMouseButtonDown(0)) ||
#if MULTI_TOUCH_SKIP
                        (Input.touchCount > 1 && Input.GetTouch(1).phase == TouchPhase.Began) ||
#endif
                        (Application.isEditor && Input.GetMouseButtonDown(1)))
                    {
                        break;
                    }
                }
            }

            while (Syncing)
            {
                yield return(null);
            }

            if (_inkStory.canContinue == false)
            {
                DisplayCurrentInkChoices();

                while (_inkStory.canContinue == false && _inkStory.currentChoices.Count > 0)
                {
                    yield return(null);
                }
            }
        }

        PlayNextScene();
    }
示例#27
0
        void LoadYird(bool bNewGame, StoryScene type = StoryScene.MainLand)
        {
            Debug.Log(System.DateTime.Now.ToString("G") + "[Start Game Mode] " + (!bNewGame ? "saved" : "new") + " story " + type.ToString());
            PeLauncher.Instance.Add(new ResetGlobalData());

            PeLauncher.Instance.Add(new LoadReputation(bNewGame));

            PeLauncher.Instance.Add(new LoadSpecialScene(type));

            //PeLauncher.Instance.Add(new LoadStoryPlayerSpawnPos(bNewGame, type));

            PeLauncher.Instance.Add(new LoadRandomItemMgr());

            PeLauncher.Instance.Add(new LoadCamera());

            PeLauncher.Instance.Add(new LoadEditedTerrain(bNewGame, ""));

            PeLauncher.Instance.Add(new LoadPathFinding());
            PeLauncher.Instance.Add(new LoadPathFindingEx());

            //add creation data to itemasset
            PeLauncher.Instance.Add(new LoadCreationData(bNewGame));
            //drag out scene agent will need this to create item.
            PeLauncher.Instance.Add(new LoadItemAsset(bNewGame));

            PeLauncher.Instance.Add(new LoadWaveSystem());

            if (type == StoryScene.PajaShip || type == StoryScene.LaunchCenter)
            {
                PeLauncher.Instance.Add(new LoadEnvironment());
            }

            PeLauncher.Instance.Add(new LoadWorldInfo(bNewGame));

            PeLauncher.Instance.Add(new LoadGameGraphInfo(new Vector2(18 * 1024, 18 * 1024)));

            PeLauncher.Instance.Add(new LoadStoryMap(bNewGame));

            PeLauncher.Instance.Add(new LoadCreature(bNewGame));

            //lz-2016.08.23 InGameAid
            PeLauncher.Instance.Add(new LoadInGameAid(bNewGame));

            PeLauncher.Instance.Add(new LoadNPCTalkHistory(bNewGame));

            PeLauncher.Instance.Add(new LoadGUI());
            //colony
            PeLauncher.Instance.Add(new LoadCSData(bNewGame));
            PeLauncher.Instance.Add(new LoadFarm());
            PeLauncher.Instance.Add(new LoadColony());

            PeLauncher.Instance.Add(new LoadEntityCreator(bNewGame));

            PeLauncher.Instance.Add(new LoadItemBox(bNewGame));

            PeLauncher.Instance.Add(new InitBuildManager(bNewGame));

            PeLauncher.Instance.Add(new LoadUiHelp(bNewGame));

            PeLauncher.Instance.Add(new LoadStory(bNewGame));

            PeLauncher.Instance.Add(new LoadMusicStroy());

            PeLauncher.Instance.Add(new LoadSingleStoryInitData(bNewGame));

            PeLauncher.Instance.Add(new LoadLootItem(bNewGame));

            PeLauncher.Instance.Add(new LoadSingleGameLevel(bNewGame));

            PeLauncher.Instance.Add(new LoadDoodadShow());

            PlayerPackageCmpt.LockStackCount = false;
        }
示例#28
0
 void Awake()
 {
     SS = this;
 }