diff --git a/.gitignore b/.gitignore
index e3a7ebb..8da7c37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,6 @@ ExportedObj/
*.user
*.unityproj
*.booproj
+
+#Sublime
+*.sublime-workspace
diff --git a/Akadoc.sublime-project b/Akadoc.sublime-project
index 4ae60a6..f50c7f9 100644
--- a/Akadoc.sublime-project
+++ b/Akadoc.sublime-project
@@ -1,3 +1,6 @@
+//Required Sublime Text plugins:
+// - SublimeAStyleFormatter: https://github.com/timonwong/SublimeAStyleFormatter
+//
{
"folders":
[
@@ -7,8 +10,27 @@
"file_exclude_patterns":
[
"*.dll",
- "*.meta"
+ "*.meta",
+ "*.csproj",
+ "*.sln"
+ ],
+ "folder_exclude_patterns":
+ [
+ "Temp",
+ "Library"
]
}
- ]
+ ],
+ "settings": {
+ "AStyleFormatter": {
+ "options_default": {
+ "autoformat_on_save": true,
+ "attach-namespaces": true,
+ "attach-classes": true,
+ "pad-oper": false,
+ "pad-header": false,
+ "unpad-paren": true
+ }
+ }
+ }
}
diff --git a/Assets/scripts/CameraController.cs b/Assets/scripts/CameraController.cs
index dcf8d0f..80a6a1b 100644
--- a/Assets/scripts/CameraController.cs
+++ b/Assets/scripts/CameraController.cs
@@ -7,13 +7,13 @@ public class CameraController : MonoBehaviour {
public Quaternion targetRot;
// Use this for initialization
- void Awake () {
+ void Awake() {
targetPos = transform.position;
targetRot = transform.rotation;
}
-
+
// Update is called once per frame
- void Update () {
+ void Update() {
transform.position = Vector3.Lerp(transform.position, targetPos, Time.deltaTime*10);
transform.rotation = Quaternion.Lerp(transform.rotation, targetRot, Time.deltaTime*10);
}
diff --git a/Assets/scripts/ChatWindow.cs b/Assets/scripts/ChatWindow.cs
index c9e6a95..20cdd8e 100644
--- a/Assets/scripts/ChatWindow.cs
+++ b/Assets/scripts/ChatWindow.cs
@@ -3,48 +3,48 @@ using System.Collections;
using UnityEngine.UI;
public class ChatWindow : MonoBehaviour {
-
+
public Text text_chat;
public ScrollRect scrollrect;
string message_old;
-
+
// Use this for initialization
- void Start () {
+ void Start() {
text_chat.text = "";
}
-
+
// Update is called once per frame
- void Update () {
+ void Update() {
}
//permet d'écrire du texte en brut dans la fenetre de chat. Sans style. A priori, ne doit pas etre utilisé...
- public void writeText(string text){
+ public void writeText(string text) {
text_chat.text += text;
- }
+ }
+
+ //prend en arguement le nombre de jour écoulé pour l'afficher dans la fenetre de chat.
+ public void writeDay(int nbDay) {
- //prend en arguement le nombre de jour écoulé pour l'afficher dans la fenetre de chat.
- public void writeDay(int nbDay){
-
text_chat.text += "\n\n\n Day " + nbDay.ToString() + "\n" ;
scrollrect.verticalNormalizedPosition = 0;
-
+
}
- //prend en argument le pseudo et le message reçu par TchatAnim.cs et l'inscrit dans la fenetre.
- public void writeMessage(string nom, string message){
-
+ //prend en argument le pseudo et le message reçu par TchatAnim.cs et l'inscrit dans la fenetre.
+ public void writeMessage(string nom, string message) {
+
text_chat.text += "" + nom + ": "+ message + "\n";
scrollrect.verticalNormalizedPosition = 0;
-
+
}
- // TODO: rédiger des fonctions pour afficher les morts, les deconnections et certains évènement importants.
+ // TODO: rédiger des fonctions pour afficher les morts, les deconnections et certains évènement importants.
}
diff --git a/Assets/scripts/Clock.cs b/Assets/scripts/Clock.cs
index 6304add..26db32b 100644
--- a/Assets/scripts/Clock.cs
+++ b/Assets/scripts/Clock.cs
@@ -9,28 +9,28 @@ public class Clock : MonoBehaviour {
DayController daycontroller;
int maxDay;
int maxNight;
-
+
// Use this for initialization
- void Start () {
- day_controller = GameObject.Find ("day_controller");
+ void Start() {
+ day_controller = GameObject.Find("day_controller");
daycontroller = day_controller.GetComponent ();
maxDay = daycontroller.maxDay;
maxNight = daycontroller.maxNight;
}
-
+
// Update is called once per frame
- void Update () {
+ void Update() {
//TODO: Sync clock with the server
//TODO: Set var as for day % or hour
float fRot = clock.transform.rotation.z;
- if(fRot>=0 && fRot>-180){
+ if(fRot>=0 && fRot>-180) {
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxNight));//2.5min
}
- else{
+ else {
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxDay));//1min
}
}
diff --git a/Assets/scripts/CreateScrollList.cs b/Assets/scripts/CreateScrollList.cs
index 7c9bba5..00cc130 100644
--- a/Assets/scripts/CreateScrollList.cs
+++ b/Assets/scripts/CreateScrollList.cs
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Collections;
[System.Serializable]
-public class Item{
+public class Item {
public string name;
public Sprite icon;
public string message;
@@ -13,7 +13,7 @@ public class Item{
}
[System.Serializable]
-public class Notification{
+public class Notification {
public string message;
Button.ButtonClickedEvent clickEvent;
}
@@ -29,59 +29,59 @@ public class CreateScrollList : MonoBehaviour {
GameObject chat_input;
TchatAnim tchatAnim;
string message_old;
-
+
//tentative d'ajout des notifications:
public GameObject logNotification;
public List notificationList;
-
- // Use this for initialization
- void Start () {
+
+ // Use this for initialization
+ void Start() {
//PopulateList ();
- chat_input = GameObject.Find ("tchat_complet");
+ chat_input = GameObject.Find("tchat_complet");
tchatAnim = chat_input.GetComponent ();
}
- void PopulateList(){
- foreach (var item in itemList) {
- GameObject newButton = Instantiate (sampleButton) as GameObject;
+ void PopulateList() {
+ foreach(var item in itemList) {
+ GameObject newButton = Instantiate(sampleButton) as GameObject;
SampleButton button = newButton.GetComponent ();
button.nameLabel.text = item.name;
button.icon.sprite = item.icon;
button.message.text = item.message;
- newButton.transform.SetParent (contentPanel);
+ newButton.transform.SetParent(contentPanel);
button.gameObject.SetActive(true);
- }
-
}
-
- // Update is called once per frame
- void Update () {
-
}
- public void writeMessage(string name, string message){
+
+ // Update is called once per frame
+ void Update() {
+
+ }
+
+ public void writeMessage(string name, string message) {
scrollrect.verticalNormalizedPosition = 0;
- GameObject myNewButton = Instantiate (sampleButton) as GameObject;
+ GameObject myNewButton = Instantiate(sampleButton) as GameObject;
SampleButton button = myNewButton.GetComponent ();
- button.nameLabel.text= name;
+ button.nameLabel.text = name;
button.message.text = tchatAnim.message;
- button.icon.sprite= portrait.sprite;
+ button.icon.sprite = portrait.sprite;
button.gameObject.SetActive(true);
myNewButton.transform.SetParent(contentPanel);
}
- public void writeNotification(string message){
+ public void writeNotification(string message) {
scrollrect.verticalNormalizedPosition = 0;
- GameObject myNewButton = Instantiate (logNotification) as GameObject;
+ GameObject myNewButton = Instantiate(logNotification) as GameObject;
LogNotification notif = myNewButton.GetComponent ();
notif.message.text = message;
- myNewButton.transform.SetParent (contentPanel);
- }
+ myNewButton.transform.SetParent(contentPanel);
+ }
}
diff --git a/Assets/scripts/DayController.cs b/Assets/scripts/DayController.cs
index 9dd316c..36da7b5 100644
--- a/Assets/scripts/DayController.cs
+++ b/Assets/scripts/DayController.cs
@@ -27,91 +27,91 @@ public class DayController : MonoBehaviour {
// Use this for initialization
- void Start () {
+ void Start() {
//calcul des différent timing.
- machine.SetInteger ("day_status", 0);
+ machine.SetInteger("day_status", 0);
maxDiscussion = (int) maxDay / 2;
maxAccusation = maxDay - maxDiscussion;
//appel de Window Chat
- chatWindowScroll = GameObject.Find ("ChatWindowScroll");
+ chatWindowScroll = GameObject.Find("ChatWindowScroll");
chatWindow = chatWindowScroll.GetComponent ();
//appel de CreateScrollList
- createScrollListObject = GameObject.Find ("log_controller");
+ createScrollListObject = GameObject.Find("log_controller");
createScrollList = createScrollListObject.GetComponent ();
//appel de ManaStack
- manaStackObject = GameObject.Find ("mana_controller");
+ manaStackObject = GameObject.Find("mana_controller");
manaStack = manaStackObject.GetComponent ();
dayNb = 1;
- chatWindow.writeDay (dayNb);
- manaStack.addDaily (dayNb);
-
+ chatWindow.writeDay(dayNb);
+ manaStack.addDaily(dayNb);
+
}
-
+
// Update is called once per frame
- void Update () {
+ void Update() {
//DISUCSSION
- if (machine.GetInteger("day_status")==0){
+ if(machine.GetInteger("day_status") == 0) {
- if (timer >= (float)maxDiscussion){
- machine.SetInteger("day_status",1);
+ if(timer >= (float)maxDiscussion) {
+ machine.SetInteger("day_status", 1);
print("Accusation!");
createScrollList.writeNotification("Denoncez-vous, pauvres fous!!!");
}
- else{
+ else {
timer += Time.deltaTime;
}
}
//ACCUSATION
- if (machine.GetInteger("day_status")==1){
+ if(machine.GetInteger("day_status") == 1) {
-
- if (timer >= (float)maxDay){
- machine.SetInteger("day_status",3);
+
+ if(timer >= (float)maxDay) {
+ machine.SetInteger("day_status", 3);
print("il fait nuit!");
timer = 0;
}
-
- else{
+
+ else {
timer += Time.deltaTime;
}
-
+
}
//NUIT
- if (machine.GetInteger("day_status")==3){
-
-
- if (timer >= (float)maxNight){
- machine.SetInteger("day_status",0);
+ if(machine.GetInteger("day_status") == 3) {
+
+
+ if(timer >= (float)maxNight) {
+ machine.SetInteger("day_status", 0);
timer = 0;
dayNb ++;
chatWindow.writeDay(dayNb);
- manaStack.addDaily (dayNb);
+ manaStack.addDaily(dayNb);
print("le jour se lève, discutez!");
}
-
- else{
+
+ else {
timer += Time.deltaTime;
}
-
+
}
-
+
}
- public int getDay(){return dayNb;}
+ public int getDay() {return dayNb;}
}
diff --git a/Assets/scripts/ManaItem.cs b/Assets/scripts/ManaItem.cs
index e77c572..217aed4 100644
--- a/Assets/scripts/ManaItem.cs
+++ b/Assets/scripts/ManaItem.cs
@@ -6,21 +6,21 @@ public class ManaItem : MonoBehaviour {
public Image manaImage;
- void Start () {
+ void Start() {
//manaImage = GetComponent ();
}
- public void setDisabled(){
+ public void setDisabled() {
manaImage.color = Color.red;
-
+
}
- public void setEnabled(){
+ public void setEnabled() {
manaImage.color = Color.blue;
}
- public void setSelected(){
+ public void setSelected() {
manaImage.color = Color.white;
}
diff --git a/Assets/scripts/ManaStack.cs b/Assets/scripts/ManaStack.cs
index dcb22e0..cd46c76 100644
--- a/Assets/scripts/ManaStack.cs
+++ b/Assets/scripts/ManaStack.cs
@@ -12,57 +12,57 @@ public class ManaStack : MonoBehaviour {
int manaLeft;
// Use this for initialization
- void Start () {
- //création de la barre de mana.
- for(int i=0; i ();
- mana.setDisabled ();
- myNewButton.transform.SetParent (contentPanel);
- }
+ mana.setDisabled();
+ myNewButton.transform.SetParent(contentPanel);
+ }
//ajoute le bon nombre de cristaux de mana chaque jour
- public void addDaily(int nbDay){
+ public void addDaily(int nbDay) {
nbDay--;
GameObject manaItemObject;
ManaItem manaButton;
-
- if (nbDay > manaMax-1) {
- nbDay = manaMax-1;
- }
+
+ if(nbDay > manaMax - 1) {
+ nbDay = manaMax - 1;
+ }
manaLeft = nbDay + 1;
- for (int i=0; i<=nbDay; i++) {
- manaItemObject = GameObject.Find("ManaItem"+i);
+ for(int i = 0; i <= nbDay; i++) {
+ manaItemObject = GameObject.Find("ManaItem" + i);
manaButton = manaItemObject.GetComponent ();
manaButton.setEnabled();
//GameObject.Find("ManaItem"+i).GetComponent("Button").int
- }
}
-
- //ajoute la quantité de mana indiqué.
- public void addMana(int manaPlus){
}
- //soustrait la quantité de mana indiqué.
- public void subMana(int manaLess){
+ //ajoute la quantité de mana indiqué.
+ public void addMana(int manaPlus) {
}
- //selectionne la quantité de mana indiqué
- //(quand on passe la souris sur un sort par exemple)
- public void selMana (int sel){
+ //soustrait la quantité de mana indiqué.
+ public void subMana(int manaLess) {
+ }
+
+ //selectionne la quantité de mana indiqué
+ //(quand on passe la souris sur un sort par exemple)
+ public void selMana(int sel) {
}
}
diff --git a/Assets/scripts/NewBehaviourScript.cs b/Assets/scripts/NewBehaviourScript.cs
deleted file mode 100644
index 77366fa..0000000
--- a/Assets/scripts/NewBehaviourScript.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-public class NewBehaviourScript : MonoBehaviour {
- CanvasGroup grp;
- // Use this for initialization
- void Start () {
-
- }
-
- // Update is called once per frame
- void Update () {
- }
-
-}
diff --git a/Assets/scripts/NewBehaviourScript.cs.meta b/Assets/scripts/NewBehaviourScript.cs.meta
deleted file mode 100644
index 73f6b0d..0000000
--- a/Assets/scripts/NewBehaviourScript.cs.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: da0f09705b89fa346b50f7e244179a80
-MonoImporter:
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
diff --git a/Assets/scripts/OnClickedMoveCamera.cs b/Assets/scripts/OnClickedMoveCamera.cs
index b2328c8..7cb6ec6 100644
--- a/Assets/scripts/OnClickedMoveCamera.cs
+++ b/Assets/scripts/OnClickedMoveCamera.cs
@@ -13,7 +13,7 @@ public class OnClickedMoveCamera : MonoBehaviour {
private Renderer[] children;
public Canvas canva;
- void Awake(){
+ void Awake() {
clrBase = GetComponent().material.color;
clrTarget = clrBase;
children = GetComponentsInChildren();
@@ -21,7 +21,7 @@ public class OnClickedMoveCamera : MonoBehaviour {
}
- void OnMouseDown(){
+ void OnMouseDown() {
//Move to position
@@ -30,22 +30,22 @@ public class OnClickedMoveCamera : MonoBehaviour {
camCtrl.targetRot = destination.rotation;
}
- void OnMouseEnter(){
+ void OnMouseEnter() {
//Lerp to hilight color
clrTarget = new Color(1.0F, 0.87F, 0.75F);
}
-
- void OnMouseExit(){
+
+ void OnMouseExit() {
//Lerp to base color
clrTarget = clrBase;
}
- void Update(){
+ void Update() {
//Lerp to clrTarget
Color clr = Color.Lerp(GetComponent().material.color, clrTarget, Time.deltaTime * 10);
//Fixme? Any newly created chilren wont be lerped
- foreach (Renderer child in children) {
+ foreach(Renderer child in children) {
child.material.color = clr;
}
}
diff --git a/Assets/scripts/TchatAnim.cs b/Assets/scripts/TchatAnim.cs
index 1611736..13d3618 100644
--- a/Assets/scripts/TchatAnim.cs
+++ b/Assets/scripts/TchatAnim.cs
@@ -22,115 +22,115 @@ public class TchatAnim : MonoBehaviour {
CreateScrollList createScrollList;
// Use this for initialization
- void Start () {
+ void Start() {
timer_sec = 0;
max_timer = 15;
//appel de WindowChat
- chatWindowScroll = GameObject.Find ("ChatWindowScroll");
+ chatWindowScroll = GameObject.Find("ChatWindowScroll");
chatWindow = chatWindowScroll.GetComponent ();
//appel de CreateScrollList
- createScrollListObject = GameObject.Find ("log_controller");
+ createScrollListObject = GameObject.Find("log_controller");
createScrollList = createScrollListObject.GetComponent ();
}
- void Awake(){
+ void Awake() {
}
-
+
// Update is called once per frame
- void Update () {
+ void Update() {
//print (machine.GetInteger("etat_chat"));
- if (myfield.isFocused) {
- img_bg.color = Color.green;
- } else
- img_bg.color = Color.white;
+ if(myfield.isFocused) {
+ img_bg.color = Color.green;
+ } else
+ img_bg.color = Color.white;
- if(machine.GetInteger("etat_chat")==0){
+ if(machine.GetInteger("etat_chat") == 0) {
myfield.gameObject.SetActive(true);
- message=myfield.text;
+ message = myfield.text;
}
//transition vers chat_up
- if (myfield.textComponent.cachedTextGenerator.lineCount > 1 && machine.GetInteger("etat_chat")==0) {
- print ("trop long");
- machine.SetInteger ("etat_chat", 1);
- charac_nb.text = " ";
- message=myfield.text;
-
+ if(myfield.textComponent.cachedTextGenerator.lineCount > 1 && machine.GetInteger("etat_chat") == 0) {
+ print("trop long");
+ machine.SetInteger("etat_chat", 1);
+ charac_nb.text = " ";
+ message = myfield.text;
+
}
//transition vers chat_long
- if (myfield.text.Length > 110 && machine.GetInteger("etat_chat")==1) {
- print ("trop trop long");
- machine.SetInteger ("etat_chat", 2);
- message=myfield.text;
+ if(myfield.text.Length > 110 && machine.GetInteger("etat_chat") == 1) {
+ print("trop trop long");
+ machine.SetInteger("etat_chat", 2);
+ message = myfield.text;
}
- //affichage nombre de caractère restant.
- if(Input.anyKey && machine.GetInteger("etat_chat")==2 ){
+ //affichage nombre de caractère restant.
+ if(Input.anyKey && machine.GetInteger("etat_chat") == 2) {
charac_nb.text = (myfield.characterLimit - myfield.text.Length).ToString();
}
//les derniers caractères sont écris en rouges
- if (myfield.text.Length > 130) {
- charac_nb.color = Color.red;
- } else
- charac_nb.color = Color.white;
+ if(myfield.text.Length > 130) {
+ charac_nb.color = Color.red;
+ } else
+ charac_nb.color = Color.white;
- //transition vers chat_empty: si l'on vide complètement un message, le tcht se rabaisse.
+ //transition vers chat_empty: si l'on vide complètement un message, le tcht se rabaisse.
//sinon on le laisse haut (y compris si le message est court).
- if ((machine.GetInteger ("etat_chat") == 1 || machine.GetInteger ("etat_chat") == 2) && myfield.text.Length == 0 ) {
+ if((machine.GetInteger("etat_chat") == 1 || machine.GetInteger("etat_chat") == 2) && myfield.text.Length == 0) {
- machine.SetInteger ("etat_chat", 0);
- message="";
+ machine.SetInteger("etat_chat", 0);
+ message = "";
}
//En cas de validation du message
- if(Input.GetKeyDown("space") && myfield.isFocused){
+ if(Input.GetKeyDown("space") && myfield.isFocused) {
- chatWindow.writeMessage("perceval",myfield.text); //inscription du message dans la fenetre de chat
- createScrollList.writeMessage("perceval", myfield.text); //inscription du message dans les logs.
+ chatWindow.writeMessage("perceval", myfield.text); //inscription du message dans la fenetre de chat
+ createScrollList.writeMessage("perceval", myfield.text); //inscription du message dans les logs.
myfield.gameObject.SetActive(false);
- myfield.text=" ";
- charac_nb.text="";
- print ("space pressed");
+ myfield.text = " ";
+ charac_nb.text = "";
+ print("space pressed");
- //texte long
- if(machine.GetInteger("etat_chat")==1 || machine.GetInteger("etat_chat")==2){
- machine.SetInteger ("etat_chat", 3);
+ //texte long
+ if(machine.GetInteger("etat_chat") == 1 || machine.GetInteger("etat_chat") == 2) {
+ machine.SetInteger("etat_chat", 3);
}
//texte court
- if(machine.GetInteger("etat_chat")==0){
- machine.SetInteger("etat_chat",3);
+ if(machine.GetInteger("etat_chat") == 0) {
+ machine.SetInteger("etat_chat", 3);
}
}
//Gestion de l'état Timer.
- if (machine.GetInteger ("etat_chat") == 3) {
+ if(machine.GetInteger("etat_chat") == 3) {
timer_sec += Time.deltaTime;
- timer.text = (max_timer - (int) timer_sec ).ToString() + " secondes restantes";
+ timer.text = (max_timer - (int) timer_sec).ToString() + " secondes restantes";
- if(timer_sec >= (float)max_timer-1){
- timer_sec=0;
- timer.text="";
- machine.SetInteger ("etat_chat", 0);
- myfield.text="";
- message="";
+ if(timer_sec >= (float)max_timer - 1) {
+ timer_sec = 0;
+ timer.text = "";
+ machine.SetInteger("etat_chat", 0);
+ myfield.text = "";
+ message = "";
}
@@ -138,8 +138,8 @@ public class TchatAnim : MonoBehaviour {
}
- public void submit(){
- print ("submit entered");
+ public void submit() {
+ print("submit entered");
}
}
diff --git a/Assets/scripts/chat_scrollbar.cs b/Assets/scripts/chat_scrollbar.cs
index 92ef398..042c97d 100644
--- a/Assets/scripts/chat_scrollbar.cs
+++ b/Assets/scripts/chat_scrollbar.cs
@@ -8,20 +8,20 @@ public class chat_scrollbar : MonoBehaviour {
public Scrollbar scrollbar;
public InputField myfield;
public ScrollRect scrollrect;
-
+
// Use this for initialization
- void Start () {
+ void Start() {
scrollbar.value = 1;
}
-
-
+
+
// Update is called once per frame
- void Update () {
+ void Update() {
+
-
//print (iseditingtop);
@@ -31,11 +31,11 @@ public class chat_scrollbar : MonoBehaviour {
- bool isTypingText(){
- if (Input.anyKey && Input.GetMouseButton (0) == false && Input.GetMouseButton (1) == false && Input.GetMouseButton (2) == false && Input.GetKey ("return") == false) {
- return true;
- } else
- return false;
+ bool isTypingText() {
+ if(Input.anyKey && Input.GetMouseButton(0) == false && Input.GetMouseButton(1) == false && Input.GetMouseButton(2) == false && Input.GetKey("return") == false) {
+ return true;
+ } else
+ return false;
}
diff --git a/Assets/src/RulesDatabase.cs b/Assets/src/RulesDatabase.cs
index 8ff0194..8fb682d 100644
--- a/Assets/src/RulesDatabase.cs
+++ b/Assets/src/RulesDatabase.cs
@@ -4,20 +4,20 @@ using System.Collections.Generic;
public class RulesDatabase {
- public static TwoDA GetTable(string name){
+ public static TwoDA GetTable(string name) {
TwoDA t = null;
- if(Get().m_tables.TryGetValue(name, out t)){
+ if(Get().m_tables.TryGetValue(name, out t)) {
return t;
}
else
return null;
}
- public static void SetLocale(string lang){
+ public static void SetLocale(string lang) {
m_inst.m_strref = GetTable("locale_"+lang);
}
-
- public static string GetStrRef(int strref){
+
+ public static string GetStrRef(int strref) {
RulesDatabase inst = Get();
return inst.m_strref.GetValue(strref, "text");
@@ -27,12 +27,12 @@ public class RulesDatabase {
- private RulesDatabase(){
+ private RulesDatabase() {
m_tables = new Dictionary();
string[] files = Directory.GetFiles(m_folder, "*.2da", SearchOption.AllDirectories);
- foreach(string file in files){
+ foreach(string file in files) {
string name = Path.GetFileNameWithoutExtension(file);
m_tables.Add(name, new TwoDA(file));
//Debug.Log ("Found "+name);
@@ -42,11 +42,11 @@ public class RulesDatabase {
m_tables.TryGetValue("locale_fr", out m_strref);
}
-
+
private static RulesDatabase m_inst = null;
private static object m_singlmutex = new Object();
- private static RulesDatabase Get(){
- lock(m_singlmutex){
+ private static RulesDatabase Get() {
+ lock(m_singlmutex) {
if(m_inst==null)
m_inst = new RulesDatabase();
}
diff --git a/Assets/src/TwoDA.cs b/Assets/src/TwoDA.cs
index 082af2e..e121f7b 100644
--- a/Assets/src/TwoDA.cs
+++ b/Assets/src/TwoDA.cs
@@ -3,86 +3,86 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
public class TwoDA : UnityEngine.Object {
-
+
public TwoDA(string filepath) {
-
+
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader(filepath);
-
+
string line = file.ReadLine();
m_header = line.Split((string[])null, System.StringSplitOptions.RemoveEmptyEntries);
int nCols = m_header.Length;
m_data = new List();
-
+
int nFileLine = 1;
while((line = file.ReadLine()) != null)
{
- if(line[0] != '#'){//Ignore commented lines
-
+ if(line[0] != '#') { //Ignore commented lines
+
MatchCollection matches = m_rgxField.Matches(line);
-
- if(matches.Count == nCols){
+
+ if(matches.Count == nCols) {
int nLine = int.Parse(matches[0].Value);
-
+
string[] buff = new string[nCols-1];
- for(int i=0 ; i=0){
+ if(nCol>=0) {
return m_data[nRow][nCol];
}
- else{
+ else {
throw new UnityException("Column '"+sColumn+"' not found in 2DA");
}
-
+
}
-
- public override string ToString(){
+
+ public override string ToString() {
string sMsg = "";
- foreach(string s in m_header){
+ foreach(string s in m_header) {
sMsg += s+"\t";
}
sMsg += "\n";
- for(int line=0 ; line m_data;