Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pView - 
//			nChar - 
//			nRepCnt - 
//			nFlags - 
// Output : Returns true if the message was handled, false otherwise.
//-----------------------------------------------------------------------------
bool Marker3D::OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CMapDoc *pDoc = pView->GetDocument();
	if (pDoc == NULL)
	{
		return false;
	}

	switch (nChar)
	{
		case VK_RETURN:
		{
			//
			// Create the entity or prefab.
			//
			if (!IsEmpty())
			{
				//CreateMapObject(pView); // TODO: support in 3D
			}
			return true;
		}

		case VK_ESCAPE:
		{
			OnEscape();
			return true;
		}
	}

	return false;
}
Ejemplo n.º 2
0
void KAIBase::DoEscape()
{
	//KGLogPrintf(KGLOG_DEBUG, "[AI State] {%s} Turn to Escape\n", m_pSelf->m_szName);
	//逃跑的函数会检测状态,所以要先停下来再逃跑
	m_EscapeData.nEscapeIdleFrame = 0;

	m_pSelf->Stop();
	SetAIState(aisEscape);
	OnEscape();
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output :
//-----------------------------------------------------------------------------
bool Cordon3D::OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if (nChar == VK_ESCAPE)
	{
		OnEscape();
		return true;
	}

	return false;
}
Ejemplo n.º 4
0
void ClientGame::keyPressed(const OIS::KeyEvent& arg)
{
    switch (arg.key)
    {
    case OIS::KC_ESCAPE:
    {
        CEGUI::EventArgs args;
        OnEscape(args);
        break;
    }
    case OIS::KC_F3:
    {
        mFreeCamera = !mFreeCamera;
        ClientApp::GetCamera().setFixedYawAxis(mFreeCamera, ClientApp::GetCamera().getPosition().normalisedCopy());
        break;
    }

    default:
        ;
    }
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: Handles character events.
// Input  : Per CWnd::OnKeyDown.
// Output : Returns true if the message was handled, false if not.
//-----------------------------------------------------------------------------
bool Clipper3D::OnKeyDown3D(CMapView3D *pView, UINT nChar, UINT nRepCnt, UINT nFlags)
{
	switch (nChar)
	{
		case VK_RETURN:
		{
			if (!IsEmpty()) // dvs: what does isempty mean for the clipper?
			{
				SaveClipResults();
			}
			return true;
		}

		case VK_ESCAPE:
		{
			OnEscape();
			return true;
		}
	}

	return false;
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pView - 
//			nChar - 
//			nRepCnt - 
//			nFlags - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool Marker3D::OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags)
{
	switch (nChar)
	{
		case VK_RETURN:
		{
			if (!IsEmpty())
			{
				CreateMapObject(pView);
			}
			return true;
		}

		case VK_ESCAPE:
		{
			OnEscape();
			return true;
		}
	}

	return false;
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : nChar - 
//			nRepCnt - 
//			nFlags - 
//-----------------------------------------------------------------------------
bool Clipper3D::OnKeyDown2D(CMapView2D *pView, UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	switch (nChar)
	{
		case 'O':
		{
			//
			// Toggle the rendering of measurements.
			//
			ToggleMeasurements();
			CMapDoc *pDoc = pView->GetDocument();
			pDoc->ToolUpdateViews(CMapView2D::updTool);
			return true;
		}

		case VK_RETURN:
		{
			//
			// Do the clip.
			//
			if (!IsEmpty() )
			{
				SaveClipResults();
			}
			return true;
		}

		case VK_ESCAPE:
		{
			OnEscape();
			return true;
		}
	}

	return false;	
}
Ejemplo n.º 8
0
void KAIBase::Activate(void)
{
	KG_PROCESS_ERROR(m_pSelf);

	if (m_eAIType <= aitInvalid || m_eAIType >= aitTotal)
		return;

	if (g_pSO3World->m_nGameLoop < m_nNextActiveFrame)
		return;

	m_nNextActiveFrame = g_pSO3World->m_nGameLoop + m_nAIInterval;

	CheckAIEvent();
    // Npc可能在脚本中被删除,所以调用脚本之后要判断下
	KG_PROCESS_ERROR(m_pSelf->m_pScene && m_pSelf->m_pCell && m_pSelf->m_eMoveState != cmsOnDeath);

	if (IS_NPC(m_pSelf->m_dwID))
	{
		if (m_pSelf->m_bFightState)
		{
			//战斗状态中
		}
		else
		{
			//非战斗状态中
			//触发NpcDialog的Idle事件
			if (m_nNextIdleActionFrame < g_pSO3World->m_nGameLoop)
			{
				//-------- AI Event:Idle ---------------------------------
				KTarget rTarget;
				rTarget.ClearTarget();

				g_pSO3World->m_Settings.m_SmartDialogList.FireEvent((KNpc*)m_pSelf, ntatIdle, rTarget);
				//--------------------------------------------------------

				m_nNextIdleActionFrame = g_pSO3World->m_nGameLoop + g_pSO3World->m_Settings.m_ConstList.nNpcIdleActionInterval;
			}
		}
	}

	switch (m_eAIState)
	{    
	case aisIdle:
		OnIdle();
		break;
	case aisWander:
		OnWander();
		break;
	case aisPatrol:
		OnPartol();
		break;
	case aisAlert:
		OnAlert();
		break;
	case aisFollow:
		OnFollow();
		break;
	case aisPursuit:
		OnPursuit();
		break;
	case aisKeepAway:
		OnKeepAway();
		break;
	case aisEscape:
		OnEscape();
		break;
	case aisReturn:
		OnReturn();
		break;
	case aisWait:
		OnWait();
		break;
	default:
		KGLOG_PROCESS_ERROR(FALSE);
		break;
	}
	return;
Exit0:
	return;
}
Ejemplo n.º 9
0
void KAIBase::OnPathResult(BOOL bSucceed)
{
	BOOL bRetCode = FALSE;
	int nMoveState = 0;

	KG_PROCESS_ERROR(m_pSelf);

	nMoveState = m_pSelf->getMoveState();
	KG_PROCESS_ERROR(nMoveState != cmsOnDeath);

	//KGLogPrintf(KGLOG_DEBUG, "[AI] path event : %d , frame : %d\n", bSucceed, g_pSO3World->m_nGameLoop);

	switch (m_eAIState)
	{
	case aisIdle:        
		break;
	case aisWander:
		if (bSucceed)
		{
			// 闲逛一段距离,发一下呆
			DoIdle(m_pAIParam->nWanderInterval);
		}
        else
        {
            // 强制往回走。
            Wander(true);
        }
		break;
	case aisPatrol:
		if (bSucceed)
		{
			// 如果成功了,则发一会儿呆再说
			if (m_pNpcTeam && m_pNpcTeam->m_pLeader != m_pSelf)
			{
				//在Npc队伍中且不是Leader
				OnPartol();
			}
			else
			{
				int nPatrolID = ((KNpc*)m_pSelf)->m_AIData.m_nPatrolPathID;
				KG_PROCESS_ERROR(nPatrolID);

				KPatrolPath* pPatrolPath = g_pSO3World->m_Settings.m_PatrolPathList.GetPatrolPath(m_pSelf->m_pScene->m_dwMapID, nPatrolID);
				int nRestFrame = 0;
				int nFaceTo = -1;

				if(pPatrolPath)
				{
					KPatrolNode rPatrolNode;
					int nIndex = 0;
					int nMemberCount = 0;

					if (m_pNpcTeam)
					{
						nMemberCount = m_pNpcTeam->GetMemberCount();
						for (nIndex = 0; nIndex < nMemberCount; nIndex++)
						{
							KNpc* pMember = m_pNpcTeam->GetMember(nIndex);
							if (pMember && pMember->m_pScene)
							{
								pMember->m_AIController.SetPatrolPath(nPatrolID, m_nNextPartolIndex + 1);
							}
						}
					}
					else
					{
						m_nNextPartolIndex++;
					}

					bRetCode = pPatrolPath->GetPoint(m_nNextPartolIndex - 1, rPatrolNode);
					if (bRetCode)
					{
						nRestFrame = rPatrolNode.nRestFrame;
						nFaceTo = rPatrolNode.nFaceTo;
						
						//触发Npc寻路到达的脚本
						if (rPatrolNode.szScriptName[0] != '\0')
						{
							bRetCode= g_pSO3World->m_ScriptCenter.IsScriptExist(rPatrolNode.szScriptName);
							if (bRetCode && g_pSO3World->m_ScriptCenter.IsFuncExist(rPatrolNode.szScriptName, SCRIPT_ON_PATROL))
							{
								int nTopIndex = 0;
								g_pSO3World->m_ScriptCenter.SafeCallBegin(&nTopIndex);

								g_pSO3World->m_ScriptCenter.PushValueToStack((KNpc*)m_pSelf);
								g_pSO3World->m_ScriptCenter.PushValueToStack(m_nNextPartolIndex);	//Lua的索引从1开始编号,所以不-1

								g_pSO3World->m_ScriptCenter.CallFunction(rPatrolNode.szScriptName, SCRIPT_ON_PATROL, 0);
								g_pSO3World->m_ScriptCenter.SafeCallEnd(nTopIndex);
							}
						}
					}
					KG_PROCESS_ERROR(m_pSelf->m_pScene && m_pSelf->m_pCell && m_pSelf->m_eMoveState != cmsOnDeath);  //Npc可能在脚本中被删除,所以调用脚本之后要判断下

					if (m_nNextPartolIndex >= pPatrolPath->GetPointCount())
						m_nNextPartolIndex = 0;
				}

				if (nFaceTo >= 0 && nRestFrame > 0)
				{
					m_pSelf->Turn(nFaceTo, true, true);
				}
				DoIdle(nRestFrame);
			}
		}
		else
		{
			/*
			// 如果寻路失败了,则换个方向再来
			int nDirection = m_pSelf->m_nFaceDirection + 40;
			if (nDirection >= DIRECTION_COUNT)
				nDirection -= DIRECTION_COUNT;
			KGLOG_PROCESS_ERROR(nDirection >= 0 && nDirection < DIRECTION_COUNT);
			m_pSelf->Turn(nDirection);
			DoPatrol();
			*/

		}
		break;
	case aisAlert:
		break;
	case aisFollow:
		if (bSucceed)
		{
			OnFollow();
		}
		break;
	case aisPursuit:
		if (bSucceed)
		{
			OnPursuit();
		}
		else
		{
			//For Debug
			//KGLogPrintf(KGLOG_DEBUG, "[AI] 追击中寻路失败\n");
		}
		break;
	case aisEscape:
		if (bSucceed)
		{
			// 到了目标点,等一下,接着逃
			m_EscapeData.nEscapeIdleFrame = g_pSO3World->m_nGameLoop + m_pAIParam->nEscapeInterval;
			m_pSelf->Stop();
			OnEscape();
		}
		break;
	case aisReturn:
		if (!bSucceed)
		{
			//返回时寻路失败,传送
			bRetCode = IS_PLAYER(m_pSelf->m_dwID);
			KG_ASSERT_EXIT(!bRetCode);
			KG_ASSERT_EXIT(m_pSelf->m_pScene);

			m_pSelf->MoveTo(m_nReturnX, m_nReturnY, m_nReturnZ);

			m_ReturnData.nReturnFrame = -1;
			m_pSelf->Stop();
			m_pSelf->m_ThreatList.ClearAllThreat();
		}
		else
		{
			m_ReturnData.nReturnFrame = -1;
		}
		break;
	case aisWait:
		break;
	default:
		KGLOG_PROCESS_ERROR(FALSE);
		break;
	}

Exit0:
	return;
}
Ejemplo n.º 10
0
Archivo: GText.cpp Proyecto: FEI17N/Lgi
int TextView::ProcessKey(GKey &K)
{
	Flags &= ~(TVF_GOTO_START | TVF_GOTO_END | TVF_EAT_MOVE);

	if (!K.IsChar)
	{
		if (K.Shift())
		{
			Flags |= TVF_SHIFT;
		}
		else
		{
			Flags &= ~(TVF_SHIFT);
		}

		if (K.Down())
		{
			switch (K.c)
			{
				case VK_ESCAPE:
				{
					OnEscape(K);
					break;
				}
				case VK_RETURN:
				{
					OnEnter(K);
					break;
				}
				case VK_BACK:
				{
					if (K.Alt())
					{
						if (K.Ctrl())
						{
							Doc.Redo(User);
						}
						else
						{
							Doc.Undo(User);
						}

						Dirty(TVF_DIRTY_ALL);
					}
					else
					{
						if (Flags & TVF_SELECTION)
						{
							OnDeleteSelection(FALSE);
							UpdateHiddenCheck();
						}
						else if (User.Y() > 0 || User.X() > 0)
						{
							Flags &= ~(TVF_SHIFT);
							OnMoveCursor(-1, 0);
							OnDeleteText(&User, 1, FALSE);
						}
					}
					break;
				}
				case VK_RIGHT:
				case VK_LEFT:
				{
					bool bLeft = K.c == VK_LEFT;
					int Inc = (bLeft) ? -1 : 1;

					if (bLeft)
					{
						Flags |= TVF_GOTO_START;
					}
					else
					{
						Flags |= TVF_GOTO_END;
					}

					Flags |= TVF_EAT_MOVE;

					if (K.Ctrl())
					{
						char *c = User;

						if (bLeft)
						{
							OnMoveCursor(Inc, 0);
							c = User;
							while (	strchr(WhiteSpace, *c) AND
									OnMoveCursor(Inc, 0))
							{
								c = User;
							}
						}

						if (strchr(Delimiters, *c))
						{
							while (	strchr(Delimiters, *c) AND
									OnMoveCursor(Inc, 0))
							{
								c = User;
							}
						}
						else
						{
							// IsText(*c)
							while (	!strchr(WhiteSpace, *c) AND
									OnMoveCursor(Inc, 0))
							{
								c = User;
							}
						}

						if (bLeft)
						{
							if (User.Y() > 0 || User.X() > 0)
							{
								OnMoveCursor(-Inc, 0);
							}
						}
						else
						{
							while (	strchr(WhiteSpace, *c) AND
									OnMoveCursor(Inc, 0))
							{
								c = User;
							}
						}
					}
					else
					{
						OnMoveCursor(Inc, 0);
					}
					break;
				}
				case VK_UP:
				{
					Flags |= TVF_GOTO_START;
					OnMoveCursor(0, -1);
					break;
				}
				case VK_DOWN:
				{
					Flags |= TVF_GOTO_END;
					OnMoveCursor(0, 1);
					break;
				}
				case VK_PRIOR:
				{
					int Move = 1-DisplayLines;
					OnSetHidden(HiddenLines+Move);
					OnMoveCursor(0, Move);
					break;
				}
				case VK_NEXT:
				{
					int Move = DisplayLines-1;
					OnSetHidden(HiddenLines+Move);
					OnMoveCursor(0, Move);
					break;
				}
				case VK_HOME:
				{
					if (K.Ctrl())
					{
						OnSetCursor(0, 0);
					}
					else
					{
						OnMoveCursor(-User.X(), 0);
					}
					break;
				}
				case VK_END:
				{
					if (K.Ctrl())
					{
						OnSetCursor(1024, Doc.GetLines());
					}
					else
					{
						OnMoveCursor(User.LineLength()-User.X(), 0);
					}
					break;
				}
				case VK_DELETE:
				{
					if (	K.Shift() AND
							(Flags & TVF_SELECTION))
					{
						Cut();
					}
					else
					{
						if (Flags & TVF_SELECTION)
						{
							OnDeleteSelection(FALSE);
							UpdateHiddenCheck();
						}
						else if (	User.Y() < Doc.GetLines() ||
									User.X() < User.LineLength())
						{
							OnDeleteText(&User, 1, FALSE);
						}
					}
					break;
				}
				case VK_INSERT:
				{
					if (Flags & TVF_SELECTION)
					{
						if (K.Ctrl())
						{
							Copy();
						}
					}

					if (K.Shift())
					{
						Paste();
					}
					break;
				}
			}
		}
	}
	else
	{
		// IsChar
		#define EXTENDED (1<<24)

		// if (	!(K.Data & EXTENDED))
		{
			bool InsertChar = K.c >= ' '; //  AND K.c < 128

			if (K.c == 9)
			{
				if ((Flags & TVF_SELECTION) AND Start.Y() != End.Y())
				{
					if (Flags & TVF_SHIFT)
					{
						InsertChar = !OnMultiLineTab(false);
					}
					else
					{
						InsertChar = !OnMultiLineTab(true);
					}
				}
				else
				{
					InsertChar = true;
				}
			}
			
			if (InsertChar)
			{
				char Char[2] = " ";
				Char[0] = K.c;
				if (OnInsertText(Char))
				{
					OnMoveCursor(1, 0, true);
				}
			}
		}
	}

	return TRUE;
}