Exemple #1
0
        private int GetAdjacentSpace(
            ObservationRowViewModel row,
            ObservationSpaceViewModel space,
            WallClickedEventArgs e)
        {
            switch (e.WallName.ToLowerInvariant())
            {
            case "left":
                if (row.ObservationSpaces[0].Position == e.Position)
                {
                    return(-1);
                }
                else
                {
                    return(e.Position - 1);
                }

            case "right":
                if (row.ObservationSpaces[row.ObservationSpaces.Count - 1].Position == e.Position)
                {
                    return(-1);
                }
                else
                {
                    return(e.Position + 1);
                }

            case "top":
                if (row.RowIndex == 0)
                {
                    return(-1);
                }
                else
                {
                    return(e.Position - Maze.Columns);
                }

            case "bottom":
                if (row.RowIndex == Maze.Rows - 1)
                {
                    return(-1);
                }
                else
                {
                    return(e.Position + Maze.Columns);
                }

            default:
                return(-1);
            }
        }
Exemple #2
0
        private void ObservationSpace_WallClicked(object sender, WallClickedEventArgs e)
        {
            var row              = GetRowByPosition(e.Position);
            var space            = GetSpaceByPosition(row, e.Position);
            int adjacentPosition = GetAdjacentSpace(row, space, e);
            var adjacentSpace    = GetSpaceByPosition(adjacentPosition);

            SetAndSpaceOpacity(adjacentSpace, e.IsVisible, e.WallName);

            if (e.IsVisible)
            {
                AddWall(e.Position, adjacentPosition);
            }
            else
            {
                RemoveWall(e.Position, adjacentPosition);
            }
        }
 protected virtual void OnWallClicked(WallClickedEventArgs e)
 {
     WallClicked?.Invoke(this, e);
 }