www.pudn.com > MobiCraft_src.rar > Unit.java


// style: tabs, tabsize=4, style=ANSI 
//+----------------------------------------------------------------------+ 
// Copyright (c) 2006 Company Name 
// Made by Andrew and Zahar 
//+----------------------------------------------------------------------+ 
// Filename: Unit.java 
//+----------------------------------------------------------------------+ 
// Comment: Unit. Has animation, properties 
//+----------------------------------------------------------------------+ 
 
//20061203 Black TODO Добавить в класс массивы воздействий  
package battle; 
 
import java.io.*; 
import java.util.Vector; 
import javax.microedition.lcdui.*; 
import javax.microedition.lcdui.game.*; 
 
public class Unit 
{ 
	// Возможные воздействия на юнит 
	public final static int UNIT_CONDITION_LOCKDOWN=	0; 
	public final static int UNIT_CONDITION_BURROWED=	1; 
	public final static int UNIT_CONDITION_MATRIX=		2; 
	public final static int UNIT_CONDITION_INVISIBLE=	3; 
	public final static int UNIT_CONDITION_IRRADIATE=	4; 
	public final static int UNIT_CONDITION_PLAGUE=		5; 
	public final static int UNIT_CONDITION_SIEGE=		6; 
	public final static int UNIT_CONDITION_ENSNARE=		7; 
	public final static int UNIT_CONDITION_TOTAL_NUMBER=8; // увеличивать при добавлении. Это размер массивов. 
 
	public int [] pConditions;	// Состояния юнита, по раному для разных типов воздействия. Для локдауна 1 - есть (можно полечить), 0 - нету	 
    // Тип юнита: номера не менять! Это индексы массивов. 
    public final static int UNIT_NONE=			-1; 
    public final static int UNIT_P_OBSERVER=    0; 
    public final static int UNIT_P_ZEALOT=      1; 
    public final static int UNIT_P_DARK=        2; 
    public final static int UNIT_P_TEMPLAR=     3; 
    public final static int UNIT_P_DRAGOON=     4; 
	public final static int UNIT_P_ARCHONT=     22; 
	public final static int UNIT_P_REAVER=		23; 
	public final static int UNIT_P_DARKARCHONT=	24; 
	public final static int UNIT_P_PROBE=		25; 
	public final static int UNIT_T_VESSEL=		5; 
	public final static int UNIT_T_MARINE=		6; 
	public final static int UNIT_T_MEDIC=		7; 
	public final static int UNIT_T_TANK=		8; 
	public final static int UNIT_T_VULTURE=		9; 
	public final static int UNIT_T_SCV=			10; 
	public final static int UNIT_T_GHOST=		11; 
	public final static int UNIT_T_FIREBAT=		12; 
	public final static int UNIT_T_GOLIATH=		13; 
	public final static int UNIT_Z_ZERGLING=	14; 
	public final static int UNIT_Z_ULTRAL=		15; 
	public final static int UNIT_Z_HYDRA=		16; 
	public final static int UNIT_Z_LURKER=		17; 
	public final static int UNIT_Z_DEFILER=		18; 
	public final static int UNIT_Z_QUEEN=		19; 
	public final static int UNIT_Z_OVERLORD=	20; 
	public final static int UNIT_Z_DRONE=		21; 
    public final static int UNIT_TOTAL_NUMBER=  26; // увеличивать при добавлении. Это размер массивов. 
     
    // Рассы, показывает как регенть хиты и т.п. 
    public final static int RACE_ZERG=		1; 
    public final static int RACE_TOSS=		2; 
    public final static int RACE_TERR=		3; 
 
    // Размеры, для подсчета наносимого урона (например гун по марину бъет 10, по танку 20) 
    public final static int SIZE_SMALL=		1; 
    public final static int SIZE_MEDIUM=	2; 
    public final static int SIZE_LARGE=		3; 
     
    public int mType; 
    public int bAir;    //20061203 Black Является ли юнит летающим? 
	public int bMechanic;	//20061215 Black Является ли юнит техникой (локдаун кидать можно?) 
	public int bOrganic;	//20061215 Black Является ли юнит органикой (можно ли лечить)	 
    // Индекс (handle) для управления UnitAnimator 
    public int iAnimationState; 
    UnitAnimator mUnitAnimator; // Сюда передадут ссылку на аниматор 
     
    // Для рисования полосок - ширина, высота 
    public final static int HEALTH_LINE_WIDTH=  25; 
    public final static int HEALTH_LINE_HEIGHT=  2; 
     
    // Если bLeft, то юнит должен смотреть в лево. ( не путать с Force.bLeft ) 
    public boolean bLeft; 
 
    // Действия 
    public UnitAction[] pActions; 
 
    // Unit characteristics 
    // [Cur]rent and [Max]imum 
    public String mName; 
    public int mRace; 
    public int mCurHealth;  // Хиты 
    public int mMaxHealth; 
    public int mCurShield;  // Шиты 
    public int mMaxShield;  // 0 значит щит не рисовать. mCurShield игнорируется 
    public int mCurEnergy;  // Мана 
    public int mMaxEnergy;  // 0 значит ману не рисовать. mCurEnergy игнорируется 
    public int mSize; // small, medium, large 
    public int mArmor; 
     
    public int mStartTime;	// Время первого действия 
    public int mNextActionTime; // Время следующего действия 
         
    public Unit() 
    { 
		// 20061118_Zahar Такое лучше делать в конструкторе перенес из Init(). 
		pActions = new UnitAction[6]; 
		pConditions = new int[UNIT_CONDITION_TOTAL_NUMBER];	//20061215 Black 
		bLeft = true; 
    } 
 
    public void InitAnimationState( int itype, UnitAnimator _mUnitAnimator ) throws IOException 
	{ 
		mUnitAnimator = _mUnitAnimator; 
		//if (mType > UNIT_NONE) // UNIT_NONE == -1 
		if (itype > UNIT_NONE) // UNIT_NONE == -1 
			iAnimationState = mUnitAnimator.AddUnit(itype); 
		// Добавление в Аниматор эффектов, сопутствующих юниту 
		switch (itype) 
		{ 
			case Unit.UNIT_P_DRAGOON: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_BULLET_DRAGOON); 
				break; 
			case Unit.UNIT_T_GHOST: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_LOCKDOWN); 
				break; 
			case Unit.UNIT_P_TEMPLAR: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_STORM); 
				break;				 
			case Unit.UNIT_T_VESSEL: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_MATRIX); 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_EMP); 
				break;								 
			case Unit.UNIT_T_VULTURE: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_BULLET_VULTURE); 
				break;	 
			case Unit.UNIT_Z_DEFILER: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_PLAGUE); 
				break; 
			case Unit.UNIT_P_REAVER: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_BULLET_REAVER); 
				break; 
			case Unit.UNIT_P_ARCHONT: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_ARCHONTHIT); 
				break;				 
			case Unit.UNIT_Z_LURKER: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_LURKERHIT_ONE); 
				break; 
			case Unit.UNIT_Z_QUEEN: 
				mUnitAnimator.LoadEffect(UnitAnimator.EFFECT_ENSNARE); 
				break;								 
			default: 
				break; 
		} 
		SetState(UnitAnimator.ANIM_IDLE); 
	} 
 
	public void InitDefaultParams( int itype, boolean bleft) 
	{ 
		bLeft = bleft; 
		mType = itype; 
		// Set hitpoints and shields, shields are only for RACE_TOSS, so by deafult 0 
		mMaxEnergy = 0; // 2006118_Zahar Это времнное просто. Потом зануление будет только в switch() 
		mMaxShield = 0;  
		mArmor = 0; //TODO: fill 
		switch (mType) 
		{ 
			case UNIT_T_MARINE: 
				mName = "Marine"; 
				mCurHealth = 400; //TODO: TEMP 
				mMaxHealth = 400; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TERR; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SHORT, 6, 0, 1500, 150*3) ; 
						pActions[1] = new UnitAction(UnitAction.ACTION_STIMPACK, 0, 10, 1500, 0) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_MEDIC: 
				mName = "Medic"; 
				mCurHealth = 600; //TODO: TEMP 
				mMaxHealth = 600; 
				mMaxShield = 0; 
				mCurEnergy = 100; 
				mMaxEnergy = 100; 
				mArmor = 1; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TERR; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_HEAL, 100, 10, 2000, 4*150) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_TANK: 
				mName = "Tank"; 
				mCurHealth = 1500; //TODO: TEMP 
				mMaxHealth = 1500; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_LARGE; 
				mRace = RACE_TERR; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_GROUND, 30, 0, 3700, 0) ; 
						pActions[1] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SPLASH, 100, 0, 5000, 0) ; 
						pActions[3] = new UnitAction(UnitAction.ACTION_SIEGE, 50, 0, 5000, 6*150) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_VULTURE: 
				mName = "Vulture"; 
				mCurHealth = 800; //TODO: TEMP 
				mMaxHealth = 800; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_MEDIUM; 
				mRace = RACE_TERR; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_GROUND, 20, 0, 3000, 500) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_SCV: 
				mName = "SCV"; 
				mCurHealth = 600; //TODO: TEMP 
				mMaxHealth = 600; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TERR; 
				bOrganic = 1; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 5, 0, 1500, 300) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_GHOST: 
				mName = "Ghost"; 
				mCurHealth = 450; //TODO: TEMP 
				mMaxHealth = 450; 
				mMaxShield = 0; 
				mCurEnergy = 200; 
				mMaxEnergy = 200; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TERR; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SHORT, 10, 0, 2200, 100); 
						pActions[1] = new UnitAction(UnitAction.ACTION_LOCKDOWN, 10000, 100, 10001, 0); 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_GOLIATH: 
				mName = "Goliath"; 
				mCurHealth = 1250; //TODO: TEMP 
				mMaxHealth = 1250; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_MEDIUM; 
				mRace = RACE_TERR; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SHORT, 12, 0, 2200, 100); 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_FIREBAT: 
				mName = "Firebat"; 
				mCurHealth = 500; //TODO: TEMP 
				mMaxHealth = 500; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TERR; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_FIREBAT, 16, 0, 2200, 100);   //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_T_VESSEL: 
				mName = "Vessel"; 
				mCurHealth = 2000; //TODO: TEMP 
				mMaxHealth = 2000; 
				mMaxShield = 0; 
				mCurEnergy = 200; 
				mMaxEnergy = 200; 
				mArmor = 1; 
				mSize = SIZE_LARGE; 
				mRace = RACE_TERR; 
				bAir = 1; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_DEFENCEMATRIX, 1000, 50, 10001, 0) ; 
						pActions[1] = new UnitAction(UnitAction.ACTION_EMP, 0, 50, 10001, 0) ; 
						//pActions[2] = new UnitAction(UnitAction.ACTION_IRRADIATE, 0, 0, 0, 0) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break; 			 
			case UNIT_Z_ZERGLING: 
				mName = "Zergling"; 
				mCurHealth = 350; //TODO: TEMP 
				mMaxHealth = 350; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 5, 0, 800, 400); 
						pActions[3] = new UnitAction(UnitAction.ACTION_BURROW, 0, 0, 5000, 450) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_Z_ULTRAL: 
				mName = "Ultralisk"; 
				mCurHealth = 4000; //TODO: TEMP 
				mMaxHealth = 4000; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_LARGE; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 20, 0, 1500, 400); 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;   
			case UNIT_Z_HYDRA: 
				mName = "Hydralisk"; 
				mCurHealth = 800; //TODO: TEMP 
				mMaxHealth = 800; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_MEDIUM; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SHORT, 10, 0, 1500, 400); 
						pActions[3] = new UnitAction(UnitAction.ACTION_BURROW, 0, 0, 5000, 450) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_Z_DRONE: 
				mName = "Drone"; 
				mCurHealth = 400; //TODO: TEMP 
				mMaxHealth = 400; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 5, 0, 2200, 400); 
						pActions[3] = new UnitAction(UnitAction.ACTION_BURROW, 0, 0, 5000, 450) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_Z_DEFILER: 
				mName = "Defiler"; 
				mCurHealth = 800; //TODO: TEMP 
				mMaxHealth = 800; 
				mMaxShield = 0; 
				mCurEnergy = 200; 
				mMaxEnergy = 200; 
				mArmor = 1; 
				mStartTime = 0; 
				mSize = SIZE_MEDIUM; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_PLAGUE, 1000, 0, 10001, 400); 
						pActions[3] = new UnitAction(UnitAction.ACTION_BURROW, 0, 0, 5000, 450) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_Z_LURKER: 
				mName = "Lurker"; 
				mCurHealth = 1250; //TODO: TEMP 
				mMaxHealth = 1250; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_LARGE; 
				mRace = RACE_ZERG; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_GROUND, 100, 0, 6000, 600); 
						pActions[3] = new UnitAction(UnitAction.ACTION_BURROW, 0, 0, 0, 600) ; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_Z_OVERLORD: 
				mName = "Overlord"; 
				mCurHealth = 2000; //TODO: TEMP 
				mMaxHealth = 2000; 
				mMaxShield = 0; 
				mMaxEnergy = 0; 
				mSize = SIZE_LARGE; 
				mRace = RACE_ZERG; 
				bAir = 1; 
				bOrganic = 1; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_Z_QUEEN: 
				mName = "Queen"; 
				mCurHealth = 1200; //TODO: TEMP 
				mMaxHealth = 1200; 
				mMaxShield = 0; 
				mCurEnergy = 200; 
				mMaxEnergy = 200; 
				mSize = SIZE_LARGE; 
				mRace = RACE_ZERG; 
				bAir = 1; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ENSNARE, 0, 50,  2000, 0); 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ; 
				break;  
			case UNIT_P_ARCHONT: 
				mName = "Archont"; 
				mCurHealth = 100;//TODO: TEMP 
				mMaxHealth = 100; 
				mCurShield = 3500;//TODO: TEMP 
				mMaxShield = 3500; 
				mMaxEnergy = 0; 
				mStartTime = 300; 
				mSize = SIZE_LARGE; 
				mRace = RACE_TOSS; 
				bOrganic = 0; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 30, 0, 2000, 500);   //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black        
				break;				 
			case UNIT_P_ZEALOT: 
				mName = "Zealot"; 
				mCurHealth = 1000;//TODO: TEMP 
				mMaxHealth = 1000; 
				mCurShield = 600;//TODO: TEMP 
				mMaxShield = 600; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 16, 0, 2200, 500);   //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black        
				break; 
			case UNIT_P_DARK: 
				mName = "Dark Templar"; 
				mCurHealth = 800;//TODO: TEMP				 
				mMaxHealth = 800; 
				mCurShield = 400;//TODO: TEMP 
				mMaxShield = 400; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 40, 0, 3000, 3*160);   //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black                   
				break;      
			case UNIT_P_PROBE: 
				mName = "Probe"; 
				mCurHealth = 200;//TODO: TEMP 
				mMaxHealth = 200; 
				mCurShield = 200;//TODO: TEMP 
				mMaxShield = 200; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_MELEE, 5, 0, 2200, 0);   //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black                   
				break;     			 
			case UNIT_P_OBSERVER: 
				mName = "Observer"; 
				mCurHealth = 400;//TODO: TEMP 
				mMaxHealth = 400; 
				mCurShield = 200;//TODO: TEMP				 
				mMaxShield = 200; 
				mMaxEnergy = 0; 
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
				bMechanic = 1; 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black                        
				bAir = 1; 
				break; 
			case UNIT_P_DARKARCHONT: 
				mName = "Dark Archont"; 
				mCurHealth = 250;//TODO: TEMP				 
				mMaxHealth = 250; 
				mCurShield = 2000;//TODO: TEMP 
				mMaxShield = 2000; 
				mCurEnergy = 200; // TODO: TEMP 
				mMaxEnergy = 300; 				 
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_FEEDBACK, 0, 100, 10000, 0) ;          //20061118 Black 
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black 
				break;				 
			case UNIT_P_TEMPLAR: 
				mName = "High Templar"; 
				mCurHealth = 400;//TODO: TEMP				 
				mMaxHealth = 400; 
				mCurShield = 400;//TODO: TEMP 
				mMaxShield = 400; 
				mCurEnergy = 200; // TODO: TEMP 
				mMaxEnergy = 300;  
				mSize = SIZE_SMALL; 
				mRace = RACE_TOSS; 
				bOrganic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_STORM, 400, 100, 10001, 1000);            //20061118 Black  
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;          //20061118 Black                       
				break; 
			case UNIT_P_REAVER: 
				mName = "Reaver"; 
				mCurHealth = 1000;//TODO: TEMP 
				mMaxHealth = 1000; 
				mCurShield = 800;//TODO: TEMP 
				mMaxShield = 800; 
				mMaxEnergy = 0; 
				mStartTime = 0; 
				mSize = SIZE_LARGE; 
				mRace = RACE_TOSS; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_GROUND, 100, 0, 6000, 1000);            
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;            
				break;  				 
			case UNIT_P_DRAGOON: 
				mName = "Dragoon"; 
				mCurHealth = 1000;//TODO: TEMP 
				mMaxHealth = 1000; 
				mCurShield = 800;//TODO: TEMP 
				mMaxShield = 800; 
				mMaxEnergy = 0; 
				mArmor = 1; 
				mSize = SIZE_LARGE; 
				mRace = RACE_TOSS; 
				bMechanic = 1; 
						pActions[0] = new UnitAction(UnitAction.ACTION_ATTACK_RANGE_SHORT, 20, 0, 3000, 1000);            
						pActions[5] = new UnitAction(UnitAction.ACTION_RETREAT, 0, 0, 0, 0) ;                      
				break;   
			default: 
			break; 
		}		 
	} 
    // To let to free memory in UnitStorage 
    public void Destroy() 
    { 
		mName = ""; 
		iAnimationState = 0; 
		mUnitAnimator = null; 
		pConditions = null; 
		pActions = null;		 
    } 
     
    // Change state of sprite by some seconds 
    public void DoTimeStep(long dt) 
    { 
		mUnitAnimator.DoTimeStep(iAnimationState, dt); 
    } 
     
    public void Draw(Graphics g, int x, int y) 
    { 
		mUnitAnimator.Draw(iAnimationState, g, x, y, !bLeft); 
		// Рисуем hitpoints, shield и ману 
		// x+(40-HEALTH_LINE_WIDTH)/2 - центрование 
		// Высота 0 - это линия. можно и толще. 
		// Мана всегда рисуется 3-й снизу, щит вторым, хиты первыми. 
		if ( mMaxEnergy>0 ) // Избежать заодно деление на ноль. 
		{ 
			g.setColor(0x6F6F6F); 
			g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-4*HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH, HEALTH_LINE_HEIGHT-1); 
			g.setColor(0x9C56AD); 
			g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-4*HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH*mCurEnergy/mMaxEnergy, HEALTH_LINE_HEIGHT-1); 
		} 
		if ( mMaxShield>0 ) // Избежать заодно деление на ноль. 
		{ 
			g.setColor(0x6F6F6F); 
			g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-2*HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH, HEALTH_LINE_HEIGHT-1); 
			g.setColor(0x175FD6); 
			g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-2*HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH*mCurShield/mMaxShield, HEALTH_LINE_HEIGHT-1); 
		} 
		g.setColor(0x6F6F6F); 
		g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH, HEALTH_LINE_HEIGHT-1); 
		if ( mCurHealth > mMaxHealth*2/3 ) 
			g.setColor(0x37AA37); 
		else 
		if ( mCurHealth > mMaxHealth/3 ) 
			g.setColor(0xFCD640); 
		else 
			g.setColor(0xB81111); 
		g.drawRect(x+(40-HEALTH_LINE_WIDTH)/2, y+40-HEALTH_LINE_HEIGHT, HEALTH_LINE_WIDTH*mCurHealth/mMaxHealth, HEALTH_LINE_HEIGHT-1); 
    } 
     
    public void SetState(int s) 
    { 
		mUnitAnimator.SetState(iAnimationState, s); 
    } 
 
}