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,23 +24,24 @@ public class BackGroundPic : Servant ...@@ -22,23 +24,24 @@ 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()
{ {
applyShowArrangement(); applyShowArrangement();
} }
} }
\ No newline at end of file
This diff is collapsed.
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)
{ {
...@@ -24,19 +22,16 @@ public static class Config ...@@ -24,19 +22,16 @@ 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; var return_value = defau;
bool finded = false; var finded = false;
for (int i = 0; i < translations.Count; i++) 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; var finded = false;
for (int i = 0; i < translations.Count; i++) 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,16 +67,16 @@ public static class InterString ...@@ -75,16 +67,16 @@ 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;
} }
public static string Get(string original, string replace) public static string Get(string original, string replace)
{ {
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,26 +15,28 @@ public class MonoDelegate : MonoBehaviour ...@@ -14,26 +15,28 @@ 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);
} }
} }
public class MonoListenerRMS_ized : MonoBehaviour 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)
{ {
...@@ -17,7 +15,7 @@ public class TextMaster ...@@ -17,7 +15,7 @@ public class TextMaster
true, true,
Program.ui_main_3d, Program.ui_main_3d,
false false
); );
UIHelper.clearITWeen(gameObject); UIHelper.clearITWeen(gameObject);
iTween.ScaleTo(gameObject, new Vector3(0.03f, 0.03f, 0.03f), 0.6f); iTween.ScaleTo(gameObject, new Vector3(0.03f, 0.03f, 0.03f), 0.6f);
} }
...@@ -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()
{ {
Program.I().ocgcore.AddUpdateAction_s(Update); Program.I().ocgcore.AddUpdateAction_s(Update);
} }
...@@ -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.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>();
} }
\ No newline at end of file
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