示例#1
0
 ///<summary>Inserts one MountItem into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountItem mountItem)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         mountItem.MountItemNum=DbHelper.GetNextOracleKey("mountitem","MountItemNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(mountItem,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     mountItem.MountItemNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(mountItem,false);
     }
 }
示例#2
0
        ///<summary>Updates one MountItem in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(MountItem mountItem, MountItem oldMountItem)
        {
            string command = "";

            if (mountItem.MountNum != oldMountItem.MountNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MountNum = " + POut.Long(mountItem.MountNum) + "";
            }
            if (mountItem.Xpos != oldMountItem.Xpos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Xpos = " + POut.Int(mountItem.Xpos) + "";
            }
            if (mountItem.Ypos != oldMountItem.Ypos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Ypos = " + POut.Int(mountItem.Ypos) + "";
            }
            if (mountItem.OrdinalPos != oldMountItem.OrdinalPos)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OrdinalPos = " + POut.Int(mountItem.OrdinalPos) + "";
            }
            if (mountItem.Width != oldMountItem.Width)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Width = " + POut.Int(mountItem.Width) + "";
            }
            if (mountItem.Height != oldMountItem.Height)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Height = " + POut.Int(mountItem.Height) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE mountitem SET " + command
                      + " WHERE MountItemNum = " + POut.Long(mountItem.MountItemNum);
            Db.NonQ(command);
        }
示例#3
0
 ///<summary>Inserts one MountItem into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountItem mountItem)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         mountItem.MountItemNum = DbHelper.GetNextOracleKey("mountitem", "MountItemNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(mountItem, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     mountItem.MountItemNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(mountItem, false));
     }
 }
示例#4
0
        ///<summary>Inserts one MountItem into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MountItem mountItem, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO mountitem (";

            if (!useExistingPK && isRandomKeys)
            {
                mountItem.MountItemNum = ReplicationServers.GetKeyNoCache("mountitem", "MountItemNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MountItemNum,";
            }
            command += "MountNum,Xpos,Ypos,OrdinalPos,Width,Height) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(mountItem.MountItemNum) + ",";
            }
            command +=
                POut.Long(mountItem.MountNum) + ","
                + POut.Int(mountItem.Xpos) + ","
                + POut.Int(mountItem.Ypos) + ","
                + POut.Int(mountItem.OrdinalPos) + ","
                + POut.Int(mountItem.Width) + ","
                + POut.Int(mountItem.Height) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountItem.MountItemNum = Db.NonQ(command, true, "MountItemNum", "mountItem");
            }
            return(mountItem.MountItemNum);
        }
示例#5
0
 ///<summary>Returns true if Update(MountItem,MountItem) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(MountItem mountItem, MountItem oldMountItem)
 {
     if (mountItem.MountNum != oldMountItem.MountNum)
     {
         return(true);
     }
     if (mountItem.Xpos != oldMountItem.Xpos)
     {
         return(true);
     }
     if (mountItem.Ypos != oldMountItem.Ypos)
     {
         return(true);
     }
     if (mountItem.OrdinalPos != oldMountItem.OrdinalPos)
     {
         return(true);
     }
     if (mountItem.Width != oldMountItem.Width)
     {
         return(true);
     }
     if (mountItem.Height != oldMountItem.Height)
     {
         return(true);
     }
     return(false);
 }
示例#6
0
 ///<summary>Inserts one MountItem into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(MountItem mountItem,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         mountItem.MountItemNum=ReplicationServers.GetKey("mountitem","MountItemNum");
     }
     string command="INSERT INTO mountitem (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MountItemNum,";
     }
     command+="MountNum,Xpos,Ypos,OrdinalPos,Width,Height) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(mountItem.MountItemNum)+",";
     }
     command+=
              POut.Long  (mountItem.MountNum)+","
         +    POut.Int   (mountItem.Xpos)+","
         +    POut.Int   (mountItem.Ypos)+","
         +    POut.Int   (mountItem.OrdinalPos)+","
         +    POut.Int   (mountItem.Width)+","
         +    POut.Int   (mountItem.Height)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         mountItem.MountItemNum=Db.NonQ(command,true);
     }
     return mountItem.MountItemNum;
 }
示例#7
0
        ///<summary>Inserts one MountItem into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(MountItem mountItem, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                mountItem.MountItemNum = ReplicationServers.GetKey("mountitem", "MountItemNum");
            }
            string command = "INSERT INTO mountitem (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MountItemNum,";
            }
            command += "MountNum,Xpos,Ypos,OrdinalPos,Width,Height) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(mountItem.MountItemNum) + ",";
            }
            command +=
                POut.Long(mountItem.MountNum) + ","
                + POut.Int(mountItem.Xpos) + ","
                + POut.Int(mountItem.Ypos) + ","
                + POut.Int(mountItem.OrdinalPos) + ","
                + POut.Int(mountItem.Width) + ","
                + POut.Int(mountItem.Height) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountItem.MountItemNum = Db.NonQ(command, true);
            }
            return(mountItem.MountItemNum);
        }
示例#8
0
 void Awake()
 {
     m_Instance = this;
     m_ItemActive.SetActive(false);
     m_ItemName.color = normalColor;
     m_ItemNormal.SetActive(true);
     SetCollectFlag(false);
 }
示例#9
0
        ///<summary>Updates one MountItem in the database.</summary>
        internal static void Update(MountItem mountItem)
        {
            string command = "UPDATE mountitem SET "
                             + "MountNum    =  " + POut.Long(mountItem.MountNum) + ", "
                             + "Xpos        =  " + POut.Int(mountItem.Xpos) + ", "
                             + "Ypos        =  " + POut.Int(mountItem.Ypos) + ", "
                             + "OrdinalPos  =  " + POut.Int(mountItem.OrdinalPos) + ", "
                             + "Width       =  " + POut.Int(mountItem.Width) + ", "
                             + "Height      =  " + POut.Int(mountItem.Height) + " "
                             + "WHERE MountItemNum = " + POut.Long(mountItem.MountItemNum);

            Db.NonQ(command);
        }
示例#10
0
    void initMountFakeObj()
    {
        if (m_MountItem.Count > 0)
        {
            int nMountID = 0;
            if (Singleton <ObjManager> .GetInstance().MainPlayer&&
                Singleton <ObjManager> .GetInstance().MainPlayer.GetEquipMountID() > 0)
            {
                nMountID = Singleton <ObjManager> .GetInstance().MainPlayer.GetEquipMountID();
            }

            if (nMountID <= 0)
            {
                for (int i = 0; i < MountParam.Max_MountCollect_Count; i++)
                {
                    Tab_MountBase MountBase = TableManager.GetMountBaseByID(i, 0);
                    if (MountBase == null)
                    {
                        continue;
                    }

                    bool bCollectFlag = GameManager.gameManager.PlayerDataPool.m_objMountParam.GetMountCollectFlag(i);
                    if (bCollectFlag == true)
                    {
                        nMountID = i;
                        break;
                    }
                }
            }

            string strName = "";
            if (nMountID <= 0)
            {
                nMountID = m_MountItem[0];
                strName += "n";
            }

            strName += "MountItem" + nMountID / 10 + nMountID % 10;
            Transform gItemObjTransform = m_MountRoot_UIGrid.transform.FindChild(strName);
            if (gItemObjTransform != null && gItemObjTransform.gameObject)
            {
                MountItem MountItemObj = gItemObjTransform.gameObject.GetComponent <MountItem>();
                if (MountItemObj)
                {
                    MountItemObj.MountItemClick();
                    //MountItemClick(MountItemObj.MountID);
                }
            }
        }
    }
示例#11
0
 ///<summary>Inserts one MountItem into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountItem mountItem)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(mountItem, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             mountItem.MountItemNum = DbHelper.GetNextOracleKey("mountitem", "MountItemNum");                  //Cacheless method
         }
         return(InsertNoCache(mountItem, true));
     }
 }
示例#12
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MountItem> TableToList(DataTable table){
			List<MountItem> retVal=new List<MountItem>();
			MountItem mountItem;
			for(int i=0;i<table.Rows.Count;i++) {
				mountItem=new MountItem();
				mountItem.MountItemNum= PIn.Long  (table.Rows[i]["MountItemNum"].ToString());
				mountItem.MountNum    = PIn.Long  (table.Rows[i]["MountNum"].ToString());
				mountItem.Xpos        = PIn.Int   (table.Rows[i]["Xpos"].ToString());
				mountItem.Ypos        = PIn.Int   (table.Rows[i]["Ypos"].ToString());
				mountItem.OrdinalPos  = PIn.Int   (table.Rows[i]["OrdinalPos"].ToString());
				mountItem.Width       = PIn.Int   (table.Rows[i]["Width"].ToString());
				mountItem.Height      = PIn.Int   (table.Rows[i]["Height"].ToString());
				retVal.Add(mountItem);
			}
			return retVal;
		}
示例#13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MountItem> TableToList(DataTable table)
        {
            List <MountItem> retVal = new List <MountItem>();
            MountItem        mountItem;

            foreach (DataRow row in table.Rows)
            {
                mountItem = new MountItem();
                mountItem.MountItemNum = PIn.Long(row["MountItemNum"].ToString());
                mountItem.MountNum     = PIn.Long(row["MountNum"].ToString());
                mountItem.Xpos         = PIn.Int(row["Xpos"].ToString());
                mountItem.Ypos         = PIn.Int(row["Ypos"].ToString());
                mountItem.OrdinalPos   = PIn.Int(row["OrdinalPos"].ToString());
                mountItem.Width        = PIn.Int(row["Width"].ToString());
                mountItem.Height       = PIn.Int(row["Height"].ToString());
                retVal.Add(mountItem);
            }
            return(retVal);
        }
示例#14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <MountItem> TableToList(DataTable table)
        {
            List <MountItem> retVal = new List <MountItem>();
            MountItem        mountItem;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mountItem = new MountItem();
                mountItem.MountItemNum = PIn.Long(table.Rows[i]["MountItemNum"].ToString());
                mountItem.MountNum     = PIn.Long(table.Rows[i]["MountNum"].ToString());
                mountItem.Xpos         = PIn.Int(table.Rows[i]["Xpos"].ToString());
                mountItem.Ypos         = PIn.Int(table.Rows[i]["Ypos"].ToString());
                mountItem.OrdinalPos   = PIn.Int(table.Rows[i]["OrdinalPos"].ToString());
                mountItem.Width        = PIn.Int(table.Rows[i]["Width"].ToString());
                mountItem.Height       = PIn.Int(table.Rows[i]["Height"].ToString());
                retVal.Add(mountItem);
            }
            return(retVal);
        }
示例#15
0
    void CreateChildForGrid(GameObject resItem, GameObject gParentObj, bool bCollectFlag, int i, Tab_MountBase mountTab)
    {
        if (mountTab == null || null == GameManager.gameManager.PlayerDataPool)
        {
            return;
        }

        GameObject gMountItem = Utils.BindObjToParent(resItem, gParentObj, "MountItem" + i / 10 + i % 10);

        if (null != gMountItem)
        {
            MountItem mountItemScript = gMountItem.GetComponent <MountItem>();
            if (null != mountItemScript)
            {
                mountItemScript.MountID = i;
                mountItemScript.SetName(mountTab.Name);
                mountItemScript.SetIcon(mountTab.MountIcon);

                // 是否有该坐骑
                if (bCollectFlag)
                {
                    mountItemScript.SetCollectFlag(true);

                    //added by mawenbin
                    //获取新坐骑,红点提示,控制显示
                    bool bRemindFlag = GameManager.gameManager.PlayerDataPool.m_objMountParam.GetMountRemindFlag(i);
                    mountItemScript.SetRemindFlag(bRemindFlag);
                }
                else
                {
                    gMountItem.name = "n" + gMountItem.name;
                }

                m_MountItem.Add(i);
            }
        }
    }
示例#16
0
        ///<summary>Renders the given image using the settings provided by the given document object into the location of the given mountItem object.</summary>
        public static void RenderImageIntoMount(Bitmap mountImage, MountItem mountItem, Bitmap mountItemImage, Document mountItemDoc)
        {
            if (mountItem == null)
            {
                return;
            }

            using (Graphics g = Graphics.FromImage(mountImage)) {
                g.FillRectangle(Brushes.Black, mountItem.Xpos, mountItem.Ypos, mountItem.Width, mountItem.Height);                //draw box behind image
                Bitmap image = ApplyDocumentSettingsToImage(mountItemDoc, mountItemImage, ApplySettings.ALL);
                if (image == null)
                {
                    return;
                }
                float      widthScale  = ((float)mountItem.Width) / image.Width;
                float      heightScale = ((float)mountItem.Height) / image.Height;
                float      scale       = (widthScale < heightScale ? widthScale : heightScale);
                RectangleF imageRect   = new RectangleF(0, 0, scale * image.Width, scale * image.Height);
                imageRect.X = mountItem.Xpos + mountItem.Width / 2 - imageRect.Width / 2;
                imageRect.Y = mountItem.Ypos + mountItem.Height / 2 - imageRect.Height / 2;
                g.DrawImage(image, imageRect);
                image.Dispose();
            }
        }
示例#17
0
 ///<summary>Inserts one MountItem into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountItem mountItem)
 {
     return(InsertNoCache(mountItem, false));
 }
示例#18
0
		///<summary>Updates one MountItem in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(MountItem mountItem,MountItem oldMountItem){
			string command="";
			if(mountItem.MountNum != oldMountItem.MountNum) {
				if(command!=""){ command+=",";}
				command+="MountNum = "+POut.Long(mountItem.MountNum)+"";
			}
			if(mountItem.Xpos != oldMountItem.Xpos) {
				if(command!=""){ command+=",";}
				command+="Xpos = "+POut.Int(mountItem.Xpos)+"";
			}
			if(mountItem.Ypos != oldMountItem.Ypos) {
				if(command!=""){ command+=",";}
				command+="Ypos = "+POut.Int(mountItem.Ypos)+"";
			}
			if(mountItem.OrdinalPos != oldMountItem.OrdinalPos) {
				if(command!=""){ command+=",";}
				command+="OrdinalPos = "+POut.Int(mountItem.OrdinalPos)+"";
			}
			if(mountItem.Width != oldMountItem.Width) {
				if(command!=""){ command+=",";}
				command+="Width = "+POut.Int(mountItem.Width)+"";
			}
			if(mountItem.Height != oldMountItem.Height) {
				if(command!=""){ command+=",";}
				command+="Height = "+POut.Int(mountItem.Height)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE mountitem SET "+command
				+" WHERE MountItemNum = "+POut.Long(mountItem.MountItemNum);
			Db.NonQ(command);
		}
示例#19
0
		///<summary>Updates one MountItem in the database.</summary>
		public static void Update(MountItem mountItem){
			string command="UPDATE mountitem SET "
				+"MountNum    =  "+POut.Long  (mountItem.MountNum)+", "
				+"Xpos        =  "+POut.Int   (mountItem.Xpos)+", "
				+"Ypos        =  "+POut.Int   (mountItem.Ypos)+", "
				+"OrdinalPos  =  "+POut.Int   (mountItem.OrdinalPos)+", "
				+"Width       =  "+POut.Int   (mountItem.Width)+", "
				+"Height      =  "+POut.Int   (mountItem.Height)+" "
				+"WHERE MountItemNum = "+POut.Long(mountItem.MountItemNum);
			Db.NonQ(command);
		}
    public void LoseItem(ItemBase item, int lose_num)
    {
        if (item == null || lose_num <= 0)
        {
            return;
        }
        if (Current_Size <= 0)
        {
            throw new System.Exception("背包为空");
        }
        ItemInfo tempitem = itemList.Find(i => i.Item == item);

        if (tempitem == null)
        {
            throw new System.Exception("该物品未在行囊中");
        }
        bool isequip = false;

        switch (tempitem.Item.ItemType)
        {
        case ItemType.Weapon:
            WeaponItem weapon = tempitem.Item as WeaponItem;
            if (weapon == null)
            {
                break;
            }
            isequip = weapon.IsEqu;
            break;

        case ItemType.Armor:
            ArmorItem armor = tempitem.Item as ArmorItem;
            if (armor == null)
            {
                break;
            }
            isequip = armor.IsEqu;
            break;

        case ItemType.Jewelry:
            JewelryItem jewelry = tempitem.Item as JewelryItem;
            if (jewelry == null)
            {
                break;
            }
            isequip = jewelry.IsEqu;
            break;

        case ItemType.Mount:
            MountItem mount = tempitem.Item as MountItem;
            if (mount == null)
            {
                break;
            }
            isequip = mount.IsEqu;
            break;
        }
        if (isequip)
        {
            throw new System.Exception("该物品已装备");
        }
        if (tempitem.Quantity <= 0)
        {
            throw new System.Exception("该物品为空");
        }
        int finallyDiscard = tempitem.StackAble ? tempitem.Quantity - lose_num > 0 ? lose_num : tempitem.Quantity : 1;

        tempitem.Quantity -= finallyDiscard;
        Current_Weight    -= tempitem.Item.Weight * finallyDiscard;
        if (tempitem.Quantity <= 0)
        {
            Current_Size -= 1;
            itemList.Remove(tempitem);
        }
        CheckSizeAndWeight();
    }