Example #1
0
        private void addProfile_Click(object sender, EventArgs e)
        {
            //Convert the current profile array to a list

            List <NpcProfile> profiles = current.profiles.ToList();

            //Create a profile with some default values

            NpcProfile profile = new NpcProfile()
            {
                character = currentProfile.character
            };

            //Find the first empty spot, or append a new one
            //if this is not available

            bool added       = false;
            int  nextProfile = 0;

            for (int p = 0; p < profiles.Count; p++)
            {
                if (profiles[p] == null)
                {
                    added = true;

                    profiles[p] = profile;
                    nextProfile = p;

                    break;
                }
            }

            if (!added)
            {
                profiles.Add(profile);

                nextProfile = profiles.Count - 1;
            }

            //Convert the list back to an array

            current.profiles = profiles.ToArray();

            //Reload the profiles

            ReloadNpcProfiles();

            //Load the new (next) profile

            profileSelect.SelectedItem = nextProfile;
        }
Example #2
0
        private void LoadNpcProfile(int profile)
        {
            //Check if the profile is valid

            if (profile >= current.profiles.Length ||
                current.profiles[profile] == null)
            {
                Logger.Error("The profile #" + profile + " is invalid for the NPC '" + current.name + "'!");

                return;
            }

            //Load the profile

            currentProfile = current.profiles[profile];

            //Set the NPC#Profile string

            npcProfileName.Text = "(Tiled property: " + current.name + "#" + profile + ")";

            //Set values

            showNameplate.Checked = currentProfile.showNameplate;

            switch (currentProfile.movement)
            {
            case "free":
                movementFree.Checked = true;
                break;

            case "static":
                movementStatic.Checked = true;
                break;
            }

            range.Value               = currentProfile.range;
            facing.SelectedIndex      = currentProfile.facing;
            collidesWithinMap.Checked = currentProfile.collidesWithinMap;

            switch (currentProfile.type)
            {
            case "friendly":
                typeFriendly.Checked = true;
                break;

            case "hostile":
                typeHostile.Checked = true;
                break;
            }

            aggressive.Checked  = currentProfile.aggressive;
            attackRange.Value   = currentProfile.attackRange;
            attackRange.Enabled = currentProfile.aggressive;

            if (currentProfile.stats == null)
            {
                currentProfile.stats = new Stats();
            }

            level.Value = currentProfile.stats.level;

            exp.Value = currentProfile.stats.exp;

            power.Value        = currentProfile.stats.power;
            agility.Value      = currentProfile.stats.agility;
            intelligence.Value = currentProfile.stats.intelligence;
            wisdom.Value       = currentProfile.stats.wisdom;
            toughness.Value    = currentProfile.stats.toughness;
            vitality.Value     = currentProfile.stats.vitality;

            if (currentProfile.health != null)
            {
                health.Value = currentProfile.health.max;
            }

            CheckTypeEnabled();

            characterName.Text = "Character: " + currentProfile.character;
        }