Пример #1
0
    public void click()
    {
        TileClickHandler tileClickHandler = getTileEventHandler();

        if (tileClickHandler != null)
        {
            tileClickHandler.rightClicked();
        }
    }
Пример #2
0
    public void click()
    {
        TileClickHandler tileClickHandler = getTileEventHandler();

        if (tileClickHandler != null)
        {
            active = true;
            currentTileClickHandler = tileClickHandler;
            currentTileClickHandler.leftHold();
        }
    }
    public TileClickHandler getTileEventHandler()
    {
        TileClickHandler tileEventHandler = null;
        Vector2          mousePosition    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D     ray = Physics2D.Raycast(mousePosition, Vector2.zero, 0);

        if (ray.collider != null)
        {
            tileEventHandler = ray.collider.GetComponent <TileClickHandler>();
        }

        return(tileEventHandler);
    }
Пример #4
0
    void GenerateMapVisual(int mapSizeX, int mapSizeY)
    {
        for (int x = 0; x < mapSizeX; x++)
        {
            for (int y = 0; y < mapSizeY; y++)
            {
                TileType tt = tileTypes[tiles[x, y]];
                //Debug.Log("Value of tt.VisualPrefab: " + tt.tileVisualPrefab.ToString());
                GameObject go = (GameObject)Instantiate(tt.tileVisualPrefab, new Vector3(x, y, 0), Quaternion.identity);

                TileClickHandler ch = go.GetComponent <TileClickHandler>();
                ch.tileX = x;
                ch.tileY = y;
                ch.map   = this;
            }
        }
    }
Пример #5
0
    private void handleHold()
    {
        TileClickHandler tileEventHandler = getTileEventHandler();

        if (tileEventHandler != currentTileClickHandler)
        {
            if (currentTileClickHandler != null)
            {
                currentTileClickHandler.leftHoldRemoved();
            }
            currentTileClickHandler = tileEventHandler;
            if (currentTileClickHandler != null)
            {
                currentTileClickHandler.leftHold();
            }
        }
    }
Пример #6
0
    private void handleRelease()
    {
        active = false;
        TileClickHandler tileEventHandler = getTileEventHandler();

        if (tileEventHandler == currentTileClickHandler)
        {
            if (currentTileClickHandler != null)
            {
                currentTileClickHandler.leftReleased();
            }
        }
        else
        {
            if (currentTileClickHandler != null)
            {
                currentTileClickHandler.leftHoldRemoved();
            }
        }
    }
Пример #7
0
    //TODO: Edit this to handle overwriting old rooms - Placing a new room and destroying the one which is overlapping
    void GenerateMapVisual(int mapSizeX, int mapSizeY, int startingPointX, int startingPointY)
    {
        int  roomSizeX = startingPointX + mapSizeX;
        int  roomSizeY = startingPointY + mapSizeY;
        Room entrance  = new Room("Entrance", startingPointX, startingPointY, roomSizeX, roomSizeY, 1, 1);
        //TODO: Test this room object - work out why a second object is being created
        GameObject room = Instantiate(entrance.room, new Vector3(startingPointX, startingPointY, 0), Quaternion.identity);

        for (int x = startingPointX; x < roomSizeX; x++)
        {
            for (int y = startingPointY; y < roomSizeY; y++)
            {
                TileType   tt   = tileTypes[tiles[x, y]];
                GameObject tile = (GameObject)Instantiate(tt.tileVisualPrefab, new Vector3(x, y, 0), Quaternion.identity, room.transform);
                //GameObject tile = tt.tileVisualPrefab;
                //Debug.Log("tile type = " + tt.name.ToString());

                TileClickHandler ch = tile.GetComponent <TileClickHandler>();
                ch.tileX = x;
                ch.tileY = y;
                ch.map   = this;
            }
        }
    }
Пример #8
0
 public void Attach(TileClickHandler tile)
 {
     Tiles.Add (tile);
 }