Exemplo n.º 1
0
int Battle( Character_t *Character, int EnemyType){	
	DrawGraph(0,0,BackGround,TRUE);
	MessageFrame();
	DrawFormatString( 60, 140, GetColor(255, 255, 255), " LV:%d ",Character->LEVEL) ;

	DrawGauge( 15, 16, Character->MaxHP, Character->HP, GetColor( 0, 255, 0 ), GetColor(0, 255/2, 0),TRUE);
	DrawGauge( 15, 31, Character->MaxMP, Character->MP, GetColor( 255, 255, 0 ),GetColor( 255/2, 255/2, 0 ),TRUE );

	DrawGraph(Enemy[EnemyType].X, Enemy[EnemyType].Y, Enemy[EnemyType].Graph, TRUE);
	// 現れたとこ
	if(move==0){if(DrawBattleMessage( 0, 2, BattleMenuString, 0, EnemyType, TRUE) == 1 )move=1;}


	// 選択
	if(move==1)switch( DrawMenu( 2, 2, KEY_INPUT_Z, BattleMenu) ){
	// 速度判定
	case 0:backmenu=0;if( Character->Speed >= Enemy[EnemyType].Speed ){
		Damage=DamageCalc2( *Character, &Enemy[EnemyType]);move=3;
		   }else {
			   Damage=DamageCalc2( Enemy[EnemyType], Character);move=5;
		   }break;
	case 1:break;
	case 2:move=2;break;
	case 3:break;
	}

	//逃げ出す勇者の処理
	if(move==2)if( DrawBattleMessage( 2, 3, BattleMenuString, 0, EnemyType,FALSE) == 1 ){move=0;Enemy[EnemyType].HP = Enemy[EnemyType].MaxHP ;return 2;}



	// 的にダメージを与える処理 中かっこの中には勝った時の処理
	if(move==3)if(DamageCalc3( Character, &Enemy[EnemyType], 3, 5, 5, EnemyType, FALSE)==1){ 
			Character->Ex += Enemy[EnemyType].Ex ; 
			Enemy->HP = Enemy[EnemyType].MaxHP ; 
			move=0 ; 
			return 2 ;
		}

	// 敵のダメージを与える分を表示 中かっこの中には負けた時の処理
	if(move==5)if(DamageCalc3( &Enemy[EnemyType], Character, 5, 7, 3, EnemyType, TRUE)==1){
			move=0 ;
			return 0 ;
		}
	

	return 4 ;
}/*
Exemplo n.º 2
0
void Window_BattleStatus::RefreshGauge(int i) {
	int y = i * 15;
	contents->ClearRect(Rect(192, y, 44, 15));
	Game_Actor* actor = Game_Battle::allies[i].game_actor;
	DrawGauge(actor, i, 192, y);
	DrawActorSp(actor, 202, y, false);
}
void Window_BattleStatus::RefreshGauge() {
	if (Player::IsRPG2k3()) {
		if (Data::battlecommands.battle_type != RPG::BattleCommands::BattleType_gauge) {
			contents->ClearRect(Rect(198, 0, 25 + 16, 15 * item_max));
		}

		for (int i = 0; i < item_max; ++i) {
			Game_Battler* actor;
			if (enemy) {
				actor = &(*Main_Data::game_enemyparty)[i];
			}
			else {
				actor = &(*Main_Data::game_party)[i];
			}

			if (!enemy && Data::battlecommands.battle_type == RPG::BattleCommands::BattleType_gauge) {
				FileRequestAsync* request = AsyncHandler::RequestFile("System2", Data::system.system2_name);
				if (!request->IsReady()) {
					request_id = request->Bind(&Window_BattleStatus::OnSystem2Ready, this);
					request->Start();
					break;
				}
				else {
					BitmapRef system2 = Cache::System2(Data::system.system2_name);
					
					// Clear number drawing area
					contents->ClearRect(Rect(40 + 80 * i, 24, 8 * 4, 16));
					contents->ClearRect(Rect(40 + 80 * i, 24 + 12 + 4, 8 * 4, 16));

					// Number clearing removed part of the face, but both, clear and redraw
					// are needed because some games don't have face graphics that are huge enough
					// to clear the number area (e.g. Ara Fell)
					DrawActorFace(static_cast<Game_Actor*>(actor), 80 * i, 24);

					// Background
					contents->StretchBlit(Rect(32 + i * 80, 24, 57, 48), *system2, Rect(0, 32, 48, 48), Opacity::opaque);

					// HP
					DrawGaugeSystem2(48 + i * 80, 24, actor->GetHp(), actor->GetMaxHp(), 0);
					// SP
					DrawGaugeSystem2(48 + i * 80, 24 + 16, actor->GetSp(), actor->GetMaxSp(), 1);
					// Gauge
					DrawGaugeSystem2(48 + i * 80, 24 + 16 * 2, actor->GetGauge() * actor->GetMaxGauge() / 100, actor->GetMaxGauge(), 2);
					
					// Numbers
					DrawNumberSystem2(40 + 80 * i, 24, actor->GetHp());
					DrawNumberSystem2(40 + 80 * i, 24 + 12 + 4, actor->GetSp());
				}
			}
			else {
				int y = 2 + i * 16;

				DrawGauge(actor, 198 - 10, y - 2);
				DrawActorSp(actor, 198, y, false);
			}
		}
	}
}
Exemplo n.º 4
0
static void DrawWeaponStatus(
	HUD *hud, const TActor *actor, Vec2i pos,
	const FontAlign hAlign, const FontAlign vAlign)
{
	const Weapon *weapon = ActorGetGun(actor);

	// Draw gun icon, and allocate padding to draw the gun icon
	const GunDescription *g = ActorGetGun(actor)->Gun;
	const Vec2i iconPos = Vec2iAligned(
		Vec2iNew(pos.x - 2, pos.y - 2),
		g->Icon->size, hAlign, vAlign, gGraphicsDevice.cachedConfig.Res);
	Blit(&gGraphicsDevice, g->Icon, iconPos);

	// don't draw gauge if not reloading
	if (weapon->lock > 0)
	{
		const Vec2i gaugePos = Vec2iAdd(pos, Vec2iNew(-1 + GUN_ICON_PAD, -1));
		const Vec2i size = Vec2iNew(GAUGE_WIDTH - GUN_ICON_PAD, FontH() + 2);
		const color_t barColor = { 0, 0, 255, 255 };
		const int maxLock = weapon->Gun->Lock;
		int innerWidth;
		color_t backColor = { 128, 128, 128, 255 };
		if (maxLock == 0)
		{
			innerWidth = 0;
		}
		else
		{
			innerWidth = MAX(1, size.x * (maxLock - weapon->lock) / maxLock);
		}
		DrawGauge(
			hud->device, gaugePos, size, innerWidth, barColor, backColor,
			hAlign, vAlign);
	}
	FontOpts opts = FontOptsNew();
	opts.HAlign = hAlign;
	opts.VAlign = vAlign;
	opts.Area = gGraphicsDevice.cachedConfig.Res;
	opts.Pad = Vec2iNew(pos.x + GUN_ICON_PAD, pos.y);
	char buf[128];
	if (ConfigGetBool(&gConfig, "Game.Ammo") && weapon->Gun->AmmoId >= 0)
	{
		// Include ammo counter
		sprintf(buf, "%s %d/%d",
			weapon->Gun->name,
			ActorGunGetAmmo(actor, weapon),
			AmmoGetById(&gAmmo, weapon->Gun->AmmoId)->Max);
	}
	else
	{
		strcpy(buf, weapon->Gun->name);
	}
	FontStrOpt(buf, Vec2iZero(), opts);
}
Exemplo n.º 5
0
void Window_BattleStatus::Refresh() {
	contents->Clear();

	for (size_t i = 0; i < Game_Battle::allies.size() && i < 4; i++) {
		int y = i * 15;
		Game_Actor* actor = Game_Battle::allies[i].game_actor;
		DrawActorName(actor, 4, y);
		DrawActorState(actor, 80, y);
		DrawActorHp(actor, 136, y, true);
		DrawGauge(actor, i, 192, y);
		DrawActorSp(actor, 202, y, false);
	}
}
Exemplo n.º 6
0
void CLayerMap::Draw(PCImg32 pDst)
{
	int y;
	PCInfoMapBase pMap;
	PCLayerBase pLayer;

	pMap = m_pMgrData->GetMap ();
	if (pMap == NULL) {
		return;
	}

	if (pMap->m_byLevel != 0) {
		RenewLevel ();
	}

	DrawPartsBase	(pDst);
	DrawMapPile		(pDst);
	DrawItem		(pDst, 0);
	for (y = -1; y < DRAW_PARTS_Y + 2; y ++) {
		DrawMapObject	(pDst, y);
		DrawChar		(pDst, y);
		DrawPartsPile	(pDst, y);
		DrawMapPile		(pDst, y);
	}
	DrawPartsPile	(pDst);
	DrawMapPile		(pDst, -98);
	DrawShadow		(pDst);

	pLayer = NULL;
	switch (pMap->m_dwWeatherType) {
	case WEATHERTYPE_CLOUD:		pLayer = m_pLayerCould;		break;
	case WEATHERTYPE_MISTY:		pLayer = m_pLayerMisty;		break;
	case WEATHERTYPE_SNOW:		pLayer = m_pLayerSnow;		break;
	}
	if (pLayer) {
		pLayer->Draw (pDst);
	}
	if (pMap->m_byLevel != 0) {
		pDst->SetLevel (m_pDibLevel);
	}
	DrawItem (pDst, 1);
	DrawCharText		(pDst);
	DrawGauge			(pDst);
	DrawSystemIcon		(pDst);
	DrawMapName			(pDst);
}
Exemplo n.º 7
0
static void DrawHealth(
	GraphicsDevice *device, const TActor *actor, const Vec2i pos,
	const FontAlign hAlign, const FontAlign vAlign)
{
	char s[50];
	Vec2i gaugePos = Vec2iAdd(pos, Vec2iNew(-1, -1));
	Vec2i size = Vec2iNew(GAUGE_WIDTH, FontH() + 2);
	HSV hsv = { 0.0, 1.0, 1.0 };
	color_t barColor;
	int health = actor->health;
	const int maxHealth = ActorGetCharacter(actor)->maxHealth;
	int innerWidth;
	color_t backColor = { 50, 0, 0, 255 };
	innerWidth = MAX(1, size.x * health / maxHealth);
	if (actor->poisoned)
	{
		hsv.h = 120.0;
		hsv.v = 0.5;
	}
	else
	{
		double maxHealthHue = 50.0;
		double minHealthHue = 0.0;
		hsv.h =
			((maxHealthHue - minHealthHue) * health / maxHealth + minHealthHue);
	}
	barColor = ColorTint(colorWhite, hsv);
	DrawGauge(
		device, gaugePos, size, innerWidth, barColor, backColor,
		hAlign, vAlign);
	sprintf(s, "%d", health);

	FontOpts opts = FontOptsNew();
	opts.HAlign = hAlign;
	opts.VAlign = vAlign;
	opts.Area = gGraphicsDevice.cachedConfig.Res;
	opts.Pad = pos;
	FontStrOpt(s, Vec2iZero(), opts);
}
Exemplo n.º 8
0
void ShowVolume(char* VolumeName, int flgShowDevName, int flgVerbose, int flgUnit, int flgGauge, int flgRemoveable, uint64_t* AllTotalSize, uint64_t* AllFreeSize) {
    DWORD  Error                = ERROR_SUCCESS;
    DWORD  CharCount            = 0;
    char   tmp[MAX_PATH]        = "";
    char   DeviceName[MAX_PATH] = "";
    char*  VolumeTypeName       = 0;
    UINT   VolumeType           = 0;
    size_t Index                = 0;
    DWORD  SectorsPerCluster    = 0;
    DWORD  BytesPerSector       = 0;
    DWORD  NumberOfFreeClusters = 0;
    DWORD  TotalNumberOfClusters= 0;
    uint64_t TotalSize          = 0;
    uint64_t FreeSize           = 0;

    UINT   flgIsRealFloppy      = 0;

    double den                  = 0.0f;
    double percent              = 0.0f;

    strcpy(tmp, VolumeName);

    VolumeType = GetDriveTypeA(tmp);
    switch(VolumeType) {
        case 0:
            VolumeTypeName = "(Unknown)";
            break;
        case 1:
            VolumeTypeName = "(invalid root path)";
            break;
        case 2:
            VolumeTypeName = "(Removable)";
            break;
        case 3:
            VolumeTypeName = "(Fixed)";
            break;
        case 4:
            VolumeTypeName = "(Remote)";
            break;
        case 5:
            VolumeTypeName = "(CD-ROM)";
            break;
        case 6:
            VolumeTypeName = "(RAM Disk)";
            break;
    }

    if(!flgVerbose && !IsTargetDrive(VolumeType,7,0)) return;
    // get free space information
    if(IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)) {
        GetDiskFreeSpaceA(tmp, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters);
        FreeSize = TotalSize = SectorsPerCluster;
        FreeSize *= BytesPerSector;
        TotalSize *= BytesPerSector;
        FreeSize *= NumberOfFreeClusters;
        TotalSize *= TotalNumberOfClusters;

        if(VolumeType == 3) {
            *AllTotalSize += TotalSize;
            *AllFreeSize += FreeSize;
        }

        den = TotalSize;
        percent = FreeSize;
        percent /= den;
        percent *= 100;
    }

    if(flgVerbose) {
        printf("\nFound a device: %s", DeviceName);
        printf("\nVolume name: %s %s", tmp, VolumeTypeName);
        printf("\nPaths:");
    }
    else if(flgGauge) {
        DrawGauge(36,(int)percent,!IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)|!TotalSize);
    }

    if (!flgShowDevName)
        printf("  %s", tmp);


    if(IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)) {
        // VolumeName is reused here
        strcpy(tmp, ComputerUnits(FreeSize, flgUnit));

        // DeviceName is reused here
        if(TotalSize)
            sprintf(DeviceName, "%.2f", percent);
        else
            strcpy(DeviceName, "--");

        printf(" (%s / %s) %s%%", tmp, ComputerUnits(TotalSize, flgUnit), DeviceName);
    }
    if(!flgVerbose) {
        if(VolumeType != 3) printf(" %s", VolumeTypeName);
    }
    printf("\n");
}
Exemplo n.º 9
0
int main(int argc, char **argv)
{
    DWORD  Error                = ERROR_SUCCESS;
    HANDLE FindHandle           = INVALID_HANDLE_VALUE;
    BOOL   Found                = FALSE;
    size_t Index                = 0;
    BOOL   Success              = FALSE;
    char   VolumeName[MAX_PATH] = "";
    DWORD  dwAttrib             = 0;

    uint64_t allTotal           = 0;
    uint64_t allFree            = 0;
    double   percent            = 0.0f;

    int i               = 1;
    int flgVerbose      = 0;
    int flgUnit         = 3;
    int flgGauge        = 0;
    int flgRemoveable   = 0;
    int flgNonEnum      = 0;
    int flgForceEnum    = 0;
    int flgShowAllTotal = 0;
    int OldMode; //a place to store the old error mode

    //save the old error mode and set the new mode to let us do the work:
    OldMode = SetErrorMode(SEM_FAILCRITICALERRORS); 

    for (; i < argc; i++) {
        if(stricmp(argv[i],"-g") == 0) {
            flgGauge = 1;
        } else if(strnicmp(argv[i],"-u",2) == 0) {
            if(argv[i][2] >= '0' && argv[i][2] <= '4')
                flgUnit = argv[i][2] - '0';
        } else if(strnicmp(argv[i],"-r",2) == 0) {
            flgRemoveable |= 1;
            if(argv[i][2] == 'f')
                flgRemoveable |= 2;
        } else if(stricmp(argv[i],"-n") == 0) {
            flgRemoveable |= 4;
        } else if(stricmp(argv[i],"-v") == 0) {
            flgVerbose = 1;
        } else if(stricmp(argv[i],"-a") == 0) {
            flgForceEnum = 1;
        } else if(stricmp(argv[i],"-t") == 0) {
            flgShowAllTotal = 1;
        } else if(strcmp(argv[i],"-?") == 0) {
            printf("%s [-v] [-g] [-a] [-r[f]] [-n] [-u#] [-t] [-?] [drive|path...]\n\n"
                " -v\t\tbe verbose (-g switch will be turned off)\n"
                " -g\t\tdraw gauge of free space\n"
                " -a\t\tappend drive|path to detected list\n"
                " -r[f]\t\tdetect removable device free space (-rf for real floppy drive)\n"
                " -n\t\tdetect mounted network drive free space\n"
                " -u[num]\tuse unit # (0=byte, 1=KB, 2=MB, 3=GB, 4=TB)\n"
                " -t\t\tshow total and free of all local fixed drives\n"
                " -?\t\tshow this help and exit\n"
                " drive|path...\tshow individual drives\n"
                " \t\texample:  C: D: F:\\mountpoint\\\n", argv[0]);
            return 0;
        } else {
            // assume it is a path
            dwAttrib = GetFileAttributesA(argv[i]);
            if(dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
                // yes it is valid path
                if(!flgForceEnum)
                    flgNonEnum = 1;
                // dwAttrib is reused
                strcpy(VolumeName, argv[i]);
                dwAttrib = strlen(VolumeName);
                // workaround on getting free space from \\host\share
                if (VolumeName[dwAttrib-2] != '\\') VolumeName[dwAttrib-1] = '\\';
                ShowVolume(VolumeName, 0, flgVerbose, flgUnit, flgGauge, flgRemoveable, &allTotal, &allFree);
            } else {
                printf("%s is not valid path.\n", argv[i]);
                return 0;
            }
        }
    }

    if(!flgNonEnum) {

        strcpy(VolumeName,"A:\\");
        if(flgRemoveable & 2) i = 0;
        else i = 2;
        // i is reused here
        for (; i< 26 ; i++) {
        	VolumeName[0] = 'A' + i;
            ShowVolume(VolumeName, 0, flgVerbose, flgUnit, flgGauge, flgRemoveable, &allTotal, &allFree);
        }

        FindHandle = INVALID_HANDLE_VALUE;

    }

    if(flgShowAllTotal) {
        percent = allFree;
        percent /= allTotal;
        percent *= 100;

        if(flgVerbose)
            printf("\n");

        if(!flgVerbose && flgGauge) {
            DrawGauge(36,(int)percent,0);
        }
        // VolumeName is reused here
        strcpy(VolumeName, ComputerUnits(allFree, flgUnit));

        printf("Total: (%s / %s) %.2f%%\n", VolumeName, ComputerUnits(allTotal, flgUnit), percent);
    }

    SetErrorMode(OldMode); //put things back the way they were
    return 0;
}
Exemplo n.º 10
0
void CMenuItem::Draw (int bIsCurrent, int bTiny)
{
SetColor (bIsCurrent, bTiny);
if (m_bRebuild) {
	Destroy ();
	m_bRebuild = 0;
	}
switch (m_nType) {
	case NM_TYPE_TEXT:
 // CCanvas::Current ()->Font () = TEXT_FONT);
		// fall through on purpose

	case NM_TYPE_MENU:
		DrawString (bIsCurrent, bTiny);
		break;

	case NM_TYPE_SLIDER: {
		SaveText ();
		if (m_value < m_minValue) 
			m_value = m_minValue;
		else if (m_value > m_maxValue) 
			m_value = m_maxValue;
		sprintf (m_text, "%s\t%s", m_savedText, SLIDER_LEFT);
		int l = int (strlen (m_text));
		int h = m_maxValue - m_minValue + 1;
		memset (m_text + l, SLIDER_MIDDLE [0], h);
		m_text [l + h] = SLIDER_RIGHT [0];
		m_text [l + h + 1] = '\0';
		m_text [m_value + 1 + strlen (m_savedText) + 1] = SLIDER_MARKER [0];
		DrawSlider (bIsCurrent, bTiny);
		RestoreText ();
		}
		break;

	case NM_TYPE_INPUT_MENU:
		if (m_group)
			DrawInputBox (m_w, m_x, m_y, m_text, bIsCurrent, bTiny);
		else
			DrawString (bIsCurrent, bTiny);
		break;

	case NM_TYPE_INPUT:
		DrawInputBox (m_w, m_x, m_y, m_text, bIsCurrent, bTiny);
		break;

	case NM_TYPE_GAUGE:
		DrawGauge (m_w, m_x, m_y, m_value, m_maxValue, bIsCurrent);
		break;

	case NM_TYPE_CHECK:
		DrawString (bIsCurrent, bTiny);
		if (m_value)
			DrawRightString (bIsCurrent, bTiny, CHECKED_CHECK_BOX);
		else														 
			DrawRightString (bIsCurrent, bTiny, NORMAL_CHECK_BOX);
		break;

	case NM_TYPE_RADIO:
		DrawString (bIsCurrent, bTiny);
		if (m_value)
			DrawRightString (bIsCurrent, bTiny, CHECKED_RADIO_BOX);
		else
			DrawRightString (bIsCurrent, bTiny, NORMAL_RADIO_BOX);
		break;

	case NM_TYPE_NUMBER:
		char text [20];
		m_value = NMCLAMP (m_value, m_minValue, m_maxValue);
		DrawString (bIsCurrent, bTiny);
		sprintf (text, "%d", m_value);
		DrawRightString (bIsCurrent, bTiny, text);
		break;
	}
}
Exemplo n.º 11
0
// 敵抽選はBefore_Battle.cppで行う
int BattleMgr( Character_t *Character, EnemySelect_t EnemySelect){
	MessageFrame();

	switch(BattlePhase){
		// 初期化 敵の枠に代入
		case 0:for(int i=0;i<4;i++){
			if(EnemySelect.Enemy[i]!=0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)]);
			if(EnemySelect.Enemy[i]==0)Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE);
			SecondIni( Enemy[i], i);
		}BattlePhase=1;break;

		// 戦闘に入ったとこ
		case 1:if(DrawBattleMessageString( 0, 1, BattleMenuString)==100)BattlePhase=2;break;

		// 何を行うかの選択
		case 2:switch(DrawMenu( 2, 2, KEY_INPUT_Z, BattleMenu )){
				case 0:BattlePhase=4;SpeedChecker( Character, Enemy );break;
				case 1:break;
				case 2:BattlePhase=3;break;
				case 3:break;
			   }break;

		// 逃げる時の文表示
		case 3:if( DrawBattleMessageString( 2, 2, BattleMenuString ) == 100 ){BattlePhase=0;MenuSelect=0;return 2;}break;

		// 攻撃する敵を選択数
		case 4:{
			switch(MenuSelect){
				case 0:{
					DrawFormatString(230,380,GetColor(255,255,255),"勇者はどの敵を攻撃する?");
					Attack[0]=DrawCursor( Enemy );
					if(Attack[0]!=100){
						if(Attack[0]!=200)MenuSelect++;
						BattlePhase=2;
					}
				}break;

				case 1:{
					DrawFormatString(230,380,GetColor(255,255,255),"勇者(二人目)どの敵を攻撃する?");
					Attack[1]=DrawCursor( Enemy );
					if(Attack[1]!=100){
						if(Attack[1]==200)BattlePhase=2;
						else MenuSelect++;
					}
				}break;

				case 2:{MenuSelect=0;BattlePhase=5;}break;
			}
		}break;

		// 攻撃実行
		case 5:{
			// 敵四体
			for(int i=0;i<4;i++){
				if( Enemy[i].Speed==Data[BattleTurn] && doing==0 && (Enemy[i].Speed2==0)){
					doing=1;
					if( Enemy[i].Defense && Enemy[i].HP>0){
						switch( DrawBattleMessageString( 5, 6, BattleMenuString, Enemy[i].NameNumber, Damage )){
							case 0:if(once==0){Rand=GetRand(1);Damage=DamageCalc( Enemy[i], *(Character+Rand) );once++;}break;
							case 1:if(Rand!=2)(Character+Rand)->HP-=Damage;Rand=2;break;
							case 100:Enemy[i].Speed2=1;Rand=0;BattleTurn++;once=0;break;
						}
					}else if( Enemy[i].HP<=0 ){
						BattleTurn++;
						Enemy[i].Speed2++;
						Enemy[i].Flag=0;
					}
				} 
			}

			if( !Character->Speed2 && Character->Speed==Data[BattleTurn] && !doing ){
				doing=1;
				if(Enemy[Attack[0]].Flag){
					switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[0]].NameNumber, Damage )){
						case 0:if(!once){Damage=DamageCalc( *Character, Enemy[Attack[0]] );once++;}break;
						case 1:if(Rand!=2)Enemy[Attack[0]].HP-=Damage;Rand=2;break;
						case 100:Character->Speed2=1;if(Enemy[Attack[0]].HP<=0)Enemy[Attack[0]].Flag=0;Rand=0;BattleTurn++;once=0;break;
					}
				}else BattleTurn+=1;
			}

			if( !(Character+1)->Speed2 && (Character+1)->Speed==Data[BattleTurn] && !doing){
				doing=1;
				if(Enemy[Attack[1]].Flag){
					switch( DrawBattleMessageString( 3, 4, BattleMenuString, Enemy[Attack[1]].NameNumber, Damage )){
						case 0:if(once==0){Damage=DamageCalc( *(Character+1), Enemy[Attack[1]] );once++;}break;
						case 1:if(Rand!=2)Enemy[Attack[1]].HP-=Damage;Rand=2;break;
						case 100:(Character+1)->Speed2=1;if(Enemy[Attack[1]].HP<=0)Enemy[Attack[1]].Flag=0;Rand=0;BattleTurn++;once=0;break;
					}
				}else BattleTurn+=1;
			}

			//BattleTurnが6は全員行動したことになっている
			if( !doing && BattleTurn==6){
				doing=1;
				BattlePhase=2;
				for(int i=0; i<4; i++ )Enemy[i].Speed2=0;
				for(int i=0; i<2; i++)(Character+i)->Speed2=0;
				//敵全滅
				if( Enemy[0].HP<=0 && Enemy[1].HP<=0 && Enemy[2].HP<=0 && Enemy[3].HP<=0 ){
					for(int i=0 ; i<4; i++){ //先に経験値の合計を求める
						EnemyExpSum+=Enemy[i].Ex;
						Substitution( &Enemy[i], EnemyStatus[(EnemySelect.Enemy[i]-1)], FALSE);
					}
					BattlePhase=6;
				}
				else BattleTurn=0;
			}
		}doing=0;break;//case 5の終了

		// 戦闘終了後の処理
		case 6:{
			if( DrawBattleMessageString( 7, 8, BattleMenuString,0,EnemyExpSum ) == 100 ){
				doing=0;
				BattlePhase=0;
				BattleTurn=0;
				for(int i=0; i<4; i++ )Enemy[i].Speed2=0;
				for(int i=0; i<2; i++)(Character+i)->Speed2=0; 
				if(Character->HP>=0)Character->Ex+=EnemyExpSum;
				// EnemyExpSumは一度の戦闘で手に入れた経験値の合計
				EnemyExpSum=0;
				if(Levelup(Character)==1)BattlePhase=7;
				else return 2;
			}
		}break;
		// レベルアップ時
		case 7:{
			if( DrawBattleMessageString( 9, 9, BattleMenuString, 0, Character->LEVEL) == 100 ){
				BattlePhase=0;
				return 2;
			}
		}break;
	}//switchの終了
	
	//数字表示系 敵の数字を表示
	DrawFormatString(420,360,GetColor(255,255,255),"BattleTurn:%d",BattleTurn);
	DrawFormatString(150,100,GetColor(255,255,255),"%d,%d,%d,%d,%d,%d",Data[0],Data[1],Data[2],Data[3],Data[4],Data[5]);
	DrawFormatString(150,120,GetColor(0,255,0),"%d",Character->Ex);
	for(int i=0;i<4;i++)DrawFormatString(320,240+20*i,GetColor(255,255,255),"%d",EnemySelect.Enemy[i]);	

	//条件を満たしている敵の枠のみ表示
	for(int i=0; i<4; i++)if(Enemy[i].HP>0 && Enemy[i].Flag==1)DrawGraph( Enemy[i].X+80*i, Enemy[i].Y, Enemy[i].Graph, TRUE );
	//勇者側のステータス表示
	for(int i=0; i<2; i++){
		if( (Character+i)->HP > 0 ){
			DrawGauge( 15, 16+35*i, (Character+i)->MaxHP, (Character+i)->HP, GetColor( 0, 255, 0 ), GetColor(0, 255/2, 0),TRUE);
			DrawGauge( 15, 31+35*i, (Character+i)->MaxMP, (Character+i)->MP, GetColor( 255, 255, 0 ),GetColor( 255/2, 255/2, 0 ),TRUE );
		}else if( (Character+i)->HP <=0 ) (Character+i)->HP=0;
	}

	if(CheckHitKey(KEY_INPUT_H)==1)return 2;
	return 4;
}
Exemplo n.º 12
0
void RenderGame()
{
	bool wasInvisible = player ? player->position.x < -50 : true;
	CanUpdate = GameOver == false && IsGamePaused == false;
	backbuffer->Clear( 0 );

	//Draw the background
	charmap->DrawCopy(backbuffer);


	//Update all entities and the background (horizontal scrolling)
	if( tick % 24 == 23 && charmap->x > -3228 && CanUpdate)
	{
		charmap->x-= ScrollingSpeed;

		if( player )
		{
			Point p2 = player->position;
			p2.x += 30;
			Point p1 = p2;
			p1.y -= 5;
			p2.y += 5;
			if( charmap->IsCollediable(p1) || charmap->IsCollediable(p2) )
			{
				player->position.x-= ScrollingSpeed;
			}
		}		

		ProcessEnemies2();
	}

	//Update the player
	if( player && player->IsAlive )
	{
		if( CanUpdate )
			player->Update();
		player->Draw(backbuffer);
	}
	/*
	else
	{
		GameOver = true;
	}
	*/
	
	//Update enemies
	ProcessEnemies();
	//Update bullets
	ProcessBullets();

	//Draw beamer-strength bar
	DrawGauge(150,260, beamstrength, 0xFFFF);
	//Draw health bar
	DrawGauge(350,260, gfx_var_health, 0x0ADF);
	//Draw scores

	char buffer[30];
	sprintf_s(buffer,"%d", score);
	font->Print(backbuffer, buffer, 140 - font->Width(buffer),253);

	
	//If we get stuck behind a tile we're gameover
	if( wasInvisible && player && player->position.x < -50 ) 
	{
		player->LeaveViewport();
	}
	
	//Draw some fonts in special occasions
	if( GameOver == true )
	{
		gameOverGraphics->AddAreaTo(0,0,gameOverGraphics->GetWidth() - 1, gameOverGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gameOverGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gameOverGraphics->GetHeight() )/ 2);
	}
	//If you die while the your ship is leaving the stage you won't be winning so much afterall.
	else if( GameWon == true )
	{
		gameWonGraphics->AddAreaTo(0,0,gameWonGraphics->GetWidth() - 1, gameWonGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gameWonGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gameWonGraphics->GetHeight() )/ 2);
	}
	else if( IsGamePaused == true )
	{
		gamePausedGraphics->AddAreaTo(0,0,gamePausedGraphics->GetWidth() - 1, gamePausedGraphics->GetHeight() - 1, backbuffer, (SCRWIDTH - gamePausedGraphics->GetWidth()  )/ 2,(SCRHEIGHT - gamePausedGraphics->GetHeight() )/ 2);
	}

	backbuffer->CopyTo(surface,0,0);

}