Ejemplo n.º 1
0
void EffectActor::EndTurnProcess(void)
{
	

	
	while(GetActionQueueNumItems() > 0) 
	{
		GetNextAction(k_doInvisible);
		MapPoint  end;
		m_curAction->GetEndMapPoint(end);
		if (end.x != 0 || end.y != 0) 
		{
			m_pos = end;
		}
	}

	

	if (m_curAction != NULL) 
	{
		sint32 x, y;

		maputils_MapXY2PixelXY(m_pos.x, m_pos.y, &x, &y);

		m_shX = m_x = x;
		m_shY = m_y = y;

		
		m_frame = m_curAction->GetSpriteFrame();

		
		m_transparency = m_curAction->GetTransparency();

		POINT curPt;

		
		if (m_curAction->GetPath() != NULL) {
			
			curPt = m_curAction->GetPosition();

			m_shX = m_x = curPt.x;
			m_shY = m_y = curPt.y;
		}

		
		m_facing = m_curAction->GetFacing();

		
		
		
		if(GetNeedsToDie())
		{
			SetDieAtTick(0);  
			SetKillNow();
		}
	}
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------
//
// Name       : specialAttackWindow_DisplayData
//
// Description: Displays the costs of a special attack
//
// Parameters : MapPoint &p: Position at that the given order should be
//              executed.
//              sint32 type: The type of the order in question.
//
// Globals    : g_selected_item:           The currently selected item
//              g_theOrderDB:              The order database
//              g_theSpecialAttackWindow:  The special attack window
//              g_c3ui:                    The civilization 3 graphical user interface
//
// Returns    : -
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void specialAttackWindow_DisplayData(MapPoint &p, sint32 type)
{
	if(!g_theSpecialAttackWindow){
		specialAttackWindow_Initialize();
	}
	Assert(g_theSpecialAttackWindow);
	if(!g_theSpecialAttackWindow)
		return;

	if(type < 0){
		g_c3ui->RemoveWindow(g_theSpecialAttackWindow->Id());
		return;
	}

	sint32 costs = 0;
	if(g_theOrderDB->Get(type)->GetUnitPretest_CanInciteRevolution()){
		ArmyData::GetInciteRevolutionCost(p, costs);
	}
	else if(g_theOrderDB->Get(type)->GetUnitPretest_CanInciteUprising()){
		ArmyData::GetInciteUprisingCost(p, costs);
	}
	else{
		costs = g_theOrderDB->Get(type)->GetGold();
	}

    if (s_saWindowCostV)
    {
	    MBCHAR       mytext[256];
	    sprintf(mytext,"%d", costs);
	    s_saWindowCostV->SetText(mytext);
    }

	sint32       x, y;
	maputils_MapXY2PixelXY(p.x,p.y,&x,&y);
	g_theSpecialAttackWindow->Move(x,y);

	sint32		visPlayer = g_selected_item->GetVisiblePlayer();
	if(costs <= g_player[visPlayer]->GetGold()){
		s_saWindowBorderColor = COLOR_GREEN;
	}
	else{
		s_saWindowBorderColor = COLOR_RED;
	}

	if(costs > 0){
		g_c3ui->AddWindow(g_theSpecialAttackWindow);
		g_theSpecialAttackWindow->ShouldDraw();
	}
	else{
		g_c3ui->RemoveWindow(g_theSpecialAttackWindow->Id());
	}
}
Ejemplo n.º 3
0
void
SpriteEditWindow::DrawSprite( )
{

	if ((m_currentSprite!=NULL)&&(g_tiledMap!=NULL))
	{
		RECT rect;

		rect.left	= m_drawX-m_spriteRect.right;
		rect.top	= m_drawY-m_spriteRect.bottom;
		rect.right	= m_drawX+m_spriteRect.right;
		rect.bottom = m_drawY+m_spriteRect.bottom;

		if (m_drawFlag)
			m_currentSprite->Draw((UNITACTION)m_animation,m_frame,m_drawX,m_drawY,m_facing,1.0,15,0,k_DRAWFLAGS_NORMAL,false,false);

		POINT flag;
		maputils_MapXY2PixelXY(m_drawPoint.x, m_drawPoint.y, flag);

		POINT *hPoint = m_currentSprite->GetShieldPoints((UNITACTION)m_animation);
		if (hPoint)
        {
			flag.x += hPoint->x;
			flag.y += hPoint->y;
		}

		MAPICON icon = MAPICON_HERALD;








		Pixel16 blue = pixelutils_RGB(0,0,255);

		g_tiledMap->DrawColorizedOverlayIntoMix(g_tiledMap->GetTileSet()->GetMapIconData(icon), flag.x, flag.y, blue);

		g_tiledMap->AddDirtyRectToMix(rect);
	}
}
Ejemplo n.º 4
0
void EffectActor::Process(void)
{
	

	
	
	
	
	if(!m_curAction)
		GetNextAction();
			
	if (m_curAction) {

		if(GetActionQueueNumItems() > 0)
			m_curAction->Process(LookAtNextAction());
		else
			m_curAction->Process();

			
		
		
		
		if (m_curAction->Finished()) 
		{
			MapPoint  end;
			m_curAction->GetEndMapPoint(end);
			if (end.x != 0 || end.y != 0) {
				m_pos = end;
			}

			GetNextAction();
		}
	}
	
	
	if (m_curAction != NULL) {
		sint32 x, y;

		maputils_MapXY2PixelXY(m_pos.x, m_pos.y, &x, &y);

		
		
		m_shX = m_x = x;
		m_shY = m_y = y;


		POINT curPt;

		
		if (m_curAction->GetPath() != NULL) {
			
			curPt = m_curAction->GetPosition();

			m_shX = m_x = curPt.x;
			m_shY = m_y = curPt.y;
		}

		if(m_curAction->GetActionType() == EFFECTACTION_PLAY)
		{
			m_lastMoveFacing = m_curAction->GetFacing();
		}

		if(m_curAction->SpecialDelayProcess())
		{
			m_facing = m_lastMoveFacing;
		}
		else
		{
			
			m_facing = m_curAction->GetFacing();
		}
		
		m_frame = m_curAction->GetSpriteFrame();
		
		m_transparency = m_curAction->GetTransparency();
		
		
		
		
		if(GetNeedsToDie() && m_curAction->GetCurrentEndCondition() == ACTIONEND_INTERRUPT)
		{
			SetKillNow();
		}

	}
}
Ejemplo n.º 5
0
void TradeActor::Process(void)
{
	

 	if (m_curAction) 
	{
		m_curAction->Process();

		
		if (m_curAction->Finished()) 
		{
			MapPoint  end;
			m_curAction->GetEndMapPoint(end);
			if (end.x != 0 || end.y != 0) 
			{
				m_currentPos = end;
			}

			GetNextAction();
		}
	}

	if (m_curAction != NULL) {
		sint32 x, y;

		
		
		
	
		if(m_curAction->GetCurrentEndCondition() == ACTIONEND_INTERRUPT && 	m_curAction->LoopAnimHasCycled())
		{
			m_curAction->ResetAnimLoop();
			m_curAction->SetCurActionCounter(0);
			m_currentPos = GetNextPos();

			
			
			
			
			
			MapPoint tempDestPos = LookAtNextPos();
			MapPoint tempCurPos = m_currentPos;

			
			m_curAction->CreatePath(m_currentPos.x, m_currentPos.y, tempDestPos.x, tempDestPos.y);

		}
		
		maputils_MapXY2PixelXY(m_currentPos.x, m_currentPos.y, &x, &y);
		
		m_x = x;
		m_y = y;

		
		m_frame = m_curAction->GetSpriteFrame();

		
		m_transparency = m_curAction->GetTransparency();

		POINT curPt;

		
		if (m_curAction->GetPath() != NULL) {

			
			curPt = m_curAction->GetPosition();

			



			m_x = curPt.x;
			m_y = curPt.y;
		}
		
		m_facing = m_curAction->GetFacing();
	}
}
Ejemplo n.º 6
0
//----------------------------------------------------------------------------
//
// Name       : tileimptracker_DisplayData
//
// Description: Displays the food, production and gold boni at the given
//              position that the given tileimp generates. In addition it
//              displays the needed time for construction and the PW costs.
//
// Parameters : MapPoint &p: Position at that the given tileimp should be
//              contructed.
//              sint32 type: The type of the tileimp in question.
//
// Globals    : g_selected_item:           The currently selected item
//              g_theWorld:                The game world
//              g_theTerrainImprovementDB: The tile improvement database
//              g_theTerrainDB:            The terrain database
//              g_theProfileDB:            The player's profile
//              g_tileImpTrackerWindow:    The tile improvement tracker window
//              g_c3ui:                    The civilization 3 graphical user interface
//
// Returns    : -
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void tileimptracker_DisplayData(MapPoint const & p, sint32 type)
{
	if(!g_tileImpTrackerWindow) {
		tileimptracker_Initialize();
	}
	Assert(g_tileImpTrackerWindow);
	if(!g_tileImpTrackerWindow)
		return;

	MBCHAR		mytext[256];
	sint32		x, y;
	sint32		visPlayer = g_selected_item->GetVisiblePlayer();

	s_tileImprovementNum = type;
	if (s_tileImprovementNum < 0) {
		g_c3ui->RemoveWindow(g_tileImpTrackerWindow->Id());
		return;
	}

	sint32 extraData = 0;







	BOOL alreadyHasIt = g_theTerrainImprovementPool->HasImprovement(p,
																	TERRAIN_IMPROVEMENT(s_tileImprovementNum),
																	extraData);

	if(g_player[visPlayer]->IsExplored(p) && !alreadyHasIt) {

		maputils_MapXY2PixelXY(p.x,p.y,&x,&y);


		g_tileImpTrackerWindow->Move(x,y);

//		TERRAIN_TYPES terr = g_theWorld->GetTerrainType(p);

		sint32  mat, time,
		        food, production,
		        gold;

		sint32 extraData = 0;

		time = terrainutil_GetProductionTime(s_tileImprovementNum, p, 0);
		mat = terrainutil_GetProductionCost(s_tileImprovementNum, p, 0);

		const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(s_tileImprovementNum);
		Cell *cell = g_theWorld->GetCell(p);

		if(rec->GetClassTerraform() || rec->GetClassOceanform())
		{
			sint32 t;
			if(rec->GetTerraformTerrainIndex(t))
			{
				const TerrainRecord *newT = g_theTerrainDB->Get(t);
				sint32 oldFood = cell->GetFoodProduced();
				sint32 oldProd = cell->GetShieldsProduced();
				sint32 oldGold = cell->GetGoldProduced();

				sint32 newFood = newT->GetEnvBase()->GetFood();
				sint32 newProd = newT->GetEnvBase()->GetShield();
				sint32 newGold = newT->GetEnvBase()->GetGold();

				if (cell->HasRiver() && newT->HasEnvRiver())
				{
					newFood += newT->GetEnvRiverPtr()->GetFood();
					newProd += newT->GetEnvRiverPtr()->GetShield();
					newGold += newT->GetEnvRiverPtr()->GetGold();
				}

				food       = newFood - oldFood;
				production = newProd - oldProd;
				gold       = newGold - oldGold;
			}
			else
			{
				Assert(false);
				food = 0;
				production = 0;
				gold = 0;
			}
		}
		else
		{
			const TerrainImprovementRecord::Effect *eff = terrainutil_GetTerrainEffect(g_theTerrainImprovementDB->Get(s_tileImprovementNum), p);

			sint32 dFood = 0;
			if(eff) eff->GetBonusFood(dFood);
			sint32 dProd = 0;
			if(eff) eff->GetBonusProduction(dProd);
			sint32 dGold = 0;
			if(eff) eff->GetBonusGold(dGold);

			food = dFood + cell->GetFoodFromTerrain();
			production = dProd + cell->GetShieldsFromTerrain();
			extraData = 0;

			gold = dGold + cell->GetGoldFromTerrain();
		}

		sprintf(mytext,"%d", (sint32)time);
		s_trackerTimeV->SetText(mytext);
		sprintf(mytext,"%d", (sint32)mat);
		s_trackerMatV->SetText(mytext);

		sprintf(mytext,"%d", food);
		s_trackerFoodV->SetText(mytext);
		sprintf(mytext,"%d", production);
		s_trackerProductionV->SetText(mytext);
		sprintf(mytext,"%d", gold);
		s_trackerGoldV->SetText(mytext);

		ERR_BUILD_INST err;
		bool const	checkMaterials	= !g_theProfileDB->GetValueByName("ShowExpensive");

		if (g_player[visPlayer]->CanCreateImprovement
				(TERRAIN_IMPROVEMENT(s_tileImprovementNum), p, extraData, checkMaterials, err)
		   )
		{
			if (g_player[visPlayer]->CanCreateImprovement
					(TERRAIN_IMPROVEMENT(s_tileImprovementNum), p, extraData, true, err)
			   )
			{
				s_trackerBorderColor = COLOR_GREEN;
			}
			else
			{
				s_trackerBorderColor = COLOR_RED;
			}
			g_c3ui->AddWindow(g_tileImpTrackerWindow);
		}
		else
		{
			g_c3ui->RemoveWindow(g_tileImpTrackerWindow->Id());
		}
		g_tileImpTrackerWindow->ShouldDraw();

		return;
	}
}
Ejemplo n.º 7
0
AUI_ERRCODE SpriteEditWindow::Idle( void )
{
	if ((g_c3ui->TheMouse()==NULL)||(g_tiledMap==NULL))
		return AUI_ERRCODE_OK;

	sint32 curTime = g_director->GetMasterCurTime();

	if ((curTime-m_lastTime)>100)
	{
		m_lastTime = curTime;

		if (m_loopInProgress)
			Animate();
	}

	ReDrawLargeSprite();

	aui_MouseEvent *me=g_c3ui->TheMouse()->GetLatestMouseEvent();

	char tbuffer[256];

	if (PtInRect(&m_largeRectAbs,me->position))
	{
		int mx,my;

		mx = (int)((float)(me->position.x-m_largeRectAbs.left)*m_widthRatio);
		my = (int)((float)(me->position.y-m_largeRectAbs.top )*m_heightRatio);

		sprintf(tbuffer,"Cursor:\t%d,%d",mx,my);
		m_hotCoordsMouse  ->SetText(tbuffer);
	}

	if (me->rbutton) {

			POINT new_herald = me->position;
			new_herald.x -= m_largeRectAbs.left;
			new_herald.y -= m_largeRectAbs.top;
			new_herald.x = (int)((float)new_herald.x*m_widthRatio);
			new_herald.y = (int)((float)new_herald.y*m_heightRatio);

			*m_currentSprite->GetShieldPoints((UNITACTION)m_animation) = new_herald;

	}

	if (!me->lbutton)
		return AUI_ERRCODE_OK;

	if (g_c3ui->TheMouse()->Y()<m_mouseChangeY)
	{
		MapPoint point;
		g_tiledMap->GetMouseTilePos(point);
		maputils_MapXY2PixelXY(point.x, point.y, &m_drawX, &m_drawY);
		m_drawX += k_ACTOR_CENTER_OFFSET_X;
		m_drawY += k_ACTOR_CENTER_OFFSET_Y;
		m_drawPoint = point;

	}
	else
	{
		if (PtInRect(&m_largeRectAbs,me->position))
		{
			POINT new_hot=me->position;

			new_hot.x -= m_largeRectAbs.left;
			new_hot.y -= m_largeRectAbs.top;

			new_hot.x = (int)((float)new_hot.x*m_widthRatio);
			new_hot.y = (int)((float)new_hot.y*m_heightRatio);

			m_currentSprite->SetHotPoint((UNITACTION)m_animation,m_facing,new_hot);
		}
	}

	return AUI_ERRCODE_OK;

}