Exemple #1
0
void MinerGob::Draw(DibBitmap *pbm, int xViewOrigin, int yViewOrigin, int nLayer)
{
#ifdef DRAW_OCCUPIED_TILE_INDICATOR
		{
			WRect wrcT;
			GetTilePaddedWRect(&wrcT);
			Rect rcT;
			rcT.FromWorldRect(&wrcT);
			rcT.Offset(-xViewOrigin, -yViewOrigin);
			DrawBorder(pbm, &rcT, 1, GetColor(kiclrWhite));
		}
#endif

	if (m_fHidden)
		return;

	MobileUnitGob::Draw(pbm, xViewOrigin, yViewOrigin, nLayer);

	if (m_st == kstMinerSuck && nLayer == knLayerDepthSorted) {
		SetAnimationStrip(&m_aniVacuum, m_ani.GetStrip());
		m_aniVacuum.Draw(pbm, PcFromUwc(m_wx) - xViewOrigin, PcFromUwc(m_wy) - yViewOrigin);
	} else if (nLayer == knLayerSelection && (m_ff & kfGobSelected)) {
		Rect rcT;
		rcT.FromWorldRect(&m_pmuntc->wrcUIBounds);
		rcT.Offset(PcFromUwc(m_wx) - xViewOrigin, PcFromUwc(m_wy) - yViewOrigin);
		DrawFullnessIndicator(pbm, &rcT, m_nGalaxiteAmount / knGalaxiteValue / 2, knMinerGalaxiteMax / knGalaxiteValue / 2);
	}
}
Exemple #2
0
bool TankGob::LoadState(Stream *pstm)
{
	byte nVer = pstm->ReadByte();
	if (nVer != knVerTankGobState)
		return false;
	m_dir16Turret = pstm->ReadByte();
	m_aniTurret.Init(m_pmuntc->panid);
	SetAnimationStrip(&m_aniTurret, m_pmuntc->anFiringStripIndices[m_dir16Turret]);
	return MobileUnitGob::LoadState(pstm);
}
Exemple #3
0
bool TankGob::Init(WCoord wx, WCoord wy, Player *pplr, fix fxHealth, dword ff, const char *pszName)
{
	if (!MobileUnitGob::Init(wx, wy, pplr, fxHealth, ff, pszName))
		return false;

	StartAnimation(&m_ani, m_dir, 0, 0);
	m_aniTurret.Init(m_pmuntc->panid);
	SetAnimationStrip(&m_aniTurret, m_pmuntc->anFiringStripIndices[m_dir16Turret]);
	return true;
}
Exemple #4
0
void MinerGob::GetClippingBounds(Rect *prc)
{
	UnitGob::GetClippingBounds(prc);

	if (m_st == kstMinerSuck) {
		SetAnimationStrip(&m_aniVacuum, m_ani.GetStrip());
		Rect rc;
		m_aniVacuum.GetBounds(&rc);
		rc.Offset(PcFromUwc(m_wx), PcFromUwc(m_wy));
		prc->Union(&rc);
	}
}
Exemple #5
0
void TankGob::Idle()
{
	// 1/2 of the time we pivot the turret left, 1/2 we pivot it right

	if (GetRandom() & 1) {
		m_dir16Turret--;
		if (m_dir16Turret < 0)
			m_dir16Turret = 15;
	} else {
		m_dir16Turret++;
		if (m_dir16Turret > 15)
			m_dir16Turret = 0;
	}
	SetAnimationStrip(&m_aniTurret, m_pmuntc->anFiringStripIndices[m_dir16Turret]);
}
Exemple #6
0
void TankGob::DefUpdate()
{
	// Try to make the turrent point toward the target (unless we're already firing)

	if (m_wptTarget.wx != kwxInvalid && !(m_wfMunt & kfMuntFiring)) {
		// Get the aim point. If we have a unit target, it is the unit's center
		// If we don't have a unit target, it is whatever is in m_wptTarget
		
		WPoint wptAim = m_wptTarget;
		Gob *pgobTarget = ggobm.GetGob(m_gidTarget);
		if (pgobTarget != NULL)
			pgobTarget->GetCenter(&wptAim);

		// If the target is in the tile we're in stop trying to look exactly at it

		if (WcTrunc(m_wx) != WcTrunc(wptAim.wx) || WcTrunc(m_wy) != WcTrunc(wptAim.wy)) {

			Direction16 dir16 = CalcDir16(wptAim.wx - m_wx, wptAim.wy - m_wy);

			// Make sure we're facing the way we want to go

			int d = dir16 - m_dir16Turret;
			if (d != 0) {
				if (d < -8)
					d = 1;
				else if (d > 8)
					d = -1;
				if (d < 0)
					m_dir16Turret--;
				else
					m_dir16Turret++;
				m_dir16Turret = ((unsigned int)m_dir16Turret) % 16;
				SetAnimationStrip(&m_aniTurret, m_pmuntc->anFiringStripIndices[m_dir16Turret]);
				m_unvl.MinSkip();
			}
		}
	}

	AdvanceAnimation(&m_aniTurret);

	MobileUnitGob::DefUpdate();
}