コード例 #1
0
    /// <summary>
    /// Here we have a superclass intercept for catching global GameObject mouse up events.
    /// If object not draggable and tinker text is not null , call stanza manager onMouseUp(tinkertext).
    /// If tinkergraphic , call tinkrgraphic.MyOnMouseUp.
    /// This function can be overriden by specific scene manager.
    /// </summary>
    /// <param name="go">Game Object selected.</param>
    public virtual void OnMouseUp(GameObject go)
    {
        // Got a TinkerText object? (Also, make sure dragActive is false)
        if (!dragActive && go.GetComponent <GTinkerText>() != null)
        {
            GTinkerText tinkerText = go.GetComponent <GTinkerText>();

            if (tinkerText != null)
            {
                if (stanzaManager != null)
                {
                    stanzaManager.OnMouseUp(tinkerText);
                }
            }
        }
        // TinkerGraphic object
        else if (go.GetComponent <GTinkerGraphic>() != null)
        {
            GTinkerGraphic tinkerGraphic = go.GetComponent <GTinkerGraphic>();

            if (tinkerGraphic != null)
            {
                tinkerGraphic.MyOnMouseUp();
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Here we have a superclass intercept for catching global GameObject mouse currently down events.
    /// If input is allowed(during stanza play / after stanza play) check if Tinkertext or Tinkergraphic
    /// If tinkertext , call stanzamanager onmousecurrentlydown(tinkrtext).
    /// If tinkergraphic , call tinkrgraphic onmousecurrentlydown.
    /// This function can be overriden by specific scene manager.
    /// </summary>
    /// <param name="go">Game object clicked.</param>
    public virtual void OnMouseCurrentlyDown(GameObject go)
    {
        // Lock out other input during auto play?
        if (IsInputAllowed())
        {
            // TinkerGraphic object
            if (go.GetComponent <GTinkerGraphic>() != null)
            {
                GTinkerGraphic tinkerGraphic = go.GetComponent <GTinkerGraphic>();

                if (tinkerGraphic != null)
                {
                    tinkerGraphic.OnMouseCurrentlyDown();
                }
            }
            // TinkerText object
            else if (!dragActive && go.GetComponent <GTinkerText>() != null)
            {
                GTinkerText tinkerText = go.GetComponent <GTinkerText>();

                if (tinkerText != null)
                {
                    if (stanzaManager != null)
                    {
                        // Only allow further drag events if we aren't autoplaying
                        if (!stanzaManager.IsAutoPlaying())
                        {
                            stanzaManager.OnMouseCurrentlyDown(tinkerText);
                        }
                    }
                }
            }
        }
    }
コード例 #3
0
 public void OnPairedMouseCurrentlyDown(GTinkerText tinkerText)
 {
     if (tinkerText.stanza != null && stanzas.Contains(tinkerText.stanza))
     {
         tinkerText.stanza.OnPairedMouseCurrentlyDown(tinkerText);
     }
 }
コード例 #4
0
 public void OnMouseUp(GTinkerText tinkerText)
 {
     if (tinkerText.stanza != null && stanzas.Contains(tinkerText.stanza))
     {
         tinkerText.stanza.OnMouseUp(tinkerText);
     }
 }
コード例 #5
0
    // Begins an auto play starting w/ a stanza
    private IEnumerator StartAutoPlay(StanzaObject startingStanza, GTinkerText startingTinkerText)
    {
        Debug.Log("autoplay started");

        // If we aren't starting from the beginning, read the audio progress from the startingTinkerText
        GetComponent <AudioSource>().time = startingTinkerText.GetStartTime();
        // Start playing the full stanza audio
        GetComponent <AudioSource>().Play();

        int startingStanzaIndex = stanzas.IndexOf(startingStanza);

        for (int i = startingStanzaIndex; i < stanzas.Count; i++)
        {
            if (i == startingStanzaIndex)
            {
                yield return(StartCoroutine(stanzas[i].AutoPlay(startingTinkerText)));
            }
            else
            {
                yield return(StartCoroutine(stanzas[i].AutoPlay()));
            }

            // Abort early?
            if (CancelAutoPlay())
            {
                autoPlaying = false;
                GetComponent <AudioSource>().Stop();
                yield break;
            }
        }

        autoPlaying = false;
        yield break;
    }
コード例 #6
0
 /// <summary>
 /// this function handles the on mouse up events of text
 /// </summary>
 /// <param name="tinkerText"></param>
 public void OnMouseUp(GTinkerText tinkerText)
 {
     // Assign this new one
     mouseDownTinkerText = tinkerText;
     // And signal the tinkerText
     tinkerText.MyOnMouseUp();
 }
コード例 #7
0
    /// <summary>
    /// If input is allowed(during stanza play / after stanza play) check if Tinkertext or Tinkergraphic
    /// If tinkertext , call stanzamanager onmousedown(tinkrtext).
    /// If tinkergraphic , call tinkrgraphic.mymousedown.
    /// This function can be overriden by specific scene manager.
    /// </summary>
    public virtual void OnMouseDown(GameObject go)
    {
        stanzaManager.RequestCancelAutoPlay();          // to stop auto narration when anything is clicked
        // Lock out other input during auto play?
        if (IsInputAllowed())
        {
            // TinkerText object
            if (go.GetComponent <GTinkerText>() != null)
            {
                GTinkerText tinkerText = go.GetComponent <GTinkerText>();

                if (tinkerText != null)
                {
                    if (stanzaManager != null)
                    {
                        // Is an autoplay in progress? If so, see if we should interrupt
                        if (stanzaManager.IsAutoPlaying() && inputInterruptsAutoplay)
                        {
                            stanzaManager.RequestCancelAutoPlay();
                        }
                        stanzaManager.OnMouseDown(tinkerText);
                    }
                }
            }
            // TinkerGraphic object
            else if (go.GetComponent <GTinkerGraphic>() != null)
            {
                GTinkerGraphic tinkerGraphic = go.GetComponent <GTinkerGraphic>();
                if (tinkerGraphic != null)
                {
                    tinkerGraphic.MyOnMouseDown();
                }
            }
        }
    }
コード例 #8
0
 /// <summary>
 /// this function is called when the tinkergraphic is paired to some tinkertext
 /// and we want have some paired graphical animation for that text
 /// </summary>
 /// <param name="tinkerText"></param>
 // Paired TinkerText Mouse Down Event
 public void OnPairedMouseDown(GTinkerText tinkerText)
 {
     sceneManager.OnPairedMouseDown(tinkerText);
     isanimplaying = true;
     checkandStoproutines();
     LoadAndPlayAnimation(tinkerText.pairedAnim);
 }
コード例 #9
0
 public void OnMouseDown(GTinkerText tinkerText, bool suppressAnim = false)
 {
     Debug.Log("mousedown2");
     if (tinkerText.stanza != null && stanzas.Contains(tinkerText.stanza))
     {
         tinkerText.stanza.OnMouseDown(tinkerText, suppressAnim);
     }
 }
コード例 #10
0
 private void ResetMouseCurrentlyDownStates()
 {
     if (mouseCurrentlyDownTinkerText != null)
     {
         mouseCurrentlyDownTinkerText.Reset();
     }
     mouseCurrentlyDownTinkerText = null;
 }
コード例 #11
0
    /// <summary>
    /// Here we have a superclass intercept for catching global TinkerText paired mouse up events.
    /// </summary>
    /// <param name="tinkerText">Tinker text.</param>
    public virtual void OnPairedMouseUp(GTinkerText tinkerText)
    {
//		Renderer[] list;
//		list = tinkerText.pairedGraphic.gameObject.GetComponentsInChildren<Renderer>();
//		foreach(Renderer item in list){   //color all the components
//			item.material.color = tinkerText.pairedGraphic.resetColor;
//		}
    }
コード例 #12
0
 // Method to request an auto play starting w/ a stanza
 public void RequestAutoPlay(StanzaObject startingStanza, GTinkerText startingTinkerText = null)
 {
     Debug.Log("request auto play");
     if (!autoPlaying)          // && !sceneManager.disableAutoplay)
     {
         Debug.Log("not auto playing");
         autoPlaying    = true;
         cancelAutoPlay = false;             // reset our cancel flag
         StartCoroutine(StartAutoPlay(startingStanza, startingTinkerText));
     }
 }
コード例 #13
0
    /// <summary>
    /// Creates TinkerText for a word at a position.
    /// </summary>
    /// <returns>The text.</returns>
    /// <param name="parent">Parent stanza of the TinkerText.</param>
    /// <param name="x">The x coordinate.</param>
    /// <param name="y">The y coordinate.</param>
    /// <param name="textToPrint">Text to print (word).</param>
    /// <param name="fontSize">Font size.</param>
    /// <param name="textColor">Text color.</param>
    GTinkerText CreateText(StanzaObject parent, float x, float y, string textToPrint, int fontSize, Color textColor)
    {
        GameObject UItextGO = new GameObject("Text_" + textToPrint);

        UItextGO.transform.SetParent(parent.transform);
        // Debug.Log(anim.runtimeAnimatorController);
        Text text = UItextGO.AddComponent <Text>();

        text.text                 = textToPrint;
        text.fontSize             = storyBookJson.textFontSize;
        text.color                = textColor;
        text.font                 = font;
        text.transform.localScale = new Vector3(1, 1, 1);

        //used for fitting the text box to the size of text.
        ContentSizeFitter csf = UItextGO.AddComponent <ContentSizeFitter> ();

        csf.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
        csf.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;

        VerticalLayoutGroup vlg = UItextGO.AddComponent <VerticalLayoutGroup> ();

        vlg.childControlHeight = true;
        vlg.childControlWidth  = true;


        RectTransform trans = UItextGO.GetComponent <RectTransform>();

        text.alignment         = TextAnchor.UpperLeft;
        trans.anchoredPosition = new Vector3(x, y, 0);
        UItextGO.GetComponent <RectTransform> ().pivot = new Vector2(0.5f, 0.5f);
        UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(trans);

        trans.anchoredPosition = new Vector3(x + trans.rect.width / 2, y, 0);
        UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(trans);

        width        = width + trans.rect.width + minWordSpace;
        stanzaLength = width;

        //audio to each word
        //		TimeStampClass[] timeStamps = storyBookJson.pages[pageNumber].timestamps;
        //		UItextGO.AddComponent<AudioSource> ().clip = LoadAudioAsset (timeStamps [wordCount].audio);
        //		wordCount++;

        //add the animator and script to the word.
        UItextGO.AddComponent <Animator>().runtimeAnimatorController = Resources.Load("TextAnimations/textzoomcontroller") as RuntimeAnimatorController;
        GTinkerText tinkerText = UItextGO.AddComponent <GTinkerText>();

        tinkerText.stanza = UItextGO.GetComponentInParent <StanzaObject>();
        tinkerTextObjects.Add(UItextGO);
        return(UItextGO.GetComponent <GTinkerText>());
    }
コード例 #14
0
/// <summary>
/// this function handles the mousedown evens on the tinkertexts of the stanza
/// </summary>
/// <param name="tinkerText">tinkertext that is pressed</param>
/// <param name="suppressAnim">bool to check whether animation is to be suppressed</param>
    public void OnMouseDown(GTinkerText tinkerText, bool suppressAnim = false)
    {
        // if we aren't already mouse down on this text
        if (mouseDownTinkerText != null && mouseDownTinkerText != tinkerText)
        {
            // Then reset the old one
            mouseDownTinkerText.Reset();
        }

        // Assign this new one
        mouseDownTinkerText = tinkerText;

        // And signal the tinkerText
        tinkerText.MyMouseDown(suppressAnim);
    }
コード例 #15
0
    /// <summary>
    /// this function handles the on paired mouse events
    /// </summary>
    /// <param name="tinkerText"></param>
    public void OnPairedMouseDown(GTinkerText tinkerText)
    {
        // if we aren't already mouse down on this text
        if (mouseDownTinkerText != null && mouseDownTinkerText != tinkerText)
        {
            // Then reset the old one
            mouseDownTinkerText.Reset();
        }

        // Assign this new one
        mouseDownTinkerText = tinkerText;

        // And trigger the tinkerText only if stanza narrate is false
        //if(stanzaNarrate==false)
        tinkerText.OnPairedMouseDown();
    }
コード例 #16
0
    /// <summary>
    /// this function handles the onPairedMouseCurrenltyDown event on tinkertext
    /// </summary>
    /// <param name="tinkerText"></param>
    public void OnPairedMouseCurrentlyDown(GTinkerText tinkerText)
    {
        // If this text is already marked as mouse down, clear that
        if (mouseDownTinkerText != null && mouseDownTinkerText == tinkerText)
        {
            mouseDownTinkerText = null;

            // and reassign it to currently down
            mouseCurrentlyDownTinkerText = tinkerText;

            //DetectStanzaAutoPlay(tinkerText);
        }
        else if (mouseCurrentlyDownTinkerText != null)
        {
            // If this text isn't already marked as currently down
            if (mouseCurrentlyDownTinkerText != tinkerText)
            {
                // Then reset the old one
                mouseCurrentlyDownTinkerText.Reset();

                // Assign this new one
                mouseCurrentlyDownTinkerText = tinkerText;

                // Signal tinkerText
                tinkerText.OnPairedMouseCurrentlyDown();

                //DetectStanzaAutoPlay(tinkerText);
            }
        }
        else
        {
            // Assign this new one
            mouseCurrentlyDownTinkerText = tinkerText;

            // Signal tinkerText
            tinkerText.OnPairedMouseCurrentlyDown();

            //DetectStanzaAutoPlay(tinkerText);
        }
    }
コード例 #17
0
 /// <summary>
 /// Here we have a superclass intercept for catching global TinkerText paired mouse down events.
 /// </summary>
 /// <param name="tinkerText">Tinker text.</param>
 public virtual void OnPairedMouseDown(GTinkerText tinkerText)
 {
 }
コード例 #18
0
 // Paired TinkerText Mouse Up Event
 public void OnPairedMouseUp(GTinkerText tinkerText)
 {
     sceneManager.OnPairedMouseUp(tinkerText);
 }
コード例 #19
0
    /// <summary>
    /// Auto stanza play of.
    /// calls on mouse down of each text to play its respective animation if present
    /// zoomin and zoomout of texts with delays acoordinf to the start and end time of texts
    /// </summary>
    /// <param name="startingTinkerText">Starting tinker text.</param>
    public IEnumerator AutoPlay(GTinkerText startingTinkerText = null)
    {
        //{   stanzaNarrate = true;
        Debug.Log("auto play");
        int startingTinkerTextIndex = 0;

        if (startingTinkerText != null)
        {
            startingTinkerTextIndex = tinkerTexts.IndexOf(startingTinkerText);
        }

        for (int i = startingTinkerTextIndex; i < tinkerTexts.Count; i++)
        {
            //link the corresponding paried animation during auto play
            GTinkerText t = null;
            if (tinkerTexts[i] != null)
            {
                t = tinkerTexts[i];
            }
            if (t.star)
            {
                for (int j = 0; j < t.pairedGraphics.Count; j++)
                {
                    t.pairedGraphics [j].PlayCompleteAnim();
                }
            }
            //GTinkerGraphic link = t.GetComponent<GTinkerText> ().pairedGraphic;
            //if paired graphic is present
            //if (link != null) {
            //GSManager scenescript = stanzaManager.sceneManager;
            //call its respective scene onmousedown
            //scenescript.OnMouseDown(t.gameObject);
            //scenescript.OnMouseUp (t.gameObject);

            //}


            Animator anim = t.GetComponent <Animator>();

            if (anim != null)
            {
                anim.speed = 1 / t.playTime;
            }

            // If we aren't on last word, delay before playing next word
            if (i < tinkerTexts.Count - 1)
            {
                // delay according to timing data
                float pauseDelay = tinkerTexts[i + 1].GetStartTime() - tinkerTexts[i].GetEndTime();
                if (anim != null)
                {
                    anim.Play("textzoomout");
                }
                yield return(new WaitForSeconds(t.playTime / 2));

                if (anim != null)
                {
                    anim.Play("textzoomin");
                }
                yield return(new WaitForSeconds(t.playTime / 2));

                if (pauseDelay != 0)
                {
                    if (anim != null)
                    {
                        anim.speed = 1 / pauseDelay;
                    }
                    if (anim != null && anim.GetCurrentAnimatorStateInfo(0).IsName("idle"))
                    {
                        anim.Play("pausedelay");
                    }
                    yield return(new WaitForSeconds(pauseDelay));
                }
            }
            else             // Delay before next stanza
            {
                if (anim != null)
                {
                    anim.Play("textzoomout");
                }
                yield return(new WaitForSeconds(t.playTime / 2));

                if (anim != null)
                {
                    anim.Play("textzoomin");
                }
                yield return(new WaitForSeconds(t.playTime / 2));

                if (anim != null && endDelay != 0)
                {
                    anim.speed = 1 / endDelay;
                    anim.Play("enddelay");
                }

                yield return(new WaitForSeconds(endDelay));
            }

            // Abort early?
            if (stanzaManager.CancelAutoPlay())
            {
                yield break;
            }
        }
        //stanzaNarrate=false;

        // Stop the coroutine
        yield break;
    }
コード例 #20
0
 /// <summary>
 /// Here we have a superclass intercept for catching global TinkerText paired mouse currently down events.
 /// </summary>
 /// <param name="tinkerText">Tinker text.</param>
 public virtual void OnPairedMouseCurrentlyDown(GTinkerText tinkerText)
 {
     // override me
 }
コード例 #21
0
 // Paired TinkerText Mouse Down Event
 public void OnPairedMouseCurrentlyDown(GTinkerText tinkerText)
 {
     sceneManager.OnPairedMouseCurrentlyDown(tinkerText);
 }