Exemple #1
0
    public static AnimationVO GetAnimationConfigByIndex(string index)
    {
        AnimationVO result = null;

        animationConfig.TryGetValue(index, out result);
        return(result);
    }
Exemple #2
0
    // 在空格处放上表情动画
    private GameObject ReplaceEmojiWithPicture(string faceName)
    {
        GameObject        sprite;
        UISprite          spFace;
        UISpriteAnimation spaFace;
        AnimationVO       aniConfig = GameConst.GetAnimationConfigByIndex(faceName);

        sprite  = GameObject.Instantiate(faceTemplate);
        spFace  = sprite.GetComponent <UISprite>();
        spaFace = sprite.GetComponent <UISpriteAnimation>();

        spFace.GetComponent <UIWidget>().width  = (int)(cellLength * aniConfig.spaceNum * 0.5f);
        spFace.GetComponent <UIWidget>().height = (int)cellLength * aniConfig.rowNum;

        sprite.transform.parent = emojiContainer;
        spFace.spriteName       = faceName + "_1";
        spaFace.namePrefix      = faceName + "_";

        if (aniConfig != null)
        {
            if (aniConfig.isNotPlay)
            {
                StopAudioAnimation(spaFace);
                if (aniConfig.isAudio)
                {
                    RegistUIButton(gameObject, (go) => {
                        if (chatData == null || chatData.voiceData == null)
                        {
                            return;
                        }
                        Byte[] wavData = SevenZipCompress.Decompress(chatData.voiceData);
                        _microPhoneInput.PlayClipData(wavData);
                        spaFace.Play();
                        Director.GetInstance().scheduler.SetTimeOut(chatData.time, () => {
                            StopAudioAnimation(spaFace);
                        });
                    });
                }
            }
            spaFace.framesPerSecond = aniConfig.rate;
        }
        if (!aniConfig.isAudio)
        {
            sprite.GetComponent <Collider>().enabled = false;
        }
        Vector3 tmpPos;

        sprite.transform.localScale = Vector3.one;
        tmpPos   = picIndex;
        tmpPos.y = picIndex.y + cellLength * (aniConfig.rowNum - 1);

        sprite.transform.localPosition = tmpPos;
        sprite.name = faceName;
        sprite.SetActive(true);
        spFace.ResizeCollider();

        return(sprite);
    }
Exemple #3
0
    private bool CheckVoiceNotPlay(AnimationVO aniConfig, ref string text, ref int index)
    {
        bool result = false;

        if (chatData == null)
        {
            return(result);
        }
        if (aniConfig.isNotPlay && chatData.voiceData == null)
        {
            text = text.Remove(index, 4);
            index--;
            result = true;
        }
        return(result);
    }
Exemple #4
0
    // 检测图文字,发现后做处理
    private bool ReplaceEmojiText(ref string text, ref int index, ref int rowNum, ref int spaceNum, ref bool isChangeRow, ref string faceName)
    {
        bool result = false;
        int  length = text.Length;
        int  delta  = 0;

        do
        {
            if (!CheckIsEmoji(text, index))
            {
                break;
            }
            faceName = text.Substring(index + 1, 3);
            AnimationVO aniConfig = GameConst.GetAnimationConfigByIndex(faceName);
            if (aniConfig == null)
            {
                break;
            }
            if (CheckVoiceNotPlay(aniConfig, ref text, ref index))
            {
                break;
            }

            result = true;
            int lastRowNum = rowNum;
            rowNum = Math.Max(rowNum, aniConfig.rowNum);

            spaceNum = aniConfig.spaceNum;

            text = text.Remove(index, 4);
            for (int j = 0; j < spaceNum; j++)
            {
                text = text.Insert(index, " ");
            }
            picIndex = SetRealRowList(text, index);

            for (delta = 0; delta < spaceNum; delta++)
            {
                isChangeRow = CheckIsChangeRowEx(index, delta);
                if (isChangeRow)
                {
                    break;
                }
            }
            // 换行后补充空格
            if (isChangeRow)
            {
                //if (delta == 0 && !CheckIncludeEmoji(text.Substring(index, Math.Min(nextRow, text.Length) - index))) {
                //	delta = 1;
                //}

                for (int j = 0; j < delta; j++)
                {
                    text = text.Insert(index, " ");
                    index++;
                }
                lastRowNum = 1;
                rowNum     = aniConfig.rowNum;
                rowListIndex++;
                picIndex   = SetRealRowList(text, index);
                picIndex.x = 0;
            }

            if (lastRowNum != rowNum)
            {
                // 添加换行
                for (int j = 0; j <= rowNum - lastRowNum; j++)
                {
                    if (rowDict[lastRow] < rowNum)
                    {
                        rowDict[lastRow] = rowDict[lastRow] + 1;
                        text             = text.Insert(lastRow, "\n");
                        index++;
                    }
                    if (j < rowNum - lastRowNum || lastRow == 0)
                    {
                        picIndex.y = picIndex.y - cellLength;
                    }

                    if (j == rowNum - lastRowNum - 1 && lastRow == 0)
                    {
                        break;
                    }
                }
            }
        } while (false);
        return(result);
    }
Exemple #5
0
	private bool CheckVoiceNotPlay(AnimationVO aniConfig, ref string text, ref int index) {
		bool result = false;
		if (chatData == null) { return result; }
		if (aniConfig.isNotPlay && chatData.voiceData == null) {
			text = text.Remove(index, 4);
			index--;
			result = true;
		}
		return result;
	}