예제 #1
0
	void AccountActionsManager::handleChangeStatusRequested ()
	{
		auto action = qobject_cast<QAction*> (sender ());
		const auto acc = GetAccountFromSender (sender (), Q_FUNC_INFO);

		QVariant stateVar = action->property ("Azoth/TargetState");
		EntryStatus status;
		if (!stateVar.isNull ())
		{
			const auto state = stateVar.value<State> ();
			status = EntryStatus (state, GetStatusText (action, state));
		}
		else
		{
			SetStatusDialog ssd (acc->GetAccountID ());
			if (ssd.exec () != QDialog::Accepted)
				return;

			status = EntryStatus (ssd.GetState (), ssd.GetStatusText ());
		}

		acc->ChangeState (status);
	}
예제 #2
0
void Engine::Update()
{
	DeltaTime = m_DeltaTimer.restart();
	TotalDeltaTime += DeltaTime;

	if(m_QueuedState != nullptr)
		ChangeState();

	while(m_DisplayWindow.pollEvent(EventHandle))
	{
		if(EventHandle.type == sf::Event::KeyPressed && EventHandle.key.code == sf::Keyboard::Return && EventHandle.key.alt)
		{
			VID_FLAGS ^= sf::Style::Fullscreen;
			m_DisplayWindow.create(sf::VideoMode(RESOLUTION.x, RESOLUTION.y), WINDOW_TITLE, VID_FLAGS);
		}

		if (EventHandle.type == sf::Event::Closed)
			Quit();
	}

	if(m_CurrentState != nullptr)
		m_CurrentState->Update(DeltaTime);
}
예제 #3
0
void CBTHidConnection::OfferControlSocket(const TBTDevAddr& aAddress,
        RSocket*& aSocket)
    {
        TRACE_FUNC
    (_L("[BTHID]\tCBTHidConnection::OfferControlSocket"));
    if (aAddress == iDevice->iAddress)
        {
        __ASSERT_DEBUG((iConnectionState == ELinkLost) || (iConnectionState == EHIDInitConnecting) ||
                (iConnectionState == EHIDReconnecting),
                User::Panic(KPanicBTConnection, ESocketsBadState));

        // Take ownership of this socket
        delete iControlSocket;
        iControlSocket = aSocket;
        aSocket = 0;

        // Mark that the HID Device is reconnecting to us. Skip the state change if an initial connection from HID device. 
        if (iConnectionState != EHIDInitConnecting) 
            {
            ChangeState(EHIDReconnecting);
            }
        }
    }
예제 #4
0
void TCompGuiDrag::Over()
{
	if (checkEnabled()) {
		if (checkOver()) {
			if (controller->IsGuiItemDragged()) {
				SetDragState(Clicked);
			}
			else render_state = RSTATE_OVER;
			if (controller->IsLeftPressed()) {
				SetValue(value - 0.1f);
				notifyValue();
			}
			else if (controller->IsRightPressed()) {
				SetValue(value + 0.1f);
				notifyValue();
			}
		}
		else {
			ChangeState(STRING(Enabled));
			notifyOver(false);
		}
	}
}
예제 #5
0
void MyWorld::TakenTurn()
{
    TurnsLeft--;
    if (TurnsLeft < 0)
    {
        // Play end of round music
        Audio::PlayMusic("game_over.mp3", false);

        // Game over
        ChangeState(eGameState_GameOver);
    }
    else
        TurnsLeftChanged = true;

    if (HasWon())
    {
        // Play end of round music
        Audio::PlayMusic("end_round.mp3", false);

        // Next round
        NextRound();
    }
}
예제 #6
0
void CAICoreEvent::Update(float _fTime)
{
	if( !m_pCurrState )
		return;

	if( m_pCurrState->Update(_fTime) )
	{
		IAIState* pNewState = nullptr;
		
		if( m_pCurrState == &m_cLaserPhase )
		{
			m_pTower->SetShieldActive(false);
			pNewState = &m_cTurretPhase;
		}
		else if( m_pCurrState == &m_cTurretPhase )
			pNewState = &m_cCoreFight;
		
		if( pNewState )
			ChangeState(pNewState);
		else
			CGame::GetInstance()->GetOF()->StopEvent(this);
	}
}
예제 #7
0
void PhoenixEngine::ToggleLoading(bool bToggle)
{
	sf::Context Cont;
	if(m_LoadingState != nullptr)
	{
		if(bToggle)
		{
			bLoading = true;
			m_QueuedState = m_LoadingState;
			ChangeState();
			m_DisplayWindow.setActive(false); //Give thread access to window context
			sf::sleep(sf::milliseconds(100));
			m_AsyncThread.launch();
		}
		else
		{
			bLoading = false;
			m_AsyncThread.wait();
			sf::sleep(sf::milliseconds(100));
			m_DisplayWindow.setActive(true);
		}
	}
}
예제 #8
0
void CThrowBomb::onCreate(const TMsgEntityCreated& msg) {
	if (statemap.empty()) {
		//Specific Bomb nodes
		AddState("born", (statehandler)&CThrowBomb::Born);
		AddState("idle", (statehandler)&CThrowBomb::Idle);
		AddState("throwing", (statehandler)&CThrowBomb::Throwing);
		AddState("throwed", (statehandler)&CThrowBomb::Throwed);
		AddState("impacted", (statehandler)&CThrowBomb::Impacted);
		AddState("explode", (statehandler)&CThrowBomb::Explode);
		AddState("dead", (statehandler)&CThrowBomb::Dead);
	}
	____TIMER_REDEFINE_(t_explode, 2.5f);
	ChangeState("born");
#ifdef CALIBRATE_GAME
	if (calibrate) {
		lmax = lmax_st;
		hmax = hmax_st;
		speed = speed_st;
		t_explode = timer_st;
		rad_squared = powf(radius_st, 2.f);
	}
#endif
}
예제 #9
0
파일: TodoList.cpp 프로젝트: wkcn/TodoList
void TodoList::on_confirmButton_clicked(){
    QString name = ui->nameBox->text();
    if(name.size() == 0){
        warnAniTime = 30;
        return;
    }

    TodoItem item;

    item.SetName(name.toStdString());
    item.SetPlace(ui->placeBox->text().toStdString());
    item.SetContent(ui->contentBox->toPlainText().toStdString());
    item.SetLabel(ui->labelBox->text().toStdString());

    item.SetKind(ui->comboBox->currentIndex());

    QDateTime dateTime = ui->dateTimeEdit->dateTime();
    QDate date = dateTime.date();
    QTime ti = dateTime.time();
    item.SetTime(Date(date.year(),date.month(),date.day(),ti.hour(),ti.minute()));
    item.SetWarnTime(ui->horizontalSlider->value() * 5); //以分为单位

    int level = 0;
    if (ui->radioButton_1->isChecked()) level = 3;
    if (ui->radioButton_2->isChecked()) level = 1;
    if (ui->radioButton_3->isChecked()) level = 2;
    if (ui->radioButton_4->isChecked()) level = 0;
    item.SetLevel(level);

    if(state == WINSTATE::EDIT){
        pa.AddTodo(item);
    }else if(state == WINSTATE::DETAIL){
        pa.ChangeTodo(item,selectID,viewDate.year,viewDate.month);
    }

    ChangeState(WINSTATE::LIST);
}
예제 #10
0
/**
 * \brief determine initial tv state and playgroup for the recording
 * \param islivetv: true if recording is livetv
 */
void PlayerContext::SetInitialTVState(bool islivetv)
{
    TVState newState = kState_None;
    QString newPlaygroup("Default");

    LockPlayingInfo(__FILE__, __LINE__);
    if (islivetv)
    {
        SetTVChain(new LiveTVChain());
        newState = kState_WatchingLiveTV;
    }
    else if (playingInfo)
    {
        int overrecordseconds = gCoreContext->GetNumSetting("RecordOverTime");
        QDateTime curtime = MythDate::current();
        QDateTime recendts = playingInfo->GetRecordingEndTime()
            .addSecs(overrecordseconds);

        if (playingInfo->IsRecording())
        {
            newState = (curtime < recendts) ?
                kState_WatchingRecording : kState_WatchingPreRecorded;
        }
        else if (playingInfo->IsVideoDVD())
            newState = kState_WatchingDVD;
        else if (playingInfo->IsVideoBD())
            newState = kState_WatchingBD;
        else
            newState = kState_WatchingVideo;

        newPlaygroup = playingInfo->GetPlaybackGroup();
    }
    UnlockPlayingInfo(__FILE__, __LINE__);

    ChangeState(newState);
    SetPlayGroup(newPlaygroup);
}
예제 #11
0
int
SetupZilla(short SpriteNum)
{
    SPRITEp sp = &sprite[SpriteNum];
    USERp u;
    ANIMATOR DoActorDecide;

    if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE))
    {
        u = User[SpriteNum];
        ASSERT(u);
    }
    else
    {
        User[SpriteNum] = u = SpawnUser(SpriteNum,ZILLA_RUN_R0,s_ZillaRun[0]);
        u->Health = 6000;
    }

    if (Skill == 0) u->Health = 2000;
    if (Skill == 1) u->Health = 4000;

    ChangeState(SpriteNum,s_ZillaRun[0]);
    u->Attrib = &ZillaAttrib;
    DoActorSetSpeed(SpriteNum, NORM_SPEED);
    u->StateEnd = s_ZillaDie;
    u->Rot = sg_ZillaRun;

    EnemyDefaults(SpriteNum, &ZillaActionSet, &ZillaPersonality);

    sp->clipdist = (512) >> 2;
    sp->xrepeat = 97;
    sp->yrepeat = 79;

    //SET(u->Flags, SPR_XFLIP_TOGGLE);

    return 0;
}
예제 #12
0
//*********************************************************************//
// Terminate
//	- exit the current state
//	- terminate the SGD wrappers
void Game::Terminate( void )
{
	// Exit the current state
	ChangeState( nullptr );


	// Terminate & Deallocate the font
	if( m_pFont != nullptr )
	{
		m_pFont->Terminate();
		delete m_pFont;
	}

	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hMainMenuBackground);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hPlayerImg);
	SGD::GraphicsManager::GetInstance()->UnloadTexture(m_hEnemyImg);

	
	// unloads audio
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hProjectileSecSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hBackgroundMus);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hEnemyHitSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hGameOverSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hGameWinSfx);
	SGD::AudioManager::GetInstance()->UnloadAudio(m_hMenuChangeSfx);

	// Terminate the SGD wrappers (in reverse order)
	SGD::AudioManager::GetInstance()->Terminate();
	SGD::AudioManager::DeleteInstance();
	
	SGD::InputManager::GetInstance()->Terminate();
	SGD::InputManager::DeleteInstance();
	
	SGD::GraphicsManager::GetInstance()->Terminate();
	SGD::GraphicsManager::DeleteInstance();
}
예제 #13
0
void MyCharacter::OnEvent(const irr::SEvent & e)
{	
	
	//键盘事件
	if (e.EventType == EET_KEY_INPUT_EVENT) {
 
		   if ( 
		   //按X 切换 站立 攻击准备模式
			if (e.KeyInput.Key == KEY_KEY_X && e.KeyInput.PressedDown==false) { 
			   ChangeState();
		    }
		   
			//按R 切换跑步走路 模式
			if (e.KeyInput.Key == KEY_KEY_R && e.KeyInput.PressedDown==false) { 
				ChangeRunMode();
		    }

			//按空格,捡物品
			if (e.KeyInput.Key == KEY_SPACE && e.KeyInput.PressedDown==false) { 
				CollectDropItem();
			}


			//按Q 使用包裹里的MP恢复药
			if (e.KeyInput.Key == KEY_KEY_Q && e.KeyInput.PressedDown==false) { 

				//请求使用装备包裹里的消耗品
				property.cmd=CMD_C2S_Request_UsePackageHPItem;
				
				cnet->SendMsg((char*)&property,sizeof(RoleProperty));
			}


	}
	
}
void CMMAVideoPlayer::CompletePrefetch(TInt aError)
{
    ELOG1(EJavaMMAPI,  "CMMAVideoPlayer::CompletePrefetch + error = %d",aError);
    // Post KNotCompleteVideoError as KErrNone to the Java side, because
    // video can be played.
    if (aError == KNotCompleteVideoError)
    {
        LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch  KNotCompleteVideoError ");
        // release java
        PostActionCompleted(KErrNone);
    }
    else
    {
        LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch  CompleteVideoError ");
        // release java
        PostActionCompleted(aError);
    }

    if (aError == KErrNone || aError == KNotCompleteVideoError)
    {
        ChangeState(EPrefetched);
    }
    LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::CompletePrefetch - ");
}
예제 #15
0
//=====================================================================================
//
//	* Function : ChatchChange()
//	* Description 
//		이 함수는 WM_SPOOF에서 List View에 문자열들중 해당구조체가 어느 인덱스를 가지는지
//		출력하는 함수이다.
//		두번째 인자로 받는 포인터에 있는 자료구조의 내용을 사용하고 세번째 인자로 
//		PSPOOF_L자료구조 링크시스트의 헤더를 받도록 약속되어있다.
//
//=====================================================================================
INT ChatchChange(HWND hWnd, PSPOOF_L ARP_LIST, PSPOOF_L HEAD)
{
	INT index=-1;
	INT flag = 0;
	PSPOOF_L tmp=HEAD;
	while(tmp!=NULL)
	{
		index++;
		if(memcmp(ARP_LIST->ipAddr,tmp->ipAddr,4)==0)
			break;
		tmp=tmp->next;
	}

	//scan flag changed
	
	ChangeState();
	InvalidateRect(hC2,NULL,TRUE);
	SendMessage(hC2,WM_PAINT,0,0);
	
	InvalidateRect(hC3,NULL,TRUE);
	SendMessage(hC3,WM_PAINT,0,0);

	return index;
}
예제 #16
0
/*!
 * \brief Performs a turn while doing backward line following.
 * \return Returns TRUE while turn is still in progress.
 */
static uint8_t EvaluateTurnBw(void) {
  REF_LineKind historyLineKind, currLineKind;
  TURN_Kind turn;
  
  REF_ClearHistory(); /* clear values */
  REF_SampleHistory(); /* store current values */
  TURN_Turn(TURN_STEP_LINE_BW); /* make step over line */
  historyLineKind = REF_HistoryLineKind(); /* new read new values */
  currLineKind = REF_GetLineKind();
#if LINE_DEBUG
  REF_DumpHistory();
  CLS1_SendStr((unsigned char*)" history: ", CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)REF_LineKindStr(historyLineKind), CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)" curr: ", CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)REF_LineKindStr(currLineKind), CLS1_GetStdio()->stdOut);
  CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
  turn = MAZE_SelectTurnBw(historyLineKind, currLineKind);
  if (turn==TURN_STOP) { /* should not happen here? */
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"stopped\r\n", CLS1_GetStdio()->stdOut);
    return ERR_FAILED; /* error case */
  } else { /* turn or do something */
#if LINE_DEBUG
    CLS1_SendStr((unsigned char*)"bw turning ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)TURN_TurnKindStr(turn), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
    TURN_Turn(TURN_STEP_LINE_FW); /* step over intersection */
    TURN_Turn(TURN_STEP_POST_LINE_FW); /* step past intersection */
    TURN_Turn(turn); /* make turn */
    MAZE_AddPath(MirrorTurn(turn));
    MAZE_SimplifyPath();
    return ERR_OK; /* turn finished */
  }
}
void CMMAVideoPlayer::PrefetchL()
{
    LOG(EJavaMMAPI, EInfo,  "CMMAVideoPlayer::PrefetchL");
    if (iFileName)
    {
        // File has already been prefetched when realizing

        // If initDisplayMode was called before prefetch,
        // then the display must notified about source size.
        if (iDisplay)
        {
            SourceSizeChanged();
        }

        PostActionCompletedFile();
        ChangeState(EPrefetched);
    }
    else
    {
        // Using TDes -- load the whole video
        iSourceStreams[ 0 ]->ReadAllL();
    }
    // CMMASourceStream will notify with ReadCompleted
}
예제 #18
0
void AMS_OpenBase::OnLowerLayerDown(Master* c)
{
	ChangeState(c, AMS_Closed::Inst());
}
예제 #19
0
bool OPvPCapturePoint::Update(uint32 diff)
{
    if (!m_capturePoint)
        return false;

    float radius = (float)m_capturePoint->GetGOInfo()->controlZone.radius;

    for (uint32 team = 0; team < 2; ++team)
    {
        for (GuidSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();)
        {
            ObjectGuid playerGuid = *itr;
            ++itr;

            if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
                if (!m_capturePoint->IsWithinDistInMap(player, radius) || !player->IsOutdoorPvPActive())
                    HandlePlayerLeave(player);
        }
    }

    std::list<Player*> players;
    Trinity::AnyPlayerInObjectRangeCheck checker(m_capturePoint, radius);
    Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(m_capturePoint, players, checker);
    Cell::VisitWorldObjects(m_capturePoint, searcher, radius);

    for (std::list<Player*>::iterator itr = players.begin(); itr != players.end(); ++itr)
    {
        Player* const player = *itr;
        if (player->IsOutdoorPvPActive())
        {
            if (m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second)
                HandlePlayerEnter(*itr);
        }
    }

    // get the difference of numbers
    float fact_diff = ((float)m_activePlayers[0].size() - (float)m_activePlayers[1].size()) * diff / OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL;
    if (!fact_diff)
        return false;

    uint32 Challenger = 0;
    float maxDiff = m_maxSpeed * diff;

    if (fact_diff < 0)
    {
        // horde is in majority, but it's already horde-controlled -> no change
        if (m_State == OBJECTIVESTATE_HORDE && m_value <= -m_maxValue)
            return false;

        if (fact_diff < -maxDiff)
            fact_diff = -maxDiff;

        Challenger = HORDE;
    }
    else
    {
        // ally is in majority, but it's already ally-controlled -> no change
        if (m_State == OBJECTIVESTATE_ALLIANCE && m_value >= m_maxValue)
            return false;

        if (fact_diff > maxDiff)
            fact_diff = maxDiff;

        Challenger = ALLIANCE;
    }

    float oldValue = m_value;
    TeamId oldTeam = m_team;

    m_OldState = m_State;

    m_value += fact_diff;

    if (m_value < -m_minValue) // red
    {
        if (m_value < -m_maxValue)
            m_value = -m_maxValue;
        m_State = OBJECTIVESTATE_HORDE;
        m_team = TEAM_HORDE;
    }
    else if (m_value > m_minValue) // blue
    {
        if (m_value > m_maxValue)
            m_value = m_maxValue;
        m_State = OBJECTIVESTATE_ALLIANCE;
        m_team = TEAM_ALLIANCE;
    }
    else if (oldValue * m_value <= 0) // grey, go through mid point
    {
        // if challenger is ally, then n->a challenge
        if (Challenger == ALLIANCE)
            m_State = OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE;
        // if challenger is horde, then n->h challenge
        else if (Challenger == HORDE)
            m_State = OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE;
        m_team = TEAM_NEUTRAL;
    }
    else // grey, did not go through mid point
    {
        // old phase and current are on the same side, so one team challenges the other
        if (Challenger == ALLIANCE && (m_OldState == OBJECTIVESTATE_HORDE || m_OldState == OBJECTIVESTATE_NEUTRAL_HORDE_CHALLENGE))
            m_State = OBJECTIVESTATE_HORDE_ALLIANCE_CHALLENGE;
        else if (Challenger == HORDE && (m_OldState == OBJECTIVESTATE_ALLIANCE || m_OldState == OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE))
            m_State = OBJECTIVESTATE_ALLIANCE_HORDE_CHALLENGE;
        m_team = TEAM_NEUTRAL;
    }

    if (m_value != oldValue)
        SendChangePhase();

    if (m_OldState != m_State)
    {
        //TC_LOG_ERROR("outdoorpvp", "%u->%u", m_OldState, m_State);
        if (oldTeam != m_team)
            ChangeTeam(oldTeam);
        ChangeState();
        return true;
    }

    return false;
}
예제 #20
0
/*!
 * \brief Performs a turn.
 * \return Returns TRUE while turn is still in progress.
 */
static uint8_t EvaluteTurn(bool *finished, bool *deadEndGoBw) {
  REF_LineKind historyLineKind, currLineKind;
  TURN_Kind turn;
  
  *finished = FALSE; /* defaults */
  *deadEndGoBw = FALSE; /* default */
  currLineKind = REF_GetLineKind();
  if (currLineKind==REF_LINE_NONE) { /* nothing, must be dead end */
#if PL_GO_DEADEND_BW
    TURN_Turn(TURN_STEP_BW); /* step back so we are again on the line for line following */
    turn = TURN_STRAIGHT;
    *deadEndGoBw = TRUE;
#else
    turn = TURN_LEFT180;
#endif
  } else {
    REF_ClearHistory(); /* clear values */
    REF_SampleHistory(); /* store current values */
    TURN_Turn(TURN_STEP_LINE_FW); /* make forward step over line */
    historyLineKind = REF_HistoryLineKind(); /* new read new values */
    currLineKind = REF_GetLineKind();
  #if LINE_DEBUG
    REF_DumpHistory();
    CLS1_SendStr((unsigned char*)" history: ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)REF_LineKindStr(historyLineKind), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)" curr: ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)REF_LineKindStr(currLineKind), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
  #endif
    turn = MAZE_SelectTurn(historyLineKind, currLineKind);
  }
  if (turn==TURN_FINISHED) {
    *finished = TRUE;
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"finished!\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK;
  } else if (turn==TURN_STRAIGHT && *deadEndGoBw) {
    MAZE_AddPath(TURN_LEFT180); /* would have been a turn around */
    MAZE_SimplifyPath();
    CLS1_SendStr((unsigned char*)"going backward\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK; 
  } else if (turn==TURN_STRAIGHT) {
    MAZE_AddPath(turn);
    MAZE_SimplifyPath();
    CLS1_SendStr((unsigned char*)"going straight\r\n", CLS1_GetStdio()->stdOut);
    return ERR_OK; 
  } else if (turn==TURN_STOP) { /* should not happen here? */
    ChangeState(STATE_STOP);
    CLS1_SendStr((unsigned char*)"stopped\r\n", CLS1_GetStdio()->stdOut);
    return ERR_FAILED; /* error case */
  } else { /* turn or do something */
#if LINE_DEBUG
    CLS1_SendStr((unsigned char*)"turning ", CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)TURN_TurnKindStr(turn), CLS1_GetStdio()->stdOut);
    CLS1_SendStr((unsigned char*)"\r\n", CLS1_GetStdio()->stdOut);
#endif
    if (turn==TURN_LEFT90 || turn==TURN_RIGHT90) {
      TURN_Turn(TURN_STEP_POST_LINE_FW); /* step before doing the turn so we turn on the middle of the intersection */
    }
    TURN_Turn(turn); /* make turn */
    MAZE_AddPath(turn);
    MAZE_SimplifyPath();
    return ERR_OK; /* turn finished */
  }
}
예제 #21
0
/**
* State machine
*/
bool SMRandomPath::States( State_Machine_Event event, MSG_Object* msg, int state, int substate )
{
BeginStateMachine

	// global message responses
    OnMsg(MSG_Damaged)

        // update health and seek player
        m_owner->SetHealth( m_owner->GetHealth() - msg->GetIntData() );
        PushStateMachine( *new SMCombat( m_owner, g_database.Find(m_idPlayer)->GetID(), true) );

    OnMsg(MSG_Reset)

        // reset machine
        ChangeState(STATE_PickPath);

    /*-------------------------------------------------------------------------*/

    DeclareState( STATE_PickPath )
    
        OnEnter

            // start path computation request
            g_world.AddPathRequest(m_owner->GetGridPosition(), g_world.GetRandomMapLocation(), m_owner->GetID());

        OnMsg(MSG_PathComputed)

            // follow path
            ChangeStateDelayed(1.0f, STATE_FollowPath);

    /*-------------------------------------------------------------------------*/
	
    DeclareState( STATE_FollowPath )
	
        OnEnter

            // set velocity
            m_owner->SetVelocity(5.0f);
            m_owner->SetAcceleration(0.5f);

        OnUpdate

            PathWaypointList* waypointList = g_world.GetWaypointList(m_owner->GetID());

            // check if player nearby               
            D3DXVECTOR3 vPlayerDist = m_owner->GetPosition() - g_database.Find(m_idPlayer)->GetPosition();
            if( D3DXVec3Length( &vPlayerDist ) < 4.0f && g_database.Find(m_idPlayer)->GetHealth() > 0 )
            {
                ChangeState( STATE_SwitchToCombat );
            }

            // if out of waypoints, pick new path
            else if(waypointList->empty())
            {
                ChangeState( STATE_PickPath );
            }            
                
            // move towards waypoint
            else
            {
                // determine direction (ignore height)
                D3DXVECTOR2 vDirection = (*waypointList->begin()) - m_owner->GetGridPosition();

                // determine if the object has arrived
	            if( D3DXVec2Length( &vDirection ) < 0.1f )
                {
                    // pop off waypoint
                    waypointList->pop_front();
                }
                else
                {
                    // set object direction towards position
                    D3DXVec2Normalize(&vDirection, &vDirection);
                    m_owner->SetGridDirection(vDirection);
                }
            }

        OnExit

            // remove any waypoints
            g_world.ClearWaypointList(m_owner->GetID());

            // stop object
            m_owner->ResetMovement();

    /*-------------------------------------------------------------------------*/

    DeclareState( STATE_SwitchToCombat )

    	OnEnter
            
            // push combat state machine
            PushStateMachine( *new SMCombat( m_owner, g_database.Find(m_idPlayer)->GetID(), false) );

    /*-------------------------------------------------------------------------*/

EndStateMachine
}
예제 #22
0
void PlayState::Update(sf::Vector2f mouseWorldPos)
{
	currentLevel->Update(mouseWorldPos);
	if (currentLevel->GetSubState() == LEVELOVER)
		ChangeState(new MainMenuState(mGameStateManager));
}
예제 #23
0
파일: boot.cpp 프로젝트: joewan/ValyriaTear
void BootMode::Update()
{
    // Update the game mode generic members.
    GameMode::Update();

    if(_exiting_to_new_game) {
        // When the fade out is done, we start a new game.
        if (!VideoManager->IsFading() && _new_game_called == false) {
            GlobalManager->NewGame();
            _new_game_called = true;
        }
        return;
    }

    // The intro is being played
    if(_boot_state == BOOT_STATE_INTRO) {
        if(InputManager->AnyRegisteredKeyPress()) {
            ChangeState(BOOT_STATE_MENU);
            return;
        } else {
            return; // Otherwise skip rest of the event handling for now
        }
    }

    // Test whether the welcome sequence should be shown once
    static bool language_selection_shown = false;
    if(!language_selection_shown) {
        _ShowLanguageSelectionWindow();
        language_selection_shown = true;
    }

    HelpWindow *help_window = ModeManager->GetHelpWindow();
    if(help_window && help_window->IsActive()) {
        // Any key, except F1
        if(!InputManager->HelpPress()
                && (InputManager->AnyKeyboardKeyPress() || InputManager->AnyJoystickKeyPress())) {
            GlobalManager->Media().PlaySound("confirm");
            help_window->Hide();
        }
        return;
    }

    // Updates the main menu when the option menu handler isn't active.
    bool is_menu_active = _menu_handler.IsActive();
    if(is_menu_active) {
        bool was_showing_first_run_dlg = _menu_handler.IsShowingFirstRunLanguageMenu();
        _menu_handler.Update();

        // We do this to prevent unwanted input going to the main menu
        // after the first app run sequence.
        if (was_showing_first_run_dlg)
            return;
    }
    else {
        _main_menu.Update();
    }

    // Update also the bar and f1 help text alpha
    uint32_t time_expired = SystemManager->GetUpdateTime();
    _boot_timer.Update(time_expired);
    if (_boot_timer.GetTimeExpired() >= 4000.0 && _boot_timer.GetTimeExpired() < 12000.0) {
        _help_text_alpha += 0.001f * time_expired;
        if (_help_text_alpha > 1.0f)
            _help_text_alpha = 1.0f;
    }
    else if (_boot_timer.GetTimeExpired() >= 12000.0 && _boot_timer.GetTimeExpired() < 14000.0) {
        _help_text_alpha -= 0.001f * time_expired;
        if (_help_text_alpha < 0.0f)
            _help_text_alpha = 0.0f;
    }

    if (_menu_bar_alpha < 0.6f) {
        _menu_bar_alpha = _menu_bar_alpha + 0.001f * time_expired;
        if (_menu_bar_alpha >= 0.6f)
            _menu_bar_alpha = 0.6f;
    }

    if (is_menu_active)
        return;

#ifdef DEBUG_FEATURES
    if (_debug_script_menu_open) {
        _debug_script_menu.Update();

        // Check whether we can quit the debug menu.
        if (InputManager->UpPress()) {
            _debug_script_menu.InputUp();
        }
        else if (InputManager->DownPress()) {
            _debug_script_menu.InputDown();
        }
        else if (InputManager->CancelPress()) {
            _debug_script_menu_open = false;
            _debug_scripts_window.Hide();
        }
        else if (InputManager->ConfirmPress()) {
            _DEBUG_OnDebugScriptRun();
        }
        return;
    }
#endif

    // Handles the main menu input.

    // Only quit when we are at the main menu level.
    if(InputManager->QuitPress()) {
        // Don't quit the game when using the joystick,
        // as it is confusing for the user.
        SDL_Event ev = InputManager->GetMostRecentEvent();
        if (ev.type == SDL_KEYDOWN)
            SystemManager->ExitGame();
    }

    if (InputManager->LeftPress()) {
        GlobalManager->Media().PlaySound("bump");
        _main_menu.InputLeft();
        return;
    }
    else if (InputManager->RightPress()) {
        GlobalManager->Media().PlaySound("bump");
        _main_menu.InputRight();
        return;
    }
    else if (!InputManager->ConfirmPress())
        return;

    // Confirm press
    int32_t selection = _main_menu.GetSelection();
    switch(selection) {
    default:
        break;
    case 0: // New Game
        _OnNewGame();
        break;
    case 1:
        _OnLoadGame();
        break;
    case 2:
        _OnOptions();
        break;
#ifdef DEBUG_FEATURES
    // Insert the debug option.
    case 3:
        _DEBUG_OnDebugScriptList();
        break;
    case 4:
        _OnQuit();
        break;
#else
    case 3:
        _OnQuit();
        break;
#endif
    }
}
예제 #24
0
void Widget::on_rbCustom_clicked(bool checked) { if(checked) ChangeState(2); }
예제 #25
0
void Widget::on_rbState2_clicked(bool checked) { if(checked) ChangeState(1); }
예제 #26
0
void AMS_Closed::OnLowerLayerUp(Master* c)
{
	ChangeState(c, AMS_Idle::Inst());
}
예제 #27
0
void AMS_Waiting::OnLowerLayerDown(Master* c)
{
	ChangeState(c, AMS_Closed::Inst());
	c->mpTask->OnFailure();
}
void AIEnemyEliteBatonGaurd::Attack()
{
	int pyt = aio->player_input->GetYTilePos();
	int th = abs(ytile - pyt);

/*#ifdef _DEBUG
	char temp[256];
	sprintf(temp, "[EBG](xt:%d)(yt:%d)(stop:%d)(state:attack)", xtile, ytile, IsStopBlock()); 
	OutputDebugString(temp);
#endif*/

	switch(attackstate)
	{
	case AIS_ATTACK_ATTACK:
	

		if(th <= tileheight )
		{
			
			if(FacePlayer())
			{
				swing_sword = 0;
//				throw_star=0;
			}

			if(fabs(aio->player_input->GetXLoc()-xpos) > attack_range)
			{
				aioutput->moveStop();
				ChangeState(AIS_CHASE);
			}
			else
			{	
				if(swing_sword <=0)
				{
					if(!aiinput->GetStateFlags()->S_DAMAGED)
					{
						swing_sword = time_sword;
						aioutput->SetAttack(0);
						aioutput->moveButton4();
					}

				}
				else swing_sword-=time;
			}
		}
		else
		{
			aioutput->moveStop();
			ChangeState(AIS_PATROL);
		}
		
		break;
	case AIS_ATTACK_WAIT:
		//attackstate = AIS_ATTACK_ATTACK;
		if(th <= tileheight )
		{
			if(fabs(aio->player_input->GetXLoc()-xpos) > attack_range)
			{
				aioutput->moveStop();
				ChangeState(AIS_CHASE);
			}
			else
			{	
				if(!aiinput->GetStateFlags()->S_DAMAGED)
				{
					aioutput->SetAttack(0);
					aioutput->moveButton4();
					movetoxtile = aio->player_input->GetXTilePos() + (int)pow(-1, (rand()%2)+1)*5;
					aioutput->moveStop();
					ChangeState(AIS_MOVE);
				}

			}
		}
		else 
		{
			aioutput->moveStop();
			ChangeState(AIS_PATROL);
		}
		break;
	}
}
예제 #29
0
void CThrowBomb::Born()
{
	nextState = false;
	rd->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, true);
	ChangeState("idle");
}
예제 #30
0
void CThrowBomb::onThrow(const TMsgThrow& msg) {
	dir_throw = msg.dir;
	initThrow();
	GETH_MY(TCompBoneTracker).destroy();
	ChangeState("throwed");
}