123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using System;
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using System.Collections.Generic;
- using LitJson;
- using Random = UnityEngine.Random;
- public class CommentItemLabel
- {
- public static string Title = "Title";
- public static string VisitButtonTitle = "VisitButtonTitle";
- public static string VisitButton = "VisitButton";
- public static string Content = "Content";
- }
- 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 Title;
- public Text ContentText;
- public Button VisitButton;
- public BestfitText VisitButtonTitle;
- 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);
- Title = childDic[CommentItemLabel.Title].GetComponent<Text>();
- ContentText = childDic[CommentItemLabel.VisitButtonTitle].GetComponent<Text>();
- VisitButton = childDic[CommentItemLabel.VisitButton].GetComponent<Button>();
- VisitButtonTitle = childDic[CommentItemLabel.Content].GetComponent<BestfitText>();
- VisitButtonTitle.VerticalMaxSize = 20;
- ContentText.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
- VisitButton.onClick.AddListener(Visit);
-
- Manager.OnLevelChange += (level) =>
- {
- ContentText.text = ResourceManager.Get<Text>(ObjectLabel.C_CostLab).text;
- };
- return false;
- }
- public void Visit()
- {
- SocialManager.CloseCommentPanel();
- SocialManager.RecordCommentPanel();
- VisitManager.Visit(ConfigSource.SerialNumber, SerialNumber);
- }
- public void Reset(string nickname, string serialNumber, string content)
- {
- Content = content;
- SerialNumber = serialNumber;
- if (serialNumber == HttpManager.SerialNumber)
- {
- VisitButton.SetActive(false);
- }
- else
- {
- VisitButton.SetActive(true);
- }
- if (!string.IsNullOrEmpty(nickname))
- {
- Title.text = nickname;
- }
- else
- {
- if (Title.text.Length >= 4)
- {
- Title.text = "****" + serialNumber.Substring(serialNumber.Length - 4);
- }
- else
- {
- Title.text = "****" + Random.Range(1000, 10000);
- }
- }
- VisitButtonTitle.text = content;
- }
- }
|