Пример #1
0
        public Character(string name, int str, int dex, int con, int intel, int wis, int cha)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name  = name;
            Stats = new StatArray(str, dex, con, intel, wis, cha);
        }
Пример #2
0
        public Character(string name, CharacterClass cClass)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name  = name;
            Class = cClass;
            Stats = new StatArray();
            Stats.Roll();
        }
Пример #3
0
        public Character(string name, CharacterClass cClass, StatArray stats)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (stats == null)
            {
                Stats = new StatArray();
            }
            else
            {
                Stats = stats;
            }

            Name  = name;
            Class = cClass;
        }
Пример #4
0
        public void AltFormsImport()
        {
            string file_path = alt_form_input.GetComponentsInChildren <Text>()[1].text;
            string full_path = Path.Combine(import_path, file_path);

            imported_forms = new List <Form>();

            try
            {
                StreamReader input_stream = new StreamReader(full_path);
                Form         current_form = null;

                while (!input_stream.EndOfStream)
                {
                    string line = input_stream.ReadLine();

                    // Line is a comment
                    if (line[0] == '#')
                    {
                    }
                    // Line is start of a new species, including base species and form id
                    else if (line[0] == '[')
                    {
                        if (current_form != null)
                        {
                            imported_forms.Add(current_form);
                        }

                        current_form = ScriptableObject.CreateInstance <Form>();
                        string[] values = line.TrimStart('[').TrimEnd(']').Split(',');
                        current_form.base_species = (Species)Enum.Parse(typeof(Species), values[0], true);
                        current_form.form_id      = uint.Parse(values[1]);

                        current_form.name = current_form.base_species.ToString() + "_" + values[1];
                    }
                    // Line contains data field
                    else
                    {
                        string[] parts = line.Split('=');
                        string   key   = parts[0].TrimEnd(' ');
                        string   value = parts[1].TrimStart(' ');

                        // Part is form name
                        if (key == "FormName")
                        {
                            current_form.form_name = value;
                        }
                        // Part is type1
                        else if (key == "Type1")
                        {
                            current_form.types    = new Pokemon.Types[2];
                            current_form.types[0] = (Pokemon.Types)Enum.Parse(typeof(Pokemon.Types), value, true);
                        }
                        // Part is type2
                        else if (key == "Type2")
                        {
                            current_form.types[1] = (Pokemon.Types)Enum.Parse(typeof(Pokemon.Types), value, true);
                        }
                        // Part is base stats
                        else if (key == "BaseStats")
                        {
                            string[]  values     = value.Split(',');
                            StatArray base_stats = new StatArray();
                            base_stats.HP     = uint.Parse(values[0]);
                            base_stats.ATK    = uint.Parse(values[1]);
                            base_stats.DEF    = uint.Parse(values[2]);
                            base_stats.SPD    = uint.Parse(values[3]);
                            base_stats.SP_ATK = uint.Parse(values[4]);
                            base_stats.SP_DEF = uint.Parse(values[5]);

                            current_form.base_stats = base_stats;
                        }
                        // Part is base exp
                        else if (key == "BaseEXP")
                        {
                            current_form.base_exp = uint.Parse(value);
                        }
                        // Part is effort values
                        else if (key == "EffortPoints")
                        {
                            string[]  values        = value.Split(',');
                            StatArray effort_values = new StatArray();
                            effort_values.HP     = uint.Parse(values[0]);
                            effort_values.ATK    = uint.Parse(values[1]);
                            effort_values.DEF    = uint.Parse(values[2]);
                            effort_values.SPD    = uint.Parse(values[3]);
                            effort_values.SP_ATK = uint.Parse(values[4]);
                            effort_values.SP_DEF = uint.Parse(values[5]);

                            current_form.effort_values = effort_values;
                        }
                        // Part is rareness
                        else if (key == "Rareness")
                        {
                            current_form.rareness = uint.Parse(value);
                        }
                        // Part is happiness
                        else if (key == "Happiness")
                        {
                            current_form.happiness = uint.Parse(value);
                        }
                        // Part is moves
                        else if (key == "Moves")
                        {
                            string[]      values         = value.Split(',');
                            int           num_moves      = values.Length / 2;
                            LevelUpMove[] level_up_moves = new LevelUpMove[num_moves];
                            for (int i = 0; i < num_moves * 2; i += 2)
                            {
                                LevelUpMove next_move = new LevelUpMove();
                                next_move.level       = uint.Parse(values[i]);
                                next_move.move        = (Moves)Enum.Parse(typeof(Moves), values[i + 1], true);
                                level_up_moves[i / 2] = next_move;
                            }

                            current_form.moves = level_up_moves;
                        }
                        // Part is egg group
                        else if (key == "Compatibility")
                        {
                            string[]    values     = value.Split(',');
                            int         num_groups = values.Length;
                            EggGroups[] egg_groups = new EggGroups[num_groups];
                            for (int i = 0; i < num_groups; i++)
                            {
                                egg_groups[i] = (EggGroups)Enum.Parse(typeof(EggGroups), values[i], true);
                            }

                            current_form.egg_groups = egg_groups;
                        }
                        // Part is steps to hatch
                        else if (key == "StepsToHatch")
                        {
                            current_form.steps_to_hatch = uint.Parse(value);
                        }
                        // Part is height
                        else if (key == "Height")
                        {
                            current_form.height = float.Parse(value);
                        }
                        // Part is weight
                        else if (key == "Weight")
                        {
                            current_form.weight = float.Parse(value);
                        }
                        // Part is color
                        else if (key == "Color")
                        {
                            current_form.color = (Colors)Enum.Parse(typeof(Colors), value, true);
                        }
                        // Part is shape
                        else if (key == "Shape")
                        {
                            current_form.shape = (Shapes)(int.Parse(value) - 1);
                        }
                        // Part is kind
                        else if (key == "Kind")
                        {
                            current_form.kind = value;
                        }
                        // Part is pokedex entry
                        else if (key == "Pokedex")
                        {
                            current_form.pokedex_entry = value;
                        }
                        // Part is abilities
                        else if (key == "Abilities")
                        {
                            string[]    values        = value.Split(',');
                            int         num_abilities = values.Length;
                            Abilities[] abilities     = new Abilities[num_abilities];
                            for (int i = 0; i < num_abilities; i++)
                            {
                                abilities[i] = (Abilities)Enum.Parse(typeof(Abilities), values[i], true);
                            }

                            current_form.abilities = abilities;
                        }
                        // Part is hidden abilities
                        else if (key == "HiddenAbility")
                        {
                            string[]    values        = value.Split(',');
                            int         num_abilities = values.Length;
                            Abilities[] abilities     = new Abilities[num_abilities];
                            for (int i = 0; i < num_abilities; i++)
                            {
                                abilities[i] = (Abilities)Enum.Parse(typeof(Abilities), values[i], true);
                            }

                            current_form.hidden_ability = abilities;
                        }
                        // Part is egg moves
                        else if (key == "EggMoves")
                        {
                            string[] values    = value.Split(',');
                            int      num_moves = values.Length;
                            Moves[]  moves     = new Moves[num_moves];
                            for (int i = 0; i < num_moves; i++)
                            {
                                moves[i] = (Moves)Enum.Parse(typeof(Moves), values[i], true);
                            }

                            current_form.egg_moves = moves;
                        }
                        // Part is habitat
                        else if (key == "Habitat")
                        {
                            current_form.habitat = (Habitats)Enum.Parse(typeof(Habitats), value, true);
                        }
                        // Part is wild item (3 varieties)
                        else if (key == "WildItemCommon")
                        {
                            current_form.wild_item_common = (Items.Items)Enum.Parse(typeof(Items.Items), value, true);
                        }
                        else if (key == "WildItemUncommon")
                        {
                            current_form.wild_item_uncommon = (Items.Items)Enum.Parse(typeof(Items.Items), value, true);
                        }
                        else if (key == "WildItemRare")
                        {
                            current_form.wild_item_rare = (Items.Items)Enum.Parse(typeof(Items.Items), value, true);
                        }
                        // Part is an in battle sprite offset
                        else if (key == "BattlerPlayerX")
                        {
                            current_form.battler_player_x = int.Parse(value);
                        }
                        else if (key == "BattlerPlayerY")
                        {
                            current_form.battler_player_y = int.Parse(value);
                        }
                        else if (key == "BattlerEnemyX")
                        {
                            current_form.battler_enemy_x = int.Parse(value);
                        }
                        else if (key == "BattlerEnemyY")
                        {
                            current_form.battler_enemy_y = int.Parse(value);
                        }
                        else if (key == "BattlerAltitude")
                        {
                            current_form.battler_altitude = int.Parse(value);
                        }
                        else if (key == "BattlerShadowX")
                        {
                            current_form.battler_shadow_x = int.Parse(value);
                        }
                        else if (key == "BattlerShadowSize")
                        {
                            current_form.battler_shadow_size = int.Parse(value);
                        }
                        // Part is evolutions
                        else if (key == "Evolutions")
                        {
                            string[]    values     = value.Split(',');
                            int         num_evos   = values.Length / 3;
                            Evolution[] evolutions = new Evolution[num_evos];
                            for (int i = 0; i < num_evos * 3; i += 3)
                            {
                                Evolution next_evo = new Evolution();
                                next_evo.evolution        = (Species)Enum.Parse(typeof(Species), values[i], true);
                                next_evo.evolution_method = (EvolutionMethods)Enum.Parse(typeof(EvolutionMethods), values[i + 1], true);
                                next_evo.parameter        = values[i + 2];
                                evolutions[i / 3]         = next_evo;
                            }

                            current_form.evolutions = evolutions;
                        }
                        // Part is mega stone
                        else if (key == "MegaStone")
                        {
                            current_form.mega_stone = (Items.Items)Enum.Parse(typeof(Items.Items), value, true);
                        }
                        // Part is mega move
                        else if (key == "MegaMove")
                        {
                            current_form.mega_move = (Moves)Enum.Parse(typeof(Moves), value, true);
                        }
                        // Part is mega message
                        else if (key == "MegaMessage")
                        {
                            current_form.mega_message = value;
                        }
                        // Part is unmega form id
                        else if (key == "UnmegaForm")
                        {
                            current_form.unmega_form_id = uint.Parse(value);
                        }
                        // Part is pokedex form id
                        else if (key == "PokedexForm")
                        {
                            current_form.pokedex_form_id = uint.Parse(value);
                        }
                    }
                }

                if (current_form != null)
                {
                    imported_forms.Add(current_form);
                }
                input_stream.Close();
            }
            catch (Exception e)
            {
                Debug.Log(e);
                return;
            }

            string forms_path = Settings.ALT_FORMS_FILE_PATH;

            for (int i = 0; i < imported_forms.Count; i++)
            {
                Form new_form = imported_forms[i];

                AssetDatabase.CreateAsset(new_form, Path.Combine(forms_path, new_form.name) + ".asset");
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = new_form;
            }
        }