112 lines
1.9 KiB
C#
112 lines
1.9 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class jkmFishPanel : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public struct stFish
|
|
{
|
|
public int id;
|
|
|
|
public Fish fish;
|
|
|
|
public Text text;
|
|
}
|
|
|
|
public stFish[] lines;
|
|
|
|
public string[] texts;
|
|
|
|
public int id;
|
|
|
|
private static jkmFishPanel instance;
|
|
|
|
public static jkmFishPanel Instance
|
|
{
|
|
get
|
|
{
|
|
if (!instance)
|
|
{
|
|
instance = UnityEngine.Object.FindObjectOfType<jkmFishPanel>();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
for (int i = 0; i < lines.Length; i++)
|
|
{
|
|
lines[i].id = -1;
|
|
}
|
|
texts = new string[lines.Length];
|
|
}
|
|
|
|
public void AddFishTextLoc(Fish fish, string s, bool reset)
|
|
{
|
|
stFish[] array = lines;
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
stFish stFish2 = array[i];
|
|
if (stFish2.fish == fish)
|
|
{
|
|
if (reset)
|
|
{
|
|
stFish2.text.text = s + " ";
|
|
}
|
|
else
|
|
{
|
|
Text text = stFish2.text;
|
|
text.text = text.text + s + " ";
|
|
}
|
|
texts[stFish2.id] = stFish2.text.text;
|
|
return;
|
|
}
|
|
}
|
|
lines[id].id = id;
|
|
lines[id].fish = fish;
|
|
lines[id].text.text = fish.name + ": " + s + " ";
|
|
texts[id] = lines[id].text.text;
|
|
id++;
|
|
id %= lines.Length;
|
|
lines[id].fish = null;
|
|
lines[id].text.text = string.Empty;
|
|
texts[id] = lines[id].text.text;
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
id = 0;
|
|
for (int i = 0; i < lines.Length; i++)
|
|
{
|
|
lines[i].id = -1;
|
|
lines[i].text.text = string.Empty;
|
|
lines[i].fish = null;
|
|
}
|
|
}
|
|
|
|
public static void AddFishText(Fish fish, string s, string color = "black", bool reset = false)
|
|
{
|
|
if (reset)
|
|
{
|
|
fish.jkmFishLogs += "XXX_RESRE_XXX\\n";
|
|
}
|
|
Debug.Log("<color=" + color + ">" + fish.jkmFishId + " " + s + " [" + fish.name + "]</color>");
|
|
fish.jkmFishLogs = fish.jkmFishLogs + s + "\\n";
|
|
if ((bool)Instance)
|
|
{
|
|
Instance.AddFishTextLoc(fish, s, reset);
|
|
}
|
|
}
|
|
}
|