コード例 #1
0
void CBoard::Render()
{
    if (m_pBoard)
    {
        m_pBoard->Render();
    }

    for (int i = 0; i < 9; i++)
    {
        int x = i / 3;
        int y = i % 3;

        if ( IsTileFree( x, y ) )
        {
            continue;
        }

        CSprite *pIcon = m_iMatrix[x][y] == PLAYER_X ? m_pX : m_pO;

        if (!pIcon)
        {
            continue;
        }

        pIcon->SetPosition( (x-1)*DELTA_WIDTH, (y-1)*DELTA_HEIGHT );
        pIcon->SetScale( SCALE );

        pIcon->Render();
    }
}
コード例 #2
0
// Return true if move was played
bool CBoard::PlayMove(int x, int y, int player)
{
    if (!IsTileFree(x, y))
    {
        return false;
    }

    PlaceMarker(x, y, player);
    m_iNumberOfIcons += 1;
    return true;
}
コード例 #3
0
bool ReplicatorGob::ClearOutputBay(TCoord txBay, TCoord tyBay, TCoord txOut, TCoord tyOut)
{
	for (Gid gid = ggobm.GetFirstGid(txBay, tyBay); gid != kgidNull; gid = ggobm.GetNextGid(gid)) {
		MobileUnitGob *pmunt = (MobileUnitGob *)ggobm.GetGob(gid);
		if (pmunt == NULL)
			continue;
		if (!(pmunt->GetFlags() & kfGobMobileUnit))
			continue;

		// Don't ask it to move if it is already trying to

		if (pmunt->IsReadyForCommand() && !pmunt->IsMobile()) {
			Message msgT;
			msgT.mid = kmidMoveCommand;
			msgT.smidSender = m_gid;
			msgT.smidReceiver = pmunt->GetId();
			msgT.MoveCommand.wptTarget.wx = WcFromTc(txOut) + kwcTileHalf;
			msgT.MoveCommand.wptTarget.wy = WcFromTc(tyOut) + kwcTileHalf;
			msgT.MoveCommand.gidTarget = kgidNull;
			msgT.MoveCommand.wptTargetCenter.wx = msgT.MoveCommand.wptTarget.wx;
			msgT.MoveCommand.wptTargetCenter.wy = msgT.MoveCommand.wptTarget.wy;
			msgT.MoveCommand.tcTargetRadius = 0;
			msgT.MoveCommand.wcMoveDistPerUpdate = ((MobileUnitConsts *)pmunt->GetConsts())->GetMoveDistPerUpdate();
			gsmm.SendMsg(&msgT);
		}

		// Jammed

		return true;
	}

	// Maybe a unit is moving into the output bay (i.e., it is jammed)

	if (!IsTileFree(txBay, tyBay, kbfMobileUnit))
		return true; // jammed

	// Open
	
	return false;
}