Beispiel #1
0
    //Creates object at Tile[x,y] if there is no other object
    public void CreateObject(GameObject newObj, int x, int y)
    {
        if (!InBounds(x, y))
        {
            Debug.Log("Tried to create an object outside of bounds and failed");
            return;
        }
        ObjectTile tile   = GetComponent <TileLayout>().GetTile(x, y);
        GameObject oldObj = tile.getObjectOnTile();

        if (oldObj == null)
        {
            Vector2    position = new Vector2(x, y);
            GameObject obj      = Instantiate(newObj, position, Quaternion.identity);
            tile.setObjectOnTile(obj);
        }
    }
Beispiel #2
0
    //Destroys object at Tile[x,y] if there is an object there
    public void DestroyObject(int x, int y)
    {
        Tutorial.Instance.TriggerDialogue(5);
        if (!InBounds(x, y))
        {
            Debug.Log("Tried to destroy an object outside of bounds and failed");
            return;
        }

        ObjectTile tile         = GetComponent <TileLayout>().GetTile(x, y);
        GameObject objectOnTile = tile.getObjectOnTile();

        if (objectOnTile != null)
        {
            Destroy(objectOnTile);
        }
        GetComponent <TileLayout>().GetTile(x, y).ResetTileInfo();
    }