Exemple #1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="addPotDelegate">The function that gets called whenever the player retreives a pot</param>
    /// <param name="addCrabDelegate">The function that gets called whenever the player gains crab</param>
    public void LiftAllPots(AddPotDelegate addPotDelegate, AddCrabDelegate addCrabDelegate)
    {
        /**
         * First make each number tile from previous round a little grayer (previousRoundColor).
         * This is to help the player read which tiles they just lifted pots up from.
         */
        foreach (var location in numberTilemap.cellBounds.allPositionsWithin)
        {
            var numberTile = (Tile)numberTilemap.GetTile(location);

            if (numberTile != null && numberTile.sprite != null)
            {
                SetNumberTileInOffsetCoordinates(location, numberTile.sprite, previousRoundColor);
            }
        }

        /**
         * Next, take each tile that has a pot in it, find out how many crab that contains, and place
         * a tile that marks the number of crab the player lifted.
         * */
        foreach (var location in markerTilemap.cellBounds.allPositionsWithin)
        {
            Tile potTile = (Tile)markerTilemap.GetTile(location);

            if (potTile != null && potTile.sprite != null && potTile.sprite.name == potSprite.name)
            {
                int liftedCrab = swarmController.GetCrab(location);

                addCrabDelegate(liftedCrab);
                addPotDelegate();

                ClearMarkerTile(location);
                SetNumberTileInOffsetCoordinates(location, liftedCrab, Color.white);
            }
        }
    }