Commit 03f0c66b authored by 神楽坂玲奈's avatar 神楽坂玲奈

code reformat

parent 59f44e6e
using UnityEngine; using System.IO;
using System; using UnityEngine;
using System.IO;
public class BackGroundPic : Servant public class BackGroundPic : Servant
{ {
GameObject backGround; private GameObject backGround;
public override void initialize() public override void initialize()
{ {
backGround = create(Program.I().mod_simple_ngui_background_texture, Vector3.zero, Vector3.zero, false, Program.ui_back_ground_2d); backGround = create(Program.I().mod_simple_ngui_background_texture, Vector3.zero, Vector3.zero, false,
FileStream file = new FileStream("texture/common/desk.jpg", FileMode.Open, FileAccess.Read); Program.ui_back_ground_2d);
var file = new FileStream("texture/common/desk.jpg", FileMode.Open, FileAccess.Read);
file.Seek(0, SeekOrigin.Begin); file.Seek(0, SeekOrigin.Begin);
byte[] data = new byte[file.Length]; var data = new byte[file.Length];
file.Read(data, 0, (int)file.Length); file.Read(data, 0, (int) file.Length);
file.Close(); file.Close();
file.Dispose(); file.Dispose();
file = null; file = null;
Texture2D pic = new Texture2D(1024, 600); var pic = new Texture2D(1024, 600);
pic.LoadImage(data); pic.LoadImage(data);
backGround.GetComponent<UITexture>().mainTexture = pic; backGround.GetComponent<UITexture>().mainTexture = pic;
backGround.GetComponent<UITexture>().depth = -100; backGround.GetComponent<UITexture>().depth = -100;
...@@ -22,19 +24,20 @@ public class BackGroundPic : Servant ...@@ -22,19 +24,20 @@ public class BackGroundPic : Servant
public override void applyShowArrangement() public override void applyShowArrangement()
{ {
UIRoot root = Program.ui_back_ground_2d.GetComponent<UIRoot>(); var root = Program.ui_back_ground_2d.GetComponent<UIRoot>();
float s = (float)root.activeHeight / Screen.height; var s = (float) root.activeHeight / Screen.height;
var tex = backGround.GetComponent<UITexture>().mainTexture; var tex = backGround.GetComponent<UITexture>().mainTexture;
float ss = (float)tex.height / (float)tex.width; var ss = tex.height / (float) tex.width;
int width = (int)(Screen.width * s); var width = (int) (Screen.width * s);
int height = (int)(width * ss); var height = (int) (width * ss);
if (height < Screen.height) if (height < Screen.height)
{ {
height = (int)(Screen.height * s); height = (int) (Screen.height * s);
width = (int)(height / ss); width = (int) (height / ss);
} }
backGround.GetComponent<UITexture>().height = height+2;
backGround.GetComponent<UITexture>().width = width+2; backGround.GetComponent<UITexture>().height = height + 2;
backGround.GetComponent<UITexture>().width = width + 2;
} }
public override void applyHideArrangement() public override void applyHideArrangement()
......
using UnityEngine; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions; using UnityEngine;
using YGOSharp.OCGWrapper.Enums; using YGOSharp.OCGWrapper.Enums;
public class Book : WindowServant2D public class Book : WindowServant2D
{ {
string kacha = ""; private string changcha = "";
string changcha = "";
string xuecha = ""; public string deckString = "";
private string kacha = "";
public UILabel lab = null;
public UILabel labop = null;
private readonly List<string> lines = new List<string>();
public string opString = "";
private lazyBookbtns texts;
private string xuecha = "";
lazyBookbtns texts;
public override void initialize() public override void initialize()
{ {
kacha = InterString.Get("卡差:"); kacha = InterString.Get("卡差:");
...@@ -24,21 +31,14 @@ public class Book : WindowServant2D ...@@ -24,21 +31,14 @@ public class Book : WindowServant2D
applyHideArrangement(); applyHideArrangement();
} }
string formatS(string from, int c,bool k) private string formatS(string from, int c, bool k)
{
string returnValue = "";
if (k)
{ {
return from + c.ToString(); var returnValue = "";
} if (k) return @from + c;
if (c < 0) if (c < 0)
{ returnValue = @from + "[ff0000]" + c + "[-]";
returnValue = from + "[ff0000]" + c.ToString() + "[-]";
}
else else
{ returnValue = @from + "[00ff00]" + c + "[-]";
returnValue = from + "[00ff00]" + c.ToString() + "[-]";
}
return returnValue; return returnValue;
} }
...@@ -47,26 +47,22 @@ public class Book : WindowServant2D ...@@ -47,26 +47,22 @@ public class Book : WindowServant2D
base.preFrameFunction(); base.preFrameFunction();
if (isShowed) if (isShowed)
{ {
gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(new Vector3(Program.I().cardDescription.width / 2, (Screen.height-Program.I().cardDescription.cHeight) / 2, 0)); gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(
texts.back.width = (int)Program.I().cardDescription.width; new Vector3(Program.I().cardDescription.width / 2,
texts.back.height = Screen.height - (int)Program.I().cardDescription.cHeight; (Screen.height - Program.I().cardDescription.cHeight) / 2, 0));
texts.back.width = (int) Program.I().cardDescription.width;
texts.back.height = Screen.height - (int) Program.I().cardDescription.cHeight;
} }
} }
public override void applyShowArrangement() public override void applyShowArrangement()
{ {
if (gameObject != null) if (gameObject != null) gameObject.SetActive(true);
{
gameObject.SetActive(true);
}
} }
public override void applyHideArrangement() public override void applyHideArrangement()
{ {
if (gameObject != null) if (gameObject != null) gameObject.SetActive(false);
{
gameObject.SetActive(false);
}
} }
public override void hide() public override void hide()
...@@ -84,151 +80,91 @@ public class Book : WindowServant2D ...@@ -84,151 +80,91 @@ public class Book : WindowServant2D
fixScreenProblem(); fixScreenProblem();
realize(); realize();
} }
public UILabel lab = null;
public UILabel labop = null;
public string deckString = "";
public string opString = "";
public void realize() public void realize()
{ {
MultiStringMaster master; MultiStringMaster master;
if (lab!=null) if (lab != null)
{ {
deckString = ""; deckString = "";
master = new MultiStringMaster(); master = new MultiStringMaster();
foreach (var item in TcpHelper.deckStrings) foreach (var item in TcpHelper.deckStrings) master.Add(item);
{
master.Add(item);
}
foreach (var item in Program.I().ocgcore.cards) foreach (var item in Program.I().ocgcore.cards)
{ {
if (item.p.location == (UInt32)CardLocation.Search) if (item.p.location == (uint) CardLocation.Search) continue;
{ if (item.p.location == (uint) CardLocation.Unknown) continue;
continue; if (item.p.location == (uint) CardLocation.Deck) continue;
} if (item.get_data().Id <= 0) continue;
if (item.p.location == (UInt32)CardLocation.Unknown) if (item.controllerBased == 0) master.remove(item.get_data().Name);
{
continue;
}
if (item.p.location == (UInt32)CardLocation.Deck)
{
continue;
}
if (item.get_data().Id <= 0)
{
continue;
}
if (item.controllerBased == 0)
{
master.remove(item.get_data().Name);
}
} }
deckString += master.managedString.TrimEnd('\n'); deckString += master.managedString.TrimEnd('\n');
lab.text = deckString; lab.text = deckString;
} }
if (labop != null) if (labop != null)
{ {
opString = ""; opString = "";
master = new MultiStringMaster(); master = new MultiStringMaster();
foreach (var item in Program.I().ocgcore.cards) foreach (var item in Program.I().ocgcore.cards)
{ {
if (item.p.location == (UInt32)CardLocation.Search) if (item.p.location == (uint) CardLocation.Search) continue;
{ if (item.get_data().Id <= 0) continue;
continue; if (item.controllerBased == 1) master.Add(item.get_data().Name);
}
if (item.get_data().Id <= 0)
{
continue;
}
if (item.controllerBased == 1)
{
master.Add(item.get_data().Name);
}
} }
opString += master.managedString.TrimEnd('\n'); opString += master.managedString.TrimEnd('\n');
if (Program.I().ocgcore.cantCheckGrave) if (Program.I().ocgcore.cantCheckGrave)
{
labop.text = InterString.Get("不能查看对手使用过的卡"); labop.text = InterString.Get("不能查看对手使用过的卡");
}
else if (master.strings.Count > 0) else if (master.strings.Count > 0)
{
labop.text = InterString.Get("[ff5555]对手使用过:@n[?][-]", opString); labop.text = InterString.Get("[ff5555]对手使用过:@n[?][-]", opString);
}
else else
{
labop.text = InterString.Get("请等待对手出牌来获取情报"); labop.text = InterString.Get("请等待对手出牌来获取情报");
} }
}
if (isShowed == false) if (isShowed == false) return;
{
return;
}
var fieldCards = new int[2] {0, 0};
int[] fieldCards = new int[2] { 0, 0 }; var handCards = new int[2] {0, 0};
int[] handCards = new int[2] { 0, 0 }; var resourceCards = new int[2] {0, 0};
int[] resourceCards = new int[2] { 0, 0 }; var died = false;
bool died = false;
foreach (var item in Program.I().ocgcore.cards) foreach (var item in Program.I().ocgcore.cards)
{ {
if (item.p.location == (UInt32)CardLocation.Search) if (item.p.location == (uint) CardLocation.Search) continue;
{ if (item.p.location == (uint) CardLocation.Unknown) continue;
continue; for (var i = 0; i < 2; i++)
}
if (item.p.location == (UInt32)CardLocation.Unknown)
{
continue;
}
for (int i = 0; i < 2; i++)
{
if (item.p.controller == i) if (item.p.controller == i)
{ {
if (item.p.location == (UInt32)CardLocation.MonsterZone || item.p.location == (UInt32)CardLocation.SpellZone) if (item.p.location == (uint) CardLocation.MonsterZone ||
{ item.p.location == (uint) CardLocation.SpellZone) fieldCards[i]++;
fieldCards[i]++; if (item.p.location == (uint) CardLocation.Hand) handCards[i]++;
} if (item.p.location == (uint) CardLocation.Grave || item.p.location == (uint) CardLocation.Removed)
if (item.p.location == (UInt32)CardLocation.Hand)
{
handCards[i]++;
}
if (item.p.location == (UInt32)CardLocation.Grave || item.p.location == (UInt32)CardLocation.Removed)
{
resourceCards[i]++; resourceCards[i]++;
} }
} }
}
}
if (!died)
{
texts.lable.text =InterString.Get("消息记录")+"\n"+ if (!died)
formatS(kacha, (fieldCards[0] + handCards[0]) - (fieldCards[1] + handCards[1]), false) + " " + texts.lable.text = InterString.Get("消息记录") + "\n" +
formatS(changcha, (fieldCards[0]) - (fieldCards[1]), false) + " " + formatS(kacha, fieldCards[0] + handCards[0] - (fieldCards[1] + handCards[1]), false) +
" " +
formatS(changcha, fieldCards[0] - fieldCards[1], false) + " " +
formatS(xuecha, formatS(xuecha,
Program.I().ocgcore.gameInfo.swaped Program.I().ocgcore.gameInfo.swaped
? ? Program.I().ocgcore.life_1 - Program.I().ocgcore.life_0
Program.I().ocgcore.life_1 - Program.I().ocgcore.life_0 : Program.I().ocgcore.life_0 - Program.I().ocgcore.life_1
:
Program.I().ocgcore.life_0 - Program.I().ocgcore.life_1
, false); , false);
} var all = "";
string all = ""; foreach (var item in lines) all += item + "\n";
foreach (var item in lines)
{
all += item + "\n";
}
try try
{ {
all = all.Substring(0, all.Length - 1); all = all.Substring(0, all.Length - 1);
} }
catch (System.Exception e) catch (Exception e)
{ {
} }
try try
{ {
texts.textlist.Clear(); texts.textlist.Clear();
...@@ -240,8 +176,6 @@ public class Book : WindowServant2D ...@@ -240,8 +176,6 @@ public class Book : WindowServant2D
} }
} }
List<string> lines = new List<string>();
public void add(string str) public void add(string str)
{ {
lines.Add(str); lines.Add(str);
...@@ -253,5 +187,4 @@ public class Book : WindowServant2D ...@@ -253,5 +187,4 @@ public class Book : WindowServant2D
lines.Clear(); lines.Clear();
realize(); realize();
} }
} }
\ No newline at end of file
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine;
public static class Config public static class Config
{ {
public static uint ClientVersion = 0x1352; public static uint ClientVersion = 0x1352;
class oneString private static readonly List<oneString> translations = new List<oneString>();
{
public string original = "";
public string translated = "";
}
static List<oneString> translations = new List<oneString>(); private static readonly List<oneString> uits = new List<oneString>();
static List<oneString> uits = new List<oneString>(); private static string path;
static string path; private static bool loaded;
public static bool getEffectON(string raw) public static bool getEffectON(string raw)
{ {
...@@ -25,18 +23,15 @@ public static class Config ...@@ -25,18 +23,15 @@ public static class Config
public static void initialize(string path) public static void initialize(string path)
{ {
Config.path = path; Config.path = path;
if (File.Exists(path) == false) if (File.Exists(path) == false) File.Create(path).Close();
{ var txtString = File.ReadAllText(path);
File.Create(path).Close(); var lines = txtString.Replace("\r", "").Split("\n");
} for (var i = 0; i < lines.Length; i++)
string txtString = File.ReadAllText(path);
string[] lines = txtString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{ {
string[] mats = lines[i].Split("->"); var mats = lines[i].Split("->");
if (mats.Length == 2) if (mats.Length == 2)
{ {
oneString s = new oneString(); var s = new oneString();
s.original = mats[0]; s.original = mats[0];
s.translated = mats[1]; s.translated = mats[1];
translations.Add(s); translations.Add(s);
...@@ -44,107 +39,102 @@ public static class Config ...@@ -44,107 +39,102 @@ public static class Config
} }
} }
static bool loaded = false;
public static string Getui(string original) public static string Getui(string original)
{ {
if (loaded == false) if (loaded == false)
{ {
loaded = true; loaded = true;
string[] lines = File.ReadAllText("texture/ui/config.txt").Replace("\r", "").Replace(" ", "").Split("\n"); var lines = File.ReadAllText("texture/ui/config.txt").Replace("\r", "").Replace(" ", "").Split("\n");
for (int i = 0; i < lines.Length; i++) for (var i = 0; i < lines.Length; i++)
{ {
string[] mats = lines[i].Split("="); var mats = lines[i].Split("=");
if (mats.Length == 2) if (mats.Length == 2)
{ {
oneString s = new oneString(); var s = new oneString();
s.original = mats[0]; s.original = mats[0];
s.translated = mats[1]; s.translated = mats[1];
uits.Add(s); uits.Add(s);
} }
} }
} }
string return_value = "";
for (int i = 0; i < uits.Count; i++) var return_value = "";
{ for (var i = 0; i < uits.Count; i++)
if (uits[i].original == original) if (uits[i].original == original)
{ {
return_value = uits[i].translated; return_value = uits[i].translated;
break; break;
} }
}
return return_value; return return_value;
} }
internal static float getFloat(string v) internal static float getFloat(string v)
{ {
int getted = 0; var getted = 0;
try try
{ {
getted = Int32.Parse(Get(v, "0")); getted = int.Parse(Get(v, "0"));
} }
catch (Exception) catch (Exception)
{ {
} }
return ((float)getted) / 100000f;
return getted / 100000f;
} }
internal static void setFloat(string v,float f) internal static void setFloat(string v, float f)
{ {
Set(v,((int)(f* 100000f)).ToString()); Set(v, ((int) (f * 100000f)).ToString());
} }
public static string Get(string original,string defau) public static string Get(string original, string defau)
{
string return_value = defau;
bool finded = false;
for (int i = 0; i < translations.Count; i++)
{ {
var return_value = defau;
var finded = false;
for (var i = 0; i < translations.Count; i++)
if (translations[i].original == original) if (translations[i].original == original)
{ {
return_value = translations[i].translated; return_value = translations[i].translated;
finded = true; finded = true;
break; break;
} }
}
if (finded == false) if (finded == false)
{
if (path != null) if (path != null)
{ {
File.AppendAllText(path, original + "->" + defau + "\r\n"); File.AppendAllText(path, original + "->" + defau + "\r\n");
oneString s = new oneString(); var s = new oneString();
s.original = original; s.original = original;
s.translated = defau; s.translated = defau;
return_value = defau; return_value = defau;
translations.Add(s); translations.Add(s);
} }
}
return return_value; return return_value;
} }
public static void Set(string original,string setted) public static void Set(string original, string setted)
{
bool finded = false;
for (int i = 0; i < translations.Count; i++)
{ {
var finded = false;
for (var i = 0; i < translations.Count; i++)
if (translations[i].original == original) if (translations[i].original == original)
{ {
finded = true; finded = true;
translations[i].translated = setted; translations[i].translated = setted;
} }
}
if (finded == false) if (finded == false)
{ {
oneString s = new oneString(); var s = new oneString();
s.original = original; s.original = original;
s.translated = setted; s.translated = setted;
translations.Add(s); translations.Add(s);
} }
string all = "";
for (int i = 0; i < translations.Count; i++) var all = "";
{ for (var i = 0; i < translations.Count; i++)
all += translations[i].original + "->" + translations[i].translated + "\r\n"; all += translations[i].original + "->" + translations[i].translated + "\r\n";
}
try try
{ {
File.WriteAllText(path, all); File.WriteAllText(path, all);
...@@ -152,7 +142,13 @@ public static class Config ...@@ -152,7 +142,13 @@ public static class Config
catch (Exception e) catch (Exception e)
{ {
Program.noAccess = true; Program.noAccess = true;
UnityEngine.Debug.Log(e); Debug.Log(e);
} }
} }
private class oneString
{
public string original = "";
public string translated = "";
}
} }
\ No newline at end of file
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.IO; using System.IO;
public static class InterString public static class InterString
{ {
static Dictionary<string, string> translations = new Dictionary<string, string>(); private static readonly Dictionary<string, string> translations = new Dictionary<string, string>();
static string path; private static string path;
public static bool loaded = false; public static bool loaded;
public static void initialize(string path) public static void initialize(string path)
{ {
InterString.path = path; InterString.path = path;
if (File.Exists(path) == false) if (File.Exists(path) == false) File.Create(path).Close();
{ var txtString = File.ReadAllText(path);
File.Create(path).Close(); var lines = txtString.Replace("\r", "").Split("\n");
} for (var i = 0; i < lines.Length; i++)
string txtString = File.ReadAllText(path);
string[] lines = txtString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{ {
string[] mats = lines[i].Split("->"); var mats = lines[i].Split("->");
if (mats.Length == 2) if (mats.Length == 2)
{
if (!translations.ContainsKey(mats[0])) if (!translations.ContainsKey(mats[0]))
{
translations.Add(mats[0], mats[1]); translations.Add(mats[0], mats[1]);
} }
}
}
GameStringHelper.xilie = Get("系列:"); GameStringHelper.xilie = Get("系列:");
GameStringHelper.opHint = Get("*控制权经过转移"); GameStringHelper.opHint = Get("*控制权经过转移");
GameStringHelper.licechuwai= Get("*里侧表示的除外卡片"); GameStringHelper.licechuwai = Get("*里侧表示的除外卡片");
GameStringHelper.biaoceewai = Get("*表侧表示的额外卡片"); GameStringHelper.biaoceewai = Get("*表侧表示的额外卡片");
GameStringHelper.teshuzhaohuan= Get("*被特殊召唤出场"); GameStringHelper.teshuzhaohuan = Get("*被特殊召唤出场");
GameStringHelper.yijingqueren = Get("卡片展示简表※ "); GameStringHelper.yijingqueren = Get("卡片展示简表※ ");
GameStringHelper._chaoliang = Get("超量:"); GameStringHelper._chaoliang = Get("超量:");
GameStringHelper._ewaikazu = Get("额外卡组:"); GameStringHelper._ewaikazu = Get("额外卡组:");
...@@ -59,13 +53,11 @@ public static class InterString ...@@ -59,13 +53,11 @@ public static class InterString
public static string Get(string original) public static string Get(string original)
{ {
var return_value = original;
string return_value = original;
if (translations.TryGetValue(original, out return_value)) if (translations.TryGetValue(original, out return_value))
{
return return_value.Replace("@n", "\r\n").Replace("@ui", ""); return return_value.Replace("@n", "\r\n").Replace("@ui", "");
}
else if (original != "") if (original != "")
{ {
try try
{ {
...@@ -75,10 +67,11 @@ public static class InterString ...@@ -75,10 +67,11 @@ public static class InterString
{ {
Program.noAccess = true; Program.noAccess = true;
} }
translations.Add(original, original); translations.Add(original, original);
return original.Replace("@n", "\r\n").Replace("@ui", ""); return original.Replace("@n", "\r\n").Replace("@ui", "");
} }
else
return original; return original;
} }
...@@ -86,5 +79,4 @@ public static class InterString ...@@ -86,5 +79,4 @@ public static class InterString
{ {
return Get(original).Replace("[?]", replace); return Get(original).Replace("[?]", replace);
} }
} }
\ No newline at end of file
This diff is collapsed.
using UnityEngine; using System;
using System; using UnityEngine;
public class MonoDelegate : MonoBehaviour public class MonoDelegate : MonoBehaviour
{ {
public Action actionInMono; public Action actionInMono;
public void function() public void function()
{ {
if (actionInMono != null) actionInMono(); if (actionInMono != null) actionInMono();
...@@ -14,9 +15,10 @@ public class MonoDelegate : MonoBehaviour ...@@ -14,9 +15,10 @@ public class MonoDelegate : MonoBehaviour
public class MonoListener : MonoBehaviour public class MonoListener : MonoBehaviour
{ {
public Action<GameObject> actionInMono; public Action<GameObject> actionInMono;
public void function() public void function()
{ {
if (actionInMono != null) actionInMono(this.gameObject); if (actionInMono != null) actionInMono(gameObject);
} }
} }
...@@ -24,16 +26,17 @@ public class MonoListenerRMS_ized : MonoBehaviour ...@@ -24,16 +26,17 @@ public class MonoListenerRMS_ized : MonoBehaviour
{ {
public Action<GameObject, Servant.messageSystemValue> actionInMono; public Action<GameObject, Servant.messageSystemValue> actionInMono;
public Servant.messageSystemValue value; public Servant.messageSystemValue value;
public void function() public void function()
{ {
UIInput input = GetComponent<UIInput>(); var input = GetComponent<UIInput>();
if (input != null) if (input != null)
{ {
value = new Servant.messageSystemValue(); value = new Servant.messageSystemValue();
value.hint = input.name; value.hint = input.name;
value.value = input.value; value.value = input.value;
} }
if (actionInMono != null) actionInMono(this.gameObject, value);
if (actionInMono != null) actionInMono(gameObject, value);
} }
} }
\ No newline at end of file
This diff is collapsed.
using System; using UnityEngine;
using UnityEngine;
public class TextMaster public class TextMaster
{ {
private readonly GameObject gameObject;
GameObject gameObject;
public TextMaster(string hint, Vector3 position, bool isWorld) public TextMaster(string hint, Vector3 position, bool isWorld)
{ {
...@@ -25,13 +23,13 @@ public class TextMaster ...@@ -25,13 +23,13 @@ public class TextMaster
{ {
gameObject = Program.I().ocgcore.create_s( gameObject = Program.I().ocgcore.create_s(
Program.I().mod_simple_ngui_text, Program.I().mod_simple_ngui_text,
(Program.camera_main_2d.ScreenToWorldPoint(position)), Program.camera_main_2d.ScreenToWorldPoint(position),
new Vector3(0, 0, 0), new Vector3(0, 0, 0),
true, true,
Program.ui_main_2d, Program.ui_main_2d
true
); );
} }
UIHelper.trySetLableText(gameObject, hint); UIHelper.trySetLableText(gameObject, hint);
} }
...@@ -39,5 +37,4 @@ public class TextMaster ...@@ -39,5 +37,4 @@ public class TextMaster
{ {
Program.I().ocgcore.destroy(gameObject, 0.6f, true); Program.I().ocgcore.destroy(gameObject, 0.6f, true);
} }
} }
\ No newline at end of file
This diff is collapsed.
using System; using System.Collections.Generic;
using System.Collections.Generic;
public class MultiStringMaster public class MultiStringMaster
{ {
public class part public string managedString = "";
{
public string str;
public int count;
}
public List<part> strings = new List<part>(); public List<part> strings = new List<part>();
public string managedString = "";
public void Add(string str) public void Add(string str)
{ {
bool exist = false; var exist = false;
for (int i = 0; i < strings.Count; i++) for (var i = 0; i < strings.Count; i++)
{
if (strings[i].str == str) if (strings[i].str == str)
{ {
exist = true; exist = true;
strings[i].count++; strings[i].count++;
} }
}
if (exist == false) if (exist == false)
{ {
part t = new part(); var t = new part();
t.count = 1; t.count = 1;
t.str = str; t.str = str;
strings.Add(t); strings.Add(t);
} }
managedString = ""; managedString = "";
for (int i = 0; i < strings.Count; i++) for (var i = 0; i < strings.Count; i++)
{
if (strings[i].count == 1) if (strings[i].count == 1)
{
managedString += strings[i].str + "\n"; managedString += strings[i].str + "\n";
}
else else
{ managedString += strings[i].str + "*" + strings[i].count + "\n";
managedString += strings[i].str + "*" + strings[i].count.ToString() + "\n";
}
}
} }
public void clear() public void clear()
...@@ -54,36 +41,28 @@ public class MultiStringMaster ...@@ -54,36 +41,28 @@ public class MultiStringMaster
public void remove(string str) public void remove(string str)
{ {
part t = null; part t = null;
for (int i = 0; i < strings.Count; i++) for (var i = 0; i < strings.Count; i++)
{
if (strings[i].str.Replace(str, "miaowu") != strings[i].str) if (strings[i].str.Replace(str, "miaowu") != strings[i].str)
{
t = strings[i]; t = strings[i];
}
}
if (t != null) if (t != null)
{ {
if (t.count == 1) if (t.count == 1)
{
strings.Remove(t); strings.Remove(t);
}
else else
{
t.count--; t.count--;
} }
}
managedString = ""; managedString = "";
for (int i = 0; i < strings.Count; i++) for (var i = 0; i < strings.Count; i++)
{
if (strings[i].count == 1) if (strings[i].count == 1)
{
managedString += strings[i].str + "\n"; managedString += strings[i].str + "\n";
}
else else
{ managedString += strings[i].str + "*" + strings[i].count + "\n";
managedString += strings[i].str + "*" + strings[i].count.ToString() + "\n";
}
}
} }
public class part
{
public int count;
public string str;
}
} }
\ No newline at end of file
using System; using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class OCGobject public class OCGobject
{ {
public List<GameObject> allObjects = new List<GameObject>();
public GameObject gameObject; public GameObject gameObject;
public List<GameObject> allObjects=new List<GameObject>();
public GameObject create( public GameObject create(
GameObject mod, GameObject mod,
Vector3 position = default(Vector3), Vector3 position = default,
Vector3 rotation = default(Vector3), Vector3 rotation = default,
bool fade = false, bool fade = false,
GameObject father = null, GameObject father = null,
bool allParamsInWorld = true, bool allParamsInWorld = true,
Vector3 wantScale = default(Vector3) Vector3 wantScale = default
) )
{ {
GameObject g = Program.I().ocgcore.create_s(mod, position, rotation, fade, father, allParamsInWorld, wantScale); var g = Program.I().ocgcore.create_s(mod, position, rotation, fade, father, allParamsInWorld, wantScale);
allObjects.Add(g); allObjects.Add(g);
return g; return g;
} }
...@@ -28,5 +26,4 @@ public class OCGobject ...@@ -28,5 +26,4 @@ public class OCGobject
allObjects.Remove(obj); allObjects.Remove(obj);
Program.I().ocgcore.destroy(obj, time, fade, instantNull); Program.I().ocgcore.destroy(obj, time, fade, instantNull);
} }
} }
\ No newline at end of file
using System; using UnityEngine;
using UnityEngine;
public class gameButton : OCGobject public class gameButton : OCGobject
{ {
public GameObject gameObjectEvent; public gameCard cookieCard;
public int response; public string cookieString;
public GameObject gameObjectEvent;
public string hint; public string hint;
public superButtonType type;
public string cookieString;
public bool notCookie; public bool notCookie;
public gameCard cookieCard; public int response;
public superButtonType type;
public gameButton(int response, string hint, superButtonType type) public gameButton(int response, string hint, superButtonType type)
{ {
...@@ -30,18 +28,22 @@ public class gameButton : OCGobject ...@@ -30,18 +28,22 @@ public class gameButton : OCGobject
{ {
if (gameObject == null) if (gameObject == null)
{ {
gameObject = create(Program.I().new_ui_superButton, Program.camera_main_2d.ScreenToWorldPoint(v), Vector3.zero, false, Program.ui_main_2d, true); gameObject = create(Program.I().new_ui_superButton, Program.camera_main_2d.ScreenToWorldPoint(v),
Vector3.zero, false, Program.ui_main_2d);
gameObjectEvent = UIHelper.getRealEventGameObject(gameObject); gameObjectEvent = UIHelper.getRealEventGameObject(gameObject);
UIHelper.registEvent(gameObject, clicked); UIHelper.registEvent(gameObject, clicked);
gameObject.GetComponent<iconSetForButton>().setTexture(type); gameObject.GetComponent<iconSetForButton>().setTexture(type);
gameObject.GetComponent<iconSetForButton>().setText(hint); gameObject.GetComponent<iconSetForButton>().setText(hint);
gameObject.transform.localScale = Vector3.zero; gameObject.transform.localScale = Vector3.zero;
iTween.ScaleTo(gameObject, new Vector3(0.7f * (float)Screen.height / 700f, 0.7f * (float)Screen.height / 700f, 0.7f * (float)Screen.height / 700f), 0.2f); iTween.ScaleTo(gameObject,
new Vector3(0.7f * Screen.height / 700f, 0.7f * Screen.height / 700f, 0.7f * Screen.height / 700f),
0.2f);
} }
gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(v); gameObject.transform.position = Program.camera_main_2d.ScreenToWorldPoint(v);
} }
void clicked() private void clicked()
{ {
Program.I().ocgcore.ES_gameButtonClicked(this); Program.I().ocgcore.ES_gameButtonClicked(this);
} }
...@@ -52,5 +54,4 @@ public class gameButton : OCGobject ...@@ -52,5 +54,4 @@ public class gameButton : OCGobject
gameObject = null; gameObject = null;
gameObjectEvent = null; gameObjectEvent = null;
} }
} }
\ No newline at end of file
using System; public class mod : OCGobject
using UnityEngine;
public class mod : OCGobject
{ {
public mod() public mod()
{ {
...@@ -15,6 +12,5 @@ public class mod : OCGobject ...@@ -15,6 +12,5 @@ public class mod : OCGobject
public void Update() public void Update()
{ {
} }
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using System.IO;
using YGOSharp;
public static class GameStringManager public static class GameStringManager
{ {
public class hashedString
{
public string region = "";
public int hashCode = 0;
public string content = "";
}
public static List<hashedString> hashedStrings = new List<hashedString>(); public static List<hashedString> hashedStrings = new List<hashedString>();
public static List<hashedString> xilies = new List<hashedString>(); public static List<hashedString> xilies = new List<hashedString>();
public static int helper_stringToInt(string str) public static int helper_stringToInt(string str)
{ {
int return_value = 0; var return_value = 0;
try try
{ {
if (str.Length > 2 && str.Substring(0, 2) == "0x") if (str.Length > 2 && str.Substring(0, 2) == "0x")
{
return_value = Convert.ToInt32(str, 16); return_value = Convert.ToInt32(str, 16);
}
else else
{ return_value = int.Parse(str);
return_value = Int32.Parse(str);
}
} }
catch (Exception) catch (Exception)
{ {
} }
return return_value; return return_value;
} }
public static void initialize(string path) public static void initialize(string path)
{ {
string text = System.IO.File.ReadAllText(path); var text = File.ReadAllText(path);
initializeContent(text); initializeContent(text);
} }
public static void initializeContent(string text) public static void initializeContent(string text)
{ {
string st = text.Replace("\r", ""); var st = text.Replace("\r", "");
string[] lines = st.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); var lines = st.Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries);
foreach (string line in lines) foreach (var line in lines)
{
if (line.Length > 1 && line.Substring(0, 1) == "!") if (line.Length > 1 && line.Substring(0, 1) == "!")
{ {
string[] mats = line.Substring(1, line.Length - 1).Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); var mats = line.Substring(1, line.Length - 1).Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries);
if (mats.Length > 2) if (mats.Length > 2)
{ {
hashedString a = new hashedString(); var a = new hashedString();
a.region = mats[0]; a.region = mats[0];
try try
{ {
...@@ -61,20 +52,14 @@ public static class GameStringManager ...@@ -61,20 +52,14 @@ public static class GameStringManager
{ {
Program.DEBUGLOG(e); Program.DEBUGLOG(e);
} }
a.content = ""; a.content = "";
for (int i = 2; i < mats.Length; i++) for (var i = 2; i < mats.Length; i++) a.content += mats[i] + " ";
{
a.content += mats[i] + " ";
}
a.content = a.content.Substring(0, a.content.Length - 1); a.content = a.content.Substring(0, a.content.Length - 1);
if (get(a.region, a.hashCode) == "") if (get(a.region, a.hashCode) == "")
{ {
hashedStrings.Add(a); hashedStrings.Add(a);
if (a.region == "setname") if (a.region == "setname") xilies.Add(a);
{
xilies.Add(a);
}
}
} }
} }
} }
...@@ -82,52 +67,51 @@ public static class GameStringManager ...@@ -82,52 +67,51 @@ public static class GameStringManager
public static string get(string region, int hashCode) public static string get(string region, int hashCode)
{ {
string re = ""; var re = "";
foreach (hashedString s in hashedStrings) foreach (var s in hashedStrings)
{
if (s.region == region && s.hashCode == hashCode) if (s.region == region && s.hashCode == hashCode)
{ {
re = s.content; re = s.content;
break; break;
} }
}
return re; return re;
} }
internal static string get_unsafe(int hashCode) internal static string get_unsafe(int hashCode)
{ {
string re = ""; var re = "";
foreach (hashedString s in hashedStrings) foreach (var s in hashedStrings)
{
if (s.region == "system" && s.hashCode == hashCode) if (s.region == "system" && s.hashCode == hashCode)
{ {
re = s.content; re = s.content;
break; break;
} }
}
return re; return re;
} }
internal static string get(int description) internal static string get(int description)
{ {
string a = ""; var a = "";
if (description < 10000) if (description < 10000)
{ {
a = get("system", (int)description); a = get("system", description);
} }
else else
{ {
int code = description >> 4; var code = description >> 4;
int index = description & 0xf; var index = description & 0xf;
try try
{ {
a = YGOSharp.CardsManager.Get(code).Str[index]; a = CardsManager.Get(code).Str[index];
} }
catch (Exception e) catch (Exception e)
{ {
Program.DEBUGLOG(e); Program.DEBUGLOG(e);
} }
} }
return a; return a;
} }
...@@ -137,23 +121,29 @@ public static class GameStringManager ...@@ -137,23 +121,29 @@ public static class GameStringManager
{ {
if (sequence < 5) if (sequence < 5)
return get(1003); return get(1003);
else if (sequence == 5) if (sequence == 5)
return get(1008); return get(1008);
else
return get(1009); return get(1009);
} }
uint filter = 1; uint filter = 1;
int i = 1000; var i = 1000;
for (; filter != 0x100 && filter != location; filter <<= 1) for (; filter != 0x100 && filter != location; filter <<= 1)
++i; ++i;
if (filter == location) if (filter == location)
return get(i); return get(i);
else
return "???"; return "???";
} }
internal static string formatLocation(GPS gps) internal static string formatLocation(GPS gps)
{ {
return formatLocation(gps.location, gps.sequence); return formatLocation(gps.location, gps.sequence);
} }
}
public class hashedString
{
public string content = "";
public int hashCode;
public string region = "";
}
}
\ No newline at end of file
using System; using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using Ionic.Zip; using Ionic.Zip;
public static class GameZipManager public static class GameZipManager
{ {
public static List<ZipFile> Zips = new List<ZipFile>(); public static List<ZipFile> Zips = new List<ZipFile>();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
using System; using UnityEngine;
using UnityEngine;
public class ServantWithCardDescription : Servant public class ServantWithCardDescription : Servant
{ {
public override void show() public override void show()
...@@ -24,10 +24,8 @@ public class ServantWithCardDescription : Servant ...@@ -24,10 +24,8 @@ public class ServantWithCardDescription : Servant
public override void preFrameFunction() public override void preFrameFunction()
{ {
var des = Program.I().cardDescription; var des = Program.I().cardDescription;
if (Program.pointedGameObject!= Program.I().cardDescription.description.gameObject) if (Program.pointedGameObject != Program.I().cardDescription.description.gameObject)
{
des.description.OnScroll(Program.wheelValue / 50f); des.description.OnScroll(Program.wheelValue / 50f);
}
des.onResized(); des.onResized();
} }
} }
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -66,3 +66,4 @@ ...@@ -66,3 +66,4 @@
// return re; // return re;
// } // }
//} //}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment