Пример #1
0
//#############################################################################
void LaneDetector::ExtractBorder(Mat image)
{
    int leftUp = 0, leftDown = 0, rightUp = image.cols - 1, rightDown = image.cols - 1;
    int lowerBound = image.rows - 1;

    while (leftUp < image.cols && image.at<tUInt8>(0, leftUp) == 5)
    {
        leftUp++;
    }

    while (leftDown < image.cols && image.at<tUInt8>(lowerBound, leftDown) == 5)
    {
        leftDown++;
    }

    while (rightUp > 0 && image.at<tUInt8>(0, rightUp) == 5)
    {
        rightUp--;
    }

    while (rightDown > 0 && image.at<tUInt8>(lowerBound, rightDown) == 5)
    {
        rightDown--;
    }

    Point2f LeftUp(leftUp + 1, 1);
    Point2f LeftDown(leftDown + 1, lowerBound - 1);
    Point2f RightDown(rightDown - 1, lowerBound - 1);
    Point2f RightUp(rightUp - 1, 1);

    border.Initialize(LeftUp, RightUp, LeftDown, RightDown);
}
Пример #2
0
bool CMouseControl::RightClick ()
{	
	if (CheckClickArea ()) {
		RightDown ();
		RightUp ();
		return true;
	}

	return false;
}
Пример #3
0
void Region::init(int type, vector<double> params_)
{
	typ=type;
	params=params_;
	Point LeftDown(params[0],params[1]);
	Point LeftUp(params[2],params[3]);
	Point RightUp(params[4],params[5]);
	Point RightDown(params[6],params[7]);
	modparams.push_back(LeftDown);
	modparams.push_back(LeftUp);
	modparams.push_back(RightUp);
	modparams.push_back(RightDown);
}
Пример #4
0
void Region::draw()
{
	if(typ==1)
	{
		Point LeftDown(params[0],params[1]);
		Point LeftUp(params[2],params[3]);
		Point RightUp(params[4],params[5]);
		Point RigthDown(params[6],params[7]);
		drawLine(LeftDown,LeftUp,0,1,1);
		drawLine(LeftUp,RightUp,0,1,1);
		drawLine(RightUp,RigthDown,0,1,1);
		drawLine(RigthDown,LeftDown,0,1,1);
	}
}
Пример #5
0
void ATotemCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (TimeSinceHit > 0.0f)
	{
		TimeSinceHit -= DeltaTime;
	}
	else
	{
		PreviousHit.controller = nullptr;
		PreviousHit.type = AbilityType::NONE;
		PreviousHit.name = "";
	}

	if (bThirdPersonDeathCamLerp)
	{
		if (Controller)
		{
			Controller->SetControlRotation(FRotator(-1.0f * DeathCamAngle, 0, 0));
		}
	}

	if (bThirdPersonCamLerp || bThirdPersonDeathCamLerp )
	{
		CameraBoom->TargetArmLength = FMath::Lerp<float>(CameraBoom->TargetArmLength, ThirdPersonCamDistance, DeltaTime*4.0f);
	}
	else
	{
		CameraBoom->TargetArmLength = FMath::Lerp<float>(CameraBoom->TargetArmLength, 0, DeltaTime*4.0f);
	}

	if (bIsDead && (ThirdPersonCamDistance!= ThirdPersonDeathCamDistance))
	{
		ThirdPersonCamDistance = ThirdPersonDeathCamDistance;
	}

	if ( ((FMath::Abs(CameraBoom->TargetArmLength - ThirdPersonCamDistance) < 0.5f) && bIsDead && bThirdPersonDeathCamLerp))
	{
		ATotemPlayerController *PC = Cast<ATotemPlayerController>(Controller);
		if (PC)
		{
			if (HasAuthority())
			{
				PC->HandleDead(FVector(0, 0, 0), FRotator(0, 0, 0));
			}
			bThirdPersonDeathCamLerp = false;
		}
	}

	if (bDeathEffectFired && RayCastOnGround() )
	{
		FireMaterialEffect();
		bDeathEffectFired = false;
	}

	if ((CameraBoom->TargetArmLength > 0.5f) && (!bIsShamanVisible))
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfVisible();
			bIsShamanVisible = true;
		}
	}
	
	if ((CameraBoom->TargetArmLength <= 0.5f) && (bIsShamanVisible))
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfInvisible();
			bIsShamanVisible = false;
		}
	}

	if (Controller && FirstTick)
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfInvisible();
			bIsShamanVisible = false;
		}
		FirstTick = false;
	}

	ATotemPlayerState *TotemPlayerState = Cast<ATotemPlayerState>(PlayerState);
	if (TotemPlayerState && bFirstSpawn)
	{
		SetActorLocation(TotemPlayerState->StartingLocation);
		SetActorRotation(TotemPlayerState->StartingRotation);
		bFirstSpawn = false;
	}

	if (bReborn && HasAuthority())
	{
		TotalRebornDuration -= DeltaTime;
		if (TotalRebornDuration < 0.0f)
		{
			bReborn = false;
			ExitReborn();
		}
	}


	if (HasAuthority())
	{
		if (bBeingKnockedBack)
		{
			TimeSinceKnockedBack -= DeltaTime;
			if (TimeSinceKnockedBack < 0.0f)
			{
				bBeingKnockedBack = false;
			}
		}
#if (WRITE_METRICS > 1)
		if (DeltaTime >= .025)
		{
			ATotemPlayerController* control = Cast<ATotemPlayerController>(Controller);
			if(control)
			{
				ATotemPlayerState* state = Cast<ATotemPlayerState>(control->PlayerState);
				if(state)
				{
					std::string team;
					switch (state->Team)
					{
					case ETeam::RED_TEAM:
						team = "Red";
						break;
					case ETeam::BLUE_TEAM:
						team = "Blue";
						break;
					default:
						team = "None";
						break;
					}
					Metrics::WriteToFile(std::string(TCHAR_TO_UTF8(*(state->MyName))), team, std::string("Frame rate hit"), std::string(std::to_string(DeltaTime) + "ms"), std::string(std::to_string(1.0f/DeltaTime) + "fps"));
				}
			}
		}
#endif
	}


	//Keep track of how long has passed since the last attack
	TimeSinceAttack += DeltaTime;
	ShotPressedDuration += DeltaTime;

	//If shot is pressed and enough time has been pressed
	if (ShotPressed && TimeSinceAttack >= TimeBetweenShots)
	{
		//And you either can rapid fire or no shot has been fired since the shot button was pressed
		if (CanRapidFire || !ShotFired)
		{
			OnFire();
			ShotFired = true;
			TimeSinceAttack = 0.0f;
		}
	}
	else if (!ShotPressed)
	{
		ShotPressedDuration = 0;
	}

	//If get hit by cyclone, then the shaman cannnot move
	if (HasAuthority())
	{
		TArray<AActor* > OverlappedActors;
		TArray<ACyclone* > OverlappedCyclones;
		GetOverlappingActors(OverlappedActors);
		for (int32 i = 0; i < OverlappedActors.Num(); i++)
		{
			ACyclone* Cyclone = Cast<ACyclone>(OverlappedActors[i]);
			if (Cyclone && !Cyclone->IsPendingKill())
			{
				//overlap myself doesn't count
				if (Cyclone->GetOwner() != GetController())
				{
					OverlappedCyclones.Add(Cyclone);
				}
			}
		}

		if (OverlappedCyclones.Num() == 0)
		{
			//Do this to prevent bCanMove be replictated every frame
			if (!bCanMove)
			{
				bCanMove = true;
			}
			AttachCyclone = nullptr;
		}
		else if (OverlappedCyclones.Num() > 0)
		{
			if (bCanMove)
			{
				bCanMove = false;
			}
			if (AttachCyclone)
			{
				FVector CycloneVelocity = AttachCyclone->ProjectileMovement->Velocity;
				ATotemPlayerController* own = Cast<ATotemPlayerController>(AttachCyclone->GetOwner());
				if (own)
				{
					ReduceHealth(AttachCyclone->Damage * DeltaTime, own, AbilityType::WIND, FName(TEXT("Cyclone"))); //every second reduce Damage amount of health
				}
				LaunchCharacter(CycloneVelocity, true, true);
			}
			//CharacterMovement->Velocity = CycloneVelocity;
		}
	}

	//temporary solution, maybe later we need more fancy stuff.
	if (bIsDead && HasAuthority())
	{
		CurrentDeadBodyDuration -= DeltaTime;
		if (CurrentDeadBodyDuration <= 0)
		{
			Destroy();
		}
	}

	if (bClickedThisFrame)
	{
		bClickedThisFrame = false;
		if (Controller)
		{
			APlayerController* control = Cast<APlayerController>(Controller);
			if (control)
			{
				if (!control->IsInputKeyDown(EKeys::LeftMouseButton))
				{
					LeftUp();
				}
			}
		}
	}

	if (bRightButtonDownThisFrame)
	{
		bRightButtonDownThisFrame = false;
		if (Controller)
		{
			APlayerController* control = Cast<APlayerController>(Controller);
			if (control)
			{
				if (!control->IsInputKeyDown(EKeys::RightMouseButton))
				{
					RightUp();
				}
			}
		}
	}

	//CheckShiftKey();

}
Пример #6
0
void CMouseControl::RightClick ()
{	
	RightDown ();
	sleep_milliseconds(m_sendActionWait);
	RightUp ();
}
Пример #7
0
void C4MouseControl::Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFlags, bool fCenter)
{
	// Control state
	ControlDown=false; if (dwKeyFlags & MK_CONTROL) ControlDown=true;
	ShiftDown=false; if (dwKeyFlags & MK_SHIFT) ShiftDown=true;
	AltDown=false; if(dwKeyFlags & MK_ALT) AltDown=true;
	// Active
	if (!Active || !fMouseOwned) return;
	// Execute caption
	if (KeepCaption) KeepCaption--; else { Caption.Clear(); CaptionBottomY=0; }
	// Check player
	if (Player>NO_OWNER)
	{
		pPlayer=::Players.Get(Player);
		if (!pPlayer) { Active=false; return; }
	}
	else
		pPlayer = nullptr;
	// Check viewport
	if (!(Viewport=::Viewports.GetViewport(Player))) return;
	// get view position
	C4Rect rcViewport = Viewport->GetOutputRect();
	fctViewport.Set(nullptr, rcViewport.x, rcViewport.y, rcViewport.Wdt, rcViewport.Hgt);
	ViewX=Viewport->GetViewX(); ViewY=Viewport->GetViewY();
	fctViewportGame = Viewport->last_game_draw_cgo;
	fctViewportGUI = Viewport->last_gui_draw_cgo;
	// First time viewport attachment: center mouse
#ifdef USE_WIN32_WINDOWS
	if (!InitCentered || fCenter)
	{
		iX = Viewport->ViewWdt/2;
		iY = Viewport->ViewHgt/2;
		if (!Application.isEditor)
		{
			int32_t iMidX = Viewport->OutX + iX;
			int32_t iMidY = Viewport->OutY + iY;
			RECT rtWindow;
			if (GetWindowRect(Application.pWindow->hWindow, &rtWindow))
			{
				iMidX += rtWindow.left; iMidY += rtWindow.top;
			}
			SetCursorPos(iMidX, iMidY);
		}
		InitCentered = true;
	}
#else
	if (!InitCentered || fCenter)
	{
		iX = Viewport->ViewWdt/2;
		iY = Viewport->ViewHgt/2;
		InitCentered = true;
	}
#endif
	// passive mode: scrolling and player buttons only
	if (IsPassive())
	{
		if (iButton != C4MC_Button_Wheel)
		{
			VpX=iX; VpY=iY;
			GameX=ViewX+VpX/Viewport->Zoom; GameY=ViewY+VpY/Viewport->Zoom;
			GuiX=float(VpX)/Viewport->GetGUIZoom(); GuiY=float(VpY)/Viewport->GetGUIZoom();
		}
		UpdateScrolling();
		if (iButton == C4MC_Button_LeftDown) LeftDown();
		else if (iButton == C4MC_Button_LeftUp) LeftUp();
		else UpdateCursorTarget();
		return;
	}

	if (iButton != C4MC_Button_Wheel)
	{
		// Position
		VpX=iX; VpY=iY;
		GameX=ViewX+VpX/Viewport->Zoom; GameY=ViewY+VpY/Viewport->Zoom;
		GuiX=float(VpX)/Viewport->GetGUIZoom(); GuiY=float(VpY)/Viewport->GetGUIZoom();
		// Scrolling
		UpdateScrolling();
		// Fog of war
		UpdateFogOfWar();

		// Blocked by fog of war: evaluate button up, dragging and region controls only
		if (FogOfWar && Drag == C4MC_Drag_None)
		{
			// Left button up
			if (iButton==C4MC_Button_LeftUp)
			{
				LeftButtonDown=false;
				// End any drag
				Drag=C4MC_Drag_None;
			}
			// Right button up
			if (iButton==C4MC_Button_RightUp)
			{
				RightButtonDown=false;
			}
		}
	}

	// Move execution by button/drag status
	switch (iButton)
	{
		//------------------------------------------------------------------------------------------
	case C4MC_Button_None:
		switch (Drag)
		{
		case C4MC_Drag_Unhandled: break; // nothing to do
		case C4MC_Drag_None: DragNone(); break;
		case C4MC_Drag_Script: DragScript(); break;
		}
		break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_LeftDown: LeftDown(); break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_LeftUp: LeftUp(); break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_LeftDouble: LeftDouble(); break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_RightDown: RightDown(); break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_RightUp: RightUp(); break;
		//------------------------------------------------------------------------------------------
	case C4MC_Button_Wheel: Wheel(dwKeyFlags); break;
	}

	// are custom menus active?
	bool menuProcessed = false;
	if (pPlayer)
		// adjust by viewport X/Y because the GUI windows calculate their positions (and thus check input) based on that
		menuProcessed = ::Game.ScriptGuiRoot->MouseInput(iButton, iX, iY, dwKeyFlags);

	if (menuProcessed)
		Cursor = C4MC_Cursor_Select;

	// if not caught by a menu
	if (!menuProcessed)
		// script handling of mouse control for everything but regular movement (which is sent at control frame intervals only)
		if (iButton != C4MC_Button_None)
			// not if blocked by selection object
			if (!TargetObject)
				// safety (can't really happen in !IsPassive, but w/e
				if (pPlayer && pPlayer->ControlSet)
				{
					if (!menuProcessed && pPlayer->ControlSet->IsMouseControlAssigned(iButton))
					{
						int wheel_dir = 0;
						if (iButton == C4MC_Button_Wheel) wheel_dir = (short)(dwKeyFlags >> 16);
						pPlayer->Control.DoMouseInput(0 /* only 1 mouse supported so far */, iButton, GameX, GameY, GuiX, GuiY, (dwKeyFlags & MK_CONTROL) != 0, (dwKeyFlags & MK_SHIFT) != 0, (dwKeyFlags & MK_ALT) != 0, wheel_dir);
					}
				}