当前位置: 首页 > 工具软件 > ichat > 使用案例 >

GameEntity(六)—— IChat

盖和洽
2023-12-01

目录为:Assets/Scripts/GameEntity/目录下
IChat.cs

聊天的接口类

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

//看来是聊天相关的接口
public class IChat
{
    public UInt64 SGUID
    {
        private set;
        get;
    }

    //昵称
    public string NickName
    {
        private set;
        get;
    }

    public int HeadID
    {
        private set;
        get;
    }

    public class IChatInfo
    {
        public string msg;
        public bool isLocalPlayer;
        public string nickName
        {
            private set;
            get;
        }

        public int head;

        //GameDefine中定义
        //ReadNull,
        //UnReadMsg,
        //ReadMsg,
        public MsgTalk TalkState;

        public void SetNickName(string nick)
        {
            nickName = nick;
        }
    }

    public List<IChatInfo> MsgInfo = new List<IChatInfo>();

    //talk状态
    public MsgTalk TalkState
    {
        private set;
        get;
    }

    //设定talk状态
    public void SetTalkState(MsgTalk talkState)
    {
        TalkState = talkState;
    }

    //设定IChatInfo并加进MsgInfo数组里
    public void SetMsgInfo(UInt64 sGUID, string nickName, string msgInfo, MsgTalk talkState, int headID, bool isLocal)
    {
        SGUID = sGUID;
        NickName = nickName;
        TalkState = talkState;
        HeadID = headID;
        IChatInfo info = new IChatInfo ();
        info.isLocalPlayer = isLocal;
        info.msg = msgInfo;
        info.head = headID;
        info.SetNickName (nickName);
        info.TalkState = talkState;
        MsgInfo.Add (info);
    }
}
 类似资料: