Exemplo n.º 1
0
    protected virtual void OnClick(Vector2 location)
    {
        // See if there is a targeted actor to select
        // at the clicked location.
        targetedActor = null;
        Vector2Int gridPosition = grid.WorldToGrid(location);

        if (grid.DoesTileExist(gridPosition))
        {
            // In theory there should only be one unit on a tile
            // at any given time during the command phase. TODO
            // may want to just check the first actor, but not doing
            // this for now in case non-unit actors are to be implemented.
            foreach (TileActor actor in grid.GetActorsOnTile(gridPosition))
            {
                if (actor.TeamID == teamID)
                {
                    currentTile   = gridPosition;
                    targetedActor = actor;
                    // Tell this actor that it has been clicked.
                    targetedActor.OnClick();
                    break;
                }
            }
        }
    }