123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using System.Collections.Generic;
- using LitJson;
- using Random = UnityEngine.Random;
- public class CommentData
- {
- public string SerialNumber;
- public string Content;
- public string NickName;
- public CommentData(JsonData jsonData)
- {
- SerialNumber = jsonData["s"].ToString();
- Content = jsonData["c"].ToString();
- NickName = jsonData["n"].ToString();
- }
- public static bool operator ==(CommentData r1, CommentData r2)
- {
- if ((r1.SerialNumber == r2.SerialNumber) && (r1.Content == r2.Content) && (r1.NickName == r2.NickName))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public static bool operator !=(CommentData r1, CommentData r2)
- {
- return !(r1 == r2);
- }
- public override bool Equals(object obj)
- {
- return this == (CommentData)obj;
- }
- public override int GetHashCode()
- {
- return SerialNumber.GetHashCode() + Content.GetHashCode() + NickName.GetHashCode();
- }
- }
- public class CommentItem : Regist
- {
- #region Config
- public Text Tit;
- public Text VisitLab;
- public Button VisitBtn;
- public BestfitText ContentLab;
- public string Content;
- public string SerialNumber;
- #endregion
- public override bool InitAtOnce()
- {
- if (base.InitAtOnce())
- {
- return true;
- }
- Dictionary<string, Transform> childDic = new Dictionary<string, Transform>();
- Auxiliary.CompileDic(transform, childDic);
- Tit = childDic["Tit"].GetComponent<Text>();
- VisitLab = childDic["VisitLab"].GetComponent<Text>();
- VisitBtn = childDic["VisitBtn"].GetComponent<Button>();
- ContentLab = childDic["ContentLab"].GetComponent<BestfitText>();
- ContentLab.VerticalMaxSize = 20;
- VisitLab.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
- VisitBtn.onClick.AddListener(Visit);
-
- Manager.OnLevelChange += () =>
- {
- VisitLab.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
- };
- return false;
- }
- public void Visit()
- {
- SocialManager.CloseCommentPanel();
- SocialManager.RecordCommentPanel();
- VisitManager.Visit(ArchiveSource.SerialNumber, SerialNumber);
- }
- public void Reset(string nickname, string serialNumber, string content)
- {
- Content = content;
- SerialNumber = serialNumber;
- if (serialNumber == HttpManager.SerialNumber)
- {
- VisitBtn.SetActive(false);
- }
- else
- {
- VisitBtn.SetActive(true);
- }
- if (!string.IsNullOrEmpty(nickname))
- {
- Tit.text = nickname;
- }
- else
- {
- if (Tit.text.Length >= 4)
- {
- Tit.text = "****" + serialNumber.Substring(serialNumber.Length - 4);
- }
- else
- {
- Tit.text = "****" + Random.Range(1000, 10000);
- }
- }
- ContentLab.text = content;
- }
- }
|