コード例 #1
0
ファイル: MiniMap.cpp プロジェクト: stev47/0ad
void CMiniMap::SetCameraPos()
{
	CTerrain* terrain = g_Game->GetWorld()->GetTerrain();

	CVector3D target;
	GetMouseWorldCoordinates(target.X, target.Z);
	target.Y = terrain->GetExactGroundLevel(target.X, target.Z);
	g_Game->GetView()->MoveCameraTarget(target);
}
コード例 #2
0
ファイル: MiniMap.cpp プロジェクト: stev47/0ad
void CMiniMap::FireWorldClickEvent(int button, int clicks)
{
	float x, z;
	GetMouseWorldCoordinates(x, z);

	CScriptValRooted coords;
	g_ScriptingHost.GetScriptInterface().Eval("({})", coords);
	g_ScriptingHost.GetScriptInterface().SetProperty(coords.get(), "x", x, false);
	g_ScriptingHost.GetScriptInterface().SetProperty(coords.get(), "z", z, false);
	ScriptEvent("worldclick", coords);

	UNUSED2(button);
	UNUSED2(clicks);
}
コード例 #3
0
ファイル: MiniMap.cpp プロジェクト: bdnaor/0ad
void CMiniMap::FireWorldClickEvent(int UNUSED(button), int UNUSED(clicks))
{
	JSContext* cx = g_GUI->GetActiveGUI()->GetScriptInterface()->GetContext();
	JSAutoRequest rq(cx);

	float x, z;
	GetMouseWorldCoordinates(x, z);

	JS::RootedValue coords(cx);
	g_GUI->GetActiveGUI()->GetScriptInterface()->Eval("({})", &coords);
	g_GUI->GetActiveGUI()->GetScriptInterface()->SetProperty(coords, "x", x, false);
	g_GUI->GetActiveGUI()->GetScriptInterface()->SetProperty(coords, "z", z, false);
	ScriptEvent("worldclick", coords);
}
コード例 #4
0
ファイル: RTSUnit.cpp プロジェクト: OpenMachines/machines
/* Moves to mouse cursor position in world coordinates. */
bool ARTSUnit::PerformCommand()
{
	FHitResult Hit = GetMouseWorldCoordinates();
	if (Hit.bBlockingHit)
	{
		if (Hit.Actor != NULL)
		{
			ARTSUnit* unit = Cast<ARTSUnit>(Hit.GetActor());

			if (unit != NULL)
			{
				Attack(unit);
				return true;
			}
		}
			
		// We hit something, move there
		Move(Hit.ImpactPoint);
		return true;
	}
	State = UnitAction::Idle;
	return false;
}