Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsNpcKillUserTable"/> class.
 /// </summary>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="nPCTemplateID">The initial value for the corresponding property.</param>
 /// <param name="npcX">The initial value for the corresponding property.</param>
 /// <param name="npcY">The initial value for the corresponding property.</param>
 /// <param name="userID">The initial value for the corresponding property.</param>
 /// <param name="userLevel">The initial value for the corresponding property.</param>
 /// <param name="userX">The initial value for the corresponding property.</param>
 /// <param name="userY">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 public WorldStatsNpcKillUserTable(UInt32 @iD, MapID? @mapID, CharacterTemplateID? @nPCTemplateID, UInt16 @npcX,
                                   UInt16 @npcY, CharacterID @userID, Byte @userLevel, UInt16 @userX, UInt16 @userY,
                                   DateTime @when)
 {
     ID            = @iD;
     MapID         = @mapID;
     NPCTemplateID = @nPCTemplateID;
     NpcX          = @npcX;
     NpcY          = @npcY;
     UserID        = @userID;
     UserLevel     = @userLevel;
     UserX         = @userX;
     UserY         = @userY;
     When          = @when;
 }
        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnAdd_Click(object sender, EventArgs e)
        {
            // Validate
            if (!_selectedItem.HasValue)
            {
                MessageBox.Show("You must select an item to add first.");
                return;
            }

            if (RequireDistinct)
            {
                if (
                    lstItems.Items.Cast <MutablePair <CharacterTemplateID, ushort> >().Any(
                        x => _selectedItem.HasValue && x.Key == _selectedItem.Value))
                {
                    MessageBox.Show("That item is already in the list.");
                    _selectedItem = null;
                    return;
                }
            }

            byte amount;

            if (!byte.TryParse(txtAmount.Text, out amount))
            {
                MessageBox.Show("Invalid amount specified.");
                return;
            }

            // Add
            var newItem = new MutablePair <CharacterTemplateID, ushort>(_selectedItem.Value, amount);

            lstItems.Items.Add(newItem);

            if (RequireDistinct)
            {
                _selectedItem = null;
                txtItem.Text  = string.Empty;
            }

            // Select the new item
            lstItems.SelectedItem = newItem;
        }
        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnAdd_Click(object sender, EventArgs e)
        {
            // Validate
            if (!_selectedItem.HasValue)
            {
                MessageBox.Show("You must select an item to add first.");
                return;
            }

            if (RequireDistinct)
            {
                if (
                    lstItems.Items.Cast<MutablePair<CharacterTemplateID, ushort>>().Any(
                        x => _selectedItem.HasValue && x.Key == _selectedItem.Value))
                {
                    MessageBox.Show("That item is already in the list.");
                    _selectedItem = null;
                    return;
                }
            }

            byte amount;
            if (!byte.TryParse(txtAmount.Text, out amount))
            {
                MessageBox.Show("Invalid amount specified.");
                return;
            }

            // Add
            var newItem = new MutablePair<CharacterTemplateID, ushort>(_selectedItem.Value, amount);
            lstItems.Items.Add(newItem);

            if (RequireDistinct)
            {
                _selectedItem = null;
                txtItem.Text = string.Empty;
            }

            // Select the new item
            lstItems.SelectedItem = newItem;
        }
        /// <summary>
        /// Handles the Click event of the btnBrowse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnBrowse_Click(object sender, EventArgs e)
        {
            using (var f = new CharacterTemplateUITypeEditorForm(null))
            {
                // If we require distinct, skip items we already have in the list
                if (RequireDistinct)
                {
                    var listItems = lstItems.Items.OfType <MutablePair <CharacterTemplateID, ushort> >().ToImmutable();
                    f.SkipItems = (x => listItems.Any(y => y.Key == x.ID));
                }

                if (f.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                var item = f.SelectedItem;
                _selectedItem = item.ID;
                txtItem.Text  = item.ID + " [" + item.Name + "]";
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewNpcCharacterTable"/> class.
 /// </summary>
 /// <param name="aIID">The initial value for the corresponding property.</param>
 /// <param name="bodyID">The initial value for the corresponding property.</param>
 /// <param name="cash">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="chatDialog">The initial value for the corresponding property.</param>
 /// <param name="exp">The initial value for the corresponding property.</param>
 /// <param name="hP">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="level">The initial value for the corresponding property.</param>
 /// <param name="loadMapID">The initial value for the corresponding property.</param>
 /// <param name="loadX">The initial value for the corresponding property.</param>
 /// <param name="loadY">The initial value for the corresponding property.</param>
 /// <param name="moveSpeed">The initial value for the corresponding property.</param>
 /// <param name="mP">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="respawnMapID">The initial value for the corresponding property.</param>
 /// <param name="respawnX">The initial value for the corresponding property.</param>
 /// <param name="respawnY">The initial value for the corresponding property.</param>
 /// <param name="shopID">The initial value for the corresponding property.</param>
 /// <param name="statPoints">The initial value for the corresponding property.</param>
 /// <param name="statAgi">The initial value for the corresponding property.</param>
 /// <param name="statDefence">The initial value for the corresponding property.</param>
 /// <param name="statInt">The initial value for the corresponding property.</param>
 /// <param name="statMaxhit">The initial value for the corresponding property.</param>
 /// <param name="statMaxhp">The initial value for the corresponding property.</param>
 /// <param name="statMaxmp">The initial value for the corresponding property.</param>
 /// <param name="statMinhit">The initial value for the corresponding property.</param>
 /// <param name="statStr">The initial value for the corresponding property.</param>
 public ViewNpcCharacterTable(AIID? @aIID, BodyID @bodyID, Int32 @cash, CharacterTemplateID? @characterTemplateID,
                              NPCChatDialogID? @chatDialog, Int32 @exp, SPValueType @hP, Int32 @iD, Byte @level,
                              MapID @loadMapID, UInt16 @loadX, UInt16 @loadY, UInt16 @moveSpeed, SPValueType @mP,
                              String @name, MapID? @respawnMapID, Single @respawnX, Single @respawnY, ShopID? @shopID,
                              Int32 @statPoints, Int16 @statAgi, Int16 @statDefence, Int16 @statInt, Int16 @statMaxhit,
                              Int16 @statMaxhp, Int16 @statMaxmp, Int16 @statMinhit, Int16 @statStr)
 {
     AIID   = @aIID;
     BodyID = @bodyID;
     Cash   = @cash;
     CharacterTemplateID = @characterTemplateID;
     ChatDialog          = @chatDialog;
     Exp          = @exp;
     HP           = @hP;
     ID           = @iD;
     Level        = @level;
     LoadMapID    = @loadMapID;
     LoadX        = @loadX;
     LoadY        = @loadY;
     MoveSpeed    = @moveSpeed;
     MP           = @mP;
     Name         = @name;
     RespawnMapID = @respawnMapID;
     RespawnX     = @respawnX;
     RespawnY     = @respawnY;
     ShopID       = @shopID;
     StatPoints   = @statPoints;
     StatAgi      = @statAgi;
     StatDefence  = @statDefence;
     StatInt      = @statInt;
     StatMaxhit   = @statMaxhit;
     StatMaxhp    = @statMaxhp;
     StatMaxmp    = @statMaxmp;
     StatMinhit   = @statMinhit;
     StatStr      = @statStr;
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterTable"/> class.
 /// </summary>
 /// <param name="aIID">The initial value for the corresponding property.</param>
 /// <param name="bodyID">The initial value for the corresponding property.</param>
 /// <param name="cash">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="chatDialog">The initial value for the corresponding property.</param>
 /// <param name="exp">The initial value for the corresponding property.</param>
 /// <param name="hP">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="level">The initial value for the corresponding property.</param>
 /// <param name="loadMapID">The initial value for the corresponding property.</param>
 /// <param name="loadX">The initial value for the corresponding property.</param>
 /// <param name="loadY">The initial value for the corresponding property.</param>
 /// <param name="moveSpeed">The initial value for the corresponding property.</param>
 /// <param name="mP">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="respawnMapID">The initial value for the corresponding property.</param>
 /// <param name="respawnX">The initial value for the corresponding property.</param>
 /// <param name="respawnY">The initial value for the corresponding property.</param>
 /// <param name="shopID">The initial value for the corresponding property.</param>
 /// <param name="statPoints">The initial value for the corresponding property.</param>
 /// <param name="statAgi">The initial value for the corresponding property.</param>
 /// <param name="statDefence">The initial value for the corresponding property.</param>
 /// <param name="statInt">The initial value for the corresponding property.</param>
 /// <param name="statMaxhit">The initial value for the corresponding property.</param>
 /// <param name="statMaxhp">The initial value for the corresponding property.</param>
 /// <param name="statMaxmp">The initial value for the corresponding property.</param>
 /// <param name="statMinhit">The initial value for the corresponding property.</param>
 /// <param name="statStr">The initial value for the corresponding property.</param>
 public CharacterTable(AIID? @aIID, BodyID @bodyID, Int32 @cash, CharacterTemplateID? @characterTemplateID,
                       NPCChatDialogID? @chatDialog, Int32 @exp, SPValueType @hP, CharacterID @iD, Byte @level,
                       MapID @loadMapID, UInt16 @loadX, UInt16 @loadY, UInt16 @moveSpeed, SPValueType @mP, String @name,
                       MapID? @respawnMapID, Single @respawnX, Single @respawnY, ShopID? @shopID, Int32 @statPoints,
                       Int16 @statAgi, Int16 @statDefence, Int16 @statInt, Int16 @statMaxhit, Int16 @statMaxhp,
                       Int16 @statMaxmp, Int16 @statMinhit, Int16 @statStr)
 {
     AIID   = @aIID;
     BodyID = @bodyID;
     Cash   = @cash;
     CharacterTemplateID = @characterTemplateID;
     ChatDialog          = @chatDialog;
     Exp          = @exp;
     HP           = @hP;
     ID           = @iD;
     Level        = @level;
     LoadMapID    = @loadMapID;
     LoadX        = @loadX;
     LoadY        = @loadY;
     MoveSpeed    = @moveSpeed;
     MP           = @mP;
     Name         = @name;
     RespawnMapID = @respawnMapID;
     RespawnX     = @respawnX;
     RespawnY     = @respawnY;
     ShopID       = @shopID;
     StatPoints   = @statPoints;
     SetStat(StatType.Agi, @statAgi);
     SetStat(StatType.Defence, @statDefence);
     SetStat(StatType.Int, @statInt);
     SetStat(StatType.MaxHit, @statMaxhit);
     SetStat(StatType.MaxHP, @statMaxhp);
     SetStat(StatType.MaxMP, @statMaxmp);
     SetStat(StatType.MinHit, @statMinhit);
     SetStat(StatType.Str, @statStr);
 }
        /// <summary>
        /// Handles the Click event of the btnBrowse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnBrowse_Click(object sender, EventArgs e)
        {
            using (var f = new CharacterTemplateUITypeEditorForm(null))
            {
                // If we require distinct, skip items we already have in the list
                if (RequireDistinct)
                {
                    var listItems = lstItems.Items.OfType<MutablePair<CharacterTemplateID, ushort>>().ToImmutable();
                    f.SkipItems = (x => listItems.Any(y => y.Key == x.ID));
                }

                if (f.ShowDialog(this) != DialogResult.OK)
                    return;

                var item = f.SelectedItem;
                _selectedItem = item.ID;
                txtItem.Text = item.ID + " [" + item.Name + "]";
            }
        }
Example #8
0
        void LoadFromQueryValues(ICharacterTable v)
        {
            Name = v.Name;
            _id = v.ID;
            _templateID = v.CharacterTemplateID;
            MoveSpeed = v.MoveSpeed;

            BodyInfo = BodyInfoManager.Instance.GetBody(v.BodyID);

            Teleport(new Vector2(v.LoadX, v.LoadY));
            Resize(BodyInfo.Size);

            ((PersistentCharacterStatusEffects)StatusEffects).Load();

            // Set the character information
            _level = v.Level;
            _exp = v.Exp;
            _cash = v.Cash;
            _hp = v.HP;
            _mp = v.MP;
            RespawnMapID = v.RespawnMapID;
            RespawnPosition = new Vector2(v.RespawnX, v.RespawnY);
            StatPoints = v.StatPoints;

            _knownSkills = new KnownSkillsCollection(this);

            // Create the AI
            if (v.AIID.HasValue)
            {
                if (!SetAI(v.AIID.Value))
                {
                    const string errmsg = "Failed to set Character `{0}`'s AI to ID `{1}`.";
                    if (log.IsErrorEnabled)
                        log.ErrorFormat(errmsg, this, v.AIID.Value);
                    Debug.Fail(string.Format(errmsg, this, v.AIID.Value));
                    RemoveAI();
                }
            }

            // Load the stats
            BaseStats.CopyValuesFrom(v.Stats);

            // Load the Character's items
            Inventory.Load();
            Equipped.Load();

            // Update the mod stats
            UpdateModStats();

            // Additional loading
            HandleAdditionalLoading(v);

            // Set the map
            var m = World.GetMap(v.LoadMapID);
            if (m != null)
                Teleport(m, Position);
            else
                ((IRespawnable)this).Respawn();

            // Mark the Character as loaded
            SetAsLoaded();

            if (log.IsInfoEnabled)
                log.InfoFormat("Loaded Character `{0}`.", Name);
        }