Ejemplo n.º 1
0
    private void moveNode(RoleNode pNode)
    {
        //屏幕外的要隐藏.
        //pNode.SetVisible((IsInScene(pNode)));
        MoveData aMoveData = pNode.moveData;

        if (aMoveData.MoveDelay > 0.0f)
        {
            aMoveData.MoveDelay -= Time.deltaTime;
            if (aMoveData.MoveDelay <= 0.0f)
            {
                pNode.MoveEndCallback();
            }
        }
        else if (pNode.IsMoving())
        {
            float dx = aMoveData.delaX * Time.deltaTime;
            float dz = aMoveData.delaY * Time.deltaTime;
            if (Mathf.Abs(dx) >= Mathf.Abs(aMoveData.dx))
            {
                dx           = aMoveData.dx;
                aMoveData.dx = 0.0f;
            }
            else
            {
                aMoveData.dx -= dx;
            }

            if (Mathf.Abs(dz) >= Mathf.Abs(aMoveData.dz))
            {
                dz           = aMoveData.dz;
                aMoveData.dz = 0.0f;
            }
            else
            {
                aMoveData.dz -= dz;
            }
            Vector3 curPos = pNode.GetPosition();
            curPos.x += dx;
            curPos.z += dz;
            pNode.SetPosition(curPos);

            if (aMoveData.dx == 0.0f && aMoveData.dz == 0.0f)
            {
                pNode.MoveEndCallback();
            }
        }
    }
Ejemplo n.º 2
0
    public void AddMovePoint(RoleNode pNode, Vector3 pos, float speedUp = 1.0f)
    {
        if (speedUp != 0)
        {
            pNode.moveData.SpeedUp = speedUp;
        }

        if (pNode.GetRoleStatus() == E_NodeStatus.Idle && pNode.moveData.MoveDelay <= 0.0f)
        {
            MoveTo(pNode, pos);
        }
        else
        {
            if (pNode.IsMoving())
            {
                pNode.PathList.Add((ushort)pos.x);
                pNode.PathList.Add((ushort)pos.z);
            }
        }
    }