// Start is called before the first frame update
    public virtual void Start()
    {
        PlayerCharacter PC = ArticyDatabase.GetObject <PlayerCharacter>("Player_Character_Entity_Tech_Name");

        //Debug.Log("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);
        StaticStuff.FlowDebug("Our player name is: " + PC.Template.Basic_Character_Attributes.NPC_Feature_Name);

        FlowPlayer = GetComponent <ArticyFlowPlayer>();
        Slot_Container sc = ArticyDatabase.GetObject <Slot_Container>("Start_On_Object");

        if (sc.Template.Slot_Feature.Slot_Feature_Slot != null)
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() setting StartOn: " + sc.Template.Slot_Feature.Slot_Feature_Slot.name);
            SetFlowPlayerStartOn(sc.Template.Slot_Feature.Slot_Feature_Slot);
        }
        else
        {
            //Debug.Log("CaptainsChairSceneRoot.Start() no StartOn");
            StaticStuff.FlowDebug("CaptainsChairSceneRoot.Start() no StartOn");
        }

        if (DialogueUI != null)
        {
            DialogueUI.gameObject.SetActive(false);
        }
        //FlowPlayer.StartOn = sc.Template.Slot_Feature.Slot_Feature_Slot;
    }
Пример #2
0
 private void Awake()
 {
     _prefabManager = GetComponent <PrefabManager>();
     _player        = GetComponent <ArticyFlowPlayer>();
     _saveSystem    = GetComponent <SaveSystem>();
     _controller    = GetComponent <GameController>();
 }
Пример #3
0
    void Awake()
    {
        // we are forming a Singleton that we can keep across multiple scenes
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            DontDestroyOnLoad(gameObject);
            Destroy(gameObject);
            DontDestroyOnLoad(gameObject);
        }

        cursorResources = GetComponent <MouseCursorResources>();
        inventory       = FindObjectOfType <Inventory>();
        flowPlayer      = GetComponent <ArticyFlowPlayer>();

        // set the default method provider for script methods, so that we needn't pass it as a parameter when calling script methods manually.
        // look into region "script methods" at the end of this class for more information.
        ArticyDatabase.DefaultMethodProvider = this;

        // disable the dialog widget, just to be safe
        dialogWidget.SetActive(false);

        // normally the Localization Caretaker works with UnityEngine.UI.Text controls
        // but in this case we want it to update our custom animated text element.
        // in that case we have to give the caretaker a method that does the text assignment for him, while the caretaker still listenes wor language changes.
        dialogText.localizedTextAssignmentMethod.AddListener(AssignDialogueText);

        // and if we are loaded we trigger a transition effect.
        transition.TransitionIn();
    }
Пример #4
0
 private bool Validate_FlowPlayer(ArticyFlowPlayer player)
 {
     if (!player || UnityEditor.EditorApplication.isPlaying)
     {
         return(true);
     }
     return(!player.enabled);
 }
Пример #5
0
    // this is called when building a list of branches for the ui and giving it all necessary informations.
    public void AssignBranch(ArticyFlowPlayer aProcessor, Branch aBranch, string aOverrideText = null)
    {
        mBranch    = aBranch;
        mProcessor = aProcessor;
        // this is a little debug help, if the branch would not be valid, we make this button red
        // usually we don't allow invalid branches and therefore never use this
        dialogText.color = aBranch.IsValid ? Color.black : Color.red;

        var target = aBranch.Target;

        dialogText.text = "";

        // the caller could set a text that he wants to use, otherwise we build it using the information we find inside the branch
        if (aOverrideText != null)
        {
            dialogTextCaretaker.LocaKey = aOverrideText;
        }
        else
        {
            // most importantly we want to use the MenuText of a DialogueFragment as the preview text
            var localizedObj = target as IObjectWithLocalizableMenuText;
            if (localizedObj != null)
            {
                dialogTextCaretaker.LocaKey = localizedObj.LocaKey_MenuText;
            }
            else
            {
                var obj = target as IObjectWithMenuText;

                if (obj != null)
                {
                    dialogText.text = obj.MenuText;
                }
            }

            // if for some reason we don't find one, we show at least 3 dots, useful when its not really a choice but more a "continue talking" branch
            if (dialogText.text == "")
            {
                dialogTextCaretaker.LocaKey = "...";
            }
        }

        // the dialogchoice contains additional information about a dialog option
        var dialogChoice = target as DialogChoice;

        if (dialogChoice != null)
        {
            // if we have a dialog choice, that uses an item, we show that items sprite and the items name
            if (dialogChoice.Template.DialogChoice.RequiredItem != null)
            {
                var item = dialogChoice.Template.DialogChoice.RequiredItem as Item;

                typeImage.sprite            = item.PreviewImage.Asset.LoadAssetAsSprite();
                dialogTextCaretaker.LocaKey = item.LocaKey_DisplayName;
            }
        }
    }
Пример #6
0
    IEnumerator AddNewFlowPlayer()
    {
        yield return(null);

        flowPlayer         = gameObject.AddComponent <ArticyFlowPlayer>();
        flowPlayer.startOn = dialogs[dialogCount];
        ClearAllBranches();
        dialogCount++;
    }
Пример #7
0
    public void UnlockNextDialog()
    {
        GameManager.instance.nextDialogUnlocked = true;
        ArticyFlowPlayer oldPlayer = GetComponent <ArticyFlowPlayer>();

        if (oldPlayer != null)
        {
            Destroy(oldPlayer);
        }
        StartCoroutine(AddNewFlowPlayer());
    }
Пример #8
0
    public override void ManageFlowPlayer(ArticyFlowPlayer player)
    {
        _uiVideoManager.showDialogue = false;
        var video = ArticyManager.Instance.LastFlowFragment as IObjectWithFeatureVideoData;

        _lastData  = video.GetFeatureVideoData();
        _videoName = ArticyManager.Instance.LastFlowFragment.DisplayName;

        _uiVideoManager.OnVideoUpdate = OnVideoUpdate;
        _uiVideoManager.OnVideoEnd    = OnVideoEnd;
        _uiVideoManager.OnVideoStart  = OnVideoStart;

        _uiVideoManager.StartVideo(_videoUrl);
    }
Пример #9
0
    // Used to initializes our debug flow player handler.
    void Start()
    {
        // you could assign this via the inspector but this works equally well for our purpose.
        flowPlayer = GetComponent <ArticyFlowPlayer>();
        Debug.Assert(flowPlayer != null, "ArticyDebugFlowPlayer needs the ArticyFlowPlayer component!.");

        // by clearing at start we can safely have a prefab instantiated in the editor for our convenience and automatically get rid of it when we play.
        ClearAllBranches();

        // just a little reminder text to actually set a start on object, otherwise the Flowplayer won't do anything and just idles.
        if (flowPlayer != null && flowPlayer.StartOn == null)
        {
            textLabel.text = "<color=green>No object selected in the flow player. Navigate to the ArticyflowPlayer and choose a StartOn node.</color>";
        }
    }
 public override void ManageFlowPlayer(ArticyFlowPlayer player)
 {
     if (ArticyManager.Instance.Dialogue)
     {
         player.Play();
     }
     else
     {
         uiDialogueManager.StartDialogue(player.Play, !lastData.HasAudio || _alwaysShowButton);
         uiDialogueManager.ShowDialogueText(lastData);
         if (lastData.HasAudio)
         {
             audioHandler.PlayClip(lastData.clip, () => uiDialogueManager.ShowNextButton(true));
         }
         else
         {
             audioHandler.StopHandler();
         }
     }
 }
Пример #11
0
 /// <summary>
 /// Called when this manager takes control of the flow player. All intialization login
 /// should go here.
 /// </summary>
 /// <param name="player"></param>
 public abstract void ManageFlowPlayer(ArticyFlowPlayer player);
    /// Called when the button is created to represent a single branch out of possible many.
    // This is important to give the ui button the branch that is used to follow along if the user pressed the button in the ui
    public void AssignBranch(ArticyFlowPlayer aProcessor, Branch aBranch)
    {
        // You would usually do this in the inspector in the button itself, but its so important for the correct functionalty
        // we placed it here to show you what happened when the button is pressed by the user.
        GetComponent <Button>().onClick.AddListener(OnBranchSelected);

        // we find the text component in our children, this should be the label of the button, unless you changed the button somewhat, then you need to take care of selecting the proper text.
        dialogText = GetComponentInChildren <TextMeshProUGUI>();

        // store for later use
        branch    = aBranch;
        processor = aProcessor;

        // a nice debug aid, if we show all branches (valid or invalid) we can identify branches that shouldn't be allowed because of our scripts
        //dialogText.color = aBranch.IsValid ? Color.black : Color.red;

        var target = aBranch.Target;

        dialogText.text = "";

        // now we figure out which text our button should have, and we just try to cast our target into different types,
        // creating some sort of priority naming  MenuText -> DisplayName -> TechnicalName -> ClassName/Null

        var obj = target as IObjectWithMenuText;

        if (obj != null)
        {
            dialogText.text = obj.MenuText;

            // Empty? Usually it would have a menu text, but it was deliberately left empty, in a normal game this could mean a single branch to just continue the dialog, if the protagonist is talking for
            // example, how you handle this is up to you, for this we just use the text normal text to show.
            if (dialogText.text == "")
            {
                var txtObj = obj as IObjectWithText;
                if (txtObj != null)
                {
                    dialogText.text = txtObj.Text;
                }
                else
                {
                    dialogText.text = "...";
                }
            }
        }

        // if the text is still empty, we can show the displayname of the target
        if (dialogText.text == "")
        {
            var dspObj = target as IObjectWithDisplayName;
            if (dspObj != null)
            {
                dialogText.text = dspObj.DisplayName;
            }
            else
            {
                // if it is still empty, we just show the technical name
                var articyObject = target as IArticyObject;
                if (articyObject != null)
                {
                    dialogText.text = articyObject.TechnicalName;
                }
                else
                {
                    // if for some reason the object cannot be cast to a basic articy type, we show its class name or null.
                    dialogText.text = target == null ? "null" : target.GetType().Name;
                }
            }
        }

        //sadest fix I ever made
        if (dialogText.text == "Questions")
        {
            Destroy(gameObject);
        }
    }
 public override void ManageFlowPlayer(ArticyFlowPlayer player)
 {
     _uiManager.StartBranches(_currentData);
 }
 public override void ManageFlowPlayer(ArticyFlowPlayer player)
 {
 }
 private void Awake()
 {
     _spawner    = GetComponent <Spawner>();
     _player     = GetComponent <ArticyFlowPlayer>();
     _saveSystem = GetComponent <SaveSystem>();
 }
 private void Awake()
 {
     _controller = GetComponent <GameController>();
     _player     = GetComponent <ArticyFlowPlayer>();
     _spawner    = GetComponent <Spawner>();
 }