using System;
using Assets.src.player;

public class Bullet
{
	public const sbyte BULL_CANNON = 0;

	public const sbyte BULL_AK = 1;

	public const sbyte BULL_PROTON = 2;

	public const sbyte BULL_BOMBAY = 3;

	public const sbyte BULL_BOMB_FLAG = 4;

	public const sbyte BULL_TELEPORT = 5;

	public const sbyte BULL_RANG_CUA = 6;

	public const sbyte BULL_GENERADE = 7;

	public const sbyte BULL_WEB = 8;

	public const sbyte BULL_CHUOI = 9;

	public const sbyte BULL_ROCKET = 10;

	public const sbyte BULL_MORTAR = 11;

	public const sbyte BULL_TORNADO = 13;

	public const sbyte BULL_TRAI_PHA = 12;

	public const sbyte BULL_LAZER_FLAG = 14;

	public const sbyte BULL_LAZER = 15;

	public const sbyte BULL_TRAI_PHA_FLAG = 16;

	public const sbyte BULL_EXPLORE_FLAG = 17;

	public const sbyte BULL_EXPLORE = 18;

	public const sbyte BULL_CHICKEN = 19;

	public const sbyte BULL_EGG = 20;

	public const sbyte BULL_BOOMERANG = 21;

	public const sbyte BULL_MOUSE = 22;

	public const sbyte BULL_METEOR_FLAG = 23;

	public const sbyte BULL_METEOR = 24;

	public const sbyte BULL_UNDERGROUND = 25;

	public const sbyte BULL_4MISSILE = 26;

	public const sbyte BULL_1MISSILE = 27;

	public const sbyte BULL_MISSILE_RAIN_FLAG = 28;

	public const sbyte BULL_MISSILE_RAIN = 29;

	public const sbyte BULL_HOLE = 30;

	public const sbyte BULL_BOMB_BOSS = 31;

	public const sbyte BULL_BOMB_BOSS_SMALL = 32;

	public const sbyte BULL_BOSS_MISSILE = 33;

	public const sbyte BULL_MINI_BOMB = 34;

	public const sbyte BULL_ROBOT_ATTACK = 35;

	public const sbyte BULL_TELEPORT_2 = 36;

	public const sbyte BULL_NUKE = 37;

	public const sbyte BULL_4LAZER = 38;

	public const sbyte BULL_1LAZER = 39;

	public const sbyte BULL_LAZER2 = 40;

	public const sbyte BULL_SPEACIAL = 41;

	public const sbyte BULL_UFO_LAZER = 42;

	public const sbyte BULL_10_BOMB = 43;

	public const sbyte BULL_BALLOON_GUN = 44;

	public const sbyte BULL_BALLOON_LAZER = 45;

	public const sbyte BULL_AXIT = 47;

	public const sbyte BULL_PINGPONG = 48;

	public const sbyte BULL_SUICIDE = 50;

	public const sbyte BULL_SMOKE = 51;

	public const sbyte BULL_BIG_HOLE = 52;

	public const sbyte BULL_UFO = 53;

	public const sbyte BULL_FREEZE = 54;

	public const sbyte BULL_POISION = 55;

	public const sbyte BULL_WEB3 = 56;

	public const sbyte BULL_TIME_BOMB = 57;

	public const sbyte BULL_WAY = 58;

	public const sbyte BULL_WATER = 59;

	public const sbyte BULL_TURTLE = 60;

	public const sbyte BULL_TURTLE_STONE = 61;

	public const sbyte BULL_LAZER_GIRL = 49;

	public int x;

	public int y;

	private int xDestination;

	private int yDestination;

	private int x_Last;

	private int y_Last;

	private int _xStart;

	private int _yStart;

	private int x_1;

	private int x_2;

	private int y_1;

	private int y_2;

	private int _w;

	private int _h;

	private int vx;

	private int vy;

	private int x_hammer;

	private int y_hammer;

	private int g = 8;

	private int g1;

	private int wind1;

	private int explDelay;

	private int vyLazer;

	private int lazerColor;

	private int subVx;

	private int subVy;

	private int subBmrVx;

	private int mouseP;

	private int trans;

	private int xS;

	private int yS;

	private int xD;

	private int yD;

	private bool isActiveMissile;

	private bool isActiveHammer;

	private bool isActiveEgg;

	private bool isActiveRain;

	private sbyte whoShot;

	private int color;

	private bool rotate;

	private bool rotateAround;

	private bool translate;

	private Image img;

	private FrameImage frmImg;

	private int curFrame;

	private int smokeDelay;

	private bool smoke;

	private bool longSmoke;

	private bool fireSmoke;

	private bool blackSmoke;

	private bool changeFrame;

	private bool lazerBullet;

	private bool changeFrameLeft;

	private bool isLightBlink;

	private bool isWaterBum;

	private bool lazerShoot;

	private bool lazerStop = true;

	private bool tonardo;

	private bool beginTimeCount;

	private bool chickenBull;

	private bool chickenHair;

	private bool isLoki;

	private bool isCaptain;

	private int nFrame;

	public static int dXLaser;

	public static int dYLaser;

	public int angle;

	private int force = 10;

	public int wind;

	public bool isSuper;

	private int sFrame;

	private int ts;

	public static Image chatlong;

	public static Image balloonBull;

	public static Image lazer;

	public static Image bomb;

	public static Image webImg;

	public static Image bomb_flag;

	public static Image grenadeImg;

	public static Image egg;

	public static Image mouse;

	public static Image meteor;

	public static Image daodat;

	public static Image rocket2;

	public static Image rainmissile;

	public static Image khoang;

	public static Image nuke;

	public static Image axit;

	public static Image daodat2;

	public static Image superShoot;

	public static Image stone;

	public static Image muiten;

	public static Image water;

	public static Image imgTurtle;

	public sbyte type;

	public static sbyte[] BULLset_WIND_AFFECT = null;

	public static sbyte[] BULLset_WEIGHT = new sbyte[21]
	{
		10, 5, 6, 7, 8, 9, 8, 7, 9, 8,
		9, 8, 12, 5, 5, 10, 10, 10, 5, 3,
		5
	};

	public short[] xPaint;

	public short[] yPaint;

	public int paintCount;

	public int idBullet;

	private MyVector postion;

	private static Image imgKhien;

	private static Image imgHammerThor;

	private static Image imgFireLoki;

	private static FrameImage frLoki;

	private int xLG;

	private int yLG;

	private int n1 = 10;

	private int n2 = 8;

	private bool isMirror;

	private int tL;

	private int xLaser1;

	private int yLaser1;

	private int xLaser2;

	private int yLaser2;

	private bool rotateByLand;

	private int angleByLand;

	public static FrameImage frballoon;

	public static FrameImage frLazer;

	public static FrameImage frNuke;

	public static FrameImage frAxit;

	private int lx;

	private int ly;

	private int pw = 1;

	private int ph = 1;

	private int px;

	private int py;

	private int nCheck;

	private bool changePositon;

	private int dis;

	private int count;

	private int dis_ChPosition = 4;

	private int dis_delay;

	private int x_3;

	private int y_3;

	private int x_4;

	private int y_4;

	private int timecount;

	private bool isfall;

	private int dym;

	private int currAngle;

	private int nextX;

	private short nextY;

	private int angleLimit = 40;

	private bool beginUdgr;

	private int bx;

	private int missileTime;

	private int pingFrame;

	private int pingColor;

	private int t;

	private int lastAngle;

	private bool isPaintLazer;

	private int tLoki;

	private int khienAngle;

	private bool pingChange;

	private int mainFrame;

	private int pos;

	public static int webId = 200;

	public bool notPaint;

	private int de;

	private Image tam;

	public Bullet(sbyte type, short[] X, short[] Y, sbyte whoShot)
	{
		init(type, X, Y, whoShot);
	}

	public Bullet(sbyte type, short[] X, short[] Y, sbyte whoShot, int idBullet)
	{
		this.idBullet = idBullet;
		init(type, X, Y, whoShot);
	}

	public Bullet(sbyte type, short[] X, short[] Y, sbyte whoShot, short[] xHit, short[] yHit)
	{
		init(type, X, Y, whoShot);
		getCollisionPingPong(xHit, yHit);
	}

	public static void loadImage()
	{
		superShoot = CCanvas.loadImage("/eff/no.png");
	}

	public void load(int type)
	{
		switch (type)
		{
		case 55:
			if (chatlong == null)
			{
				chatlong = CCanvas.loadImage("/item/chatlong.png");
			}
			break;
		case 48:
			if (balloonBull == null)
			{
				balloonBull = CCanvas.loadImage("/item/balloonBull.png");
			}
			break;
		case 44:
			if (lazer == null)
			{
				lazer = CCanvas.loadImage("/item/laser.png");
			}
			break;
		case 3:
		case 43:
			if (bomb == null)
			{
				bomb = CCanvas.loadImage("/item/bomb.png");
			}
			break;
		case 8:
		case 56:
			if (webImg == null)
			{
				webImg = CCanvas.loadImage("/item/web.png");
			}
			break;
		case 4:
		case 5:
		case 16:
		case 36:
			if (bomb_flag == null)
			{
				bomb_flag = CCanvas.loadImage("/item/specialbullet.png");
			}
			break;
		case 6:
		case 7:
		case 12:
		case 31:
			if (grenadeImg == null)
			{
				grenadeImg = CCanvas.loadImage("/item/grenade.png");
			}
			break;
		case 20:
			if (egg == null)
			{
				egg = CCanvas.loadImage("/item/trungvang.png");
			}
			break;
		case 22:
			if (mouse == null)
			{
				mouse = CCanvas.loadImage("/item/chuotBull.png");
			}
			break;
		case 24:
			if (meteor == null)
			{
				meteor = CCanvas.loadImage("/item/thienthach.png");
			}
			break;
		case 25:
			if (daodat == null)
			{
				daodat = CCanvas.loadImage("/item/daodat.png");
			}
			break;
		case 27:
		case 29:
			if (rocket2 == null)
			{
				rocket2 = CCanvas.loadImage("/item/rocket2.png");
			}
			break;
		case 28:
			if (rainmissile == null)
			{
				rainmissile = CCanvas.loadImage("/item/13Missile.png");
			}
			break;
		case 30:
			if (khoang == null)
			{
				khoang = CCanvas.loadImage("/item/khoang.png");
			}
			break;
		case 37:
			if (muiten == null)
			{
				muiten = CCanvas.loadImage("/eff/muiten.png");
			}
			break;
		case 47:
			if (axit == null)
			{
				axit = CCanvas.loadImage("/item/axit.png");
			}
			break;
		case 52:
			if (daodat2 == null)
			{
				daodat2 = CCanvas.loadImage("/item/daodat2.png");
			}
			break;
		case 59:
			if (water == null)
			{
				water = CCanvas.loadImage("/item/bongbong2.png");
			}
			break;
		case 60:
			if (imgTurtle == null)
			{
				imgTurtle = CCanvas.loadImage("/item/danrua.png");
			}
			break;
		}
	}

	public static void unload()
	{
		chatlong = null;
		balloonBull = null;
		lazer = null;
		bomb = null;
		webImg = null;
		bomb_flag = null;
		grenadeImg = null;
		egg = null;
		mouse = null;
		meteor = null;
		daodat = null;
		rocket2 = null;
		rainmissile = null;
		khoang = null;
		nuke = null;
		axit = null;
		daodat2 = null;
		stone = null;
		frballoon = null;
		frLazer = null;
		frNuke = null;
		frAxit = null;
		muiten = null;
		imgKhien = null;
		imgFireLoki = null;
		frLoki = null;
	}

	public void init(sbyte type, short[] X, short[] Y, sbyte whoShot)
	{
		CRes.outz(">>>>>>>>>>>>>>>>>type " + type);
		switch (type)
		{
		case 1:
			Music.play(Music.AK, 10f);
			break;
		case 49:
			Music.play(Music.LASER, 10f);
			break;
		case 17:
		case 18:
			Music.play(Music.HAMMER, 10f);
			break;
		case 2:
			Music.play(Music.SHOTGUN, 10f);
			break;
		case 19:
		case 20:
			Music.play(Music.CHICKEN, 10f);
			break;
		case 5:
			Music.play(Music.TELEPORT, 10f);
			break;
		case 21:
			Music.play(Music.BOOMERANG, 10f);
			break;
		default:
			Music.play(Music.PISTOL, 10f);
			break;
		}
		this.type = type;
		this.whoShot = whoShot;
		xPaint = X;
		yPaint = Y;
		x = xPaint[0];
		y = yPaint[0];
		initBulletType(type);
		if (type == 49)
		{
			xLG = getXYMirror(X, Y)[0];
			yLG = getXYMirror(X, Y)[1];
			CPlayer.xM = xLG;
			CPlayer.yM = yLG;
			CPlayer.isMirror = true;
		}
		Camera.shaking = 0;
		getPlayerEffect();
		if (CScreen.isUseHighFrameRate())
		{
			short[] array = new short[xPaint.Length * 2];
			short[] array2 = new short[yPaint.Length * 2];
			for (int i = 0; i < array.Length; i++)
			{
				if (i == 0)
				{
					array[i] = xPaint[0];
					array2[i] = yPaint[0];
				}
				else if (i == array.Length - 1)
				{
					array[i] = xPaint[xPaint.Length - 1];
					array2[i] = yPaint[yPaint.Length - 1];
				}
				else if (i % 2 != 0)
				{
					array[i] = (short)((xPaint[(i + 1) / 2] + xPaint[(i + 1) / 2 - 1]) / 2);
					array2[i] = (short)((yPaint[(i + 1) / 2] + yPaint[(i + 1) / 2 - 1]) / 2);
				}
				else
				{
					array[i] = xPaint[i / 2];
					array2[i] = yPaint[i / 2];
				}
			}
			xPaint = new short[array.Length];
			yPaint = new short[array2.Length];
			for (int j = 0; j < array.Length; j++)
			{
				xPaint[j] = array[j];
				yPaint[j] = array2[j];
			}
		}
		isLoki = false;
		isCaptain = false;
		if (PM.p[whoShot].isAvenger == 4 && !PM.p[whoShot].isLokiCopy)
		{
			isLoki = true;
			if (imgFireLoki == null)
			{
				imgFireLoki = CCanvas.loadImage("/eff/loki.png");
			}
			if (frLoki == null)
			{
				frLoki = new FrameImage(imgFireLoki, 32, 32);
			}
		}
		if (PM.p[whoShot].isAvenger == 5)
		{
			isCaptain = true;
			if (imgKhien == null)
			{
				imgKhien = CCanvas.loadImage("/item/khien.png");
			}
		}
		if (PM.p[whoShot].isAvenger != 8)
		{
			return;
		}
		if (PM.p[whoShot].isUsedItem)
		{
			if (PM.p[whoShot].is2TurnItem)
			{
				new Explosion(PM.p[whoShot].x + ((PM.p[whoShot].look != 0) ? (-15) : 15), PM.p[whoShot].y - 12, xPaint[xPaint.Length - 1], yPaint[yPaint.Length - 1], 16);
			}
		}
		else
		{
			new Explosion(PM.p[whoShot].x + ((PM.p[whoShot].look != 0) ? (-15) : 15), PM.p[whoShot].y - 12, xPaint[xPaint.Length - 1], yPaint[yPaint.Length - 1], 16);
		}
	}

	public void getCollisionPingPong(short[] X, short[] Y)
	{
		postion = new MyVector("postion");
		if (type == 48)
		{
			for (int i = 0; i < X.Length; i++)
			{
				postion.addElement(new Position(X[i], Y[i]));
			}
		}
		CRes.outz("POSTION LENGHT= " + postion.size());
	}

	public int[] getXYMirror(short[] X, short[] Y)
	{
		short num = min(Y);
		for (int i = 0; i < Y.Length; i++)
		{
			if (Y[i] == num)
			{
				return new int[2]
				{
					X[i],
					Y[i]
				};
			}
		}
		return null;
	}

	public void getPlayerEffect()
	{
		if (type == 31 || type == 32 || type == 35)
		{
			explode();
		}
		checkBackBody();
		if (GameScr.bm.critical == 1)
		{
			if (type != 11 && type != 18)
			{
				new Explosion(xPaint[0], yPaint[0], 0);
			}
		}
		else if (type != 42 && type != 47)
		{
			GameScr.sm.addSmoke(xPaint[0], yPaint[0], 0);
		}
		if (type == 45)
		{
			CCanvas.lockNotify = true;
			CCanvas.tNotify = 0;
		}
	}

	public void paintLazerGirl(mGraphics g)
	{
		CRes.outz("dx lazse = " + dXLaser + " dy lazer= " + dYLaser);
		int num = ((GameScr.bm.critical != 1) ? color : 718162);
		if (!isMirror)
		{
			xLaser1 += dXLaser;
			yLaser1 += dYLaser;
			GameScr.cam.setTargetPointMode(xPaint[0] + xLaser1, yPaint[0] + yLaser1);
			if (yPaint[0] + yLaser1 < yLG)
			{
				yLaser1 = yLG - yPaint[0];
				xLaser1 = xLG - xPaint[0];
				isMirror = true;
				Music.play(Music.LASER, 10f);
			}
		}
		else
		{
			xLaser2 += dXLaser;
			yLaser2 += dYLaser;
			GameScr.cam.setTargetPointMode(xLG + xLaser2, yLG - yLaser2);
			if (yLG - yLaser2 >= yPaint[yPaint.Length - 1])
			{
				x = xPaint[xPaint.Length - 1];
				y = yPaint[yPaint.Length - 1];
				explode();
			}
		}
		if (changePositon)
		{
			dis += 2;
		}
		else
		{
			dis -= 2;
		}
		dis_ChPosition = 2;
		x_3 = ((!isMirror) ? xPaint[0] : xLG) + ((!isMirror) ? xLaser1 : xLaser2) + (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 9);
		y_3 = ((!isMirror) ? yPaint[0] : yLG) + ((!isMirror) ? yLaser1 : (-yLaser2)) + -(CRes.sin(CRes.fixangle(BM.angle)) * dis >> 9);
		x_4 = ((!isMirror) ? xPaint[0] : xLG) + ((!isMirror) ? xLaser1 : xLaser2) - (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 9);
		y_4 = ((!isMirror) ? yPaint[0] : yLG) + ((!isMirror) ? yLaser1 : (-yLaser2)) - (CRes.sin(CRes.fixangle(BM.angle)) * dis >> 9);
		GameScr.sm.addSmoke(x_4, y_4, 7);
		if (!CScreen.highFrameRate())
		{
			count++;
			if (count == 2)
			{
				count = 0;
				changePositon = !changePositon;
			}
		}
	}

	public static short min(short[] array)
	{
		short num = array[0];
		for (int i = 1; i < array.Length; i++)
		{
			if (array[i] < num)
			{
				num = array[i];
			}
		}
		return num;
	}

	public void checkBackBody()
	{
		if (PM.getCurPlayer().gun == 13)
		{
			PM.getCurPlayer().xBugBack = -5;
			PM.getCurPlayer().yBugBack = 5;
			if (type == 36)
			{
				PM.getCurPlayer().frameleg_1 = 1;
				PM.getCurPlayer().xBug = xPaint[xPaint.Length - 1];
				notPaint = true;
			}
		}
	}

	public void checkFlyPlayer()
	{
		if (type == 36 && PM.getCurPlayer().isJump)
		{
			PM.getCurPlayer().x = x;
			PM.getCurPlayer().y = y;
		}
	}

	private void initBulletType(int type)
	{
		CRes.outz("type = " + type);
		int num = GameScr.bm.critical;
		load(type);
		switch (type)
		{
		case 32:
		case 41:
			img = stone;
			smoke = true;
			isLightBlink = true;
			break;
		case 0:
			if (num == 0)
			{
				longSmoke = true;
				isLightBlink = true;
			}
			if (num == 1)
			{
				fireSmoke = true;
			}
			if (PM.p[whoShot].isAvenger == 3)
			{
				rotateAround = true;
				longSmoke = false;
			}
			break;
		case 55:
			img = chatlong;
			changeFrame = true;
			nFrame = 4;
			break;
		case 54:
			rotate = true;
			break;
		case 51:
		case 53:
			longSmoke = true;
			break;
		case 48:
			if (frballoon == null)
			{
				frballoon = new FrameImage(balloonBull, 14, 14);
			}
			frmImg = frballoon;
			break;
		case 1:
			rotate = true;
			if (num == 0)
			{
				smoke = true;
			}
			if (num == 1)
			{
				fireSmoke = true;
			}
			break;
		case 44:
			if (frLazer == null)
			{
				frLazer = new FrameImage(lazer, 19, 19);
			}
			frmImg = frLazer;
			rotate = true;
			break;
		case 2:
			if (num == 0)
			{
				changeFrame = true;
			}
			if (num == 1)
			{
				changeFrame = true;
			}
			nFrame = 2;
			break;
		case 8:
		case 56:
			img = webImg;
			smoke = true;
			changeFrame = true;
			nFrame = 2;
			break;
		case 4:
		case 16:
			img = bomb_flag;
			smoke = true;
			changeFrame = true;
			nFrame = 2;
			break;
		case 5:
		case 36:
			img = bomb_flag;
			changeFrame = true;
			if (!PM.getCurPlayer().isJump)
			{
				smoke = true;
			}
			nFrame = 2;
			break;
		case 6:
		case 12:
			img = grenadeImg;
			rotateAround = true;
			break;
		case 7:
		case 31:
			img = grenadeImg;
			rotateAround = true;
			smoke = true;
			break;
		case 3:
			img = bomb;
			changeFrame = true;
			blackSmoke = true;
			nFrame = 2;
			break;
		case 43:
			img = bomb;
			changeFrame = true;
			blackSmoke = true;
			nFrame = 2;
			break;
		case 9:
			rotateAround = true;
			checkTranslate();
			if (num == 1)
			{
				fireSmoke = true;
			}
			if (PM.p[whoShot].isAvenger == 7)
			{
				rotate = true;
			}
			break;
		case 10:
			if (num == 0)
			{
				rotate = true;
			}
			if (num == 1)
			{
				rotate = true;
				fireSmoke = true;
			}
			break;
		case 11:
			if (num == 0)
			{
				blackSmoke = true;
				rotateAround = true;
			}
			if (num == 1)
			{
				rotateAround = true;
				fireSmoke = true;
			}
			break;
		case 14:
		case 40:
			lazerBullet = true;
			break;
		case 15:
			lazerShoot = true;
			lazerStop = false;
			break;
		case 13:
			tonardo = true;
			break;
		case 17:
		case 18:
			if (num == 0)
			{
				rotateAround = true;
			}
			if (num == 1)
			{
				fireSmoke = true;
				rotateAround = true;
			}
			translate = true;
			break;
		case 19:
			if (num == 0)
			{
			}
			if (num == 1)
			{
				longSmoke = true;
			}
			chickenBull = true;
			rotate = true;
			break;
		case 20:
			if (num == 0)
			{
				img = egg;
			}
			if (num == 1)
			{
				img = egg;
			}
			fireSmoke = true;
			changeFrame = true;
			nFrame = 2;
			break;
		case 21:
			if (num == 0)
			{
				rotateAround = true;
			}
			if (num == 1)
			{
				rotateAround = true;
				fireSmoke = true;
			}
			break;
		case 22:
			rotateByLand = true;
			img = mouse;
			changeFrame = true;
			nFrame = 2;
			translate = true;
			break;
		case 23:
			changeFrame = true;
			rotate = true;
			break;
		case 24:
			img = meteor;
			changeFrame = true;
			nFrame = 2;
			break;
		case 25:
			img = daodat;
			changeFrame = true;
			nFrame = 3;
			break;
		case 26:
		case 27:
		case 33:
			img = rocket2;
			rotate = true;
			smoke = true;
			break;
		case 28:
			img = rainmissile;
			changeFrame = true;
			nFrame = 2;
			break;
		case 29:
			img = rocket2;
			rotate = true;
			break;
		case 30:
			img = khoang;
			changeFrame = true;
			nFrame = 3;
			break;
		case 34:
			tonardo = true;
			break;
		case 37:
			img = muiten;
			changeFrame = true;
			nFrame = 2;
			break;
		case 47:
			if (frAxit == null)
			{
				frAxit = new FrameImage(axit, 15, 15);
			}
			frmImg = frAxit;
			rotate = true;
			break;
		case 52:
			img = daodat2;
			changeFrame = true;
			nFrame = 2;
			break;
		case 57:
			tonardo = true;
			break;
		case 49:
			if (!BackgroundNew.lowGraphic)
			{
				longSmoke = true;
			}
			break;
		case 58:
			longSmoke = true;
			break;
		case 59:
			img = water;
			changeFrame = true;
			nFrame = 2;
			break;
		case 60:
			img = imgTurtle;
			changeFrame = true;
			nFrame = 4;
			break;
		}
		if (frmImg != null)
		{
			_w = frmImg.frameWidth;
			_h = frmImg.frameHeight;
		}
		else if (img != null)
		{
			_w = img.getWidth();
			_h = img.getHeight();
		}
		else
		{
			_w = 2;
			_h = 2;
		}
		if (PM.p[whoShot].isAvenger == 8)
		{
			longSmoke = false;
		}
	}

	public int getColor(Image img)
	{
		try
		{
			int width = img.getWidth();
			int height = img.getHeight();
			int[] rgbData = new int[width * height];
			img.getRGB(ref rgbData, 0, width, 0, 0, width, height);
			return rgbData[5];
		}
		catch (Exception)
		{
			return 16722988;
		}
	}

	public static sbyte setBulletType(sbyte curGunType)
	{
		switch (curGunType)
		{
		case 0:
			return 0;
		case 1:
			return 1;
		case 2:
			return 2;
		case 3:
			return 9;
		case 4:
			return 10;
		case 5:
			return 11;
		case 6:
			return 19;
		case 7:
			return 21;
		case 8:
			return 17;
		case 14:
			return 33;
		case 10:
			return 48;
		case 9:
			return 49;
		default:
			return 0;
		}
	}

	public void checkTranslate()
	{
		if (x > PM.getCurPlayer().x)
		{
			trans = 0;
		}
		else
		{
			trans = 2;
		}
	}

	public void checkFrameDirect()
	{
		if (x > PM.getCurPlayer().x)
		{
			changeFrame = true;
		}
		else
		{
			changeFrameLeft = true;
		}
	}

	public void lazerBullUpdate(int type)
	{
		if (changePositon)
		{
			dis += dis_ChPosition;
		}
		else
		{
			dis -= dis_ChPosition;
		}
		dis_ChPosition = 2;
		x_1 = x + (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 10);
		y_1 = y + -(CRes.sin(CRes.fixangle(BM.angle)) * dis >> 10);
		x_2 = x - (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 10);
		y_2 = y - -(CRes.sin(CRes.fixangle(BM.angle)) * dis >> 10);
		GameScr.sm.addSmoke(x_1, y_1, (sbyte)((type != 0) ? 13 : 7));
		GameScr.sm.addSmoke(x_2, y_2, (sbyte)((type != 0) ? 13 : 7));
		if (type == 1)
		{
			x_3 = x + (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 9);
			y_3 = y + -(CRes.sin(CRes.fixangle(BM.angle)) * dis >> 9);
			x_4 = x - (CRes.cos(CRes.fixangle(BM.angle)) * dis >> 9);
			y_4 = y - -(CRes.sin(CRes.fixangle(BM.angle)) * dis >> 9);
			GameScr.sm.addSmoke(x_3, y_3, 7);
			GameScr.sm.addSmoke(x_4, y_4, 7);
		}
		if (!CScreen.highFrameRate())
		{
			count++;
			if (count == 3)
			{
				count = 0;
				changePositon = !changePositon;
			}
		}
	}

	public bool collisionTornado()
	{
		MyVector vTornado = BM.vTornado;
		if (vTornado.size() >= 0)
		{
			for (int i = 0; i < vTornado.size(); i++)
			{
				Tornado tornado = (Tornado)vTornado.elementAt(i);
				if (CRes.inRect(x, y, tornado.x, -100, 20, tornado.y + 100))
				{
					return true;
				}
			}
		}
		return false;
	}

	public void tornadoBullet()
	{
		GameScr.sm.addSmoke(x, y, 1);
	}

	public bool isSkyBullet()
	{
		if (type == 3 || type == 15)
		{
			return true;
		}
		return false;
	}

	public void getBullAngle()
	{
		if (paintCount < 0 || paintCount >= xPaint.Length - 3)
		{
			return;
		}
		int num = 3 * mGraphics.zoomLevel;
		lastAngle = currAngle;
		bool flag = true;
		if (xPaint[0] <= PM.p[whoShot].x)
		{
			if (nextX == 0 || x <= nextX + num / 2)
			{
				nextX = xPaint[paintCount + 2];
			}
			else
			{
				flag = false;
			}
		}
		else if (nextX == 0 || x >= nextX - num / 2)
		{
			nextX = xPaint[paintCount + 2];
		}
		else
		{
			flag = false;
		}
		if (!flag)
		{
			return;
		}
		nextY = yPaint[paintCount + 2];
		if (xPaint[1] < PM.p[whoShot].x)
		{
			currAngle = CRes.angle(x - nextX, y - nextY);
			if (nextY < y && currAngle > angleLimit)
			{
				currAngle = angleLimit;
			}
			else if (nextY > y && currAngle < 360 - angleLimit)
			{
				currAngle = 360 - angleLimit;
			}
			else if (currAngle == 270)
			{
				return;
			}
		}
		else if (xPaint[1] > PM.p[whoShot].x)
		{
			currAngle = CRes.angle(nextX - x, nextY - y);
			if (nextY > y && currAngle > angleLimit)
			{
				currAngle = angleLimit;
			}
			else if (nextY < y && currAngle < 360 - angleLimit)
			{
				currAngle = 360 - angleLimit;
			}
			else if (currAngle == 270)
			{
				return;
			}
		}
		CRes.outz("angle land= " + angleByLand);
		angleByLand = currAngle;
	}

	public void mouseUpdate()
	{
		if (isfall)
		{
			dym++;
			y += dym / 2;
		}
		if (collisionTornado())
		{
			y -= 4;
		}
		timecount++;
		if (timecount < 3 * force)
		{
			if (GameScr.mm.isLand(x, y - 5))
			{
				return;
			}
			x += mouseP;
			if (!GameScr.mm.isLand(x - 8, y + 4) && !GameScr.mm.isLand(x + 8, y + 4) && !GameScr.mm.isLand(x, y + 4))
			{
				if (!collisionTornado())
				{
					isfall = true;
				}
			}
			else
			{
				y--;
				dym = 0;
				isfall = false;
			}
		}
		else if (timecount == 3 * force)
		{
			explode();
		}
	}

	public void undergUpdate()
	{
		timecount++;
		if (GameScr.mm.isLand(x, y))
		{
			GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 2);
			GameScr.mm.makeHole(x, y, type);
		}
		if (x < 0 || x > MM.mapWidth || y > MM.mapHeight || y < 100)
		{
			explode();
		}
	}

	public void missileRainUpdate()
	{
		if (isActiveRain)
		{
			timecount++;
			if (timecount == 20)
			{
				timecount = 0;
				explode();
			}
		}
	}

	public void holeBulletUpdate()
	{
		if (!CScreen.highFrameRate())
		{
			y += 2;
			if (GameScr.mm.isLand(x, y))
			{
				GameScr.mm.makeHole(x, y - 5, type);
				addRock();
			}
			timecount++;
			if (timecount == force * 2)
			{
				explode();
			}
		}
	}

	public void nBullUpdate()
	{
		if (type == 26)
		{
			isActiveMissile = false;
			GameScr.bm.nBull = 1;
		}
		if (type == 17)
		{
			isActiveHammer = false;
			GameScr.bm.nBull = 1;
		}
	}

	public void update()
	{
		if (isLoki)
		{
			tLoki++;
			if (tLoki > 3)
			{
				tLoki = 0;
			}
		}
		if (PM.p[whoShot].isGetGun)
		{
			return;
		}
		int num = x;
		int num2 = y;
		x = xPaint[paintCount];
		y = yPaint[paintCount];
		if (PM.p[whoShot].isAvenger == 5)
		{
			khienAngle += 45;
			if (khienAngle > 360)
			{
				khienAngle = 0;
			}
			if (type == 21)
			{
				for (int i = 0; i < PM.p.Length; i++)
				{
					if (PM.p[i] != null && i != whoShot && !PM.p[i].isExplodeFlag && CRes.inRect(x, y, PM.p[i].x - 12, PM.p[i].y - 36, 24, 36))
					{
						PM.p[i].isExplodeFlag = true;
						new Explosion(x, y, 8);
					}
				}
			}
		}
		if (PM.p[whoShot].isAvenger == 2 && ((PM.getCurPlayer().isUsedItem && (PM.getCurPlayer().itemUsed == 100 || PM.getCurPlayer().itemUsed == 0 || PM.getCurPlayer().itemUsed == 33 || PM.getCurPlayer().itemUsed == 32 || PM.getCurPlayer().itemUsed == 10 || PM.getCurPlayer().itemUsed == 3)) || !PM.p[whoShot].isUsedItem))
		{
			PM.p[whoShot].x = x;
			PM.p[whoShot].y = y;
			PM.p[whoShot].nextx = x;
			PM.p[whoShot].nexty = y;
			if (paintCount < xPaint.Length - 1)
			{
				if (num < x)
				{
					PM.p[whoShot].look = 0;
				}
				else if (num > x)
				{
					PM.p[whoShot].look = 2;
				}
			}
			if (num2 <= y)
			{
				PM.p[whoShot].frame = 5;
			}
			else
			{
				PM.p[whoShot].frame = 4;
			}
		}
		if (type == 37 && num2 < y)
		{
			trans = 1;
		}
		if (type == 49)
		{
			if (dXLaser != 0 && dYLaser != 0)
			{
				if (paintCount == xPaint.Length - ((!CScreen.isUseHighFrameRate()) ? 2 : 4))
				{
					xLG = xPaint[paintCount];
					yLG = yPaint[paintCount];
					if (xLG < 0 || xLG > MM.mapWidth)
					{
						explode();
					}
					tL++;
					if (tL == ((!CScreen.isUseHighFrameRate()) ? 10 : 20))
					{
						tL = 0;
						isPaintLazer = true;
					}
					return;
				}
			}
			else if (paintCount == xPaint.Length - 1)
			{
				explode();
				return;
			}
		}
		if (!BackgroundNew.lowGraphic && longSmoke)
		{
			GameScr.sm.addSmoke(x + CRes.random(-3, 3), y + CRes.random(-3, 3), 19);
		}
		if (type == 36)
		{
			if (paintCount < 1)
			{
				paintCount = 1;
			}
			if (PM.getCurPlayer().isJump)
			{
				PM.getCurPlayer().x = xPaint[paintCount - 1];
				PM.getCurPlayer().y = yPaint[paintCount - 1];
			}
		}
		if (paintCount > xPaint.Length - 1)
		{
			paintCount = xPaint.Length - 1;
			if (type == 27)
			{
				new Explosion(x, y, 0);
			}
			nBullUpdate();
			x = xPaint[paintCount];
			y = yPaint[paintCount];
			if (type != 28)
			{
				explode();
			}
			if (type == 28)
			{
				isActiveRain = true;
				changeFrame = true;
			}
		}
		if (smoke)
		{
			createSmoke(0);
		}
		if (blackSmoke)
		{
			createSmoke(1);
		}
		if (fireSmoke)
		{
			int num3 = CRes.random(-7, 7);
			int num4 = CRes.random(-7, 7);
			GameScr.sm.addSmoke(x + num3, y + num4, 21);
		}
		if (x == CPlayer.xSuper && y == CPlayer.ySuper)
		{
			new Explosion(x, y, 0);
			isSuper = true;
		}
		if (type == 48 && pingFrame < postion.size())
		{
			Position position = (Position)postion.elementAt(pingFrame);
			int num5 = position.x;
			int num6 = position.y;
			int num7 = Smoke.checkWay(num, num2, x, y);
			int num8 = ((num7 != 0 && num7 != 1) ? 1 : 3);
			if (x == num5 && y == num6)
			{
				getPingPongFrame(0, num8);
				pingFrame++;
				pingColor += 4;
			}
		}
		if (pingChange)
		{
			curFrame = mainFrame + pos + pingColor;
			t++;
			if (t == 3)
			{
				t = 0;
				pingChange = false;
				curFrame = pingColor;
			}
			CRes.outz("CURR FRAME= " + curFrame);
		}
		if (longSmoke && (Math.abs(x - num) >= 10 || Math.abs(y - num2) >= 10))
		{
			GameScr.sm.addSmoke((x + num) / 2 + CRes.random(-3, 3), (y + num2) / 2 + CRes.random(-3, 3), 19);
		}
		if (chickenHair && CCanvas.gameTick % 10 == 0)
		{
			GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 8);
		}
		if (fireSmoke)
		{
			int num9 = CRes.random(-7, 7);
			int num10 = CRes.random(-7, 7);
			if (Math.abs(x - num) >= 10 || Math.abs(y - num2) >= 10)
			{
				GameScr.sm.addSmoke((x + num) / 2 + num9, (y + num2) / 2 + num10, 21);
			}
		}
		if (isDoubleBull(type) && !CScreen.highFrameRate())
		{
			timecount++;
			CRes.outz("TIME COUNT= " + timecount + " FORCE2= " + BM.force2);
			if (BM.nOrbit > 1)
			{
				if (timecount == BM.force2 && type == 17)
				{
					isActiveHammer = true;
					GameScr.bm.nBull += 3;
					explode();
				}
				if (timecount == BM.force2 && type == 19)
				{
					isActiveEgg = true;
					GameScr.bm.activeEgg(x, y);
				}
			}
		}
		if (lazerBullet)
		{
			if (type == 14)
			{
				lazerBullUpdate(0);
			}
			if (type == 40)
			{
				lazerBullUpdate(1);
			}
		}
		if (type == 25)
		{
			undergUpdate();
		}
		if (type == 52 && GameScr.mm.isLand(x, y))
		{
			GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 2);
			GameScr.mm.makeHole(x, y, type);
		}
		if (type == 28)
		{
			missileRainUpdate();
		}
		if (type == 30)
		{
			holeBulletUpdate();
		}
		if (tonardo)
		{
			tornadoBullet();
		}
		if (rotateByLand)
		{
			getBullAngle();
		}
		if (rotate)
		{
			lastAngle = de;
			curFrame = (angle << 1) / 45;
			de = mGraphics.angle(x, num, y, num2);
			if (type == 44 && curFrame > 7)
			{
				curFrame = 15 - curFrame;
			}
		}
		else if (rotateAround)
		{
			if (PM.p[whoShot].look == 0)
			{
				de += 18;
				if (de > 360)
				{
					de = 0;
				}
			}
			else
			{
				de -= 18;
				if (de < -360)
				{
					de = 0;
				}
			}
		}
		if (translate)
		{
			checkTranslate();
		}
		if (changeFrame)
		{
			if (type == 59)
			{
				curFrame = ((CCanvas.gameTick % 4 <= 1) ? 1 : 0);
			}
			else if (type == 60)
			{
				curFrame++;
				if (curFrame > 3)
				{
					curFrame = 0;
				}
			}
			else
			{
				curFrame = GameScr.tickCount / ((!CScreen.isUseHighFrameRate()) ? 2 : 4) % 2;
				if (curFrame == nFrame)
				{
					curFrame = 0;
				}
			}
		}
		else if (changeFrameLeft)
		{
			changeFramez(true);
		}
		if (type == 4 && !BackgroundNew.lowGraphic)
		{
			GameScr.isDarkEffect = true;
		}
		if (type == 23 || type == 54)
		{
			GameScr.sm.addSmoke(x - CRes.random(5), y - CRes.random(5), 11);
			GameScr.sm.addSmoke(x + CRes.random(5), y + CRes.random(5), 11);
			GameScr.sm.addSmoke(x + CRes.random(5), y - CRes.random(5), 11);
		}
		if (type == 15)
		{
			if (!lazerStop)
			{
				explDelay++;
				if (explDelay == 26)
				{
					GameScr.bm.removeBullet(this, true, x, y, x_Last, y_Last, whoShot);
					return;
				}
				if (explDelay == 5 || explDelay == 8)
				{
					lazerShoot = true;
				}
			}
			if (lazerShoot)
			{
				lazerShoot = false;
				explode();
			}
		}
		if (MM.isHaveWaterOrGlass && !isWaterBum)
		{
			sbyte bumType = 0;
			if (type == 0)
			{
				bumType = 1;
			}
			if (MM.checkWaterBum(x, y, bumType))
			{
				isWaterBum = true;
			}
		}
		int num11 = ((type == 19) ? 500 : 100);
		if (x < -num11 || x > MM.mapWidth + num11 || y > MM.mapHeight + 100)
		{
			if (GameScr.isDarkEffect)
			{
				GameScr.isDarkEffect = false;
			}
			x_Last = x;
			y_Last = y;
			nBullUpdate();
			GameScr.bm.removeBullet(this, false, x, y, x_Last, y_Last, whoShot);
			return;
		}
		if (paintCount < xPaint.Length - 1)
		{
			paintCount++;
			return;
		}
		if (type == 26)
		{
			if (BM.nOrbit != 1)
			{
				CRes.outz("isActive Missile = true");
				isActiveMissile = true;
				GameScr.bm.nBull = 4;
			}
			else
			{
				GameScr.bm.nBull = 1;
			}
		}
		explode();
	}

	public void getPingPongFrame(int mainFrame, int pos)
	{
		this.mainFrame = mainFrame;
		this.pos = pos;
		pingChange = true;
	}

	public void addRock()
	{
		if (!BackgroundNew.lowGraphic)
		{
			if (type == 1 || type == 9)
			{
				GameScr.sm.addRock(x, y, CRes.random(-5, -2), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(-4, -1), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(-5, -2), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(-4, -1), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(2, 5), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 4), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(2, 5), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 4), CRes.random(-15, -10), 3);
			}
			else if (type == 2)
			{
				GameScr.sm.addRock(x, y, CRes.random(-15, -10), CRes.random(-10, -8), 3);
				GameScr.sm.addRock(x, y, CRes.random(-12, -8), CRes.random(-10, -8), 2);
				GameScr.sm.addRock(x, y, CRes.random(-15, -10), CRes.random(-10, -8), 3);
				GameScr.sm.addRock(x, y, CRes.random(4, 6), CRes.random(-10, -8), 2);
				GameScr.sm.addRock(x, y, CRes.random(8, 12), CRes.random(-10, -8), 2);
				GameScr.sm.addRock(x, y, CRes.random(5, 8), CRes.random(-10, -8), 3);
				GameScr.sm.addRock(x, y, CRes.random(-10, -5), CRes.random(-10, -8), 3);
				GameScr.sm.addRock(x, y, CRes.random(-6, -4), CRes.random(-10, -8), 2);
			}
			else if (type == 10 || type == 11)
			{
				GameScr.sm.addRock(x, y, CRes.random(-3, -1), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(-2, -1), CRes.random(-20, -15), 3);
				GameScr.sm.addRock(x, y, CRes.random(1, 3), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 2), CRes.random(-20, -15), 3);
				GameScr.sm.addRock(x, y, CRes.random(1, 3), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 2), CRes.random(-20, -15), 3);
			}
			else
			{
				GameScr.sm.addRock(x, y, CRes.random(-10, -4), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(-5, -2), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(-4, -1), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(-10, -4), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(-5, -2), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(-4, -1), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(4, 10), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(2, 5), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 4), CRes.random(-15, -10), 3);
				GameScr.sm.addRock(x, y, CRes.random(4, 10), CRes.random(-20, -15), 2);
				GameScr.sm.addRock(x, y, CRes.random(2, 5), CRes.random(-15, -10), 2);
				GameScr.sm.addRock(x, y, CRes.random(1, 4), CRes.random(-15, -10), 3);
			}
		}
	}

	public void explode()
	{
		if (type == 21 && PM.p[whoShot].isAvenger == 5)
		{
			PM.p[whoShot].setCaptainReturn(x, y);
		}
		if (PM.p[whoShot].isAvenger == 2 && !PM.p[whoShot].isUsedItem)
		{
			PM.p[whoShot].x = x;
			PM.p[whoShot].y = y;
			PM.p[whoShot].frame = 0;
		}
		for (int i = 0; i < PM.p.Length; i++)
		{
			if (PM.p[i] != null && i != whoShot && PM.p[i].isExplodeFlag)
			{
				PM.p[i].isExplodeFlag = false;
			}
		}
		if (PM.p[whoShot].isAvenger == 3)
		{
			if (PM.p[whoShot].isUsedItem)
			{
				if (PM.p[whoShot].is2TurnItem)
				{
					new Explosion(xPaint[xPaint.Length - 1], Camera.y, xPaint[xPaint.Length - 1], yPaint[yPaint.Length - 1], 17);
				}
			}
			else
			{
				new Explosion(xPaint[xPaint.Length - 1], Camera.y, xPaint[xPaint.Length - 1], yPaint[yPaint.Length - 1], 17);
			}
		}
		Camera.shaking = 2;
		bool flag = true;
		if (type != 6 && type != 5 && type != 22 && type != 30)
		{
			for (int j = 0; j < PM.p.Length; j++)
			{
				if (PM.p[j] == null)
				{
					continue;
				}
				px = PM.p[j].x - CPlayer.pW / 2;
				py = PM.p[j].y - CPlayer.pH;
				if (PM.p[j].GetType() == typeof(BigBoss))
				{
					if (CRes.inRect(x, y, px - 15, py - 15, CPlayer.pW + 30, CPlayer.pH + 30))
					{
						flag = false;
						PM.p[j].activeHurt((PM.p[j].look == 2) ? 2 : 0);
						break;
					}
				}
				else if (CRes.inRect(x, y, px - 5, py - 5, CPlayer.pW + 10, CPlayer.pH + 10))
				{
					flag = false;
					PM.p[j].activeHurt((PM.p[j].look == 2) ? 2 : 0);
					break;
				}
			}
		}
		if (type == 34)
		{
			new Explosion(x, y, 1);
		}
		else if (type == 4)
		{
			GameScr.bm.activeAirplane(x, y);
		}
		else if (type == 14)
		{
			GameScr.bm.activeLazer(x, y);
		}
		else if (type == 13)
		{
			GameScr.bm.activeTornado(x, y);
		}
		else if (type == 23)
		{
			GameScr.bm.activeMeteor(x, y, angle);
		}
		else if (type == 16)
		{
			new Explosion(x, y, 0);
			GameScr.bm.activeMortarBum(x, y);
		}
		else if (type == 17)
		{
			if (isActiveHammer)
			{
				GameScr.bm.activeExplore(xD, yD, x, y, vx, vy, (byte)force, angle);
			}
			new Explosion(x, y, 0);
			GameScr.mm.makeHole(x, y, type);
		}
		else if (type == 26)
		{
			CRes.outz("VY= " + vy);
			if (isActiveMissile)
			{
				GameScr.bm.active4Missle(xS, yS, xD, yD);
			}
			new Explosion(x, y, 0);
			GameScr.mm.makeHole(x, y, type);
		}
		else if (type == 28)
		{
			GameScr.bm.activeMissleRain(x, y);
			new Explosion(x, y, 0);
		}
		else if (type == 30)
		{
			new Explosion(x, y, 1);
		}
		else if (type == 5 || type == 36)
		{
			GameScr.pm.updatePlayerXY(whoShot, (short)x, (short)y);
			PM.p[whoShot].falling = true;
			PM.p[whoShot].active = false;
			if (!PM.getCurPlayer().isJump)
			{
				new Explosion(x, y, 1);
			}
		}
		else if (type == 8 || type == 56)
		{
			CMap cMap = new CMap(webId++, x - 21, y - 20, CMap.MANGNHEN, true);
			cMap.index = MM.maps.size();
			GameScr.mm.addMap(cMap);
			new Explosion(x, y, 1);
		}
		else if (type == 61)
		{
			CMap cMap2 = new CMap(webId++, x - 15, y - 37, CMap.BULLRUA, true);
			cMap2.index = MM.maps.size();
			GameScr.mm.addMap(cMap2);
			new Explosion(x, y, 1);
		}
		else if (type == 57)
		{
			new Explosion(x, y, 1);
		}
		else if (type != 53)
		{
			if (type == 47)
			{
				new Explosion(x, y, 10);
				GameScr.mm.makeHole(x, y, type);
			}
			else
			{
				CRes.outz("x Last= " + x + " y Last= " + y);
				if (type == 1 && PM.p[whoShot].isAvenger == 1)
				{
					GameScr.mm.makeHole(x, y, 47);
				}
				else if (type == 0 && PM.p[whoShot].isAvenger == 2)
				{
					GameScr.mm.makeHole(x, y, 6);
				}
				else
				{
					GameScr.mm.makeHole(x, y, type);
				}
				int num = 3;
				if (type == 0 || type == 7 || type == 3 || type == 31 || type == 32)
				{
					if (type == 31 || type == 32)
					{
						PM.getCurPlayer().isPaint = false;
					}
					num = 2;
				}
				if (type == 31)
				{
					new Explosion(x - 30, y + 5, 0);
					new Explosion(x, y, 0);
					new Explosion(x + 30, y + 5, 0);
					GameScr.sm.addSmoke(x - 30, y + 5, 4);
					GameScr.sm.addSmoke(x, y, 4);
					GameScr.sm.addSmoke(x + 30, y + 5, 4);
					GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 3);
					GameScr.sm.addRock(x, y, CRes.random(3 + force / 3), CRes.random(-8 - force / 3, -4 - force / 3), 3);
					GameScr.sm.addRock(x, y, CRes.random(2 + force / 3), CRes.random(-8 - force / 3, -4 - force / 3), 3);
				}
				sbyte b = 2;
				if (type == 19)
				{
					b = 8;
				}
				if (flag)
				{
					addRock();
				}
				if (type == 3)
				{
					new Explosion(x - 30, y + 5, 0);
					new Explosion(x, y, 0);
					new Explosion(x + 30, y + 5, 0);
					GameScr.sm.addSmoke(x - 30, y + 5, 4);
					GameScr.sm.addSmoke(x, y, 4);
					GameScr.sm.addSmoke(x + 30, y + 5, 4);
				}
				else if (type == 15)
				{
					new Explosion(x, y + 20, 0);
					GameScr.sm.addSmoke(x, y, 4);
				}
				else if (type != 13)
				{
					if (type == 19)
					{
						GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 10);
					}
					else if (type == 22)
					{
						new Explosion(x - 30, y + 5, 0);
						new Explosion(x, y, 0);
						new Explosion(x + 30, y + 5, 0);
						GameScr.sm.addRock(x, y, CRes.random(4 + force / 3), CRes.random(-8 - force / 3, -5 - force / 3), 9);
					}
					else if (type == 35)
					{
						new Explosion(x - 15, y + 15, 0);
						new Explosion(x + 15, y + 15, 0);
					}
					else if (type == 37)
					{
						GameScr.electricEffect = true;
						GameScr.xElectric = x;
						GameScr.yElectric = y;
					}
					else if (type == 40)
					{
						GameScr.electricEffect = true;
						GameScr.xElectric = x;
						GameScr.yElectric = y;
					}
					else if (type == 54)
					{
						GameScr.freezeEffect = true;
						GameScr.xFreeze = x;
						GameScr.yFreeze = y;
					}
					else if (type == 50)
					{
						GameScr.suicideEffect = true;
						GameScr.xSuicide = x;
						GameScr.ySuicide = y;
						Camera.shaking = 2;
					}
					else if (type == 55)
					{
						GameScr.poisonEffect = true;
						GameScr.xPoison = x;
						GameScr.yPoison = y;
					}
					else if (type == 55)
					{
						new Explosion(x, y, 15);
					}
					else if (type == 54)
					{
						new Explosion(x, y, 14);
					}
					else if (type == 42)
					{
						for (int k = 0; k < PM.p.Length; k++)
						{
							CPlayer cPlayer = PM.p[k];
							if (cPlayer != null && cPlayer.gun == 16 && cPlayer.state != 5)
							{
								BM.lazerPosition.addElement(new Position(cPlayer.x, cPlayer.y, x, y));
							}
						}
						BM.activeUFOLazer = true;
					}
					else if (type == 45)
					{
						GameScr.sm.addLazer(PM.p[whoShot].x, PM.p[whoShot].y, x, y, 0);
						GameScr.electricEffect = true;
						GameScr.xElectric = x;
						GameScr.yElectric = y;
					}
					else if (type == 43)
					{
						new Explosion(x, y, 7);
					}
					else if (type == 44)
					{
						new Explosion(x, y, 9);
					}
					else if (type == 48)
					{
						new Explosion(x, y, 7);
					}
					else if (type == 51)
					{
						new Explosion(x, y, 12);
					}
					else if (type != 53)
					{
						if (type == 60)
						{
							if (PM.p[whoShot] != null)
							{
								short[] array = new short[1] { (short)x };
								short[] array2 = new short[1] { (short)y };
								GameScr.bm.bullets.addElement(new Bullet(55, array, array2, whoShot));
							}
						}
						else if (GameScr.bm.critical == 0)
						{
							if (type == 49)
							{
								new Explosion(x, y, 9);
							}
							else
							{
								new Explosion(x, y, 0);
							}
						}
						else
						{
							if (type == 0)
							{
								new Explosion(x, y, 0);
								new Explosion(x - 35, y, 0);
								new Explosion(x + 35, y, 0);
							}
							else if (type == 10)
							{
								new Explosion(x, y, 7);
							}
							else if (type == 49)
							{
								for (int l = 0; l < 3; l++)
								{
									BM.lazerPosition.addElement(new Position(CRes.random(Camera.x, CCanvas.w + Camera.x), 0, x, y));
								}
								BM.activeUFOLazer = true;
								new Explosion(x, y, 0);
							}
							else if (type == 20 || type == 9)
							{
								new Explosion(x, y, 7);
							}
							else
							{
								new Explosion(x, y, 0);
								GameScr.sm.addSmoke(x, y, 4);
							}
							Camera.shaking = 2;
						}
					}
				}
				if (BM.isActiveTornado)
				{
					CRes.outz("voi rong ");
					MyVector vTornado = BM.vTornado;
					for (int m = 0; m < vTornado.size(); m++)
					{
						Tornado tornado = (Tornado)vTornado.elementAt(m);
						if (x >= tornado.x + 10 || x > tornado.x - 10)
						{
						}
					}
				}
			}
		}
		if (type != 15)
		{
			Music.play(Music.EXPLOSION, 10f);
			GameScr.bm.removeBullet(this, true, x, y, x_Last, y_Last, whoShot);
		}
		if (CPlayer.isGetPosition)
		{
			PM.getXYResult();
			CPlayer.isGetPosition = false;
		}
	}

	public static bool isFlagBull(int type)
	{
		if (type == 4 || type == 14 || type == 16 || type == 23 || type == 28)
		{
			return true;
		}
		return false;
	}

	public static bool isDoubleBull(int type)
	{
		if (type == 17 || type == 19)
		{
			return true;
		}
		return false;
	}

	public void changeFramez(bool isLeftDirect)
	{
		if (!isLeftDirect)
		{
			if (type == 3)
			{
				curFrame = GameScr.tickCount / ((!CScreen.isUseHighFrameRate()) ? 2 : 4) % 2;
			}
			else if (type == 4)
			{
				curFrame = GameScr.tickCount / ((!CScreen.isUseHighFrameRate()) ? 2 : 4) % 2;
			}
			else if (type == 20)
			{
				curFrame = GameScr.tickCount / ((!CScreen.isUseHighFrameRate()) ? 2 : 4) % 2;
			}
			else if (type == 55)
			{
				if (CCanvas.gameTick % 2 == 0)
				{
					curFrame++;
				}
			}
			else if (!CScreen.highFrameRate())
			{
				curFrame++;
			}
			if (curFrame == frmImg.nFrame)
			{
				curFrame = 0;
			}
		}
		else if (curFrame < 0)
		{
			curFrame = frmImg.nFrame - 1;
		}
		else if (type == 4)
		{
			curFrame = GameScr.tickCount / ((!CScreen.isUseHighFrameRate()) ? 2 : 4) % 2;
		}
		else if (!CScreen.highFrameRate())
		{
			curFrame--;
		}
	}

	public void createSmoke(sbyte TYPE)
	{
		smokeDelay++;
		if (smokeDelay > 3)
		{
			GameScr.sm.addSmoke(x, y, TYPE);
			smokeDelay = 0;
		}
	}

	public void paintLazer(mGraphics g)
	{
		int num = 20;
		int num2 = -500;
		int num3 = x - 10;
		if (explDelay < 15)
		{
			g.setColor(16771821);
			g.fillRect(num3, num2, 20, y + num - num2, false);
			g.setColor(16756407);
			g.fillRect(num3 + 2, num2, 16, y + num - num2, false);
			g.setColor(16737907);
			g.fillRect(num3 + 5, num2, 10, y + num - num2, false);
			g.setColor(15745615);
			g.fillRect(num3 + 8, num2, 4, y + num - num2, false);
		}
		if (explDelay >= 15 && explDelay < 17)
		{
			g.setColor(16771821);
			g.fillRect(num3 + 3, num2, 14, y + num - num2, false);
			g.setColor(16737907);
			g.fillRect(num3 + 5, num2, 10, y + num - num2, false);
			g.setColor(15745615);
			g.fillRect(num3 + 8, num2, 4, y + num - num2, false);
		}
		if (explDelay >= 17 && explDelay < 20)
		{
			g.setColor(16771821);
			g.fillRect(num3 + 6, num2, 8, y + num - num2, false);
			g.setColor(15745615);
			g.fillRect(num3 + 8, num2, 4, y + num - num2, false);
		}
		if (explDelay >= 20 && explDelay < 23)
		{
			g.setColor(16771821);
			g.fillRect(num3 + 8, num2, 4, y + num - num2, false);
		}
	}

	public bool isWeaponBull()
	{
		return type == 0 || type == 11 || type == 1 || type == 2 || type == 10 || type == 9 || type == 19 || type == 17 || type == 21 || type == 49 || type == 18;
	}

	private void paintKhien(mGraphics g)
	{
		if (mSystem.isSmartPhone)
		{
			mGraphics.rotateImage(imgKhien, khienAngle, g, x, y, true);
		}
		else
		{
			g.drawImage(imgKhien, x, y, 3, false);
		}
	}

	public void paint(mGraphics g)
	{
		if (PM.p[whoShot].isGetGun || (PM.p[whoShot].isAvenger == 2 && ((PM.getCurPlayer().isUsedItem && (PM.getCurPlayer().itemUsed == 100 || PM.getCurPlayer().itemUsed == 0 || PM.getCurPlayer().itemUsed == 33 || PM.getCurPlayer().itemUsed == 32 || PM.getCurPlayer().itemUsed == 10 || PM.getCurPlayer().itemUsed == 3)) || !PM.p[whoShot].isUsedItem)) || notPaint || type == 31)
		{
			return;
		}
		if (isSuper)
		{
			sFrame++;
			if (sFrame == 5)
			{
				sFrame = 0;
			}
			g.drawRegion(superShoot, 0, 32 * sFrame, 32, 32, 0, x, y, 3, false);
		}
		Image image = null;
		if (PM.p[whoShot].isAvenger == 0 || PM.p[whoShot].isAvenger == 9)
		{
			image = ((!isWeaponBull()) ? img : ((BulletForGun.getBull(PM.p[whoShot].wp) == null) ? null : BulletForGun.getBull(PM.p[whoShot].wp).bullImage));
		}
		else
		{
			if (isCaptain)
			{
				if (!PM.p[whoShot].isUsedItem)
				{
					paintKhien(g);
					return;
				}
				if (PM.p[whoShot].is2TurnItem)
				{
					paintKhien(g);
					return;
				}
			}
			if (PM.p[whoShot].isAvenger == 4 && !PM.p[whoShot].isLokiCopy)
			{
				if (!PM.p[whoShot].isUsedItem)
				{
					frLoki.drawFrame(tLoki, x, y, 0, 3, g, false);
					return;
				}
				if (PM.p[whoShot].is2TurnItem)
				{
					frLoki.drawFrame(tLoki, x, y, 0, 3, g, false);
					return;
				}
			}
			image = ((!isWeaponBull()) ? img : ((BulletForGun.getBull(PM.p[whoShot].wp) == null) ? null : BulletForGun.getBull(PM.p[whoShot].wp).bullImage));
		}
		if (image != null)
		{
			if (!changeFrame)
			{
				if (!rotate && !rotateAround)
				{
					g.drawImage(image, x, y, 3, false);
				}
				else
				{
					mGraphics.rotateImage(image, de, g, x, y, true);
				}
			}
			else
			{
				g.drawRegion(image, 0, curFrame * mGraphics.getImageHeight(image) / nFrame, mGraphics.getImageWidth(image), mGraphics.getImageHeight(image) / nFrame, trans, x, y, 3, false);
			}
		}
		if (!lazerStop)
		{
			paintLazer(g);
		}
		if (type == 49 && isPaintLazer)
		{
			paintLazerGirl(g);
		}
	}

	public static int[] getCollisionPoint(int x1, int y1, int x2, int y2)
	{
		int num = x2 - x1;
		int num2 = y2 - y1;
		int num4;
		int num5;
		int num6;
		int num3 = (num4 = (num5 = (num6 = 0)));
		if (num < 0)
		{
			num3 = (num5 = -1);
		}
		else if (num > 0)
		{
			num3 = (num5 = 1);
		}
		if (num2 < 0)
		{
			num4 = -1;
		}
		else if (num2 > 0)
		{
			num4 = 1;
		}
		int num7 = Math.abs(num);
		int num8 = Math.abs(num2);
		if (num7 <= num8)
		{
			num7 = Math.abs(num2);
			num8 = Math.abs(num);
			if (num2 < 0)
			{
				num6 = -1;
			}
			else if (num2 > 0)
			{
				num6 = 1;
			}
			num5 = 0;
		}
		int num9 = num7 >> 1;
		for (int i = 0; i <= num7; i++)
		{
			if (GameScr.mm.isLand(x1, y1))
			{
				return new int[2] { x1, y1 };
			}
			num9 += num8;
			if (num9 >= num7)
			{
				num9 -= num7;
				x1 += num3;
				y1 += num4;
			}
			else
			{
				x1 += num5;
				y1 += num6;
			}
		}
		return null;
	}
}
