Exemplo n.º 1
0
    public virtual void CreateGrid()
    {
        if (canMove == false)
        {
            return;
        }
        canMove = false;
        Realign();
        ClearGrid();
        //grid = GenerateGrid.CreateGrid(actionPoints, this.transform.position);
        gridInfo = GridGen.GenPoints(actionPoints, actionPoints, this.transform.position, navMeshAgent);

        if (gridInfo.gridPoints != null || gridInfo.gridPoints.Count > 0)
        {
            grid = GridGen.CreateGrid(gridInfo, this.transform.position, actionPoints);
        }
    }
Exemplo n.º 2
0
    public override void Update()
    {
        base.Update();

        if (navMeshAgent.destination == this.transform.position)
        {
            if (selected && createGrid == true)
            {
                ClearGrid();

                gridInfo = GridGen.GenPoints(actionPoints, actionPoints, this.transform.position, navMeshAgent);

                if (gridInfo.gridPoints != null || gridInfo.gridPoints.Count > 0)
                {
                    grid = GridGen.CreateGrid(gridInfo, this.transform.position, actionPoints);
                }

                createGrid = false;
            }
            path = null;
            navMeshAgent.ResetPath();
            lineRenderer.positionCount = 0;
            canMove = true;
            Realign();

            animator.SetBool("Moving", false);
        }

        if (path == null)
        {
            return;
        }
        lineRenderer.positionCount = path.corners.Length;

        for (int i = 0; i < path.corners.Length; i++)
        {
            lineRenderer.SetPosition(i, path.corners[i]);
        }
    }