Beta Sprint2

Beta Sprint2

catalogue

1.Achievements
2. Some important codes
3. SCRUM meeting
4.Expected tasks and completed tasks
5.Project Burnout Diagram
6.Task Total Change Chart
7. Result presentation

I.SCRUM section

1.Achievements

Recent Task Description Members Links
Implementation of chat function[6h] 汪郑贤【832102222_21124744】 https://github.com/Tyler-Linchenwei/chat
Implementation of adding friends function[4h] 邱韦翔【832102209_21125309】 https://github.com/Tyler-Linchenwei/chat
Implementation of adding friends function[4h] 吴正坤【832102209_21126917】 https://github.com/Tyler-Linchenwei/chat
Modify database design vulnerabilities【4h】 方光贤【832102209_21125929】 https://github.com/MochNevin/WechatServer

2. Some important codes

//------------------------------------------------------------
// 偷我的代码就会被拖进黑暗空间
// Copyright © 2023 Molth Nevin. All rights reserved.
//------------------------------------------------------------

using TMPro;
using UnityEngine;

namespace Erinn
{
   
    /// <summary>
    ///     表示一个用于显示聊天文本的网格的类
    /// </summary>
    public sealed class ChatGrid : MonoBehaviour
    {
   
        /// <summary>
        ///     获取或设置用于显示文本的 TextMeshPro 文本组件
        /// </summary>
        public TMP_Text TMPText;
    }
}
//------------------------------------------------------------
// 偷我的代码就会被拖进黑暗空间
// Copyright © 2023 Molth Nevin. All rights reserved.
//------------------------------------------------------------

using System.Collections.Generic;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;

namespace Erinn
{
   
    /// <summary>
    ///     表示一个聊天面板的类,用于管理和显示聊天视图
    /// </summary>
    public sealed class ChatPanel : MonoBehaviour
    {
   
        /// <summary>
        ///     当前活动的聊天视图
        /// </summary>
        [HideInInspector] public ChatView Active;

        /// <summary>
        ///     聊天面板的名称文本
        /// </summary>
        [LabelText("名称")] public TMP_Text ChatName;

        /// <summary>
        ///     聊天视图的预制件
        /// </summary>
        [LabelText("预制件")] public ChatView Prefab;

        /// <summary>
        ///     聊天视图的对象池
        /// </summary>
        [LabelText("池")] public Transform Pool;

        /// <summary>
        ///     存储用户和对应聊天视图的字典
        /// </summary>
        public Dictionary<string, ChatView> ChatViews;

        /// <summary>
        ///     在对象被唤醒时调用,用于初始化字典
        /// </summary>
        public void OnAwake() => ChatViews = new Dictionary<string, ChatView>();

        /// <summary>
        ///     接收用户的消息并在对应的聊天视图中显示
        /// </summary>
        /// <param name="username">发送消息的用户名</param>
        /// <param name="message">接收到的消息内容</param>
        public void Receive(string username, string message)
        {
   
            if (!ChatViews.TryGetValue(username, out var chatView))
            {
   
                chatView = Instantiate(Prefab, Pool, false);
                chatView.Name = username;
                ChatViews[username] = chatView;
            }

            chatView.Receive(message);
        }

        /// <summary>
        ///     切换到指定用户的聊天视图或创建新的视图
        /// </summary>
        public void Chat()
        {
   
            if (Active != null)
            {
   
                if (Active.Name == ChatName.text)
                    return;
                Active.gameObject.SetActive(false);
            }

            if (!ChatViews.TryGetValue(ChatName.text, out var chatView))
            {
   
                chatView = Instantiate(Prefab, Pool, false);
                chatView.Name = ChatName.text;
                ChatViews[ChatName.text] = chatView;
            }

            Active = chatView;
            chatView.gameObject.SetActive(true);
        }
    }
}

In this code, we first set up a class for the chat panel to manage and display the chat view. Next, we set the text name, prefabricated parts, object pool, and other contents for the chat view. At the same time, we initialized the dictionary that stores users and corresponding chat views and called it when the object is awakened.

//------------------------------------------------------------
// 偷我的代码就会被拖进黑暗空间
// Copyright © 2023 Molth Nevin. All rights reserved.
//------------------------------------------------------------

using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Erinn
{
   
    /// <summary>
    ///     聊天视图类,用于管理聊天界面的显示与消息发送
    /// </summary>
    public class ChatView : MonoBehaviour
    {
   
        /// <summary>
        ///     用户名,隐藏在Inspector面板中
        /// </summary>
        [HideInInspector] public string Name;

        /// <summary>
        ///     输入框,用于用户输入消息
        /// </summary>
        
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值