void ATopDown_HitmanCleanPlayerController::MoveToTouchLocation(const ETouchIndex::Type FingerIndex, const FVector Location){
	FVector2D ScreenSpaceLocation(Location);

	// Trace to see what is under the touch location
	FHitResult HitResult;
	GetHitResultAtScreenPosition(ScreenSpaceLocation, CurrentClickTraceChannel, true, HitResult);
	if (HitResult.bBlockingHit){
		// We hit something, move there
		SetNewMoveDestination(HitResult.ImpactPoint);
	}
}
void AAmbitionOfNobunagaPlayerController::PlayerTick(float DeltaTime)
{
    Super::PlayerTick(DeltaTime);

    if(Hud)
    {
        CurrentMouseXY = GetMouseScreenPosition();
        FHitResult Hit;
        bool res = GetHitResultAtScreenPosition(CurrentMouseXY, ECC_Visibility, false, Hit);
//      if (Hit.Actor.IsValid())
//      {
//          Hit.Actor->AddActorWorldOffset(FVector(0, 0, 100));
//      }
        Hud->OnMouseMove(CurrentMouseXY, Hit.ImpactPoint);
    }
    ServerUpdateMove();
}
Пример #3
0
AActor* ASrPlayerController::GetFriendlyTargetUnderCursor(const FVector2D& ScreenPoint, FVector& WorldImpactPoint) const
{
	FHitResult Hit;
	if (GetHitResultAtScreenPosition(ScreenPoint, COLLISION_WEAPON, true, Hit))
	{
		auto HitActor = Hit.GetActor();
		if (HitActor && HitActor->Implements<USrSelectionInterface>())
		{
			if (this == ISrSelectionInterface::Execute_GetTeamController(HitActor))
			{
				WorldImpactPoint = Hit.ImpactPoint;
				return Hit.GetActor();
			}
		}
	}

	return nullptr;
}
bool AAmbitionOfNobunagaPlayerController::InputKey(FKey Key, EInputEvent EventType, float AmountDepressed, bool bGamepad)
{
    bool bResult = false;

    if(GEngine->HMDDevice.IsValid())
    {
        bResult = GEngine->HMDDevice->HandleInputKey(PlayerInput, Key, EventType, AmountDepressed, bGamepad);
        if(bResult)
        {
            return bResult;
        }
    }

    if(PlayerInput)
    {
        bResult = PlayerInput->InputKey(Key, EventType, AmountDepressed, bGamepad);

        // TODO: Allow click key(s?) to be defined
        if(bEnableClickEvents && (Key == EKeys::LeftMouseButton || Key == EKeys::RightMouseButton))
        {
			if (Key == EKeys::LeftMouseButton)
			{
				AAmbitionOfNobunagaPlayerController::OnMouseLButtonPressed1();
			}
			else if (Key == EKeys::RightMouseButton)
			{
				AAmbitionOfNobunagaPlayerController::OnMouseRButtonPressed1();
			}

            FVector2D MousePosition;
            if(CastChecked<ULocalPlayer>(Player)->ViewportClient->GetMousePosition(MousePosition))
            {
                ClickedPrimitive = NULL;
                if(bEnableMouseOverEvents)
                {
                    ClickedPrimitive = CurrentClickablePrimitive.Get();
                }
                else
                {
                    FHitResult HitResult;
                    const bool bHit = GetHitResultAtScreenPosition(MousePosition, CurrentClickTraceChannel, true, HitResult);
                    if(bHit)
                    {
                        ClickedPrimitive = HitResult.Component.Get();
                    }
                }
                if(GetHUD())
                {
                    if(GetHUD()->UpdateAndDispatchHitBoxClickEvents(MousePosition, EventType))
                    {
                        ClickedPrimitive = NULL;
                    }
                }

                if(ClickedPrimitive)
                {
                    switch(EventType)
                    {
                    case IE_Pressed:
                    case IE_DoubleClick:
                        ClickedPrimitive->DispatchOnClicked();
                        break;

                    case IE_Released:
                        ClickedPrimitive->DispatchOnReleased();
                        break;

                    case IE_Axis:
                    case IE_Repeat:
                        break;
                    }
                }

                bResult = true;
            }
			if (Key == EKeys::LeftMouseButton)
			{
				AAmbitionOfNobunagaPlayerController::OnMouseLButtonPressed2();
			}
			else if (Key == EKeys::RightMouseButton)
			{
				AAmbitionOfNobunagaPlayerController::OnMouseRButtonPressed2();
			}
        }
    }

    return bResult;
}
void AAmbitionOfNobunagaPlayerController::ServerUpdateMove_Implementation()
{
    if(HeroMoveQueue.Num() > 0)
    {
        TArray<FMoveData> TmpQueue;
        TmpQueue = HeroMoveQueue;
        HeroMoveQueue.Empty();
        for(FMoveData& EachMove : TmpQueue)
        {
            ServerMoveHeros(EachMove.DestLocation, EachMove.Heros);
        }
    }
    if(HeroMoveQueue2D.Num() > 0)
    {
        TArray<FMoveData2D> TmpQueue;
        TmpQueue = HeroMoveQueue2D;
        HeroMoveQueue2D.Empty();
        for(FMoveData2D& EachMove : TmpQueue)
        {
            FHitResult Hit;
            bool res = GetHitResultAtScreenPosition(EachMove.DestLocation, ECC_Visibility, false, Hit);
            ServerMoveHeros(Hit.ImpactPoint, EachMove.Heros);
        }
    }
    if(HeroStopMoveQueue.Num() > 0)
    {
        TArray<AHeroCharacter*> TmpQueue;
        TmpQueue = HeroStopMoveQueue;
        HeroStopMoveQueue.Empty();
        for(AHeroCharacter* EachHero : TmpQueue)
        {
            TArray<AHeroCharacter*> oneHero;
            oneHero.Add(EachHero);
            ServerStopMovement(oneHero);
        }
    }
    if(HeroThrowQueue.Num() > 0)
    {
        TArray<FHeroThrow> TmpQueue;
        TmpQueue = HeroThrowQueue;
        HeroThrowQueue.Empty();
        for(FHeroThrow& EachMove : TmpQueue)
        {
            AHeroCharacter* Selection = EachMove.Heros;
            Selection->WantThrow = Selection->Equipments[EachMove.EquIndex];
            Selection->ThrowDestination = EachMove.DestLocation;
			Selection->WantAttack = NULL;
			Selection->WantPickup = NULL;
            TArray<AHeroCharacter*> oneHero;
            oneHero.Add(EachMove.Heros);
            ServerMoveHeros(EachMove.DestLocation, oneHero);
        }
    }
    if(HeroPickupQueue.Num() > 0)
    {
        TArray<FHeroPickup> TmpQueue;
        TmpQueue = HeroPickupQueue;
        HeroPickupQueue.Empty();
        for(FHeroPickup& EachMove : TmpQueue)
        {
            AHeroCharacter* Selection = EachMove.Heros;
            Selection->WantPickup = EachMove.Equptr;
            Selection->ThrowDestination = EachMove.DestLocation;
			Selection->WantAttack = NULL;
			Selection->WantThrow = NULL;
            TArray<AHeroCharacter*> oneHero;
            oneHero.Add(EachMove.Heros);
            ServerMoveHeros(EachMove.DestLocation, oneHero);
        }
    }
    if(HeroAttackQueue.Num() > 0)
    {
        TArray<FHeroAttack> TmpQueue;
        TmpQueue = HeroAttackQueue;
        HeroAttackQueue.Empty();
        for(FHeroAttack& EachMove : TmpQueue)
        {
            AHeroCharacter* Selection = EachMove.Heros;
            Selection->WantAttack = EachMove.beAttack;
			Selection->WantPickup = NULL;
			Selection->WantThrow = NULL;
            TArray<AHeroCharacter*> oneHero;
            oneHero.Add(EachMove.Heros);
            ServerMoveHeros(EachMove.beAttack->GetActorLocation(), oneHero);
        }
    }
}