2024-12-15 01:39:39 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public enum ChatType { Connect, DisConnect, Chat, Notice, HotTime }
|
|
|
|
|
|
|
|
|
|
public class ChatUI : uScrollViewMgr
|
|
|
|
|
{
|
|
|
|
|
public TMP_InputField m_Input;
|
|
|
|
|
public List<ChatCard> list_ChatCard = new List<ChatCard>();
|
|
|
|
|
public BanListUI m_BanListUI;
|
|
|
|
|
|
2025-01-04 00:06:47 +00:00
|
|
|
int CCIndex;
|
2024-12-15 01:39:39 +00:00
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
base.Awake();
|
|
|
|
|
m_ChatBan = Get_ChatBan();
|
|
|
|
|
CCIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
m_BanListUI.Check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add_Chat(string[] split)
|
|
|
|
|
{
|
|
|
|
|
if (m_ChatBan.m_List.Exists(f => f.ID == split[1])) return;
|
|
|
|
|
int index = split[1] == ServerInfo.Ins.m_LoginInfo.PlayFabId ? 0 : 1;
|
|
|
|
|
var cc = list_ChatCard[CCIndex++];
|
2025-01-04 00:06:47 +00:00
|
|
|
if (CCIndex > list_ChatCard.Count - 1) CCIndex = 0;
|
2024-12-15 01:39:39 +00:00
|
|
|
cc.Set(split);
|
|
|
|
|
ScrollTo(cc.transform, true, 47 >> 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeleteAllChatMsg()
|
|
|
|
|
{
|
|
|
|
|
list_ChatCard.ForEach(f => f.gameObject.SetActive(false));
|
|
|
|
|
CCIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnSubmit_Intput()
|
|
|
|
|
{
|
|
|
|
|
var inputmsg = table_localtext.Ins.Get_Text(132);
|
|
|
|
|
if (!string.IsNullOrEmpty(m_Input.text) && !m_Input.text.Equals(inputmsg))
|
|
|
|
|
{
|
|
|
|
|
if (m_Input.text[0] == '/' && m_Input.text.Length > 1)
|
|
|
|
|
OptionInfo.Ins.Use_Coupon(m_Input.text.Replace("/", ""));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
|
|
|
if (sdata.PC.Lv >= MyValue.ChatLimitLV)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(m_Input.text) && !m_Input.text.Equals(inputmsg))
|
|
|
|
|
MessageInfo.Ins.Send_Msg(ChatType.Chat, m_Input.text);
|
|
|
|
|
else
|
|
|
|
|
ToastUI.Ins.Set(132);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ToastUI.Ins.Set(133, MyValue.ChatLimitLV);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OnSubmit_ResetStatus();
|
|
|
|
|
}
|
|
|
|
|
public void OnSubmit_ResetStatus()
|
|
|
|
|
{
|
|
|
|
|
m_Input.text = "";
|
|
|
|
|
if (m_Input.placeholder is TextMeshProUGUI placeholderText)
|
|
|
|
|
{
|
|
|
|
|
// 조건에 따라 텍스트 설정
|
|
|
|
|
placeholderText.text = ServerInfo.Ins.m_ServerData.PC.Lv < MyValue.ChatLimitLV
|
|
|
|
|
? DSUtil.Format(133, MyValue.ChatLimitLV)
|
|
|
|
|
: table_localtext.Ins.Get_Text(132);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnClick_Banlist()
|
|
|
|
|
{
|
|
|
|
|
m_BanListUI.Set(m_ChatBan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 밴
|
|
|
|
|
ChatBan m_ChatBan;
|
|
|
|
|
ChatBan Get_ChatBan()
|
|
|
|
|
{
|
|
|
|
|
var f = new FileInfo(Application.persistentDataPath + "\\" + "BanList");
|
|
|
|
|
if (f.Exists)
|
|
|
|
|
{
|
|
|
|
|
StreamReader r = File.OpenText(Application.persistentDataPath + "\\" + "BanList");
|
|
|
|
|
string info = r.ReadToEnd();
|
|
|
|
|
r.Dispose();
|
|
|
|
|
r.Close();
|
|
|
|
|
var text = AesOperation.DecryptString(info);
|
|
|
|
|
var data = JsonUtility.FromJson<ChatBan>(text);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return new ChatBan { m_List = new List<ChatBanData>() };
|
|
|
|
|
}
|
|
|
|
|
public void Add_ChatBan(ChatBanData _data)
|
|
|
|
|
{
|
|
|
|
|
if (m_ChatBan.m_List.Exists(f => f.ID == _data.ID))
|
|
|
|
|
ToastUI.Ins.Set(134, _data.Nick);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_ChatBan.m_List.Add(_data);
|
|
|
|
|
Save_BanFile();
|
|
|
|
|
ToastUI.Ins.Set(135, _data.Nick);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Del_ChatBan(string _id, string _nick)
|
|
|
|
|
{
|
|
|
|
|
if (m_ChatBan.m_List.Exists(f => f.ID == _id))
|
|
|
|
|
{
|
|
|
|
|
m_ChatBan.m_List.RemoveAll(f => f.ID == _id);
|
|
|
|
|
Save_BanFile();
|
|
|
|
|
ToastUI.Ins.Set(136, _nick);
|
|
|
|
|
OnClick_Banlist();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Save_BanFile()
|
|
|
|
|
{
|
|
|
|
|
var encry = AesOperation.EncryptString(JsonUtility.ToJson(m_ChatBan));
|
|
|
|
|
File.WriteAllText(Application.persistentDataPath + "\\" + "BanList", encry);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class ChatBan
|
|
|
|
|
{
|
|
|
|
|
public List<ChatBanData> m_List;
|
|
|
|
|
}
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class ChatBanData
|
|
|
|
|
{
|
|
|
|
|
public string ID, Nick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class AesOperation
|
|
|
|
|
{
|
|
|
|
|
private static string key = "kl!sd@k#lo44$4G%00^55&aj*k(mb)dl";
|
|
|
|
|
|
|
|
|
|
public static string EncryptString(string plainText)
|
|
|
|
|
{
|
|
|
|
|
byte[] iv = new byte[16];
|
|
|
|
|
byte[] array;
|
|
|
|
|
|
|
|
|
|
using (Aes aes = Aes.Create())
|
|
|
|
|
{
|
|
|
|
|
aes.Key = Encoding.UTF8.GetBytes(key);
|
|
|
|
|
aes.IV = iv;
|
|
|
|
|
|
|
|
|
|
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
|
|
|
|
|
|
|
|
|
|
using (MemoryStream memoryStream = new MemoryStream())
|
|
|
|
|
{
|
|
|
|
|
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
|
|
|
|
|
{
|
|
|
|
|
using (StreamWriter streamWriter = new StreamWriter(cryptoStream))
|
|
|
|
|
{
|
|
|
|
|
streamWriter.Write(plainText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array = memoryStream.ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Convert.ToBase64String(array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string DecryptString(string cipherText)
|
|
|
|
|
{
|
|
|
|
|
byte[] iv = new byte[16];
|
|
|
|
|
byte[] buffer = Convert.FromBase64String(cipherText);
|
|
|
|
|
|
|
|
|
|
using (Aes aes = Aes.Create())
|
|
|
|
|
{
|
|
|
|
|
aes.Key = Encoding.UTF8.GetBytes(key);
|
|
|
|
|
aes.IV = iv;
|
|
|
|
|
ICryptoTransform decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
|
|
|
|
|
|
|
|
|
|
using (MemoryStream memoryStream = new MemoryStream(buffer))
|
|
|
|
|
{
|
|
|
|
|
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
|
|
|
|
|
{
|
|
|
|
|
using (StreamReader streamReader = new StreamReader(cryptoStream))
|
|
|
|
|
{
|
|
|
|
|
return streamReader.ReadToEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|