Ejemplo n.º 1
0
void cMonster::InStateIdle(std::chrono::milliseconds a_Dt)
{
	if (m_IsFollowingPath)
	{
		return;  // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > std::chrono::seconds(1))
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= std::chrono::seconds(1);  // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
		Dist.z = (double)m_World->GetTickRandomNumber(10) - 5;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{
			Vector3d Destination(GetPosX() + Dist.x, 0, GetPosZ() + Dist.z);
			Destination.y = FindFirstNonAirBlockPosition(Destination.x, Destination.z);
			MoveToPosition(Destination);
		}
	}
}
Ejemplo n.º 2
0
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(float a_Dt)
{
	super::InStateChasing(a_Dt);
	m_ChaseTime += a_Dt;
	if (m_Target != NULL)
	{
		if (m_Target->IsPlayer())
		{
			cPlayer * Player = (cPlayer *) m_Target;
			if (Player->GetGameMode() == 1)
			{
				m_EMState = IDLE;
				return;
			}
		}

		Vector3f Pos = Vector3f( GetPosition() );
		Vector3f Their = Vector3f( m_Target->GetPosition() );
		if ((Their - Pos).Length() <= m_AttackRange)
		{
			cMonster::Attack(a_Dt);
		}
		MoveToPosition(Their + Vector3f(0, 0.65f, 0));
	}
	else if (m_ChaseTime > 5.f)
	{
		m_ChaseTime = 0;
		m_EMState = IDLE;
	}	
} 
Ejemplo n.º 3
0
// What to do if in Idle State
void cMonster::InStateIdle(float a_Dt)
{
	idle_interval += a_Dt;
	if (idle_interval > 1)
	{
		// at this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		// LOGD("Moving: int: %3.3f rem: %i",idle_interval,rem);
		idle_interval -= 1;		// So nothing gets dropped when the server hangs for a few seconds
		Vector3f Dist;
		Dist.x = (float)(m_World->GetTickRandomNumber(10) - 5);
		Dist.z = (float)(m_World->GetTickRandomNumber(10) - 5);
		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{
			m_Destination.x = (float)(GetPosX() + Dist.x);
			m_Destination.z = (float)(GetPosZ() + Dist.z);
			int PosY;
			if (m_World->TryGetHeight((int)m_Destination.x, (int)m_Destination.z, PosY))
			{
				m_Destination.y = (float)PosY + 1.2f;
				MoveToPosition(m_Destination);
			}
		}
	}
}
Ejemplo n.º 4
0
void cMonster::InStateIdle(float a_Dt)
{
	if (m_bMovingToDestination)
	{
		return; // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > 1)
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = (double)m_World->GetTickRandomNumber(10) - 5;
		Dist.z = (double)m_World->GetTickRandomNumber(10) - 5;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{
			Vector3d Destination(GetPosX() + Dist.x, 0, GetPosZ() + Dist.z);

			int NextHeight = FindFirstNonAirBlockPosition(Destination.x, Destination.z);

			if (IsNextYPosReachable(NextHeight))
			{
				Destination.y = NextHeight;
				MoveToPosition(Destination);
			}
		}
	}
}
Ejemplo n.º 5
0
void cWolf::TickFollowPlayer()
{
	class cCallback :
		public cPlayerListCallback
	{
		virtual bool Item(cPlayer * a_Player) override
		{
			OwnerPos = a_Player->GetPosition();
			return false;
		}
	public:
		Vector3d OwnerPos;
	} Callback;

	if (m_World->DoWithPlayer(m_OwnerName, Callback))
	{
		// The player is present in the world, follow him:
		double Distance = (Callback.OwnerPos - GetPosition()).Length();
		if (Distance > 20)
		{
			Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z);
			TeleportToCoords(m_World, Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
		}
		else
		{
			MoveToPosition(Callback.OwnerPos);
		}
	}
}
// 专门为两个从属thumb movepage使用
void CTripleLinkageOpt::LBtnUpForOtherThumb(const CPoint& point)
{
    if(m_bStartDraging)// begin to drag?
    {
        CFSBThumb* pThumb = m_szThumb[m_nFocusThumb];

        m_bStartDraging = FALSE;
        //ReleaseCapture();

        int nPos = SearchThumbPosition(point);

        int nMin, nMax;
        GetThumbRange(m_nFocusThumb,  nMin, nMax);

        if (nPos >= nMax)
        {
            nPos = nMax;
        }
        if(nPos <= nMin)
        {
            nPos = nMin;
        }
        pThumb->SetPosition(nPos);

        MoveToPosition(m_nFocusThumb, nPos);
    }
}
void CMultiThumbOpt::OnLButtonUp(const CPoint& point)
{
	if(m_bStartDraging)// begin to drag?
	{
		CFSBThumb* pThumb = m_szThumb[m_nFocusThumb];

		m_bStartDraging = FALSE;
		//ReleaseCapture();

		int nPos = SearchThumbPosition(point);

		int nMin, nMax;
		GetThumbRange(m_nFocusThumb,  nMin, nMax);
		if (nPos >= nMax)
		{
			nPos = nMax;
		}
		if(nPos <= nMin)
		{
			nPos = nMin;
		}
		pThumb->SetPosition(nPos);

		MoveToPosition(m_nFocusThumb, nPos);

		ReCalcChannelRect();
	}
	((CFlexSlideWnd*)m_pParent)->SendCallBackMsg();
}
Ejemplo n.º 8
0
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
    super::InStateChasing(a_Dt, a_Chunk);

    if (m_Target != nullptr)
    {
        MoveToPosition(m_Target->GetPosition());
    }
}
Ejemplo n.º 9
0
void cOcelot::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	if (!IsTicking())
	{
		// The base class tick destroyed us
		return;
	}

	if (!IsTame() && !IsBaby())
	{
		if (m_CheckPlayerTickCount == 23)
		{
			m_World->DoWithNearestPlayer(GetPosition(), 10, [&](cPlayer & a_Player) -> bool
			{
				cItems Items;
				GetBreedingItems(Items);
				if (Items.ContainsType(a_Player.GetEquippedItem().m_ItemType))
				{
					if (!IsBegging())
					{
						SetIsBegging(true);
						m_World->BroadcastEntityMetadata(*this);
					}

					MoveToPosition(a_Player.GetPosition());
				}
				else
				{
					if (IsBegging())
					{
						SetIsBegging(false);
						m_World->BroadcastEntityMetadata(*this);
					}
				}

				return true;
			}, true);
			m_CheckPlayerTickCount = 0;
		}
		else
		{
			m_CheckPlayerTickCount++;
		}
	}

	if (IsTame() && !IsSitting())
	{
		TickFollowPlayer();
	}
	else if (IsSitting())
	{
		StopMovingToPosition();
	}

	m_World->BroadcastEntityMetadata(*this);
}
Ejemplo n.º 10
0
void hhCenturion::Event_MoveToTunnel() {
	if (!armchop_Target.IsValid()) {
		idThread::ReturnInt(0);
		return;
	}

	StopMove(MOVE_STATUS_DONE);
	MoveToPosition(armchop_Target->GetOrigin());
	idThread::ReturnInt(1);
}
Ejemplo n.º 11
0
void hhCenturion::Event_MoveToObstruction() {
	idVec3 temp;
	if ( aas ) {
		int toAreaNum = PointReachableAreaNum( pillarEntity.GetEntity()->GetOrigin() );
		temp = pillarEntity.GetEntity()->GetOrigin();
		aas->PushPointIntoAreaNum( toAreaNum, temp );
		MoveToPosition( temp );
	} else {
		gameLocal.Warning( "Centurion has no aas for MoveToObstruction\n" );
	}
}
void CTripleLinkageOpt::SetThumbPosition(int nIndex, int nPosition)
{
    if (nIndex < 3)
    {
        m_szThumb[nIndex]->SetPosition(nPosition);
        //m_szThumb[nIndex]->MoveThumb(nPosition);
        MoveToPosition(nIndex, nPosition);
    }

//////////////////////////////////////////////////////////////////////////
//	MoveToPosition(nIndex, nPosition);
    ReCalcChannelRect();
}
void CMultiThumbOpt::SetThumbPosition(int nIndex, int nPosition)
{	
	if (nPosition >= (int)m_szTicMarks->size())   // 超过刻度那么裁减掉
	{
		nPosition = m_szTicMarks->size()-1;
	}

	if (nIndex < (int)m_szThumb.size())
	{
		MoveToPosition(nIndex, nPosition);
		ReCalcChannelRect();
	}	
}
Ejemplo n.º 14
0
    void MoveInLineOfSight(Unit* pWho)
    {
        // start intro (summon initiates, speach, etc handled in UpdateAI)
        if (Phase == PHASE_BEFORE_INTRO && pWho->GetTypeId() == TYPEID_PLAYER && m_creature->GetDistance(pWho) <= 35.0f)
        {
            MoveToPosition(true);
            Phase = PHASE_INTRO;
            return;
        }

        // if passed intro return regular ScriptedAI behaviur
        if (Phase == PHASE_READY_TO_ATTACK)
            ScriptedAI::MoveInLineOfSight(pWho);
    }
Ejemplo n.º 15
0
void cPig::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

	// If the attachee player is holding a carrot-on-stick, let them drive this pig:
	if (m_bIsSaddled && (m_Attachee != NULL))
	{
		if (m_Attachee->IsPlayer() && (m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK))
		{
			MoveToPosition((m_Attachee->GetPosition()) + (m_Attachee->GetLookVector()*10));
			m_bMovingToDestination = true;
		}
	}
}
Ejemplo n.º 16
0
// What to do if in Escaping State
void cMonster::InStateEscaping(std::chrono::milliseconds a_Dt)
{
	UNUSED(a_Dt);

	if (m_Target != nullptr)
	{
		Vector3d newloc = GetPosition();
		newloc.x = (m_Target->GetPosition().x < newloc.x)? (newloc.x + m_SightDistance): (newloc.x - m_SightDistance);
		newloc.z = (m_Target->GetPosition().z < newloc.z)? (newloc.z + m_SightDistance): (newloc.z - m_SightDistance);
		MoveToPosition(newloc);
	}
	else
	{
		m_EMState = IDLE;  // This shouldnt be required but just to be safe
	}
}
Ejemplo n.º 17
0
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt)
{
	super::InStateChasing(a_Dt);

	if (m_Target != nullptr)
	{
		if (m_Target->IsPlayer())
		{
			if (((cPlayer *)m_Target)->IsGameModeCreative())
			{
				m_EMState = IDLE;
				return;
			}
		}
		MoveToPosition(m_Target->GetPosition());
	}
}
Ejemplo n.º 18
0
void cMonster::InStateIdle(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	if (m_PathfinderActivated)
	{
		return;  // Still getting there
	}

	m_IdleInterval += a_Dt;

	if (m_IdleInterval > std::chrono::seconds(1))
	{
		// At this interval the results are predictable
		int rem = m_World->GetTickRandomNumber(6) + 1;
		m_IdleInterval -= std::chrono::seconds(1);  // So nothing gets dropped when the server hangs for a few seconds

		Vector3d Dist;
		Dist.x = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;
		Dist.z = static_cast<double>(m_World->GetTickRandomNumber(10)) - 5.0;

		if ((Dist.SqrLength() > 2)  && (rem >= 3))
		{

			Vector3d Destination(GetPosX() + Dist.x, GetPosition().y, GetPosZ() + Dist.z);

			cChunk * Chunk = a_Chunk.GetNeighborChunk(static_cast<int>(Destination.x), static_cast<int>(Destination.z));
			if ((Chunk == nullptr) || !Chunk->IsValid())
			{
				return;
			}

			BLOCKTYPE BlockType;
			NIBBLETYPE BlockMeta;
			int RelX = static_cast<int>(Destination.x) - Chunk->GetPosX() * cChunkDef::Width;
			int RelZ = static_cast<int>(Destination.z) - Chunk->GetPosZ() * cChunkDef::Width;
			int YBelowUs = static_cast<int>(Destination.y) - 1;
			if (YBelowUs >= 0)
			{
				Chunk->GetBlockTypeMeta(RelX, YBelowUs, RelZ, BlockType, BlockMeta);
				if (BlockType != E_BLOCK_STATIONARY_WATER)  // Idle mobs shouldn't enter water on purpose
				{
					MoveToPosition(Destination);
				}
			}
		}
	}
}
Ejemplo n.º 19
0
void cVillager::HandleFarmerPrepareFarmCrops()
{
	if (!m_World->VillagersShouldHarvestCrops())
	{
		return;
	}

	cBlockArea Surrounding;

	// Read a 11x7x11 area:
	Surrounding.Read(
		m_World,
		FloorC(GetPosX()) - 5,
		FloorC(GetPosX()) + 6,
		FloorC(GetPosY()) - 3,
		FloorC(GetPosY()) + 4,
		FloorC(GetPosZ()) - 5,
		FloorC(GetPosZ()) + 6
	);

	for (int I = 0; I < 5; I++)
	{
		for (int Y = 0; Y < 6; Y++)
		{
			// Pick random coordinates and check for crops.
			int X = m_World->GetTickRandomNumber(11);
			int Z = m_World->GetTickRandomNumber(11);

			// A villager can't farm this.
			if (!IsBlockFarmable(Surrounding.GetRelBlockType(X, Y, Z)))
			{
				continue;
			}
			if (Surrounding.GetRelBlockMeta(X, Y, Z) != 0x7)
			{
				continue;
			}

			m_VillagerAction = true;
			m_CropsPos = Vector3i(static_cast<int>(GetPosX()) + X - 5, static_cast<int>(GetPosY()) + Y - 3, static_cast<int>(GetPosZ()) + Z - 5);
			MoveToPosition(Vector3f(static_cast<float>(m_CropsPos.x + 0.5), static_cast<float>(m_CropsPos.y), static_cast<float>(m_CropsPos.z + 0.5)));
			return;
		}  // for Y loop.
	}  // Repeat the procces 5 times.
}
Ejemplo n.º 20
0
void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);
	if (!IsTicking())
	{
		// The base class tick destroyed us
		return;
	}

	// If the attachee player is holding a carrot-on-stick, let them drive this pig:
	if (m_bIsSaddled && (m_Attachee != nullptr))
	{
		if (m_Attachee->IsPlayer() && (m_Attachee->GetEquippedWeapon().m_ItemType == E_ITEM_CARROT_ON_STICK))
		{
			MoveToPosition((m_Attachee->GetPosition()) + (m_Attachee->GetLookVector()*10));
		}
	}
}
Ejemplo n.º 21
0
void cWolf::TickFollowPlayer()
{
	Vector3d OwnerPos;
	bool OwnerFlying;
	auto Callback = [&](cPlayer & a_Player)
	{
		OwnerPos = a_Player.GetPosition();
		OwnerFlying = a_Player.IsFlying();
		return true;
	};

	if (m_World->DoWithPlayerByUUID(m_OwnerUUID, Callback))
	{
		// The player is present in the world, follow him:
		double Distance = (OwnerPos - GetPosition()).Length();
		if (Distance > 20)
		{
			if (!OwnerFlying)
			{
				OwnerPos.y = FindFirstNonAirBlockPosition(OwnerPos.x, OwnerPos.z);
				TeleportToCoords(OwnerPos.x, OwnerPos.y, OwnerPos.z);
				SetTarget(nullptr);
			}
		}
		if (Distance < 2)
		{
			if (GetTarget() == nullptr)
			{
				StopMovingToPosition();
			}
		}
		else
		{
			if (GetTarget() == nullptr)
			{
				if (!OwnerFlying)
				{
					MoveToPosition(OwnerPos);
				}
			}
		}
	}
}
Ejemplo n.º 22
0
    void SummonedCreatureJustDied(Creature* pSummoned)
    {

        if (pSummoned->GetEntry() == MOB_INITIATE)
        {
            lInitiates.remove(pSummoned->GetGUID());

            if (lInitiates.empty())
            {
                Phase = PHASE_READY_TO_ATTACK;
                MoveToPosition(false);
            }
        }
        else if (pSummoned->GetEntry() == MOB_VOLUNTEER)
        {
            lVolunteers.remove(pSummoned->GetGUID());
            bSacrificeEnding = true;
        }
    }
Ejemplo n.º 23
0
    void SummonedCreatureJustDied(Creature* pSummoned)
    {

        if (pSummoned->GetEntry() == NPC_TWILIGHT_INITIATE)
        {
            lInitiates.remove(pSummoned->GetObjectGuid());

            if (lInitiates.empty())
            {
                Phase = PHASE_READY_TO_ATTACK;
                MoveToPosition(false);
            }
        }
        else if (pSummoned->GetEntry() == NPC_TWILIGHT_VOLUNTEER)
        {
            lVolunteers.remove(pSummoned->GetObjectGuid());
            m_bSacrifice = true;
            
        }
    }
Ejemplo n.º 24
0
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(float a_Dt)
{
	super::InStateChasing(a_Dt);

	if (m_Target != NULL)
	{
		if (m_Target->IsPlayer())
		{
			if (((cPlayer *)m_Target)->IsGameModeCreative())
			{
				m_EMState = IDLE;
				return;
			}
		}

		if (!IsMovingToTargetPosition())
		{
			MoveToPosition(m_Target->GetPosition());
		}
	}
} 
Ejemplo n.º 25
0
// What to do if in Chasing State
void cAggressiveMonster::InStateChasing(float a_Dt)
{
	super::InStateChasing(a_Dt);

	if (m_Target != NULL)
	{
		if (m_Target->IsPlayer())
		{
			if (((cPlayer *)m_Target)->IsGameModeCreative())
			{
				m_EMState = IDLE;
				return;
			}
		}

		if (((float)m_FinalDestination.x != (float)m_Target->GetPosX()) || ((float)m_FinalDestination.z != (float)m_Target->GetPosZ()))
		{
			MoveToPosition(m_Target->GetPosition());
		}
	}
} 
Ejemplo n.º 26
0
void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
{
	super::Tick(a_Dt, a_Chunk);

	if (m_EMState == ESCAPING)
	{
		CheckEventLostPlayer();
	}
	cItem FollowedItem = GetFollowedItem();
	if (FollowedItem.IsEmpty())
	{
		return;
	}
	cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), (float)m_SightDistance);
	if (a_Closest_Player != nullptr)
	{
		if (a_Closest_Player->GetEquippedItem().IsEqual(FollowedItem))
		{
			Vector3d PlayerPos = a_Closest_Player->GetPosition();
			MoveToPosition(PlayerPos);
		}
	}
}
Ejemplo n.º 27
0
void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	if (!IsAngry())
	{
		cMonster::Tick(a_Dt, a_Chunk);
		if (m_NotificationCooldown > 0)
		{
			m_NotificationCooldown -= 1;
		}
	}
	else
	{
		super::Tick(a_Dt, a_Chunk);
	}

	if (!IsTicking())
	{
		// The base class tick destroyed us
		return;
	}

	if (GetTarget() == nullptr)
	{
		m_World->DoWithNearestPlayer(GetPosition(), static_cast<float>(m_SightDistance), [&](cPlayer & a_Player) -> bool
		{
			switch (a_Player.GetEquippedItem().m_ItemType)
			{
				case E_ITEM_BONE:
				case E_ITEM_RAW_BEEF:
				case E_ITEM_STEAK:
				case E_ITEM_RAW_CHICKEN:
				case E_ITEM_COOKED_CHICKEN:
				case E_ITEM_ROTTEN_FLESH:
				case E_ITEM_RAW_PORKCHOP:
				case E_ITEM_COOKED_PORKCHOP:
				{
					if (!IsBegging())
					{
						SetIsBegging(true);
						m_World->BroadcastEntityMetadata(*this);
					}

					m_FinalDestination = a_Player.GetPosition();  // So that we will look at a player holding food

					// Don't move to the player if the wolf is sitting.
					if (!IsSitting())
					{
						MoveToPosition(a_Player.GetPosition());
					}

					break;
				}
				default:
				{
					if (IsBegging())
					{
						SetIsBegging(false);
						m_World->BroadcastEntityMetadata(*this);
					}
				}
			}

			return true;
		});
	}
	else
	{
		if (IsSitting())
		{
			SetTarget(nullptr);
		}
		else
		{
			MoveToPosition(GetTarget()->GetPosition());
			if (TargetIsInRange())
			{
				Attack(a_Dt);
			}
		}
	}

	if (IsTame() && !IsSitting())
	{
		TickFollowPlayer();
	}
	else if (IsSitting())
	{
		StopMovingToPosition();
	}
}
Ejemplo n.º 28
0
void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
	if (!IsAngry())
	{
		cMonster::Tick(a_Dt, a_Chunk);
	}
	else
	{
		super::Tick(a_Dt, a_Chunk);
	}

	cPlayer * a_Closest_Player = m_World->FindClosestPlayer(GetPosition(), static_cast<float>(m_SightDistance));
	if (a_Closest_Player != nullptr)
	{
		switch (a_Closest_Player->GetEquippedItem().m_ItemType)
		{
			case E_ITEM_BONE:
			case E_ITEM_RAW_BEEF:
			case E_ITEM_STEAK:
			case E_ITEM_RAW_CHICKEN:
			case E_ITEM_COOKED_CHICKEN:
			case E_ITEM_ROTTEN_FLESH:
			case E_ITEM_RAW_PORKCHOP:
			case E_ITEM_COOKED_PORKCHOP:
			{
				if (!IsBegging())
				{
					SetIsBegging(true);
					m_World->BroadcastEntityMetadata(*this);
				}

				m_FinalDestination = a_Closest_Player->GetPosition();  // So that we will look at a player holding food

				// Don't move to the player if the wolf is sitting.
				if (!IsSitting())
				{
					MoveToPosition(a_Closest_Player->GetPosition());
				}

				break;
			}
			default:
			{
				if (IsBegging())
				{
					SetIsBegging(false);
					m_World->BroadcastEntityMetadata(*this);
				}
			}
		}
	}

	if (IsTame() && !IsSitting())
	{
		TickFollowPlayer();
	}
	else if (IsSitting())
	{
		StopMovingToPosition();
	}
}
// 专门为主Thumb使用
void CTripleLinkageOpt::LBtnUpForMainThumb(const CPoint& point)
{
    if(m_bStartDraging)// begin to drag?
    {
        CFSBThumb* pThumb = m_szThumb[m_nFocusThumb];

        int nPos = SearchThumbPosition(point);

        int nltGap, nrbGap;
        int nMin, nMax;

        int nltPos;
        int nrbPos;
        if(m_bHorizontal)
        {
            nltGap=  pThumb->GetPosition()-m_szThumb[0]->GetPosition();
            nrbGap = m_szThumb[2]->GetPosition() - pThumb->GetPosition();

            nMin =  nltGap;
            nMax = m_szTicMarks->size()-1 - nrbGap;

            nltPos = nPos-nltGap;
            nrbPos = nPos+nrbGap;

            //int nMin, nMax;
            //GetThumbRange(m_nFocusThumb,  nMin, nMax);
            if (nPos >= nMax)
            {
                nPos = nMax;
                nltPos = nPos-nltGap;
                nrbPos = nPos + nrbGap;
            }
            if(nPos <= nMin)
            {
                nPos = nMin;
                nltPos = nPos-nltGap;
                nrbPos = nPos + nrbGap;
            }


            pThumb->SetPosition(nPos);
            m_szThumb[0]->SetPosition(nltPos);
            m_szThumb[2]->SetPosition(nrbPos);

            MoveToPosition(0,nltPos);
            MoveToPosition(1,nPos);
            MoveToPosition(2,nrbPos);
        }
        else
        {
            nltGap =  m_szThumb[2]->GetPosition()-pThumb->GetPosition();
            nrbGap = pThumb->GetPosition()-m_szThumb[0]->GetPosition();

            nMin =  nrbGap;
            nMax = m_szTicMarks->size()-1 - nltGap;

            nltPos = nPos+nltGap;
            nrbPos = nPos-nrbGap;

            if (nPos >= nMax)
            {
                nPos = nMax;
            }
            if(nPos <= nMin)
            {
                nPos = nMin;

            }
            nltPos = nPos+nltGap;
            nrbPos = nPos - nrbGap;

            pThumb->SetPosition(nPos);
            m_szThumb[0]->SetPosition(nrbPos);
            m_szThumb[2]->SetPosition(nltPos);

            MoveToPosition(0,nrbPos);
            MoveToPosition(1,nPos);
            MoveToPosition(2,nltPos);
        }




        m_bStartDraging = FALSE;
// 		//ReleaseCapture();
//




    }

}
Ejemplo n.º 30
0
void Wrist::BumpToPosition(bool direction) {
	m_bumpDir = direction;

	MoveToPosition(BUMP_ANGLE);
}