Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        pathTile = CustomTile.CreateCustomTile(pathSprite, 0, 0);


        //testing
        generatePath();
    }
Exemplo n.º 2
0
    public bool placeBaseFinal()
    {
        // Check to see if selected cell has a tower already built at that location
        GameObject[] towerList = GameObject.FindGameObjectsWithTag("tower");
        foreach (GameObject towerObj in towerList)
        {
            towerScript towerObjCode = towerObj.GetComponent <towerScript>();
            if ((towerObjCode.currentCell == currentCell) && (towerObjCode.towerPlaced))
            {
                // Replace existing tower tile
                //Debug.Log(prevTile.name);
                prevTile = CustomTile.CreateCustomTile(prevTileSprite);
                towerLevelMap.SetTile(currentCell, prevTile);
                return(false);
            }
        }

        // Do the same check for power stations



        // Only place tower if we have the coin
        Text coinValue     = GameObject.Find("coinValue").GetComponent <Text>();
        int  coinRemaining = (int.Parse(coinValue.text) - cost);

        if (coinRemaining > 0)
        {
            coinValue.text = coinRemaining.ToString();
        }
        else
        {
            return(false);
        }

        // Flag that the tower has been placed
        stationPlaced = true;

        // remove the range marker
        stationRangeMarkerVisible = false;

        // Tell path generator to update path if the tower is placed on the path
        GameObject.Find("pathGenerator").GetComponent <pathGeneratorScript>().newTowerLocation(currentCell);

        return(true);
    }
Exemplo n.º 3
0
    public void moveBasePosition(Vector3 newCursorPosition)
    {
        //Debug.Log("moveTowerPosition");

        // Set prevtile to its original state
        if (stationActive)
        {
            if (prevTile != null)
            {
                // Debug.Log(prevTile.name);
                if (prevTileSprite.name != null)
                {
                    prevTile = CustomTile.CreateCustomTile(prevTileSprite, 0f, 0f);
                }
                else
                {
                    // Unities tilebase is such a POS, have to create a new tile of the old tiles existing sprite for the hex pattern to match up.
                    prevTile = CustomTile.CreateCustomTile(prevTileSprite);
                }
            }
            towerLevelMap.SetTile(currentCell, prevTile);
        }
        // Update the new current cell position vars
        currentCell = towerLevelMap.WorldToCell(newCursorPosition);
        centerPos   = towerLevelMap.GetCellCenterLocal(currentCell);
        //Debug.Log("CenterPos=" + centerPos);

        // save prev tile
        prevTile       = towerLevelMap.GetTile(currentCell);
        prevTileSprite = towerLevelMap.GetSprite(currentCell);

        // Only set tower tile if a tower does not already exist there
        if (prevTileSprite == null)
        {
            towerLevelMap.SetTile(currentCell, CustomTile.CreateCustomTile(tileSprite));
        }

        // Draw red range marker
        if (stationRangeMarkerVisible)
        {
            DrawCircle();
        }
    }
Exemplo n.º 4
0
    public void init(Vector3 cursorPosition)
    {
        // Enable all functionality for tower
        stationActive             = true;
        stationRangeMarkerVisible = true;

        currentCell = towerLevelMap.WorldToCell(cursorPosition);
        centerPos   = towerLevelMap.GetCellCenterLocal(currentCell);

        // Save previous tile, just incase
        prevTile       = towerLevelMap.GetTile(currentCell);
        prevTileSprite = towerLevelMap.GetSprite(currentCell);

        // Create new tile for sprite
        //newTowerTile = CustomTile.CreateCustomTile(tileSprite, 0, 0);
        towerLevelMap.SetTile(currentCell, CustomTile.CreateCustomTile(tileSprite, 0, 0));

        // Draw red range marker
        if (stationRangeMarkerVisible)
        {
            DrawCircle();
        }
    }