示例#1
0
    public void MoveTo(GameObject actor, Vector3 target, float time, Sequence sequence)
    {
        // Initialize the cancel action
        cancelActionHandler = () => {
            // If the coroutine hasn't completed yet
            StopCoroutine(moveCoroutine);
            Animator animator = actor.GetComponentInChildren <Animator> ();
            if (animator != null)
            {
                animator.SetFloat("speed", 0);
            }
            sequence.Next();
        };

        if (time > 0)
        {
            if (moveCoroutine != null)
            {
                StopCoroutine(moveCoroutine);
            }
            moveCoroutine = MoveToCoroutine(actor, target, time / 1000, sequence);
            StartCoroutine(moveCoroutine);
        }
        else
        {
            actor.transform.position = target;
            sequence.Next();
        }
    }
示例#2
0
    /**
     * SpeakLine
     * Causes a speech bubble containing the specified line to appear above the specified actor.
     * Will also move other speech bubbles off the screen
     */
    public void SpeakLine(GameObject actor, string line, int wordTime, Sequence sequence)
    {
        //float speakTime = wordTime * line.Split (new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries).Length;

        // Meat of this one is done within the bubble script.
        //Create a new speech bubble instance
        GameObject   bubble       = Instantiate(Resources.Load(Constants.Resources.Narrative.PREFAB_SPEECH_BUBBLE_PATH, typeof(GameObject)), sceneCanvas.gameObject.transform) as GameObject;   // Parent the speech bubble to the scene canvas
        SpeechBubble bubbleScript = bubble.GetComponentInChildren <SpeechBubble> (true);

        if (bubbleScript == null)
        {
            Debug.LogError("Created a speech bubble without a script. What?! Terminating direction and moving to next.");
            DestroyImmediate(bubble);
            sequence.Next();
            return;
        }
        // Initialize the cancel action
        cancelActionHandler = () => {
            bubbleScript.DismissBubble();             // Bail out sooner than usual.
        };

        // Initialize the speech bubble
        bubbleScript.sceneCamera = sceneCamera;
        bubbleScript.Initialize(actor, line, wordTime, () => {
            sequence.Next();
        });
    }
示例#3
0
 public void SkipCurrentAction()
 {
     if (cancelActionHandler != null)
     {
         cancelActionHandler();
         cancelActionHandler = null;
     }
 }
示例#4
0
 public void Delay(float time, Sequence sequence)
 {
     // Initialize the cancel action
     cancelActionHandler = () => {
         StopCoroutine(delayCoroutine);
         sequence.Next();
     };
     if (time <= 0)
     {
         sequence.Next();
         return;
     }
     if (delayCoroutine != null)
     {
         StopCoroutine(delayCoroutine);
     }
     delayCoroutine = DelayCoroutine(time, sequence);
     StartCoroutine(delayCoroutine);
 }