Ejemplo n.º 1
0
        //changes the current menu, removes any listeners on buttons and adds new listeners
        void changeMenu(string menuName)
        {
            activeMenu = menuName;
            int i;

            switch (activeMenu)
            {
            case "main":
                string[] mainText = { "Attack", "Party", "Item", "Run" };
                for (i = 0; i < mainText.Length; i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = mainText[i];
                }
                for (i = mainText.Length; i < choices.Length; i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = "";
                }
                break;

            case "attack":
                for (i = 0; i < AbilityList.getAbilityLimit(); i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = player1ActiveMonster.abilities.abilityList[i].name;
                }
                choices[AbilityList.getAbilityLimit()].GetComponentInChildren <Text>().text = "Return";
                break;

            case "party":
                for (i = 0; i < player1.party.monsterList.Count; i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = player1.party.monsterList[i].name;
                }
                for (; i < Party.getMaxPartySize(); i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = "none";
                }
                choices[Party.getMaxPartySize()].GetComponentInChildren <Text>().text = "Return";
                break;

            case "item":
                for (i = 0; i < player1.itemList.Count; i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = player1.itemList[i].name;
                }
                for (; i < Item.maxNumItems; i++)
                {
                    choices[i].GetComponentInChildren <Text>().text = "none";
                }
                choices[i].GetComponentInChildren <Text>().text = "Return";
                break;
            }
            //adds new listeners to buttons
            for (i = 0; i < choices.Length; i++)
            {
                string x = choices[i].GetComponentInChildren <Text>().text;
                choices[i].onClick.RemoveAllListeners();
                choices[i].onClick.AddListener(() => actionOnClick(x));
            }
        }
Ejemplo n.º 2
0
        void loadMasterMonsterList()
        {
            string[] s       = File.ReadAllLines(monsterFile);
            int      numArgs = 10;

            for (int i = 0; i < s.Length; i += numArgs)
            {
                //grabs stat values
                int   offset1;
                int[] statValues = new int[StatList.statNames.Length];
                for (offset1 = 1; offset1 <= statValues.Length; offset1++)
                {
                    statValues[offset1 - 1] = int.Parse(s[i + offset1]);
                }
                Type type = new Type(s[i + offset1]);
                offset1++;
                //gets the names of the monster's abilities
                int      offset2      = offset1;
                string[] abilityNames = new string[AbilityList.getAbilityLimit()];
                for (; offset2 < offset1 + AbilityList.getAbilityLimit(); offset2++)
                {
                    abilityNames[offset2 - offset1] = s[i + offset2];
                }

                //puts the abilities into the monsters ability list
                List <Ability> abilityList = new List <Ability>();
                for (int j = 0; j < AbilityList.getAbilityLimit(); j++)
                {
                    if (!abilityNames[j].Equals("none"))
                    {
                        for (int m = 0; m < masterAbilityList.Count; m++)
                        {
                            if (abilityNames[j].Equals(masterAbilityList[m].name))
                            {
                                abilityList.Add(masterAbilityList[m]);
                            }
                        }
                    }
                }
                StatList    stats     = new StatList(statValues);
                AbilityList abilities = new AbilityList(abilityList);
                Monster     mon       = new Monster(s[i], stats, type, abilities, i / numArgs);
                masterMonsterList.Add(mon);
            }
        }