Esempio n. 1
0
        public SimpleNpc(int id, BaseGame game, NpcInfo npcInfo, int type)
            : base(id, game, npcInfo.Camp, npcInfo.Name, npcInfo.ModelID, npcInfo.Blood, npcInfo.Immunity, -1)
        {
            if (type == 0)
            {
                Type = eLivingType.SimpleNpc;
            }
            else
            {
                Type = eLivingType.SimpleNpc1;
            }
            m_npcInfo = npcInfo;

            m_ai = ScriptMgr.CreateInstance(npcInfo.Script) as ABrain;
            if (m_ai == null)
            {
                log.ErrorFormat("Can't create abrain :{0}", npcInfo.Script);
                m_ai = SimpleBrain.Simple;
            }
            m_ai.Game = m_game;
            m_ai.Body = this;
            try
            {

                m_ai.OnCreated();
            }
            catch (Exception ex)
            {
                log.ErrorFormat("SimpleNpc Created error:{1}", ex);
            }

        }
Esempio n. 2
0
 public static XElement CreatNPCInfo(NpcInfo info)
 {
     return new XElement("Item", new XAttribute("ID", info.ID),
         new XAttribute("Name", info.Name),
         new XAttribute("Level", info.Level),
         new XAttribute("Camp", info.Camp),
         new XAttribute("Type", info.Type),
         new XAttribute("Blood", info.Blood),
         new XAttribute("MoveMin", info.MoveMin),
         new XAttribute("MoveMax", info.MoveMax),
         new XAttribute("BaseDamage", info.BaseDamage),
         new XAttribute("BaseGuard", info.BaseGuard),
         new XAttribute("Defence", info.Defence),
         new XAttribute("Agility", info.Agility),
         new XAttribute("Lucky", info.Lucky),
         new XAttribute("ModelID", info.ModelID),
         new XAttribute("ResourcesPath", info.ResourcesPath),
         new XAttribute("DropRate", info.DropRate),
         new XAttribute("Experience", info.Experience),
         new XAttribute("Delay", info.Delay),
         new XAttribute("Immunity", info.Immunity),
         new XAttribute("Alert", info.Alert),
         new XAttribute("Range", info.Range),
         new XAttribute("Preserve", info.Preserve),
         new XAttribute("Script", info.Script),
         new XAttribute("FireX", info.FireX),
         new XAttribute("FireY", info.FireY),
         new XAttribute("DropId", info.DropId));
 }
Esempio n. 3
0
 public NpcInfo[] GetAllNPCInfo()
 {
     List<NpcInfo> infos = new List<NpcInfo>();
     SqlDataReader reader = null;
     try
     {
         db.GetReader(ref reader, "SP_NPC_Info_All");
         while (reader.Read())
         {
             NpcInfo info = new NpcInfo();
             info.ID = (int)reader["ID"];
             info.Name = reader["Name"] == null ? "" : reader["Name"].ToString();
             info.Level = (int)reader["Level"];
             info.Camp = (int)reader["Camp"];
             info.Type = (int)reader["Type"];
             info.Blood = (int)reader["Blood"];
             info.X = (int)reader["X"];
             info.Y = (int)reader["Y"];
             info.Width = (int)reader["Width"];
             info.Height = (int)reader["Height"];
             info.MoveMin = (int)reader["MoveMin"];
             info.MoveMax = (int)reader["MoveMax"];
             info.BaseDamage = (int)reader["BaseDamage"];
             info.BaseGuard = (int)reader["BaseGuard"];
             info.Attack = (int)reader["Attack"];
             info.Defence = (int)reader["Defence"];
             info.Agility = (int)reader["Agility"];
             info.Lucky = (int)reader["Lucky"];
             info.ModelID = reader["ModelID"] == null ? "" : reader["ModelID"].ToString();
             info.ResourcesPath = reader["ResourcesPath"] == null ? "" : reader["ResourcesPath"].ToString();
             info.DropRate = reader["DropRate"] == null ? "" : reader["DropRate"].ToString();
             info.Experience = (int)reader["Experience"];
             info.Delay = (int)reader["Delay"];
             info.Immunity = (int)reader["Immunity"];
             info.Alert = (int)reader["Alert"];
             info.Range = (int)reader["Range"];
             info.Preserve = (int)reader["Preserve"];
             info.Script = reader["Script"] == null ? "" : reader["Script"].ToString();
             info.FireX = (int)reader["FireX"];
             info.FireY = (int)reader["FireY"];
             info.DropId = (int)reader["DropId"];
             infos.Add(info);
         }
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
             log.Error("GetAllNPCInfo", e);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
     }
     return infos.ToArray();
 }