Example #1
0
    void switchConversation()
    {
        DialogBubble temp = talker;

        talker   = listener;
        listener = temp;
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if ((vchoice && valpha < 255) || (!vchoice && valpha > 0))
        {
            ImageAppear();
        }
        else if (!vchoice && valpha <= 0)
        {
            DialogBubble vCharacter = transform.parent.GetComponent <DialogBubble>();

            //before deleting himself, we tell the character this buble is no more
            foreach (PixelBubble vBubble in transform.parent.GetComponent <DialogBubble>().vBubble)
            {
                if (vCharacter.vCurrentBubble == this.gameObject && !vBubble.vClickToCloseBubble) //remove current bubble ONLY if it must dissappear by itself
                {
                    vCharacter.vCurrentBubble = null;                                             //remove it
                    vCharacter.IsTalking      = false;
                }
            }

            //destroy itself
            GameObject.Destroy(this.gameObject);
        }
        else if ((valpha == 255f) && (!needtoclick))
        {
            valpha = 254f;
            StartCoroutine(WaitInSeconds(3f, "False"));
        }
    }
Example #3
0
 // Use this for initialization
 void Start()
 {
     talker               = actor1.GetComponent <DialogBubble> ();
     listener             = actor2.GetComponent <DialogBubble> ();
     totalNumberofBubbles = talker.vBubble.Count + listener.vBubble.Count;
     if (isAuto == true)
     {
         nextMessage();
     }
 }
Example #4
0
    public void showTextBubble(string msg)
    {
        DialogBubble dialogBubble = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <DialogBubble>();

        AssemblyCSharp.PixelBubble message = new AssemblyCSharp.PixelBubble();
        message.vMessage = msg;

        dialogBubble.vBubble.Add(message);

        dialogBubble.ShowBubble(dialogBubble);

        dialogBubble.vBubble.Clear();
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        DialogBubble bubbleScript = animator.gameObject.GetComponent <DialogBubble> ();

        if (bubbleScript != null)
        {
            if (stateInfo.fullPathHash == BUBBLE_IN_STATE)
            {
                bubbleScript.HandleBubbleInFinished();
            }
            else if (stateInfo.fullPathHash == BUBBLE_OUT_STATE)
            {
                bubbleScript.HandleBubbleOutFinished();
            }
        }
    }
Example #6
0
    private GameObject InstantiateBubble(PixelBubble bubblesList, DialogBubble dialogBubble)
    {
        GameObject newBubbleDialogObject = null;

        //create a rectangle or round bubble
        if (bubblesList.messageForm == BubbleType.Rectangle)
        {
            newBubbleDialogObject = (GameObject)Instantiate(prefab, dialogBubble.transform.position + new Vector3(4f, 4.25f, 0f)
                                                            , Quaternion.identity);
        }
        else
        {
            newBubbleDialogObject = (GameObject)Instantiate(prefab2, dialogBubble.transform.position + new Vector3(0.25f, 4.5f, 0f)
                                                            , Quaternion.identity);
        }

        return(newBubbleDialogObject);
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        if ((vchoice && valpha < 255) || (!vchoice && valpha > 0))
        {
            ImageAppear();
        }
        else if (!vchoice && valpha <= 0)
        {
            DialogBubble vCharacter = transform.parent.GetComponent <DialogBubble>();

            //before deleting himself, we tell the character this buble is no more
            if (vCharacter.vCurrentBubble == this.gameObject && !transform.parent.GetComponent <DialogBubble>().vBubble.vClickToCloseBubble) //remove current bubble ONLY if it must dissappear by itself
            {
                vCharacter.vCurrentBubble = null;                                                                                            //remove it
                vCharacter.IsTalking      = false;
            }

            //destroy itself
            GameObject.Destroy(this.gameObject);
        }
    }
Example #8
0
    //show the right bubble on the current character
    private void ShowBubble(DialogBubble dialogBubble)
    {
        //if vcurrentbubble is still there, just close it
        if (activeBubble != null)
        {
            if (activeBubble.clickToCloseBubble)
            {
                if (dialogBubble.currentBubble != null)                   //get the function to close bubble
                {
                    Appear appear = dialogBubble.currentBubble.GetComponent <Appear> ();
                    appear.closeBubble = true;                     //close bubble
                }
            }
        }

        foreach (PixelBubble pixelBubble in dialogBubble.bubblesList)
        {
            if (dialogBubble.currentBubble == null)               //make sure the bubble isn't already opened

            {
                string trueMessage = ModifyTextFromComponentByAddindNewLineAfterWords(pixelBubble);

                GameObject bubblesListObject = InstantiateBubble(pixelBubble, dialogBubble);

                //show the mouse and wait for the user to left click OR NOT (if not, after X sec, it disappear)
                bubblesListObject.GetComponent <Appear> ().needToClick = pixelBubble.clickToCloseBubble;

                RenderBodyOfBubble(bubblesListObject, pixelBubble, trueMessage);

                dialogBubble.currentBubble         = bubblesListObject;         //attach it to the player
                bubblesListObject.transform.parent = dialogBubble.transform;    //make him his parent
            }
            else if (activeBubble == pixelBubble && activeBubble.clickToCloseBubble)
            {
                //gotonextbubble = true;
                dialogBubble.currentBubble = null;
            }
        }
    }
Example #9
0
    void Update()       // Update is called once per frame
    {
        DialogBubble dialogBubbleScriptComponent = transform.parent.GetComponent <DialogBubble> ();

        if (closeBubble)
        {
            //before deleting himself, we tell the character this buble is no more
            foreach (PixelBubble bubble in transform.parent.GetComponent <DialogBubble>().bubblesList)
            {
                if (dialogBubbleScriptComponent.currentBubble == this.gameObject && !bubble.clickToCloseBubble)
                {
                    //remove current bubble ONLY if it must dissappear by itself
                    dialogBubbleScriptComponent.currentBubble = null;                     //remove it
                }
            }
            //destroy itself
            GameObject.Destroy(this.gameObject);
        }
        if (!needToClick)
        {
            StartCoroutine(CloseBubblesAfterSeconds(dialogBubbleScriptComponent.timeToCloseBubble));
        }
    }
	//show the right bubble on the current character
	void ShowBubble(DialogBubble vcharacter)
	{
		bool gotonextbubble = false;

		//if vcurrentbubble is still there, just close it
		if (vActiveBubble != null) {
			if (vActiveBubble.vClickToCloseBubble) {
				//get the function to close bubble
				Appear vAppear = vcharacter.vCurrentBubble.GetComponent<Appear> ();
				vAppear.valpha = 0f;
				vAppear.vTimer = 0f; //instantly
				vAppear.vchoice = false; //close bubble
				
				//check if last bubble
				if (vActiveBubble == vcharacter.vBubble.Last ())
					vcharacter.IsTalking = false;
			}
		}
		
		foreach (PixelBubble vBubble in vcharacter.vBubble)
		{
			//make sure the bubble isn't already opened
			if (vcharacter.vCurrentBubble == null)
			{
				//make the character in talking status
				vcharacter.IsTalking = true;
				
				//cut the message into 24 characters
				string vTrueMessage = "";
				string cLine = "";
				int vLimit = 24;
				if (vBubble.vMessageForm == BubbleType.Round)
					vLimit = 16;
				
				//cut each word in a text in 24 characters.
				foreach (string vWord in vBubble.vMessage.Split(' '))
				{
					if (cLine.Length + vWord.Length > vLimit)
					{
						vTrueMessage += cLine+System.Environment.NewLine;  
						
						//add a line break after
						cLine = ""; //then reset the current line
					}
					
					//add the current word with a space
					cLine += vWord+" ";
				}
				
				//add the last word
				vTrueMessage += cLine;
				GameObject vBubbleObject = null;
				
				//create a rectangle or round bubble
				if (vBubble.vMessageForm == BubbleType.Rectangle)
				{
					//create bubble
					vBubbleObject = (GameObject)Instantiate(Resources.Load("Customs/myBubbleRectangle"), this.transform.position, this.transform.rotation);
					//vBubbleObject.transform.position = vcharacter.transform.position + new Vector3(1.35f, 1.9f, 0f); //move a little bit the teleport particle effect
				}
				else 
				{
					//create bubble
					vBubbleObject = (GameObject)Instantiate(Resources.Load("Customs/myBubbleRound"), this.transform.position + RoundOffset, this.transform.rotation);
					//vBubbleObject.transform.position = vcharacter.transform.position + new Vector3(0.15f, 1.75f, 0f); //move a little bit the teleport particle effect
				}

				//show the mouse and wait for the user to left click OR NOT (if not, after 10 sec, it disappear)
				vBubbleObject.GetComponent<Appear>().needtoclick = vBubble.vClickToCloseBubble;
				
				Color vNewBodyColor = new Color(vBubble.vBodyColor.r, vBubble.vBodyColor.g, vBubble.vBodyColor.b, 0f);
				Color vNewBorderColor = new Color(vBubble.vBorderColor.r, vBubble.vBorderColor.g, vBubble.vBorderColor.b, 0f);
				Color vNewFontColor = new Color(vBubble.vFontColor.r, vBubble.vFontColor.g, vBubble.vFontColor.b, 255f);
				
				//get all image below the main Object
				foreach (Transform child in vBubbleObject.transform)
				{
					SpriteRenderer vRenderer = child.GetComponent<SpriteRenderer> ();
					TextMesh vTextMesh = child.GetComponent<TextMesh> ();
					
					if (vRenderer != null && child.name.Contains("Body"))
					{
						//change the body color
						vRenderer.color = vNewBodyColor;
						
						if (vRenderer.sortingOrder < 10)
							vRenderer.sortingOrder = 1500;
					}
					else if (vRenderer != null && child.name.Contains("Border"))
					{
						//change the border color
						vRenderer.color = vNewBorderColor;
						if (vRenderer.sortingOrder < 10)
							vRenderer.sortingOrder = 1501;
					} 
					else if (vTextMesh != null && child.name.Contains("Message"))
					{
						//change the message and show it in front of everything
						vTextMesh.color = vNewFontColor;
						vTextMesh.text = vTrueMessage;
						child.GetComponent<MeshRenderer>().sortingOrder = 1550;
						
						Transform vMouseIcon = child.FindChild("MouseIcon");
						if (vMouseIcon != null && !vBubble.vClickToCloseBubble)
							vMouseIcon.gameObject.SetActive(false);
					}
					
					//disable the mouse icon because it will close by itself
					if (child.name == "MouseIcon" && !vBubble.vClickToCloseBubble)
						child.gameObject.SetActive(false);
					else
						vActiveBubble =  vBubble; //keep the active bubble and wait for the Left Click
				}
				
				vcharacter.vCurrentBubble = vBubbleObject; //attach it to the player
				vBubbleObject.transform.parent = vcharacter.transform; //make him his parent
			} else if (vActiveBubble == vBubble && vActiveBubble.vClickToCloseBubble)
			{
				gotonextbubble = true;
				vcharacter.vCurrentBubble = null;
			}
		}
	}	
Example #11
0
 public override void StartInteraction()
 {
     base.StartInteraction();
     EndMessageBubble = null;
 }
Example #12
0
 public void CorrectAnswer()
 {
     EndMessageBubble = SuccessBubble;
     Succeeded        = true;
     End();
 }
Example #13
0
 // Use this for initialization
 void Start()
 {
     crtBubble = GetComponent <DialogBubble> ();
     animator  = GetComponent <Animator> ();
 }
Example #14
0
 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType<Player>();
     dialog = GetComponentInChildren<DialogBubble>();
     Debug.Assert(player != null);
 }
Example #15
0
	//show the right bubble on the current character
	public void ShowBubble(DialogBubble vcharacter, string message, SpeechType speechType)
	{
      if (message != null)
      {
         vBubble = new List<PixelBubble> {new PixelBubble
		      {
		         vMessage = message,
               vMessageForm = BubbleType.Rectangle,
               vBodyColor = new Color(0,0,0,0),
               vBorderColor = new Color(0, 0, 0, 0),
               vClickToCloseBubble = false,
               vFontColor = Color.white,
               vFontSize = 20
		      }};

         if (speechType == SpeechType.Blood)
            vBubble.First().vFontColor = Color.red;
         if (speechType == SpeechType.Quake)
            vBubble.First().vFontColor = Color.yellow;
         if (speechType == SpeechType.Flip)
            vBubble.First().vFontColor = Color.cyan;

         if (speechType == SpeechType.GodVotingRequest || speechType == SpeechType.GodVotingResolved)
         {
            vBubble.First().vFontSize = 30;
            vBubble.First().vFontColor = Color.white;
         }
         vActiveBubble = vBubble[0];
      }

		bool gotonextbubble = true;

		//if vcurrentbubble is still there, just close it
		if (vActiveBubble != null) {
			if (vActiveBubble.vClickToCloseBubble) {
				//get the function to close bubble
				Appear vAppear = vcharacter.vCurrentBubble.GetComponent<Appear> ();
				vAppear.valpha = 0f;
				vAppear.vTimer = 0f; //instantly
				vAppear.vchoice = false; //close bubble
				
				//check if last bubble
				if (vActiveBubble == vcharacter.vBubble.Last ())
					vcharacter.IsTalking = false;
			}
		}
		
		foreach (PixelBubble vBubble in vcharacter.vBubble)
		{
			//make sure the bubble isn't already opened
			if (vcharacter.vCurrentBubble == null)
			{
				//make the character in talking status
				vcharacter.IsTalking = true;
				
				//cut the message into 24 characters
				string vTrueMessage = "";
				string cLine = "";
				int vLimit = 24;
				if (vBubble.vMessageForm == BubbleType.Round)
					vLimit = 16;
				
				//cut each word in a text in 24 characters.
				foreach (string vWord in vBubble.vMessage.Split(' '))
				{
					if (cLine.Length + vWord.Length > vLimit)
					{
						vTrueMessage += cLine+System.Environment.NewLine;  
						
						//add a line break after
						cLine = ""; //then reset the current line
					}
					
					//add the current word with a space
					cLine += vWord+" ";
				}
				
				//add the last word
				vTrueMessage += cLine;
				GameObject vBubbleObject = null;
				
				//create a rectangle or round bubble
				if (vBubble.vMessageForm == BubbleType.Rectangle)
				{
					//create bubble
					vBubbleObject = Instantiate(Resources.Load<GameObject> ("Customs/BubbleRectangle"));
				   float offset = vBubble.vMessage.Length < vLimit ? 0.3f : -.15f;
               vBubbleObject.transform.position = vcharacter.transform.position + new Vector3(offset, 0.5f, 0f); //move a little bit the teleport particle effect
				}
				else 
				{
					//create bubble
					vBubbleObject = Instantiate(Resources.Load<GameObject> ("Customs/BubbleRound"));
               vBubbleObject.transform.position = vcharacter.transform.position + new Vector3(-0.5f, 0.5f, 0f); //move a little bit the teleport particle effect
				}

				//show the mouse and wait for the user to left click OR NOT (if not, after 10 sec, it disappear)
				vBubbleObject.GetComponent<Appear>().needtoclick = vBubble.vClickToCloseBubble;

            Color vNewBodyColor = new Color(vBubble.vBodyColor.r, vBubble.vBodyColor.g, vBubble.vBodyColor.b, vBubble.vBodyColor.a);
            Color vNewBorderColor = new Color(vBubble.vBorderColor.r, vBubble.vBorderColor.g, vBubble.vBorderColor.b, vBubble.vBorderColor.a);
				Color vNewFontColor = new Color(vBubble.vFontColor.r, vBubble.vFontColor.g, vBubble.vFontColor.b, 255f);
			   int fontSize = vBubble.vFontSize;

				//get all image below the main Object
				foreach (Transform child in vBubbleObject.transform)
				{
					SpriteRenderer vRenderer = child.GetComponent<SpriteRenderer> ();
					TextMesh vTextMesh = child.GetComponent<TextMesh> ();
					
					if (vRenderer != null && child.name.Contains("Body"))
					{
						//change the body color
						vRenderer.color = vNewBodyColor;
						
						if (vRenderer.sortingOrder < 10)
							vRenderer.sortingOrder = 1500;
					}
					else if (vRenderer != null && child.name.Contains("Border"))
					{
						//change the border color
						vRenderer.color = vNewBorderColor;
						if (vRenderer.sortingOrder < 10)
							vRenderer.sortingOrder = 1501;
					} 
					else if (vTextMesh != null && child.name.Contains("Message"))
					{
						//change the message and show it in front of everything
						vTextMesh.color = vNewFontColor;
						vTextMesh.text = vTrueMessage;
                  Font biancoRegularFont = (Font)Resources.Load<Font>("Biancoenero Regular.otf");
					   vTextMesh.font = biancoRegularFont;
					   vTextMesh.fontSize = fontSize;
						child.GetComponent<MeshRenderer>().sortingOrder = 1550;
						
						Transform vMouseIcon = child.FindChild("MouseIcon");
						if (vMouseIcon != null && !vBubble.vClickToCloseBubble)
							vMouseIcon.gameObject.SetActive(false);
					}
					
					//disable the mouse icon because it will close by itself
					if (child.name == "MouseIcon" && !vBubble.vClickToCloseBubble)
						child.gameObject.SetActive(false);
					else
						vActiveBubble =  vBubble; //keep the active bubble and wait for the Left Click
				}
				
				vcharacter.vCurrentBubble = vBubbleObject; //attach it to the player
				vBubbleObject.transform.parent = vcharacter.transform; //make him his parent
			} else if (vActiveBubble == vBubble && vActiveBubble.vClickToCloseBubble)
			{
				gotonextbubble = true;
				vcharacter.vCurrentBubble = null;
			}
		}
	}	
Example #16
0
    //show the right bubble on the current character
    public void ShowBubble(DialogBubble vcharacter)
    {
        bool gotonextbubble = false;

        //if vcurrentbubble is still there, just close it
        if (vActiveBubble != null)
        {
            if (vActiveBubble.vClickToCloseBubble)
            {
                //get the function to close bubble
                Appear vAppear = vcharacter.vCurrentBubble.GetComponent <Appear> ();
                vAppear.valpha  = 0f;
                vAppear.vTimer  = 0f;                //instantly
                vAppear.vchoice = false;             //close bubble

                //check if last bubble
                if (vActiveBubble == vcharacter.vBubble.Last())
                {
                    vcharacter.IsTalking = false;
                }
            }
        }

        foreach (PixelBubble vBubble in vcharacter.vBubble)
        {
            //make sure the bubble isn't already opened
            if (vcharacter.vCurrentBubble == null)
            {
                //make the character in talking status
                vcharacter.IsTalking = true;

                //cut the message into 24 characters
                string vTrueMessage = "";
                string cLine        = "";
                int    vLimit       = 35;
                if (vBubble.vMessageForm == BubbleType.Round)
                {
                    vLimit = 30;
                }

                //cut each word in a text in 24 characters.
                foreach (string vWord in vBubble.vMessage.Split(' '))
                {
                    if (cLine.Length + vWord.Length > vLimit)
                    {
                        vTrueMessage += cLine + System.Environment.NewLine;

                        //add a line break after
                        cLine = "";                         //then reset the current line
                    }

                    //add the current word with a space
                    cLine += vWord + " ";
                }

                //add the last word
                vTrueMessage += cLine;
                GameObject vBubbleObject = null;

                Vector3 shift = new Vector3(0, 0, 0);

                //create a rectangle or round bubble
                if (vBubble.vMessageForm == BubbleType.Rectangle)
                {
                    //create bubble
                    vBubbleObject = Instantiate(Resources.Load <GameObject> ("Customs/BubbleRectangle"));
                    shift         = new Vector3(1f, 3.1f, 0f);
                }
                else
                {
                    //create bubble
                    vBubbleObject = Instantiate(Resources.Load <GameObject> ("Customs/BubbleRound"));
                    shift         = new Vector3(1f, 2.9f, 0f);
                }

                if (vCustomBubblePosition == true)
                {
                    shift = vBubblePosition;
                }

                vBubbleObject.transform.position   = vcharacter.transform.position + shift;               //move a little bit the teleport particle effect
                vBubbleObject.transform.localScale = new Vector3(1f, 1f, 1f);

                //show the mouse and wait for the user to left click OR NOT (if not, after 10 sec, it disappear)
                vBubbleObject.GetComponent <Appear>().needtoclick = vBubble.vClickToCloseBubble;

                Color vNewBodyColor   = new Color(vBubble.vBodyColor.r, vBubble.vBodyColor.g, vBubble.vBodyColor.b, 0f);
                Color vNewBorderColor = new Color(vBubble.vBorderColor.r, vBubble.vBorderColor.g, vBubble.vBorderColor.b, 0f);
                Color vNewFontColor   = new Color(vBubble.vFontColor.r, vBubble.vFontColor.g, vBubble.vFontColor.b, 255f);

                //get all image below the main Object
                foreach (Transform child in vBubbleObject.transform)
                {
                    SpriteRenderer vRenderer = child.GetComponent <SpriteRenderer> ();
                    TextMesh       vTextMesh = child.GetComponent <TextMesh> ();

                    if (vRenderer != null && child.name.Contains("Body"))
                    {
                        //change the body color
                        vRenderer.color = vNewBodyColor;

                        if (vRenderer.sortingOrder < 10)
                        {
                            vRenderer.sortingOrder = 1500;
                        }
                    }
                    else if (vRenderer != null && child.name.Contains("Border"))
                    {
                        //change the border color
                        vRenderer.color = vNewBorderColor;
                        if (vRenderer.sortingOrder < 10)
                        {
                            vRenderer.sortingOrder = 1501;
                        }
                    }
                    else if (vTextMesh != null && child.name.Contains("Message"))
                    {
                        //change the message and show it in front of everything
                        vTextMesh.color = vNewFontColor;
                        vTextMesh.text  = vTrueMessage;
                        child.GetComponent <MeshRenderer>().sortingOrder = 1550;

                        Transform vMouseIcon = child.FindChild("MouseIcon");
                        if (vMouseIcon != null && !vBubble.vClickToCloseBubble)
                        {
                            vMouseIcon.gameObject.SetActive(false);
                        }
                    }

                    if (vBubbleOnRight == false && (child.name.Equals("BaseBody") || child.name.Equals("BaseBorder")))
                    {
                        child.transform.Rotate(Vector3.up * 180);
                    }

                    //disable the mouse icon because it will close by itself
                    if (child.name == "MouseIcon" && !vBubble.vClickToCloseBubble)
                    {
                        child.gameObject.SetActive(false);
                    }
                    else
                    {
                        vActiveBubble = vBubble;                          //keep the active bubble and wait for the Left Click
                    }
                }

                vcharacter.vCurrentBubble      = vBubbleObject;            //attach it to the player
                vBubbleObject.transform.parent = vcharacter.transform;     //make him his parent
            }
            else if (vActiveBubble == vBubble && vActiveBubble.vClickToCloseBubble)
            {
                gotonextbubble            = true;
                vcharacter.vCurrentBubble = null;
            }
        }
    }
Example #17
0
 public void WrongAnswer()
 {
     EndMessageBubble = FailBubble;
     End();
 }