Esempio n. 1
0
//--------------------------------------------------------------------------
//				   PCMoveToPoint
//				   -------------
//	General      : moves the checker turn made by computer
//	Parameters   : opp1 - X destination coordinat
//				   opp2 - Y destination coordinat
//	Return Value : Moved to the target point or not
//--------------------------------------------------------------------------
int CPlay::PCMoveToPoint(CMovesNode* node,HWND &hWnd)
{
	int moved;
	int destX,destY,x,y;
	HDC hdc = GetDC(hWnd);
	moved = 0;
	int jump = CheckMustJump(RED);

	while(node)
	{
		node->GetCoordinats(x,y,destX,destY);
		m_Active.x = x; m_Active.y = y;
		MoveToPoint(destX,destY,hdc,hWnd,true);
		InvalidateGameRect(destX - 2,destY - 2);
		InvalidateGameRect(x - 2,y - 2);
		if(jump != 0)
		{
			InvalidateGameRect(x + (destX - x)/2 - 2,
							   y + (destY - y)/2 - 2);
			numBlueCheckers++;
		}
		node = node->GetNext();
	}
	ReleaseDC(hWnd,hdc);
	return moved;
}
Esempio n. 2
0
void wxGraphicsPathData::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
{
    MoveToPoint(x,y);
    AddLineToPoint(x,y+h);
    AddLineToPoint(x+w,y+h);
    AddLineToPoint(x+w,y);
    CloseSubpath();
}
Esempio n. 3
0
void wxGraphicsPathData::AddRoundedRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h, wxDouble radius)
{
    if ( radius == 0 )
        AddRectangle(x,y,w,h);
    else
    {
        MoveToPoint( x + w, y + h / 2);
        AddArcToPoint(x + w, y + h, x + w / 2, y + h, radius);
        AddArcToPoint(x, y + h, x, y + h / 2, radius);
        AddArcToPoint(x, y , x + w / 2, y, radius);
        AddArcToPoint(x + w, y, x + w, y + h / 2, radius);
        CloseSubpath();
    }
}
Esempio n. 4
0
void wxGraphicsPathData::AddCircle( wxDouble x, wxDouble y, wxDouble r )
{
    MoveToPoint(x+r,y);
    AddArc( x,y,r,0,2*M_PI,false);
    CloseSubpath();
}
Esempio n. 5
0
void wxGraphicsPath::MoveToPoint( const wxPoint2DDouble& p)
{
    MoveToPoint( p.m_x , p.m_y);
}
   void UpdateAI(const uint32 uiDiff)
   {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim() && m_creature->IsTemporarySummon())
        {
          if(MoveTimer < uiDiff)
          {   
             if(m_pInstance->GetData(TYPE_WING) == RIGHT)
             {
                switch(WaypointId)
                {
                  case 1:
                     MoveToPoint(2356.659f, 1185.501f, 130.636f);
                     JumpNextStep(10000);
                     break;
                  case 2:
                     MoveToPoint(2301.735f, 1179.265f, 136.944f);
                     JumpNextStep(8000);
                     break;
                  case 3:
                     MoveToPoint(2234.787f, 1180.638f, 136.344f);
                     JumpNextStep(9000);
                     break;
                  case 4:
                     MoveToPoint(2178.313f, 1244.350f, 136.107f);
                     JumpNextStep(12000);
                     break; 
                  case 5:
                     MoveToPoint(2163.553f, 1277.814f, 133.444f);
                     JumpNextStep(5000);
                     break; 
                  case 6:
                     MoveToPoint(2083.952f, 1287.716f, 141.146f);
                     JumpNextStep(5000);
                     break; 
                }
             }

             if(m_pInstance->GetData(TYPE_WING) == LEFT)
             {
                switch(WaypointId)
                {
                  case 1:
                     MoveToPoint(2188.318f, 1331.410f, 130.003f);
                     JumpNextStep(10000);
                     break; 
                  case 2:
                     MoveToPoint(2165.351f, 1279.156f, 133.388f);    
                     JumpNextStep(8000);
                     break;  
                  case 3:
                     MoveToPoint(2083.952f, 1287.716f, 141.146f);    
                     JumpNextStep(9000);
                     break; 
                }
             }

           } else MoveTimer -= uiDiff;
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if(m_uiFleshTimer < uiDiff)
        {
           DoCast(m_creature->getVictim(), SPELL_FLESH);
           m_uiFleshTimer = (urand(3000, 10000));
        }
        else m_uiFleshTimer -= uiDiff;

        DoMeleeAttackIfReady();

        return;
   }
Direction DiamondQbertModelEnemyChaser::WhereToMove()
{
	if (IsMoving)
		return None;

	Math::Point3D QbertCenter = static_cast<QbertModel*>(_model)->GetModelObjects()->Qbert->NextBox->Center 
		+ static_cast<QbertModel*>(_model)->GetModelObjects()->Qbert->NextUpDirection;
	float sizeOfModel = (float)static_cast<DiamondQbertModel*>(_model)->Size();

	if (((Center.Y() * QbertCenter.Y()) > 0))		//Same half (up, down)
	{
		if (IsEqulZero(Center.X()))
			return MoveToPoint(Center + Math::Point3D(0, 0, -Math::Sign(Center.Z())));
		else if (IsEqulZero(Center.Z()))
			return MoveToPoint(Center + Math::Point3D(-Math::Sign(Center.X()), 0, 0));
		
		return MoveToPoint(QbertCenter);
	}
	
	if (IsEqulZero(Center.Y()))						//The Enemy is on the perimeter
	{
		if (IsEqulZero(QbertCenter.Y()))						//Both the Qbert and the Enemy are one the perimeter
		{
			if (IsEqulZero(Center.X()))
				return MoveToPoint(Center + Math::Point3D(Math::Sign(QbertCenter.X()), 0, 0));
			if (IsEqulZero(Center.Z()))
				return MoveToPoint(Center + Math::Point3D(0, 0, Math::Sign(QbertCenter.Z())));


			if ((Center.X() * QbertCenter.X()) >= 0)				//Near quarter on the perimeter
			{
				if(Center.Z() * QbertCenter.Z() >= 0)				//Same quarter on the perimeter
					return MoveToPoint(QbertCenter);
				else
					return MoveToPoint(Center + Math::Point3D(Math::Sign(Center.X()), 0, -Center.Z()));
			}
			
			if ((Center.Z() * QbertCenter.Z()) >= 0)				//Near but not the same quarter on the perimeter
				return MoveToPoint(Center + Math::Point3D(-Center.X(), 0, Math::Sign(Center.Z())));

			return MoveToPoint(Center + Math::Point3D(1, 0, 1));	//Go right to change to another quarter of the perimeter and then think
		}
		else
			return MoveToPoint(Center + Math::Point3D(0, Math::Sign(QbertCenter.Y()), 0));
	}

	else if (IsEqulZero(QbertCenter.Y()))			//Only the Qbert Is on the Perimeter
		return MoveToPoint(QbertCenter);


	else		//different half, tries to find the shortest pass... 
	{
		/*
			To cross the perimeter Enemy has at least to directions, in (+-1, 0, 0) and (0, 0, +-1) directions, 
			try each of those two and decide on the shortest from there to the Qbert.

			To decide on the distance from there to the Qbert lets notice that :
				the X coordinate == Center.X() OR Z == Center.Z() 
					AND
				[abs(Center.X()) + abs(Center.Y()) == sizeOfModel]
		*/

		Math::Point3D direction;
		float minQbertDist;

		if (Center.X() >= 0)
		{
			direction = Math::Point3D(1, 0, 0);
			minQbertDist = std::abs(QbertCenter.Z() - Center.Z()) + std::abs(QbertCenter.X() - (sizeOfModel - std::abs(Center.Z())));
		}
		else
		{
			direction = Math::Point3D(-1, 0, 0);
			minQbertDist = std::abs(QbertCenter.Z() - Center.Z()) + std::abs(QbertCenter.X() + (sizeOfModel - std::abs(Center.Z())));
		}

		if (Center.X() == 0)
		{
			float tempQbertDist =  std::abs(QbertCenter.Z() - Center.Z()) + std::abs(QbertCenter.X() + (sizeOfModel - std::abs(Center.Z())));
			if (tempQbertDist < minQbertDist)
			{
				direction = Math::Point3D(-1, 0, 0);
				minQbertDist = tempQbertDist;
			}
		}

		if (Center.Z() >= 0)
		{
			float tempQbertDist = std::abs(QbertCenter.X() - Center.X()) + std::abs(QbertCenter.Z() - (sizeOfModel - std::abs(Center.X())));
			if (tempQbertDist < minQbertDist)
			{
				direction = Math::Point3D(0, 0, 1);
				minQbertDist = tempQbertDist;
			}
		}
		else
		{
			float tempQbertDist = std::abs(QbertCenter.X() - Center.X()) + std::abs(QbertCenter.Z() + (sizeOfModel - std::abs(Center.X())));
			if (tempQbertDist < minQbertDist)
			{
				direction = Math::Point3D(0, 0, -1);
				minQbertDist = tempQbertDist;
			}
		}

		if (Center.Z() == 0)
		{
			float tempQbertDist =  std::abs(QbertCenter.X() - Center.X()) + std::abs(QbertCenter.Z() + (sizeOfModel - std::abs(Center.X())));
			if (tempQbertDist < minQbertDist)
			{
				direction = Math::Point3D(0, 0, -1);
				minQbertDist = tempQbertDist;
			}
		}

		return MoveToPoint(Center + direction);
	}
}