Exemple #1
0
vector<MoveCommand> SoulFind::getCommand(int playerId, const Status& status) {
	vector<MoveCommand> command;

	auto soulPoints = status.getSoulPoints();
	if (soulPoints.empty()) return command;

	const Point point = status.getNinjas()[playerId].point;

	int num = 0;
	int range = manhattan(point, soulPoints[0]);

	for (int i = 1; i < int(soulPoints.size()); i++)
	{
		int r = manhattan(point, soulPoints[i]);

		if (range > r)
		{
			range = r;
			num = i;
		}
	}
	const Point d = soulPoints[num] - point;

	command = move(playerId, status, d);

	if (command.empty())
	{
		command.resize(2);
		auto stage = status.getStage();
		for (int i = 0; i < 4; i++)
		{
			Stage stage01(stage.getStage());
			const Point p1 = stage.moveSimulation(point, MoveCommand(i), stage01);
			if (p1 != point)
			{
				for (int j = 0; j < 4; j++)
				{
					Stage stage02(stage01.getStage());
					const Point p2 = stage.moveSimulation(p1, MoveCommand(j), stage02);
					if (p2 != p1)
					{
						command[0] = MoveCommand(i);
						command[1] = MoveCommand(j);
					}
				}
			}
		}
	}

	return command;
}
Exemple #2
0
void CALLBACK CPlayer::Update(float fTime)
{
	// Если игрок уже отдал команду на перемещение.
	if (_eState < PS_STAND_UP)
		Move(fTime);
	
	// Если игрок стоит на месте - проверяем нажатие клавиш для начала движения.
	if (_eState >= PS_STAND_UP)
		MoveCommand();

	_pCurrAnim->SetPosition(Vector2f(_position.x + 4, _position.y - 16));
	_pCurrAnim->Play(fTime);

	//if (pInput->Is
}
Exemple #3
0
vector<MoveCommand> SoulFind::getCommand2(int playerId, const Status& status) {
	vector<MoveCommand> command;

	struct Data {
		Point point;
		Stage stage;
		vector<MoveCommand> commands;
	};
	StageArray search;
	for (auto& s : search) s.fill(Stage::State::None);

	queue<Data> que;
	{
		Data data;
		data.point = status.getNinjas()[playerId].point;
		data.stage = status.getStage();
		data.commands.clear();
		que.push(data);
	}
	const Point checkPoint[4] = { Point(0,-1),Point(-1,0),Point(1,0),Point(0,1) };

	while (true)
	{
		queue<Data> nextQue;
		while (!que.empty())
		{
			Data data;

			const Data cd = que.front();

			for (const auto& sp : status.getSoulPoints())
			{
				if (cd.point == sp)
				{
					command = cd.commands;
					if (command.size() > 2)
						command.resize(2);
					return command;
				}
			}

			for (int i = 0; i < 4; i++)
			{
				data = que.front();
				const Point pp = data.point + checkPoint[i];

				if (search[pp.x][pp.y] == Stage::State::None)
				{
					data.point = Stage::moveSimulation(data.point, status.getNinjas()[(playerId + 1) % 2].point, MoveCommand(i), data.stage, status.getDogs());
					if (que.front().point != data.point)
					{
						search[data.point.x][data.point.y] = Stage::State::Wall;
						data.commands.push_back(MoveCommand(i));
						nextQue.push(data);
					}
				}
			}
			que.pop();
		}
		que = nextQue;
	}

	return command;
}
void CRunMapExpertDlg::OnMoveup() 
{
	MoveCommand(-1, TRUE);
}
void CRunMapExpertDlg::OnMovedown() 
{
	MoveCommand(-1, FALSE);
}
BOOL plResponderProc::DragListProc(HWND hWnd, DRAGLISTINFO *info)
{
    static int oldIdx = -1;

    int curIdx = LBItemFromPt(info->hWnd, info->ptCursor, TRUE);

    switch (info->uNotification)
    {
        // Allow the drag
        case DL_BEGINDRAG:
            // When you click on an item in the listbox, the rollups are changed and Max can
            // shift the position of dialog you were just clicking in.  Since this happens
            // before you let go of the mouse button, the listbox thinks you are dragging.
            // To get around it, we don't allow a selection change and a drag in the same click.
            if (fIgnoreNextDrop)
            {
                SetWindowLong(hWnd, DWL_MSGRESULT, FALSE);
            }
            else
            {
                oldIdx = curIdx;
                SetWindowLong(hWnd, DWL_MSGRESULT, TRUE);
            }
            return TRUE;

        case DL_DRAGGING:
            {
                if (curIdx < oldIdx)
                    DrawInsert(hWnd, info->hWnd, curIdx);
                else if (curIdx > oldIdx && ListBox_GetCount(info->hWnd) > curIdx+1)
                    DrawInsert(hWnd, info->hWnd, curIdx+1);
                else
                    DrawInsert(hWnd, info->hWnd, -1);
            }
            return TRUE;

        case DL_CANCELDRAG:
            // Clear drag arrow
            DrawInsert(hWnd, info->hWnd, -1);
            return TRUE;

        case DL_DROPPED:
        {
            if (fIgnoreNextDrop)
            {
                fIgnoreNextDrop = false;
                return TRUE;
            }

            // Clear drag arrow
            DrawInsert(hWnd, info->hWnd, -1);

            if (curIdx != -1 && oldIdx != -1 && curIdx != oldIdx)
            {
                // Make sure this won't mess up any wait commands, or at least
                // that the user approves if it does.
                if (!ResponderWait::ValidateCmdMove(fStatePB, oldIdx, curIdx))
                    return TRUE;

                MoveCommand(oldIdx, curIdx);
            }

            return TRUE;
        }
    }

    return FALSE;
}