예제 #1
0
파일: Tile.cs 프로젝트: phelow/GameAIHW6
    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;
        }
    }