Ejemplo n.º 1
0
    void OnMouseDown()
    {
        //if it's a right click, cycle between passable, out of bounds and tree
        if (AStarSearch.ms_rmbDown)
        {
            Debug.Log("MouseButtonOneIsDown");
            AStarSearch.ReplaceTile(this);
            return;
        }


        if (ms_startingPosition == null)
        {
            ms_startingPosition = AStarSearch.GetAStarTileByWorldTile(this);
            ms_startingPosition.StartLerping();
        }
        else if (ms_endingPosition == null)
        {
            ms_endingPosition = AStarSearch.GetAStarTileByWorldTile(this);
            ms_endingPosition.StartLerping();
        }

        if (ms_startingPosition != null && ms_endingPosition != null)
        {
            ms_startingPosition.StopLerping();
            ms_endingPosition.StopLerping();

            AStarSearch.PerformSearch(ms_startingPosition, ms_endingPosition);

            ms_startingPosition = null;
            ms_endingPosition   = null;
        }
    }