예제 #1
0
    private void OnClose()
    {
        if (blackPlane != null)
        {
            blackPlane.SetActive(false);
        }

        isGenerated = false;

        if (stringToGenerate.Count > 0)
        {
            string tempFraseToGenerate = stringToGenerate[0];
            int tempFaceToGenerate = facesIdToGenerate[0];
            float tempDelayToClose = listDelayToClose[0];
            string tempNameText = namesToGenerate[0];
            GeneratePopUp(tempNameText, tempFraseToGenerate, tempFaceToGenerate, tempDelayToClose);
            stringToGenerate.Remove(tempFraseToGenerate);
            facesIdToGenerate.Remove(tempFaceToGenerate);
            listDelayToClose.Remove(tempDelayToClose);
            namesToGenerate.Remove(tempNameText);
        }

        posCallBack--;
        if (posCallBack + 1 <= 0)
        {
            posCallBack = 0;
            if (onComplete != null)
            {
                OnCompleteAll tempComplete = onComplete;
                onComplete = null;
                tempComplete();
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Gerar popup
    /// </summary>
    /// <param name="frase">Frase que sera gerada</param>
    /// <param name="faceId">Id do rosto que ira aparecer</param>
    /// <param name="delayToClose">se for -1 nao utiliza o delay, se usar de 0 para cima ele usa o delay para fechar altomatico a popUp</param>
    /// <param name="onCompleteCallBack">Callback quando fechar a popUp</param>
    public void GeneratePopUp(string nameText, string frase, int faceId = -1,float delayToClose = -1, OnCompleteAll onCompleteCallBack = null)
    {
        bool fraseContains = false;

        if (frase.Contains("||"))
        {
            char[] charsTemp = new char[2];
            for (int i = 0; i < charsTemp.Length; i++) { charsTemp[i] = '|'; }
            string[] temp = frase.Split(charsTemp);
           // List<string> fraseListTemp = new List<string>();
            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i] != "")
                {
                    //fraseListTemp.Add(temp[i]);

                    stringToGenerate.Add(temp[i]);
                    facesIdToGenerate.Add(faceId);
                    listDelayToClose.Add(delayToClose);
                    namesToGenerate.Add(nameText);
                }
            }
            // GeneratePopUp(nameText, fraseListTemp,faceId,delayToClose);
            //return;

            frase = temp[0];

            fraseContains = true;

        }

        if (isGenerated == true)
        {

            if (fraseContains == false)
            {
                stringToGenerate.Add(frase);
                facesIdToGenerate.Add(faceId);
                listDelayToClose.Add(delayToClose);
                namesToGenerate.Add(nameText);
                posCallBack++;

            }

            if (onCompleteCallBack != null)
            {
                onComplete = onCompleteCallBack;
            }

            return;
        }
        else if (onCompleteCallBack != null)
        {
            posCallBack = 0;
            onComplete = onCompleteCallBack;
        }

        if (blackPlane != null)
        {
            blackPlane.SetActive(true);
        }

        isGenerated = true;
        PopUpDialog tempPopUp = GameObject.Instantiate(dialogBox);
        tempPopUp.textMesh.text = StringFormater.Format(frase, quantCaracteresToJumpLine, true);

        if (tempPopUp.nameTextMesh != null)
        {
            tempPopUp.nameTextMesh.text = nameText;
        }

        if (delayToClose >= 0)
        {
            tempPopUp.useDelayToClose = true;
            tempPopUp.delayToClose = delayToClose;
        }

        if (faceId != -1)
        {
            if (facesSprites != null)
            {
                if (faceId < facesSprites.Count)
                {
                    tempPopUp.haveFace = true;
                    tempPopUp.spriteFace = facesSprites[faceId];
                }
            }
        }
        tempPopUp.onClose = OnClose;

        lastFaceId = faceId;
    }
예제 #3
0
 public void GeneratePopUp(string nameText, List<string> frase, int faceId = -1,float delayToClose = -1, OnCompleteAll onCompleteCallBack = null)
 {
     for (int i = 0; i < frase.Count; i++)
     {
         if (i == frase.Count - 1)
         {
             GeneratePopUp(nameText, frase[i], faceId, delayToClose, onCompleteCallBack);
         }
         else
         {
             GeneratePopUp(nameText, frase[i], faceId, delayToClose);
         }
     }
 }