Exemplo n.º 1
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(ICharacterTable source, IDictionary <String, Object> dic)
 {
     dic["ai_id"]   = source.AIID;
     dic["body_id"] = source.BodyID;
     dic["cash"]    = source.Cash;
     dic["character_template_id"] = source.CharacterTemplateID;
     dic["chat_dialog"]           = source.ChatDialog;
     dic["exp"]            = source.Exp;
     dic["hp"]             = source.HP;
     dic["id"]             = source.ID;
     dic["level"]          = source.Level;
     dic["load_map_id"]    = source.LoadMapID;
     dic["load_x"]         = source.LoadX;
     dic["load_y"]         = source.LoadY;
     dic["move_speed"]     = source.MoveSpeed;
     dic["mp"]             = source.MP;
     dic["name"]           = source.Name;
     dic["respawn_map_id"] = source.RespawnMapID;
     dic["respawn_x"]      = source.RespawnX;
     dic["respawn_y"]      = source.RespawnY;
     dic["shop_id"]        = source.ShopID;
     dic["statpoints"]     = source.StatPoints;
     dic["stat_agi"]       = (Int16)source.GetStat(StatType.Agi);
     dic["stat_defence"]   = (Int16)source.GetStat(StatType.Defence);
     dic["stat_int"]       = (Int16)source.GetStat(StatType.Int);
     dic["stat_maxhit"]    = (Int16)source.GetStat(StatType.MaxHit);
     dic["stat_maxhp"]     = (Int16)source.GetStat(StatType.MaxHP);
     dic["stat_maxmp"]     = (Int16)source.GetStat(StatType.MaxMP);
     dic["stat_minhit"]    = (Int16)source.GetStat(StatType.MinHit);
     dic["stat_str"]       = (Int16)source.GetStat(StatType.Str);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this CharacterTable.
 /// </summary>
 /// <param name="source">The ICharacterTable to copy the values from.</param>
 public void CopyValuesFrom(ICharacterTable source)
 {
     AIID   = source.AIID;
     BodyID = source.BodyID;
     Cash   = source.Cash;
     CharacterTemplateID = source.CharacterTemplateID;
     ChatDialog          = source.ChatDialog;
     Exp          = source.Exp;
     HP           = source.HP;
     ID           = source.ID;
     Level        = source.Level;
     LoadMapID    = source.LoadMapID;
     LoadX        = source.LoadX;
     LoadY        = source.LoadY;
     MoveSpeed    = source.MoveSpeed;
     MP           = source.MP;
     Name         = source.Name;
     RespawnMapID = source.RespawnMapID;
     RespawnX     = source.RespawnX;
     RespawnY     = source.RespawnY;
     ShopID       = source.ShopID;
     StatPoints   = source.StatPoints;
     SetStat(StatType.Agi, source.GetStat(StatType.Agi));
     SetStat(StatType.Defence, source.GetStat(StatType.Defence));
     SetStat(StatType.Int, source.GetStat(StatType.Int));
     SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit));
     SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP));
     SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP));
     SetStat(StatType.MinHit, source.GetStat(StatType.MinHit));
     SetStat(StatType.Str, source.GetStat(StatType.Str));
 }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
///  this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void CopyValues(this ICharacterTable source, NetGore.Db.DbParameterValues paramValues)
        {
            paramValues["ai_id"]   = (System.Nullable <System.UInt16>)source.AIID;
            paramValues["body_id"] = (System.UInt16)source.BodyID;
            paramValues["cash"]    = (System.Int32)source.Cash;
            paramValues["character_template_id"] = (System.Nullable <System.UInt16>)source.CharacterTemplateID;
            paramValues["chat_dialog"]           = (System.Nullable <System.UInt16>)source.ChatDialog;
            paramValues["exp"]            = (System.Int32)source.Exp;
            paramValues["hp"]             = (System.Int16)source.HP;
            paramValues["id"]             = (System.Int32)source.ID;
            paramValues["level"]          = (System.Int16)source.Level;
            paramValues["load_map_id"]    = (System.UInt16)source.LoadMapID;
            paramValues["load_x"]         = (System.UInt16)source.LoadX;
            paramValues["load_y"]         = (System.UInt16)source.LoadY;
            paramValues["move_speed"]     = (System.UInt16)source.MoveSpeed;
            paramValues["mp"]             = (System.Int16)source.MP;
            paramValues["name"]           = (System.String)source.Name;
            paramValues["respawn_map_id"] = (System.Nullable <System.UInt16>)source.RespawnMapID;
            paramValues["respawn_x"]      = (System.Single)source.RespawnX;
            paramValues["respawn_y"]      = (System.Single)source.RespawnY;
            paramValues["shop_id"]        = (System.Nullable <System.UInt16>)source.ShopID;
            paramValues["statpoints"]     = (System.Int32)source.StatPoints;
            paramValues["stat_agi"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
            paramValues["stat_defence"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
            paramValues["stat_int"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
            paramValues["stat_maxhit"]    = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
            paramValues["stat_maxhp"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
            paramValues["stat_maxmp"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
            paramValues["stat_minhit"]    = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
            paramValues["stat_str"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
        }
Exemplo n.º 4
0
        // TODO: Class is currently unused because displaying persistent Characters in the editor is not yet supported

        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCharacter"/> class.
        /// </summary>
        /// <param name="table">The <see cref="ICharacterTable"/> describing the character.</param>
        /// <param name="map">The <see cref="Map"/> to place the character on.</param>
        /// <exception cref="ArgumentNullException"><paramref name="table" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map" /> is <c>null</c>.</exception>
        public EditorCharacter(ICharacterTable table, EditorMap map)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            _table       = table;
            _characterID = table.ID;

            var dbController = DbControllerBase.GetInstance();

            var charInfo = dbController.GetQuery <SelectCharacterByIDQuery>().Execute(_characterID);

            BodyID = charInfo.BodyID;
            Teleport(new Vector2(charInfo.RespawnX, charInfo.RespawnY));
            Resize(BodyInfo.Size);
            Name = charInfo.Name;

            Initialize(map, SkeletonManager.Create(ContentPaths.Build));
        }
/// <summary>
/// Checks if this <see cref="ICharacterTable"/> contains the same values as another <see cref="ICharacterTable"/>.
/// </summary>
/// <param name="source">The source <see cref="ICharacterTable"/>.</param>
/// <param name="otherItem">The <see cref="ICharacterTable"/> to compare the values to.</param>
/// <returns>
/// True if this <see cref="ICharacterTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
/// </returns>
        public static System.Boolean HasSameValues(this ICharacterTable source, ICharacterTable otherItem)
        {
            return(Equals(source.AIID, otherItem.AIID) &&
                   Equals(source.BodyID, otherItem.BodyID) &&
                   Equals(source.Cash, otherItem.Cash) &&
                   Equals(source.CharacterTemplateID, otherItem.CharacterTemplateID) &&
                   Equals(source.ChatDialog, otherItem.ChatDialog) &&
                   Equals(source.Exp, otherItem.Exp) &&
                   Equals(source.HP, otherItem.HP) &&
                   Equals(source.ID, otherItem.ID) &&
                   Equals(source.Level, otherItem.Level) &&
                   Equals(source.LoadMapID, otherItem.LoadMapID) &&
                   Equals(source.LoadX, otherItem.LoadX) &&
                   Equals(source.LoadY, otherItem.LoadY) &&
                   Equals(source.MoveSpeed, otherItem.MoveSpeed) &&
                   Equals(source.MP, otherItem.MP) &&
                   Equals(source.Name, otherItem.Name) &&
                   Equals(source.RespawnMapID, otherItem.RespawnMapID) &&
                   Equals(source.RespawnX, otherItem.RespawnX) &&
                   Equals(source.RespawnY, otherItem.RespawnY) &&
                   Equals(source.ShopID, otherItem.ShopID) &&
                   Equals(source.StatPoints, otherItem.StatPoints) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Int)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Str)));
        }
Exemplo n.º 6
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
        public static void CopyValues(ICharacterTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic)
        {
            dic["ai_id"]   = (System.Nullable <NetGore.AI.AIID>)source.AIID;
            dic["body_id"] = (DemoGame.BodyID)source.BodyID;
            dic["cash"]    = (System.Int32)source.Cash;
            dic["character_template_id"] = (System.Nullable <DemoGame.CharacterTemplateID>)source.CharacterTemplateID;
            dic["chat_dialog"]           = (System.Nullable <NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
            dic["exp"]            = (System.Int32)source.Exp;
            dic["hp"]             = (DemoGame.SPValueType)source.HP;
            dic["id"]             = (DemoGame.CharacterID)source.ID;
            dic["level"]          = (System.Int16)source.Level;
            dic["load_map_id"]    = (NetGore.World.MapID)source.LoadMapID;
            dic["load_x"]         = (System.UInt16)source.LoadX;
            dic["load_y"]         = (System.UInt16)source.LoadY;
            dic["move_speed"]     = (System.UInt16)source.MoveSpeed;
            dic["mp"]             = (DemoGame.SPValueType)source.MP;
            dic["name"]           = (System.String)source.Name;
            dic["respawn_map_id"] = (System.Nullable <NetGore.World.MapID>)source.RespawnMapID;
            dic["respawn_x"]      = (System.Single)source.RespawnX;
            dic["respawn_y"]      = (System.Single)source.RespawnY;
            dic["shop_id"]        = (System.Nullable <NetGore.Features.Shops.ShopID>)source.ShopID;
            dic["statpoints"]     = (System.Int32)source.StatPoints;
            dic["stat_agi"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
            dic["stat_defence"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
            dic["stat_int"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
            dic["stat_maxhit"]    = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
            dic["stat_maxhp"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
            dic["stat_maxmp"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
            dic["stat_minhit"]    = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
            dic["stat_str"]       = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
        }
Exemplo n.º 7
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterTable.
/// </summary>
/// <param name="source">The ICharacterTable to copy the values from.</param>
        public void CopyValuesFrom(ICharacterTable source)
        {
            this.AIID   = (System.Nullable <NetGore.AI.AIID>)source.AIID;
            this.BodyID = (DemoGame.BodyID)source.BodyID;
            this.Cash   = (System.Int32)source.Cash;
            this.CharacterTemplateID = (System.Nullable <DemoGame.CharacterTemplateID>)source.CharacterTemplateID;
            this.ChatDialog          = (System.Nullable <NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
            this.Exp          = (System.Int32)source.Exp;
            this.HP           = (DemoGame.SPValueType)source.HP;
            this.ID           = (DemoGame.CharacterID)source.ID;
            this.Level        = (System.Int16)source.Level;
            this.LoadMapID    = (NetGore.World.MapID)source.LoadMapID;
            this.LoadX        = (System.UInt16)source.LoadX;
            this.LoadY        = (System.UInt16)source.LoadY;
            this.MoveSpeed    = (System.UInt16)source.MoveSpeed;
            this.MP           = (DemoGame.SPValueType)source.MP;
            this.Name         = (System.String)source.Name;
            this.RespawnMapID = (System.Nullable <NetGore.World.MapID>)source.RespawnMapID;
            this.RespawnX     = (System.Single)source.RespawnX;
            this.RespawnY     = (System.Single)source.RespawnY;
            this.ShopID       = (System.Nullable <NetGore.Features.Shops.ShopID>)source.ShopID;
            this.StatPoints   = (System.Int32)source.StatPoints;
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str));
        }
Exemplo n.º 8
0
        /// <summary>
        /// When overridden in the derived class, handles additional loading stuff.
        /// </summary>
        /// <param name="v">The ICharacterTable containing the database values for this Character.</param>
        protected override void HandleAdditionalLoading(ICharacterTable v)
        {
            base.HandleAdditionalLoading(v);

            // Set the chat dialog
            _chatDialog = v.ChatDialog.HasValue ? _npcChatManager[v.ChatDialog.Value] : null;

            // Set up the shop
            SetShopFromID(v.ShopID);
        }
Exemplo n.º 9
0
        // TODO: Class is currently unused because displaying persistent Characters in the editor is not yet supported

        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCharacter"/> class.
        /// </summary>
        /// <param name="table">The <see cref="ICharacterTable"/> describing the character.</param>
        /// <param name="map">The <see cref="Map"/> to place the character on.</param>
        /// <exception cref="ArgumentNullException"><paramref name="table" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map" /> is <c>null</c>.</exception>
        public EditorCharacter(ICharacterTable table, EditorMap map)
        {
            if (table == null)
                throw new ArgumentNullException("table");
            if (map == null)
                throw new ArgumentNullException("map");

            _table = table;
            _characterID = table.ID;

            var dbController = DbControllerBase.GetInstance();

            var charInfo = dbController.GetQuery<SelectCharacterByIDQuery>().Execute(_characterID);
            BodyID = charInfo.BodyID;
            Teleport(new Vector2(charInfo.RespawnX, charInfo.RespawnY));
            Resize(BodyInfo.Size);
            Name = charInfo.Name;

            Initialize(map, SkeletonManager.Create(ContentPaths.Build));
        }
 /// <summary>
 /// Checks if this <see cref="ICharacterTable"/> contains the same values as another <see cref="ICharacterTable"/>.
 /// </summary>
 /// <param name="source">The source <see cref="ICharacterTable"/>.</param>
 /// <param name="otherItem">The <see cref="ICharacterTable"/> to compare the values to.</param>
 /// <returns>
 /// True if this <see cref="ICharacterTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
 /// </returns>
 public static Boolean HasSameValues(this ICharacterTable source, ICharacterTable otherItem)
 {
     return Equals(source.AIID, otherItem.AIID) && Equals(source.BodyID, otherItem.BodyID) &&
            Equals(source.Cash, otherItem.Cash) && Equals(source.CharacterTemplateID, otherItem.CharacterTemplateID) &&
            Equals(source.ChatDialog, otherItem.ChatDialog) && Equals(source.Exp, otherItem.Exp) &&
            Equals(source.HP, otherItem.HP) && Equals(source.ID, otherItem.ID) && Equals(source.Level, otherItem.Level) &&
            Equals(source.LoadMapID, otherItem.LoadMapID) && Equals(source.LoadX, otherItem.LoadX) &&
            Equals(source.LoadY, otherItem.LoadY) && Equals(source.MoveSpeed, otherItem.MoveSpeed) &&
            Equals(source.MP, otherItem.MP) && Equals(source.Name, otherItem.Name) &&
            Equals(source.RespawnMapID, otherItem.RespawnMapID) && Equals(source.RespawnX, otherItem.RespawnX) &&
            Equals(source.RespawnY, otherItem.RespawnY) && Equals(source.ShopID, otherItem.ShopID) &&
            Equals(source.StatPoints, otherItem.StatPoints) &&
            Equals(source.GetStat(StatType.Agi), otherItem.GetStat(StatType.Agi)) &&
            Equals(source.GetStat(StatType.Defence), otherItem.GetStat(StatType.Defence)) &&
            Equals(source.GetStat(StatType.Int), otherItem.GetStat(StatType.Int)) &&
            Equals(source.GetStat(StatType.MaxHit), otherItem.GetStat(StatType.MaxHit)) &&
            Equals(source.GetStat(StatType.MaxHP), otherItem.GetStat(StatType.MaxHP)) &&
            Equals(source.GetStat(StatType.MaxMP), otherItem.GetStat(StatType.MaxMP)) &&
            Equals(source.GetStat(StatType.MinHit), otherItem.GetStat(StatType.MinHit)) &&
            Equals(source.GetStat(StatType.Str), otherItem.GetStat(StatType.Str));
 }
Exemplo n.º 11
0
 /// <summary>
 /// When overridden in the derived class, handles additional loading stuff.
 /// </summary>
 /// <param name="v">The ICharacterTable containing the database values for this Character.</param>
 protected virtual void HandleAdditionalLoading(ICharacterTable v)
 {
 }
Exemplo n.º 12
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(ICharacterTable source, IDictionary<String, Object> dic)
 {
     dic["ai_id"] = source.AIID;
     dic["body_id"] = source.BodyID;
     dic["cash"] = source.Cash;
     dic["character_template_id"] = source.CharacterTemplateID;
     dic["chat_dialog"] = source.ChatDialog;
     dic["exp"] = source.Exp;
     dic["hp"] = source.HP;
     dic["id"] = source.ID;
     dic["level"] = source.Level;
     dic["load_map_id"] = source.LoadMapID;
     dic["load_x"] = source.LoadX;
     dic["load_y"] = source.LoadY;
     dic["move_speed"] = source.MoveSpeed;
     dic["mp"] = source.MP;
     dic["name"] = source.Name;
     dic["respawn_map_id"] = source.RespawnMapID;
     dic["respawn_x"] = source.RespawnX;
     dic["respawn_y"] = source.RespawnY;
     dic["shop_id"] = source.ShopID;
     dic["statpoints"] = source.StatPoints;
     dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi);
     dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence);
     dic["stat_int"] = (Int16)source.GetStat(StatType.Int);
     dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit);
     dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP);
     dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP);
     dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit);
     dic["stat_str"] = (Int16)source.GetStat(StatType.Str);
 }
Exemplo n.º 13
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterTable.
/// </summary>
/// <param name="source">The ICharacterTable to copy the values from.</param>
public void CopyValuesFrom(ICharacterTable source)
{
this.AIID = (System.Nullable<NetGore.AI.AIID>)source.AIID;
this.BodyID = (DemoGame.BodyID)source.BodyID;
this.Cash = (System.Int32)source.Cash;
this.CharacterTemplateID = (System.Nullable<DemoGame.CharacterTemplateID>)source.CharacterTemplateID;
this.ChatDialog = (System.Nullable<NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
this.Exp = (System.Int32)source.Exp;
this.HP = (DemoGame.SPValueType)source.HP;
this.ID = (DemoGame.CharacterID)source.ID;
this.Level = (System.Int16)source.Level;
this.LoadMapID = (NetGore.World.MapID)source.LoadMapID;
this.LoadX = (System.UInt16)source.LoadX;
this.LoadY = (System.UInt16)source.LoadY;
this.MoveSpeed = (System.UInt16)source.MoveSpeed;
this.MP = (DemoGame.SPValueType)source.MP;
this.Name = (System.String)source.Name;
this.RespawnMapID = (System.Nullable<NetGore.World.MapID>)source.RespawnMapID;
this.RespawnX = (System.Single)source.RespawnX;
this.RespawnY = (System.Single)source.RespawnY;
this.ShopID = (System.Nullable<NetGore.Features.Shops.ShopID>)source.ShopID;
this.StatPoints = (System.Int32)source.StatPoints;
this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str));
}
Exemplo n.º 14
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
public static void CopyValues(ICharacterTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic)
{
dic["ai_id"] = (System.Nullable<NetGore.AI.AIID>)source.AIID;
dic["body_id"] = (DemoGame.BodyID)source.BodyID;
dic["cash"] = (System.Int32)source.Cash;
dic["character_template_id"] = (System.Nullable<DemoGame.CharacterTemplateID>)source.CharacterTemplateID;
dic["chat_dialog"] = (System.Nullable<NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
dic["exp"] = (System.Int32)source.Exp;
dic["hp"] = (DemoGame.SPValueType)source.HP;
dic["id"] = (DemoGame.CharacterID)source.ID;
dic["level"] = (System.Int16)source.Level;
dic["load_map_id"] = (NetGore.World.MapID)source.LoadMapID;
dic["load_x"] = (System.UInt16)source.LoadX;
dic["load_y"] = (System.UInt16)source.LoadY;
dic["move_speed"] = (System.UInt16)source.MoveSpeed;
dic["mp"] = (DemoGame.SPValueType)source.MP;
dic["name"] = (System.String)source.Name;
dic["respawn_map_id"] = (System.Nullable<NetGore.World.MapID>)source.RespawnMapID;
dic["respawn_x"] = (System.Single)source.RespawnX;
dic["respawn_y"] = (System.Single)source.RespawnY;
dic["shop_id"] = (System.Nullable<NetGore.Features.Shops.ShopID>)source.ShopID;
dic["statpoints"] = (System.Int32)source.StatPoints;
dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
}
Exemplo n.º 15
0
/// <summary>
/// Initializes a new instance of the <see cref="CharacterTable"/> class.
/// </summary>
/// <param name="source">ICharacterTable to copy the initial values from.</param>
public CharacterTable(ICharacterTable source)
{
CopyValuesFrom(source);
}
Exemplo n.º 16
0
 /// <summary>
 /// When overridden in the derived class, handles additional loading stuff.
 /// </summary>
 /// <param name="v">The ICharacterTable containing the database values for this Character.</param>
 protected override void HandleAdditionalLoading(ICharacterTable v)
 {
     // Do not perform additional loading, since the additional loading is just for special NPC things like
     // shops and chat, which are things we do not want in a thralled NPC
 }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
/// <summary>
/// Initializes a new instance of the <see cref="CharacterTable"/> class.
/// </summary>
/// <param name="source">ICharacterTable to copy the initial values from.</param>
        public CharacterTable(ICharacterTable source)
        {
            CopyValuesFrom(source);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this CharacterTable.
 /// </summary>
 /// <param name="source">The ICharacterTable to copy the values from.</param>
 public void CopyValuesFrom(ICharacterTable source)
 {
     AIID = source.AIID;
     BodyID = source.BodyID;
     Cash = source.Cash;
     CharacterTemplateID = source.CharacterTemplateID;
     ChatDialog = source.ChatDialog;
     Exp = source.Exp;
     HP = source.HP;
     ID = source.ID;
     Level = source.Level;
     LoadMapID = source.LoadMapID;
     LoadX = source.LoadX;
     LoadY = source.LoadY;
     MoveSpeed = source.MoveSpeed;
     MP = source.MP;
     Name = source.Name;
     RespawnMapID = source.RespawnMapID;
     RespawnX = source.RespawnX;
     RespawnY = source.RespawnY;
     ShopID = source.ShopID;
     StatPoints = source.StatPoints;
     SetStat(StatType.Agi, source.GetStat(StatType.Agi));
     SetStat(StatType.Defence, source.GetStat(StatType.Defence));
     SetStat(StatType.Int, source.GetStat(StatType.Int));
     SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit));
     SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP));
     SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP));
     SetStat(StatType.MinHit, source.GetStat(StatType.MinHit));
     SetStat(StatType.Str, source.GetStat(StatType.Str));
 }
Exemplo n.º 20
0
 /// <summary>
 /// When overridden in the derived class, handles additional loading stuff.
 /// </summary>
 /// <param name="v">The ICharacterTable containing the database values for this Character.</param>
 protected override void HandleAdditionalLoading(ICharacterTable v)
 {
     // Do not perform additional loading, since the additional loading is just for special NPC things like
     // shops and chat, which are things we do not want in a thralled NPC
 }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The key must already exist in the DbParameterValues
/// for the value to be copied over. If any of the keys in the DbParameterValues do not
/// match one of the column names, or if there is no field for a key, then it will be
/// ignored. Because of this, it is important to be careful when using this method
/// since columns or keys can be skipped without any indication.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this ICharacterTable source, NetGore.Db.DbParameterValues paramValues)
        {
            for (int i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "ai_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.AIID;
                    break;


                case "body_id":
                    paramValues[i] = (System.UInt16)source.BodyID;
                    break;


                case "cash":
                    paramValues[i] = (System.Int32)source.Cash;
                    break;


                case "character_template_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.CharacterTemplateID;
                    break;


                case "chat_dialog":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.ChatDialog;
                    break;


                case "exp":
                    paramValues[i] = (System.Int32)source.Exp;
                    break;


                case "hp":
                    paramValues[i] = (System.Int16)source.HP;
                    break;


                case "id":
                    paramValues[i] = (System.Int32)source.ID;
                    break;


                case "level":
                    paramValues[i] = (System.Int16)source.Level;
                    break;


                case "load_map_id":
                    paramValues[i] = (System.UInt16)source.LoadMapID;
                    break;


                case "load_x":
                    paramValues[i] = (System.UInt16)source.LoadX;
                    break;


                case "load_y":
                    paramValues[i] = (System.UInt16)source.LoadY;
                    break;


                case "move_speed":
                    paramValues[i] = (System.UInt16)source.MoveSpeed;
                    break;


                case "mp":
                    paramValues[i] = (System.Int16)source.MP;
                    break;


                case "name":
                    paramValues[i] = (System.String)source.Name;
                    break;


                case "respawn_map_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.RespawnMapID;
                    break;


                case "respawn_x":
                    paramValues[i] = (System.Single)source.RespawnX;
                    break;


                case "respawn_y":
                    paramValues[i] = (System.Single)source.RespawnY;
                    break;


                case "shop_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.ShopID;
                    break;


                case "statpoints":
                    paramValues[i] = (System.Int32)source.StatPoints;
                    break;


                case "stat_agi":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
                    break;


                case "stat_defence":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
                    break;


                case "stat_int":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
                    break;


                case "stat_maxhit":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
                    break;


                case "stat_maxhp":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
                    break;


                case "stat_maxmp":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
                    break;


                case "stat_minhit":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
                    break;


                case "stat_str":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
                    break;
                }
            }
        }