Beispiel #1
0
void GCastle::ReceveAttack(gint32 iDamage)
{
	if( mCastleStateFlag == eDestroy )
		return;
	
	mCurrentHP -= iDamage;
	if( GetCurrentHP() <= 0 )
	{
		mCastleStateFlag = eDestroy;
		SetCurrentState();
		return;
	}
	else if( GetCurrentHP() < GetHP() / 2 )
	{
		mCastleStateFlag = eBreak;
		SetCurrentState();
	}	
	GetCastleGege()->SetProgressPercent( (float)GetCurrentHP() / (float)GetHP() * 100.0f );
	
	if( mIsDamage == false )
	{
		mIsDamage = true;
		mpTopDamageEffect->SetVisible( true );
		mpBottomDamageEffect->SetVisible( true );
		GnTimeController::StartTimeControllers( mpTopDamageEffect );
		GnTimeController::StartTimeControllers( mpBottomDamageEffect );
	}
}
void FCrashUpload::PostReportComplete()
{
	if (PauseState == EUploadState::PostingReportComplete)
	{
		// Wait for confirmation
		SetCurrentState(EUploadState::WaitingToPostReportComplete);
		return;
	}

	AssignReportIdToPostDataBuffer();

	
	auto Request = CreateHttpRequest();
	Request->SetVerb( TEXT( "POST" ) );
	Request->SetURL(UrlPrefix / TEXT("UploadComplete"));
	Request->SetHeader( TEXT( "Content-Type" ), TEXT( "text/plain; charset=us-ascii" ) );
	Request->SetContent(PostData);
	UE_LOG( CrashReportClientLog, Log, TEXT( "Sending HTTP request: %s" ), *Request->GetURL() );

	if (Request->ProcessRequest())
	{
		SetCurrentState(EUploadState::PostingReportComplete);
	}
	else
	{
		CheckPendingReportsForFilesToUpload();
	}
}
//-----------------------------------------------------------------------------
// Purpose: updates the building postion and checks the new postion
//-----------------------------------------------------------------------------
void CTFWeaponBuilder::UpdatePlacementState( void )
{
	// This updates the building position
	bool bValidPos = IsValidPlacement();

	// If we're in placement mode, update the placement model
	switch( m_iBuildState )
	{
	case BS_PLACING:
	case BS_PLACING_INVALID:
		{
			if ( bValidPos )
			{
				SetCurrentState( BS_PLACING );
			}
			else
			{
				SetCurrentState( BS_PLACING_INVALID );
			}
		}
		break;

	default:
		break;
	}
}
bool RoomLayoutCtrller::OnPostEvent( const irr::SEvent& evt )
{
	if ( evt.EventType == irr::EET_USER_EVENT )
	{
		if ( evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_DRAWLINE_FINISH )
		{
			::PostMessage((HWND)GetRenderContextSPtr()->GetHandle(), WM_IRR_DLG_MSG, WM_USER_ROOMLAYOUT_DRAWWALL_FINISH, 0);
			SetCurrentState(ERoomLayoutSatate::ERS_BROWSE);
			return true;
		}

		if ( evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTURE_FINISH )
		{
			SetCurrentState(ERoomLayoutSatate::ERS_BROWSE);
			return true;
		}

		if ( evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_DRAWWALL )
		{
			SetCurrentState(ERoomLayoutSatate::ERS_DRAWING);
		}

		if ( evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTURE_ALPHA ||
			evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTURE_VISIBLE ||
			evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTURE_SETTING ||
			evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTUREREFLINE_SIZE ||
			evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTUREREFLINE_DRAW ||
			evt.UserEvent.UserData1 == EUT_ROOMLAYOUT_PICTURE_POSITION)
		{
			SetCurrentState(ERoomLayoutSatate::ERS_PICTURE);
		}
	}

	return StatesController::OnPostEvent(evt);
}
//-----------------------------------------------------------------------------
// Purpose: Idle updates the position of the build placement model
//-----------------------------------------------------------------------------
void CWeaponBuilder::WeaponIdle( void )
{
	CBaseTFPlayer *pOwner = ToBaseTFPlayer( GetOwner() );
	if ( !pOwner )
		return;

	// If we're in placement mode, update the placement model
	switch( m_iBuildState )
	{
	case BS_PLACING:
	case BS_PLACING_INVALID:
		{
			if ( UpdatePlacement() )
			{
				SetCurrentState( BS_PLACING );
			}
			else
			{
				SetCurrentState( BS_PLACING_INVALID );
			}
		}
		break;

	default:
		break;
	}

	if ( HasWeaponIdleTimeElapsed() )
	{
		SendWeaponAnim( ACT_VM_IDLE );
	}
}
void AAssignment_1GameMode::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    
    // Check that we using the Character
    AAssignment_1Character * MyCharacter = Cast<AAssignment_1Character>(UGameplayStatics::GetPlayerPawn(this, 0));
    if (MyCharacter)
    {
        // If our power is greater than needed to win, Set the games state to won
        if (MyCharacter->GetCurrentPower() > PowerToWin)
        {
            SetCurrentState(EBatteryPlayState::EWon);
        }
        // If the character's power is positive
        else if (MyCharacter->GetCurrentPower() > 0.f)
        {
            // Decrease the Character's power using the decay rate
            MyCharacter->UpdatePower(-DeltaTime * DecayRate*(MyCharacter->GetInitialPower()));
        }
        else
        {
            SetCurrentState(EBatteryPlayState::EGameOver);
        }
    }
}
void BallsManager::Update(float dt)
{
    ClearDeadBalls();
    timer.Update(dt);

    if (focus != nullptr) {
        attackHitbox.pos.x = focus->box.pos.x - 45;
        attackHitbox.pos.y = focus->box.pos.y - 70;
        attackHitbox.dim = Vec2(0, 0);
        if (currentState == BallsState::RESTING && timer.Get() >= REST_TIME) {
            currentState = BallsState::WARNING;
            timer.Restart();
            SetCurrentState(WARNING);
        } else if (currentState == BallsState::WARNING &&
                   timer.Get() >= WARN_TIME) {
            currentState = BallsState::ATTACKING;
            timer.Restart();
            SetCurrentState(ATTACKING);
            for (size_t i = 0; (i < ballArray.size()) && (focus != nullptr);
                 i++) {
                Game::GetInstance()->GetCurrentState().AddObject(new Animation(
                    ballArray[i]->box.pos, 0,
                    "sprites/monsters/ball/BOLOTA_BLINK.png", 6, 0.02, true));
            }

        } else if (currentState == BallsState::ATTACKING) {
            attackHitbox.dim = Vec2(220, 180);
            for (size_t i = 0; (i < ballArray.size()) && (focus != nullptr);
                 i++) {
                float angle = 2 * M_PI * (i + 1) / ballArray.size();
                Vec2 pos = Vec2(BALL_EVA_DISTANCE, 60);
                ballArray[i]->box.pos =
                    Vec2(pos.x * cos(angle) - pos.y * sin(angle),
                         pos.y * cos(angle) + pos.x * sin(angle));

                Vec2 evaPos = focus->box.pos + Vec2(0, 70);
                evaPos.y -= focus->box.dim.y / 2;
                ballArray[i]->box.pos += evaPos;

                focus->TakeDamage(ballArray.size() * 1.5);
            }
            if (timer.Get() >= ATTACK_TIME) {
                currentState = BallsState::RESTING;
                RandTeleport();
                timer.Restart();
                SetCurrentState(RESTING);
            }
        }
    } else {
        currentState = BallsState::RESTING;
        SetCurrentState(RESTING);
    }
}
Beispiel #8
0
AWeapon::AWeapon(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer){
	weaponMesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("WeaponMesh"));
	weaponMesh->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::OnlyTickPoseWhenRendered;
	weaponMesh->bChartDistanceFactor = true;
	weaponMesh->bReceivesDecals = false;
	weaponMesh->CastShadow = true;
	weaponMesh->SetCollisionObjectType(ECC_WorldDynamic);
	weaponMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
	weaponMesh->SetCollisionResponseToAllChannels(ECR_Ignore);
	RootComponent = weaponMesh;

	bPlayingAttackAnim = false;
	SetEquiped(false);
	bWantsToAttack = false;
	bPendingEquip = false;
	SetCurrentState(EWeaponState::Idle);

	LastAttackTime = 0.0f;

	PrimaryActorTick.bCanEverTick = true;
	PrimaryActorTick.TickGroup = TG_PrePhysics;
	SetRemoteRoleForBackwardsCompat(ROLE_SimulatedProxy);
	bReplicates = true;
	//bReplicateInstigator = true;
	bNetUseOwnerRelevancy = true;
}
Beispiel #9
0
void FCrashUpload::LocalDiagnosisComplete(const FString& DiagnosticsFile)
{
	if (State >= EUploadState::FirstCompletedState)
	{
		// Must be a failure/cancelled state, or the report was a rejected by the server
		return;
	}

	bool SendDiagnosticsFile = !bDiagnosticsFileSent && !DiagnosticsFile.IsEmpty();

	CRASHREPORTCLIENT_CHECK(PauseState == EUploadState::PostingReportComplete);
	PauseState = EUploadState::Finished;
	if (State == EUploadState::WaitingToPostReportComplete)
	{
		if (SendDiagnosticsFile)
		{
			PendingFiles.Push(DiagnosticsFile);
			SetCurrentState(EUploadState::SendingFiles);
			UploadNextFile();
		}
		else
		{
			PostReportComplete();
		}
	}
	else if (SendDiagnosticsFile)
	{
		PendingFiles.Push(DiagnosticsFile);
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CWeaponBuilder::CanDeploy( void )
{
	if ( m_iCurrentObject != BUILDER_INVALID_OBJECT )
	{
		SetCurrentState( BS_PLACING );
		StartPlacement(); 
		m_flNextPrimaryAttack = gpGlobals->curtime + 0.35f;
	}
	else
	{
		m_hObjectBeingBuilt = NULL;
		SetCurrentState( BS_IDLE );
		SetCurrentObject( m_iCurrentObject );
	}
	return BaseClass::CanDeploy();
}
Beispiel #11
0
void Game::PauseGame()
{
  if (m_pauseState)
  {
    SetCurrentState(m_pauseState);
  }
}
static inline void enter_go_off_one_mode(void){
	SetCurrentState(ECUM_STATE_GO_OFF_ONE);
	EcuM_OnGoOffOne();

	/* @req EcuMf0008 Only set LIN to false when not going to sleep.
	 *                Kind a strange that COMM is deini on the next line.
	 */
	/* @req EcuMf0019 */
	SetComMCommunicationAllowed(ONLY_LIN, FALSE);

#if defined(USE_COMM)
	ComM_DeInit();
#endif

#if defined(USE_BSWM)
	/* @req EcuMf0017 */
	BswM_Deinit();
#endif

#if defined(USE_NVM)

	// Start NvM_WriteAll and timeout timer
	NvM_WriteAll();

	EcuM_World_go_off_one_state_timeout = EcuM_World.config->EcuMNvramWriteAllTimeout / ECUM_MAIN_FUNCTION_PERIOD;
#endif
}
Beispiel #13
0
cPlayerFSM::cPlayerFSM(cGameObject* _pOwner, cIState* _pState)
{
	m_pOwner = _pOwner;
	SetGlobalState(new cPlayerState(_pState));
	SetCurrentState(cIdleState::GetInstance());
	m_pOwner->GetAction()->SetOwner(_pOwner);
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::Deploy( void )
{
	bool bDeploy = BaseClass::Deploy();

	if ( bDeploy )
	{
		SetCurrentState( BS_PLACING );
		StartPlacement(); 
		m_flNextPrimaryAttack = gpGlobals->curtime + 0.35f;
		m_flNextSecondaryAttack = gpGlobals->curtime;		// asap

		CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
		if (!pPlayer)
			return false;

		pPlayer->SetNextAttack( gpGlobals->curtime );

		m_iWorldModelIndex = modelinfo->GetModelIndex( GetWorldModel() );

		m_flNextDenySound = 0;

		// Set off the hint here, because we don't know until now if our building
		// is rotate-able or not.
		if ( m_hObjectBeingBuilt && !m_hObjectBeingBuilt->MustBeBuiltOnAttachmentPoint() )
		{
			// set the alt-fire hint so it gets removed when we holster
			m_iAltFireHint = HINT_ALTFIRE_ROTATE_BUILDING;
			pPlayer->StartHintTimer( m_iAltFireHint );
		}
	}

	return bDeploy;
}
void CNetServiceBase::SerRun()
{
	if (m_ListenPort == 0) {
		throw std::exception("port must be set");
	}
	mIOCPMgr = new CIOCPManager();
	mSerList = new CIOCPBaseList(mIOCPMgr);

	DOnIOCPBaseEvent iocp_event(this, reinterpret_cast<EOnIOCPBaseEvent>(&CNetServiceBase::IOCPEvent));
	mSerList->SetIOCPEvent(iocp_event);

	mExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

	mSockLst = new CSocketLst();
	// 启动监听
	if (mSockLst->StartListen(mSerList, m_ListenPort)) {
		//
		SetCurrentState(SERVICE_RUNNING);
		// 等待退出
		WaitForSingleObject(mExitEvent, INFINITE);
		mSockLst->Close();
	} else {
		OutputDebugStr(_T("启动监听失败!\n"));
		delete mSockLst;
		mSockLst = NULL;
	}

	CloseHandle(mExitEvent);
	delete mSerList;
	delete mIOCPMgr;

	mSerList = NULL;
	mIOCPMgr = NULL;
}
DWORD CNetServiceBase::SerHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData)
{
	// Handle the requested control code.
	switch (dwControl){
	case SERVICE_CONTROL_STOP:
	case SERVICE_CONTROL_SHUTDOWN:
		// 关闭服务
		OutputDebugStr(_T("服务端接收到关闭命令\n"));
		SetExitEvent();
		break;
	case SERVICE_CONTROL_INTERROGATE:
		break;
	case SERVICE_CONTROL_PAUSE:
		break;
	case SERVICE_CONTROL_CONTINUE:
		break;
		// invalid control code
	default:
		// update the service status.
		SetCurrentState(GetCurrentState());
		return ERROR_CALL_NOT_IMPLEMENTED;
		break;
	}
	return NO_ERROR;
}
void ABatteryCollectorGameMode::BeginPlay() {
    Super::BeginPlay();

    // find all spawn volume Actors
    TArray<AActor*> FoundActors;
    UGameplayStatics::GetAllActorsOfClass(GetWorld(), ASpawnVolume::StaticClass(), FoundActors);

    for (auto Actor : FoundActors)
    {
        ASpawnVolume* SpawnVolumeActor = Cast<ASpawnVolume>(Actor);
        if (SpawnVolumeActor)
        {
            SpawnVolumeActors.AddUnique(SpawnVolumeActor);
        }
    }

    SetCurrentState(EBatteryPlayState::EPlaying);

    ABatteryCollectorCharacter* MyCharacter = Cast<ABatteryCollectorCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
    if (MyCharacter) {
        PowerToWin = (MyCharacter->GetInitialPower()) * 1.25f;
    }

    if (HUDWidgetClass != nullptr) {
        CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), HUDWidgetClass);
        if (CurrentWidget != nullptr)
        {
            CurrentWidget->AddToViewport();
        }
    }
}
/**
 * RUN II entry
 * - Called from EcuM_StartupTwo()
 * - Called from
 *
 *
 */
void EcuM_enter_run_mode(void){
	EcuM_OnEnterRun(); /** @req EcuMf2308 */

	/* @req EcuMf0019 */
	/* @req EcuMf0008 */
	SetComMCommunicationAllowed(ALL, TRUE);

	/*
	 * time we could leave the state before it has been completed.
	 */
	SetCurrentState(ECUM_STATE_APP_RUN);

#if defined(USE_COMM) && (ECUM_AR_VERSION < 40000)
	/* !req EcuMf0027
	 * ECU in RUN state shall also perform wake up validation of sleeping busses
	 */
	{
		uint32 cMask = EcuM_World.run_comm_requests;
		uint8  channel;

		for (; cMask; cMask &= ~(1ul << channel)) {
			channel = ilog2(cMask);
			DEBUG_ECUM_CALLOUT_W_ARG("ComM_EcuM_RunModeIndication","%ld",(uint32)channel);
			ComM_EcuM_RunModeIndication(channel);
		}
	}
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Player holding this weapon has started building something
//-----------------------------------------------------------------------------
void CWeaponBuilder::StartBuilding( void )
{
	if ( m_hObjectBeingBuilt.Get() && UpdatePlacement() )
	{
		SetCurrentState( BS_BUILDING );
		m_hObjectBeingBuilt->StartBuilding( GetOwner() );
	}
}
void updateStatisticsFrame() {
    UIParent()->HideChildren();

    if (GetGame().GetLevel().IsFailed() == true) {
        app()>SetCurrentState(AppState::Menu);
    } else if (GetGame().GetLevel().IsCompleted() = true) {
        if (GetGame().GetLevel().HasNext() == true) {
            GetGame().LoadLevel(GetGame().GetLevel().GetNext());
            RestoreGameWindows();
        } else {
            app()>SetCurrentState(AppState::Menu);
        }
    } else {
        GetGame().SetState(GameState::Level);
        RestoreGameWindows();
    }
}
void ABatteryCollectorGameMode::Tick(float DeltaTime) {
    Super::Tick(DeltaTime);

    ABatteryCollectorCharacter* MyCharacter = Cast<ABatteryCollectorCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
    if (MyCharacter) {

        // If our power is greater than needed to win, set the game's state to Won
        if (MyCharacter->GetCurrentPower() > PowerToWin) {
            SetCurrentState(EBatteryPlayState::EWon);
        }
        else if (MyCharacter->GetCurrentPower() > 0) {
            MyCharacter->UpdatePower(-DeltaTime * DecayRate * (MyCharacter->GetInitialPower()));
        }
        else {
            SetCurrentState(EBatteryPlayState::EGameOver);
        }
    }
}
void ABatteryCollectorGameMode::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	ABatteryCollectorCharacter* myCharacter = Cast<ABatteryCollectorCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
	if (myCharacter)
	{
		if ((myCharacter->GetCurrentPower()) > powerToWin) {
			SetCurrentState(EBatteryPlayState::EWon);
		}
		else if ((myCharacter->GetCurrentPower()) > 0) {
			myCharacter->UpdatePower(-DeltaTime * decayRate * (myCharacter->GetInitialPower()));
		}
		else {
			SetCurrentState(EBatteryPlayState::EGameOver);
		}
	}
}
Beispiel #23
0
void FCrashUpload::CheckPendingReportsForFilesToUpload()
{
	SetCurrentState(EUploadState::CheckingReport);
	do
	{
		if (PendingReportDirectories.Num() == 0)
		{
			// Nothing to upload
			UE_LOG(CrashReportClientLog, Log, TEXT("All uploads done"));
			SetCurrentState(EUploadState::Finished);
			return;
		}

		ErrorReport = FPlatformErrorReport(PendingReportDirectories.Pop());
		PendingFiles = ErrorReport.GetFilesToUpload();
	}
	while (PendingFiles.Num() == 0 || !SendCheckReportRequest());
}
//-----------------------------------------------------------------------------
// Purpose: Stop placement when holstering
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::Holster( CBaseCombatWeapon *pSwitchingTo )
{
	if ( m_iBuildState == BS_PLACING || m_iBuildState == BS_PLACING_INVALID )
	{
		SetCurrentState( BS_IDLE );
	}
	StopPlacement();

	return BaseClass::Holster(pSwitchingTo);
}
Beispiel #25
0
void FCrashUpload::OnPingSuccess()
{
	if (PauseState > EUploadState::Ready)
	{
		BeginUploadImpl();
	}
	else
	{
		// Await instructions
		SetCurrentState(EUploadState::Ready);
	}
}
//-----------------------------------------------------------------------------
// Purpose: Player holding this weapon has aborted the build of an object
//-----------------------------------------------------------------------------
void CWeaponBuilder::StoppedBuilding( int iObjectType )
{
	CBaseTFPlayer *pPlayer = ToBaseTFPlayer( GetOwner() );
	if ( pPlayer )
	{
		// Force a recalculation of the state for this object
		SetCurrentObject( m_iCurrentObject );
		SetCurrentState( BS_IDLE );

		WeaponSound( SPECIAL2 );
	}
}
void AMaximumTopSpinGameState::PlayerDied(AMaximumTopSpinBall* DeadPlayer)
{
	DeadPlayer->stats.Lives--;

	/** check remaining lives and respawn or remove */
	if (DeadPlayer->stats.Lives == 0)
		ActivePlayerPawns.Remove(DeadPlayer);
	else
		DeadPlayer->Respawn();	//let the ball handle resetting its vars to respawn

	if (ActivePlayerPawns.Num() == 1)
		SetCurrentState(EMaximumTopSpinPlayState::EGameOver);
}
//-----------------------------------------------------------------------------
// Purpose: The player holding this weapon has just finished building an object
//-----------------------------------------------------------------------------
void CWeaponBuilder::FinishedObject( void )
{
	CBaseTFPlayer *pPlayer = ToBaseTFPlayer( GetOwner() );
	if ( pPlayer )
	{
		// We're no longer building anything...
		m_hObjectBeingBuilt = NULL;

		// Force a recalculation of the state for this object
		SetCurrentObject( m_iCurrentObject );
		SetCurrentState( BS_IDLE );
	}
}
void RoomLayoutCtrller::Init()
{
	//ÁÙġͼ
	AddController(ERoomLayoutSatate::ERS_PICTURE, std::make_shared<RoomLayoutPictureCtrller>(GraphODL_, GetRenderContextSPtr()));

	//»æÖÆ
	AddController(ERoomLayoutSatate::ERS_DRAWING, std::make_shared<RoomLayoutDrawingCtrller>(GraphODL_, GetRenderContextSPtr()));

	//ä¯ÀÀ
	AddController(ERoomLayoutSatate::ERS_BROWSE, std::make_shared<RoomLayoutBrowserCtrller>(GraphODL_, GetRenderContextSPtr()));

	//ĬÈÏ״̬
	SetCurrentState(ERoomLayoutSatate::ERS_BROWSE);
}
void AUETutorialGameMode::Tick(float DeltaSeconds)
{
	AUETutorialCharacter * MyCharacter = Cast<AUETutorialCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));

	if (MyCharacter->PowerLevel > 1.0)
	{
		MyCharacter->PowerLevel = FMath::FInterpTo(MyCharacter->PowerLevel, 0.f, DeltaSeconds, DecayRate);
	}
	else
	{
		MyCharacter->PowerLevel = 0.0;
		SetCurrentState(EUETutorialGameModeState::EGameOver);
	}
}