using System;

public class Item
{
	public const int IMG_SIZE = 20;

	public const int IMG_SIZE_2 = 24;

	public const sbyte numItem = 36;

	public const sbyte ITEM_NULL = -2;

	public const sbyte ITEM_AFTER_USED = -1;

	public const sbyte ITEM_HEALTH = 0;

	public const sbyte ITEM_TELEPORT = 1;

	public const sbyte ITEM_DOUBLE = 2;

	public const sbyte ITEM_RUN_SPEED = 3;

	public const sbyte ITEM_INVISIBLE = 4;

	public const sbyte ITEM_STOP_WIND = 5;

	public const sbyte ITEM_RANG_CUA_BULL = 6;

	public const sbyte ITEM_GENERADE = 7;

	public const sbyte ITEM_BOMB_BAY = 8;

	public const sbyte ITEM_WEB = 9;

	public const sbyte ITEM_HEALTH_FOR_TEAM = 10;

	public const sbyte ITEM_DAN_TRAI_PHA = 11;

	public const sbyte ITEM_SLOT_1 = 12;

	public const sbyte ITEM_SLOT_2 = 13;

	public const sbyte ITEM_SLOT_3 = 14;

	public const sbyte ITEM_SLOT_4 = 15;

	public const sbyte ITEM_LAZER = 16;

	public const sbyte ITEM_TORNADO = 17;

	public const sbyte ITEM_MOUSE = 18;

	public const sbyte ITEM_4MISSILE = 19;

	public const sbyte ITEM_UNDERGROUND = 20;

	public const sbyte ITEM_METEOR = 21;

	public const sbyte ITEM_MRAIN = 22;

	public const sbyte ITEM_HOLE = 23;

	public const sbyte ITEM_SUICIDE = 24;

	public const sbyte ITEM_SMOKE = 25;

	public const sbyte ITEM_BIG_HOLE = 26;

	public const sbyte ITEM_UFO = 27;

	public const sbyte ITEM_FREEZE = 28;

	public const sbyte ITEM_POSION = 29;

	public const sbyte ITEM_ANGRY = 100;

	public const sbyte ITEM_WEB3 = 30;

	public const sbyte ITEM_TIME_BOMB = 31;

	public const sbyte ITEM_HEALTH_500 = 32;

	public const sbyte ITEM_HEALTH_1000 = 33;

	public const sbyte ITEM_INVISIBLE_2 = 34;

	public const sbyte ITEM_VAMPIRE = 35;

	public const sbyte ITEM_RESETPOINT = 36;

	public const sbyte ITEM_X2EXP = 37;

	public const sbyte ITEM_WAY = 42;

	public const int TYPE_BODY_MIN = 0;

	public const int TYPE_BODY_MAX = 6;

	public const int TYPE_AO = 0;

	public const int TYPE_QUAN = 1;

	public const int TYPE_GANGTAY = 2;

	public const int TYPE_GIAY = 3;

	public const int TYPE_RADA = 4;

	public const int TYPE_HAIR = 5;

	public const int TYPE_DAUTHAN = 6;

	public const int TYPE_NGOCRONG = 12;

	public const int TYPE_SACH = 7;

	public const int TYPE_NHIEMVU = 8;

	public const int TYPE_GOLD = 9;

	public const int TYPE_DIAMOND = 10;

	public const int TYPE_BALO = 11;

	private static Image s_imgITEM;

	public static string[] ITEM_NAME = L.items();

	public static sbyte[] NUM_MAX_USED = new sbyte[39]
	{
		2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
		1, 1, -1, -1, -1, -1, 1, 1, 1, 1,
		1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		1, 1, 1, 1, 1, 1, 1, 1, 1
	};

	public static sbyte[] NUM_BUY_PACKAGE = new sbyte[41]
	{
		1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
		1
	};

	public sbyte type;

	public string decription;

	public sbyte num;

	public int price;

	public int price2;

	public sbyte numUsed;

	public sbyte numToBuy;

	public sbyte nCurBuyPackage;

	public sbyte nCurMaxUsed;

	public bool isSell = true;

	public bool isPassive_Item;

	public bool isCannotBuy;

	public bool isFreeItem;

	private static int blank = 2;

	public static int iWitdh = 4;

	public bool isSocketing;

	public bool isKhamNam;

	public int nSocket;

	public int daySocket;

	public int hourSocket;

	public int level;

	public int iInBag;

	public MyVector gems;

	public ItemOption[] itemOption;

	public ItemTemplate template;

	public MyVector options;

	public int itemId;

	public int playerId;

	public bool isSelect;

	public int indexUI;

	public int quantity;

	public int quantilyToBuy;

	public long expires;

	public sbyte HP;

	public int powerRequire;

	public bool isLock;

	public int sys;

	public int upgrade;

	public int buyCoin;

	public int buyCoinLock;

	public int buyGold;

	public int buyGoldLock;

	public int saleCoinLock;

	public string strbuyCoin = string.Empty;

	public string strbuyGold = string.Empty;

	public sbyte buyType = -1;

	public int typeUI;

	public bool isExpires;

	public EffectCharPaint eff;

	public int indexEff;

	public Image img;

	public string info;

	public string content;

	public int compare;

	public sbyte isMe;

	public sbyte indexInBag;

	public bool isInBalo;

	public Item(sbyte Type, sbyte Num, int Price, int Price2)
	{
		type = Type;
		num = Num;
		numUsed = 0;
		numToBuy = 0;
		price = Price;
		price2 = Price2;
		decription = ITEM_NAME[Type];
		nCurBuyPackage = NUM_BUY_PACKAGE[Type];
		nCurMaxUsed = NUM_MAX_USED[Type];
		if (Price < 0)
		{
			isSell = false;
		}
		else
		{
			isSell = true;
		}
		isPassive_Item = false;
		switch (type)
		{
		case 0:
			isFreeItem = true;
			num = 99;
			break;
		case 1:
			isFreeItem = true;
			num = 99;
			break;
		case 12:
			isPassive_Item = true;
			break;
		case 13:
			isPassive_Item = true;
			break;
		case 14:
			isPassive_Item = true;
			break;
		case 15:
			isPassive_Item = true;
			break;
		}
	}

	public Item()
	{
	}

	public static void loadImage()
	{
		s_imgITEM = CCanvas.loadImage("/gui2/item.png");
	}

	public void getCompare()
	{
		compare = CCanvas.panel.getCompare(this);
	}

	public string getPrice()
	{
		string result = string.Empty;
		if (buyCoin <= 0 && buyGold <= 0)
		{
			return null;
		}
		if (buyCoin > 0 && buyGold <= 0)
		{
			result = buyCoin + L.xu();
		}
		else if (buyGold > 0 && buyCoin <= 0)
		{
			result = buyGold + L.luong();
		}
		else if (buyCoin > 0 && buyGold > 0)
		{
			result = buyCoin + L.xu() + "/" + buyGold + L.luong();
		}
		return result;
	}

	public bool isHaveOption(int id)
	{
		for (int i = 0; i < this.itemOption.Length; i++)
		{
			ItemOption itemOption = this.itemOption[i];
			if (itemOption != null && itemOption.optionTemplate.id == id)
			{
				return true;
			}
		}
		return false;
	}

	public Item clone()
	{
		Item item = new Item();
		item.template = template;
		if (options != null)
		{
			item.options = new MyVector();
			for (int i = 0; i < options.size(); i++)
			{
				ItemOption itemOption = new ItemOption();
				itemOption.optionTemplate = ((ItemOption)options.elementAt(i)).optionTemplate;
				itemOption.param = ((ItemOption)options.elementAt(i)).param;
				item.options.addElement(itemOption);
			}
		}
		item.itemId = itemId;
		item.playerId = playerId;
		item.indexUI = indexUI;
		item.quantity = quantity;
		item.expires = expires;
		item.isLock = isLock;
		item.sys = sys;
		item.upgrade = upgrade;
		item.buyCoin = buyCoin;
		item.buyCoinLock = buyCoinLock;
		item.buyGold = buyGold;
		item.buyGoldLock = buyGoldLock;
		item.saleCoinLock = saleCoinLock;
		item.typeUI = typeUI;
		item.isExpires = isExpires;
		return item;
	}

	public bool isTypeBody()
	{
		if (0 <= template.type && template.type < 6)
		{
			return true;
		}
		return false;
	}

	public string getExpiresString()
	{
		return string.Empty;
	}

	public string getExpiresShopString()
	{
		return string.Empty;
	}

	public bool isUpMax()
	{
		if (getUpMax() == upgrade)
		{
			return true;
		}
		return false;
	}

	public int getUpMax()
	{
		if (template.level >= 1 && template.level < 20)
		{
			return 4;
		}
		if (template.level >= 20 && template.level < 40)
		{
			return 8;
		}
		if (template.level >= 40 && template.level < 50)
		{
			return 12;
		}
		if (template.level >= 50 && template.level < 60)
		{
			return 14;
		}
		return 16;
	}

	public static void DrawItem(mGraphics g, int itemID, int x, int y)
	{
		try
		{
			SmallImage.drawSmallImage(g, itemID, x, y, 0, 3, false);
		}
		catch (Exception)
		{
			g.setColor(16777215);
			g.fillRect(x, y, 20, 20, false);
		}
	}

	public void drawThisItem(mGraphics g, int x, int y)
	{
		try
		{
		}
		catch (Exception)
		{
			g.setColor(16777215);
			g.fillRect(x, y, 20, 20, false);
		}
	}

	public static void DrawSetItem(mGraphics g, int[] setItem, int curItem, int x, int y, bool isTouch, byte[] num)
	{
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = (isTouch ? 22 : 0);
		for (int i = 0; i < setItem.Length; i++)
		{
			int num7 = x + num2 * (20 + blank + num6);
			int num8 = ((CCanvas.curScr != CCanvas.gameScr) ? (y + num3 * (20 + blank + num6)) : (y + num3 * (20 + blank + num6)));
			if (curItem >= 0 && i == curItem)
			{
				g.setColor((CCanvas.gameTick % 5 <= 2) ? 16711680 : 16776960);
				g.fillRect(num7 - blank / 2, num8 - blank / 2, 20 + blank, 20 + blank, false);
			}
			try
			{
			}
			catch (Exception)
			{
				g.fillRect(num7, num8, 16, 16, false);
			}
			num2++;
			if (num2 > iWitdh - 1)
			{
				num2 = 0;
				num3++;
			}
		}
		for (int j = 0; j < setItem.Length; j++)
		{
			int num9 = x + num4 * (20 + blank + num6);
			int num10 = ((CCanvas.curScr != CCanvas.gameScr) ? (y + num5 * (20 + blank + num6)) : (y + num5 * (20 + blank + num6)));
			try
			{
				string st = ((num[j] == 100) ? string.Empty : (num[j] + string.Empty));
				mFont.smallFontYellow.drawString(g, st, num9 + 12, num10 + 12, 0);
			}
			catch (Exception)
			{
			}
			num4++;
			if (num4 > iWitdh - 1)
			{
				num4 = 0;
				num5++;
			}
		}
	}

	public static void DrawSetItem(mGraphics g, int[] setItem, int curItem, int x, int y, bool isTouch, sbyte[] num, int iWitdh)
	{
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		int num5 = 0;
		int num6 = ((!isTouch) ? 3 : 3);
		int num7 = 0;
		for (int i = 0; i < setItem.Length; i++)
		{
			int num8 = x + num2 * (20 + num7 + num6 + 1);
			int num9 = ((CCanvas.curScr != CCanvas.gameScr) ? (y + num3 * (20 + num7 + num6)) : (y + num3 * (20 + num7 + num6)));
			if (curItem >= 0 && i == curItem)
			{
				g.drawImage(GameScr.box0, num8 + 10, num9 + 10, 3, false);
			}
			else
			{
				g.drawImage(GameScr.box1, num8 + 10, num9 + 10, 3, false);
			}
			try
			{
			}
			catch (Exception)
			{
				g.fillRect(num8, num9, 16, 16, false);
			}
			num2++;
			if (num2 > iWitdh - 1)
			{
				num2 = 0;
				num3++;
			}
		}
		for (int j = 0; j < setItem.Length; j++)
		{
			int num10 = x + num4 * (20 + num7 + num6);
			int num11 = ((CCanvas.curScr != CCanvas.gameScr) ? (y + num5 * (20 + num7 + num6)) : (y + num5 * (20 + num7 + num6)));
			try
			{
				string st = ((num[j] == 100) ? string.Empty : (num[j] + string.Empty));
				mFont.smallFontYellow.drawString(g, st, num10 + 12, num11 + 12, 0);
			}
			catch (Exception)
			{
			}
			num4++;
			if (num4 > iWitdh - 1)
			{
				num4 = 0;
				num5++;
			}
		}
	}
}
