コード例 #1
0
    private Dictionary <int, GameObject> mVoiceDic           = new Dictionary <int, GameObject>();           //语音聊天喇叭

    #region 互动表情
    /// <summary>
    /// 添加一个互动表情
    /// </summary>
    /// <param name="from"></param>
    /// <param name="to"></param>
    /// <param name="con"></param>
    public void AddOneInteractionFace(Vector3 from, Vector3 to, SendReceiveGameChat data)
    {
        List <ConfigDada>   conList = ConfigManager.GetConfigs <TSTHuDongFaceConfig>();
        TSTHuDongFaceConfig con     = null;

        for (int i = 0; i < conList.Count; i++)
        {
            TSTHuDongFaceConfig temp = conList[i] as TSTHuDongFaceConfig;
            if (temp.id == data.faceIndex)
            {
                con = temp;
                break;
            }
        }
        if (con == null)
        {
            return;
        }
        GameObject go = NGUITools.AddChild(mItemRoot, mItem);

        go.gameObject.SetActive(true);
        TweenPosition   tween = go.GetComponent <TweenPosition>();
        UISprite        sp    = go.GetComponent <UISprite>();
        SpriteAnimation anim  = go.GetComponent <SpriteAnimation>();

        //设置起始点和目标点
        mFrom.position = from;
        mTo.position   = to;
        from           = mFrom.localPosition;
        to             = mTo.localPosition;
        //飞行动画和表情动画
        sp.spriteName  = con.foreName + "0";
        tween.duration = 0.4f;
        string sound = con.sound;

        tween.AddOnFinished(() =>
        {
            anim.SetBegin(con.foreName, 1, con.length);
            anim.SetDalayDestory(4.0f);
            SoundProcess.PlaySound("HuDongFaceSound/" + sound);
        });
        tween.from = from;
        tween.to   = to;
        tween.PlayForward();
    }
コード例 #2
0
    /// <summary>
    /// 显示互动表情
    /// </summary>
    /// <param name="chat"></param>
    protected void PlayHuDongFace(SendReceiveGameChat chat)
    {
        if (mGameInteractionView == null)
        {
            mGameInteractionView = Global.Inst.GetController <GameInteractionController>().OpenWindow() as GameInteractionView;
        }

        List <ConfigDada>   config = ConfigManager.GetConfigs <TSTHuDongFaceConfig>();
        TSTHuDongFaceConfig con    = null;

        for (int i = 0; i < config.Count; i++)
        {
            TSTHuDongFaceConfig hdf = config[i] as TSTHuDongFaceConfig;
            if (hdf.id == chat.faceIndex)
            {
                con = hdf;
                break;
            }
        }
        //起始位置
        Vector3 from = Vector3.zero;
        //目标位置
        Vector3 to = Vector3.zero;

        NiuniuGameView view = Global.Inst.GetController <NNGameController>().mView;

        NiuniuPlayerUI fromPlayer = null;
        NiuniuPlayerUI toPlayer   = null;

        if (view.TryGetPlayer(chat.fromSeatId, out fromPlayer) && view.TryGetPlayer(chat.toSeatId, out toPlayer))
        {
            from = fromPlayer.GetBaseInfoPos();
            to   = toPlayer.GetBaseInfoPos();

            mGameInteractionView.AddOneInteractionFace(from, to, chat);
        }
    }