Exemplo n.º 1
0
//---------------------------------------------------//
// [8/4/2009 Albert]
// Description:	清除路径点
//---------------------------------------------------//
void CDynamicObject::BeginPathPoint()
{
	if( m_hUpdateTimer != INVALID_TIMER_HANDLE )
	{
		unsigned int release_time = ThisTimer()->remove_event( m_hUpdateTimer );
		m_hUpdateTimer = INVALID_TIMER_HANDLE;

		if( release_time > 0 )
		{
			// 计算向量
			XVector3 Vec = m_vNextPosition - GetPosition();
			Vec.NormalizeFast();
			// 剩余了多少距离
			Vec *= release_time/1000.0f;
			// 下此更新坐标和剩余距离的差值则为当前的位置
			m_vNextPosition -= Vec;

			CGameMap* pScene = static_cast< CGameMap* >( CXObjectPool::GetInstance().GetObj( GetParent(), TypeGameMap ) );
			if( pScene )
			{
				if( pScene->DynamicMoveTo( this, m_vNextPosition, false ) )
				{
					OnStep( m_vNextPosition );
				}
			}
		}
	}
	m_PointList.clear();
}
Exemplo n.º 2
0
//---------------------------------------------------//
// [8/5/2009 Albert]
// Description:	移动定时器
//---------------------------------------------------//
bool CDynamicObject::UpdateTimer( unsigned int handle, unsigned short& repeat, unsigned int& timer )
{
	repeat = 1;
	timer = TIMER_SECONDS(1.0f);

	// 先移动到当前所在的位置.
	CGameMap* pScene = static_cast< CGameMap* >( CXObjectPool::GetInstance().GetObj( GetParent(), TypeGameMap ) );
	if( pScene )
	{
		if( pScene->DynamicMoveTo( this, m_vNextPosition, false ) )
		{
			//CLogger::GetInstance(_T("Log"))->WriteLog( _T("角色[%08x]移动到路点[%f,%f,%f]")
			//	, GetObjID()
			//	, m_vNextPosition[0], m_vNextPosition[1], m_vNextPosition[2] );
			OnStep( m_vNextPosition );
		}
		else
		{
			OnArrived( m_vNextPosition );
			return true;
		}
	}
	else
	{
		m_hUpdateTimer = INVALID_TIMER_HANDLE;
		return true;
	}

	// 计算下一个点
	if( m_PointList.empty() ) 
	{
		m_hUpdateTimer = INVALID_TIMER_HANDLE;
		OnArrived( m_vNextPosition );
		return true;
	}

	const PathPoint& target = m_PointList.front();

	XVector3 Vec = target.vPosition - m_vNextPosition;

	float distance = Vec.SqurLength();
	float fSpeed = target.fSpeed;
	if( distance < fSpeed*fSpeed )
	{
		// 当前坐标到目标点的距离小于速度值
		m_vNextPosition = target.vPosition;

		float t = XMath::Sqrt( distance )/fSpeed;
		timer = TIMER_SECONDS(t);
		m_PointList.pop_front();
	}
	else
	{
		Vec.NormalizeFast();
		Vec *= fSpeed;
		m_vNextPosition += Vec;
	}

	return false;
}
Exemplo n.º 3
0
void CProgressMeterClass::OnStepTo(int newPercent)
{
	if (newPercent < percent) {
		lastUpdate = percent = 0;
		RedrawWindow(m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE);
	}
    while (percent<newPercent) 
        OnStep();
}
Exemplo n.º 4
0
GDisAsmView::GDisAsmView(QWidget* parent, EmuThread& emu_thread) : QDockWidget(parent), base_addr(0), emu_thread(emu_thread)
{
    disasm_ui.setupUi(this);

    model = new QStandardItemModel(this);
    model->setColumnCount(3);
    disasm_ui.treeView->setModel(model);

    RegisterHotkey("Disassembler", "Step", QKeySequence(Qt::Key_F10), Qt::ApplicationShortcut);
//    RegisterHotkey("Disassembler", "Step into", QKeySequence(Qt::Key_F11), Qt::ApplicationShortcut);
//    RegisterHotkey("Disassembler", "Pause", QKeySequence(Qt::Key_F5), Qt::ApplicationShortcut);
    RegisterHotkey("Disassembler", "Continue", QKeySequence(Qt::Key_F5), Qt::ApplicationShortcut);
    RegisterHotkey("Disassembler", "Set Breakpoint", QKeySequence(Qt::Key_F9), Qt::ApplicationShortcut);

    connect(disasm_ui.button_breakpoint, SIGNAL(clicked()), this, SLOT(OnSetBreakpoint()));
    connect(disasm_ui.button_step, SIGNAL(clicked()), this, SLOT(OnStep()));
    connect(disasm_ui.button_pause, SIGNAL(clicked()), this, SLOT(OnPause()));
    connect(disasm_ui.button_continue, SIGNAL(clicked()), this, SLOT(OnContinue()));
    connect(GetHotkey("Disassembler", "Step", this), SIGNAL(activated()), this, SLOT(OnStep()));
//    connect(GetHotkey("Disassembler", "Step into", this), SIGNAL(activated()), this, SLOT(OnStepInto()));
//    connect(GetHotkey("Disassembler", "Pause", this), SIGNAL(activated()), this, SLOT(OnPause()));
    connect(GetHotkey("Disassembler", "Continue", this), SIGNAL(activated()), this, SLOT(OnContinue()));
    connect(GetHotkey("Disassembler", "Set Breakpoint", this), SIGNAL(activated()), this, SLOT(OnSetBreakpoint()));
}
Exemplo n.º 5
0
void LifeFrame::OnTimer(wxTimerEvent& WXUNUSED(event))
{
    OnStep();
}
Exemplo n.º 6
0
// OnMenu handles all events which don't have their own event handler
void LifeFrame::OnMenu(wxCommandEvent& event)
{
    switch (event.GetId())
    {
        case wxID_NEW:
        {
            // stop if it was running
            OnStop();
            m_life->Clear();
            m_canvas->Recenter(0, 0);
            m_tics = 0;
            UpdateInfoText();
            break;
        }
        case wxID_ABOUT:
        {
            LifeAboutDialog dialog(this);
            dialog.ShowModal();
            break;
        }
        case wxID_EXIT:
        {
            // true is to force the frame to close
            Close(true);
            break;
        }
        case ID_SHOWNAV:
        {
            bool checked = GetMenuBar()->GetMenu(1)->IsChecked(ID_SHOWNAV);
            if (m_navigator)
                m_navigator->Show(checked);
            break;
        }
        case ID_INFO:
        {
            wxString desc = m_life->GetDescription();

            if ( desc.empty() )
                desc = _("Not available");

            // should we make the description editable here?
            wxMessageBox(desc, _("Description"), wxOK | wxICON_INFORMATION);

            break;
        }
        case ID_START   : OnStart(); break;
        case ID_STEP    : OnStep(); break;
        case wxID_STOP  : OnStop(); break;
        case ID_TOPSPEED:
        {
            m_running = true;
            m_topspeed = true;
            UpdateUI();
            while (m_running && m_topspeed)
            {
                OnStep();
                wxYield();
            }
            break;
        }
    }
}