Exemplo n.º 1
0
    bool isConllider(Vector3 direction)
    {
        Vector3 step        = Vector3.zero;
        Vector3 newPosition = topRock.transform.position;

        int count = 0;

        direction /= 1.9f;

        if (direction.x != 0)
        {
            direction     *= attributes.rockSize.x;
            count          = attributes.rockSize.z;
            newPosition.z += (count - 1) * 0.5f;
            step           = Vector3.back;
        }
        else if (direction.z != 0)
        {
            direction     *= attributes.rockSize.z;
            count          = attributes.rockSize.x;
            newPosition.x += (count - 1) * 0.5f;
            step           = Vector3.left;
        }

        for (int i = 1; i <= count; i++)
        {
            if (gameMapController.isMovable(newPosition + direction) == false)
            {
                return(true);
            }
            newPosition += step;
        }

        return(false);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 通过玩家滑动的方向判断岩石移动的方向
    /// </summary>
    /// <param name="clickPosition"></param>
    void movingDirection(Vector3 clickPosition)
    {
        Vector3 nowPosition  = posDis + clickPosition;
        Vector3 moveDirction = Vector3.zero;
        //true==X,false==Y
        bool dir = true;

        lastClickPosition -= clickPosition;

        nowPosition.y = clickObj.transform.position.y;

        //判断岩石移动的方向
        int moveType = rockAttributes.getRockType(clickObj.transform.position);

        if (moveType == 11)
        {
            dir = Mathf.Abs(lastClickPosition.x) >= Mathf.Abs(lastClickPosition.z) ? true : false;
        }
        else if (moveType == 12)
        {
            dir = true;
        }
        else if (moveType == 13)
        {
            dir = false;
        }
        //确定岩石移动的方向
        float nestStep = 0.5f;

        if (dir == true)
        {
            nestStep     *= rockAttributes.rockSize.x;
            nowPosition.z = clickObj.transform.position.z;
            moveDirction  = lastClickPosition.x > 0 ? new Vector3(-nestStep, 0, 0) : new Vector3(nestStep, 0, 0);
        }
        else
        {
            nestStep     *= rockAttributes.rockSize.z;
            nowPosition.x = clickObj.transform.position.x;
            moveDirction  = lastClickPosition.z > 0 ? new Vector3(0, 0, -nestStep) : new Vector3(0, 0, nestStep);
        }

        lastClickPosition = clickPosition;

        if (gameMapController.isMovable(nowPosition + moveDirction) == true)
        {
            rockAttributes.markingGameMap(clickObj.transform.position, false);
            clickObj.transform.position = nowPosition;
        }
        else
        {
            posDis = clickObj.transform.position - clickPosition;
        }
    }