Beispiel #1
0
    private void CheckRightClickTile()
    {
        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit2D mouseHit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (mouseHit.collider != null)
            {
                Tile_script tileHit = mouseHit.collider.GetComponent <Tile_script>();

                if (tileHit != null)
                {
                    if (this._start == null)
                    {
                        this._start                      = tileHit;
                        this._start.Debugging            = true;
                        this._start.SpriteRenderer.color = Color.green;
                    }
                    else if (this._goal == null)
                    {
                        this._goal                      = tileHit;
                        this._goal.Debugging            = true;
                        this._goal.SpriteRenderer.color = Color.red;
                    }
                    else
                    {
                        this.ResetVisualization();
                    }
                }
            }
        }
    }
Beispiel #2
0
    private void PlaceTile(int type, int row, int column, Vector3 offset)
    {
        Tile_script tile = Instantiate(_tilePrefabs[type]).GetComponent <Tile_script>();

        tile.Initialize(
            new GridPosition_script(row, column),
            new Vector3((offset.x + (this.TileSize.x * column)), (offset.y - (this.TileSize.y * row)), 0),
            this.transform,
            type
            );
    }
Beispiel #3
0
    private void ResetVisualization()
    {
        this._start.SpriteRenderer.color = Color.white;
        this._goal.SpriteRenderer.color  = Color.white;
        this._start = null;
        this._goal  = null;
        this.Visualize(_path, Color.white);
        this._path.Clear();

        foreach (GameObject arrow in this._arrows)
        {
            Destroy(arrow);
        }
    }
 public Node_script(Tile_script tileScript)
 {
     this.TileScript    = tileScript;
     this.Position      = tileScript.Position;
     this.WorldPosition = tileScript.WorldPosition;
 }