public void SelectUpgrade() { agentMeta.LevelUp("Spirit", ref game.exp); levelText.text = "LEVEL " + agentMeta.level; costText.text = "- " + agentMeta.cost; expText.text = "EXP " + game.exp; }
public AgentMeta NextDay() { AgentMeta nextAgentMeta = new AgentMeta(); nextAgentMeta.tag = tag; nextAgentMeta.name = name; nextAgentMeta.damage = damage; nextAgentMeta.damageTime = damageTime; nextAgentMeta.num = num; nextAgentMeta.speed = speed; nextAgentMeta.health = health; nextAgentMeta.defense = defense; nextAgentMeta.level = level; nextAgentMeta.rate = rate; nextAgentMeta.gameObject = gameObject; if (nextAgentMeta.tag == "Ghost") { nextAgentMeta.LevelUp(ref nextAgentMeta); nextAgentMeta.rate++; } return(nextAgentMeta); }
public void Init() { trees.Clear(); treeBook.Clear(); spirits.Clear(); spiritBook.Clear(); ghosts.Clear(); ghostBook.Clear(); int index; // trees index = 1; foreach (GameObject tree in allTrees) { Agent agent = tree.GetComponent <Agent>(); if (!treeBook.ContainsKey(agent.name)) { treeBook.Add(agent.name, agent.gameObject); agent.id = index; // agent.level = 1; agent.agentManager = this; trees.Add(agent); index++; } } // spirits index = 1; foreach (GameObject spirit in allSpirits) { Agent agent = spirit.GetComponent <Agent>(); if (!spiritBook.ContainsKey(agent.name)) { spiritBook.Add(agent.name, agent.gameObject); agent.id = index; // agent.level = 1; agent.agentManager = this; spirits.Add(agent); index++; } } // ghosts index = 1; foreach (GameObject ghost in allGhosts) { Agent agent = ghost.GetComponent <Agent>(); if (!ghostBook.ContainsKey(agent.name)) { ghostBook.Add(agent.name, agent.gameObject); agent.id = index; // agent.level = 1; agent.agentManager = this; ghosts.Add(agent); index++; } } // dictionary dayMeta.Clear(); // AgentMeta todaysTree = null; List <AgentMeta> todaysTrees = new List <AgentMeta> (); List <AgentMeta> todaysSpirits = new List <AgentMeta> (); List <AgentMeta> todaysGhosts = new List <AgentMeta> (); DayMeta todaysMeta; AgentMeta agentMeta; int day = 0; int spiritNum = 0; int ghostNum = 0; int lineNum = 0; int lineIndex = 0; // string line; //-------start loading data TextAsset txt = (TextAsset)Resources.Load("DayMeta", typeof(TextAsset)); string content = txt.text; string[] lines = Regex.Split(content, "\n|\r|\r\n"); // StreamReader theReader = new StreamReader ("Assets/Data/DayMeta.txt", Encoding.Default); // using (theReader) // { // do // { // line = theReader.ReadLine(); // if (line != null) // { foreach (string line in lines) { string[] entries = line.Split(','); if (entries.Length == 4) { day = int.Parse(entries [0]); spiritNum = int.Parse(entries [1]); ghostNum = int.Parse(entries [2]); lineNum = int.Parse(entries [3]); lineIndex = 0; // todaysTree = null; todaysTrees = new List <AgentMeta> (); todaysSpirits = new List <AgentMeta> (); todaysGhosts = new List <AgentMeta> (); } if (lineIndex < lineNum) { if (entries.Length == 12) { lineIndex++; if (day != int.Parse(entries [0])) { continue; } if (treeBook.ContainsKey(entries [2])) { agentMeta = new AgentMeta(entries [1], entries [2], entries [3], entries [4], entries [5], entries [6], entries [7], entries [8], entries [9], entries [10], entries [11], treeBook [entries [2]]); agentMeta.ExportToPrefab(); agentMeta.ExportFromPrefab(); todaysTrees.Add(agentMeta); } if (spiritBook.ContainsKey(entries [2])) { agentMeta = new AgentMeta(entries [1], entries [2], entries [3], entries [4], entries [5], entries [6], entries [7], entries [8], entries [9], entries [10], entries [11], spiritBook [entries [2]]); agentMeta.ExportToPrefab(); agentMeta.ExportFromPrefab(); todaysSpirits.Add(agentMeta); } } if (entries.Length == 13) { lineIndex++; if (day != int.Parse(entries [0])) { continue; } if (ghostBook.ContainsKey(entries [2])) { agentMeta = new AgentMeta(entries [1], entries [2], entries [3], entries [4], entries [5], entries [6], entries [7], entries [8], entries [9], entries [10], entries [11], ghostBook [entries [2]]); agentMeta.ExportToPrefab(); agentMeta.ExportFromPrefab(); agentMeta.LevelUp(int.Parse(entries [12])); todaysGhosts.Add(agentMeta); } } } if (lineIndex == lineNum) { lineIndex++; todaysMeta = new DayMeta(day, todaysTrees, todaysSpirits, todaysGhosts, spiritNum, ghostNum); dayMeta.Add(todaysMeta); } } // } // } // while (line != null); // theReader.Close(); // } //-------finish loading data }