示例#1
0
 /// <summary>
 /// Strong Construction
 /// </summary>
 /// <param name="aGameUI"></param>
 public GameCoords(GameUI aGameUI)
 {
     GameUI = aGameUI;
     GlobalOffset = new VectorInt(10, 30);
     GlobalTileSize = new SizeInt(16, 16);
     windowRegion =  new RectangleInt(new VectorInt(0, 0), new SizeInt(400, 300));
 }
示例#2
0
        /// <summary>
        /// Strong Construction
        /// </summary>
        /// <param name="aSizeX"></param>
        /// <param name="aSizeY"></param>
        public Bitmap(int aSizeX, int aSizeY)
        {
            if (aSizeX > 32) throw new NotSupportedException("Only 32bit sizes are excepted");
            size = new SizeInt(aSizeX, aSizeY);
            map = new uint[aSizeY];

            Clear();
        }
        public NodeListVisualisation(List<SolverNode> nodes, SizeInt cellSize)
        {
            this.nodes = nodes;
            this.cellSize = cellSize;

            int maxH = ((nodes.Count + 1)/maxCellWidth)*cellSize.Height;
            renderCanvas = new RectangleInt(0,0, cellSize.Width*maxCellWidth, maxH);
            windowRegion = renderCanvas;
        }
        /// <summary>
        /// Strong COnstructoin
        /// </summary>
        /// <param name="sourceTree"></param>
        public TreeVisualisation(Tree<SolverNode> sourceTree, RectangleInt renderSize, SizeInt cellSize)
        {
            // this.controller = controller;
            this.tree = sourceTree;

            // Calculate the render size
            RenderCanvas = renderSize;
            CellSize = cellSize;
        }
        /// <summary>
        /// Strong constructor
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="cellSize"></param>
        public NodeListVisualisation(SolverController controller, List<SolverNode> nodes, SizeInt cellSize)
        {
            Display = new CommonDisplay(controller);
            this.nodes = nodes;
            this.cellSize = cellSize;

            int maxH = ((nodes.Count + 1)/maxCellWidth+1)*cellSize.Height;
            renderCanvas = new RectangleInt(0,0, cellSize.Width*maxCellWidth, maxH);
            windowRegion = renderCanvas;
        }
示例#6
0
        /// <summary>
        /// Semi-Strong construction
        /// </summary>
        /// <param name="myGameUI">Game to which the node belongs</param>
        /// <param name="myDepth">Z-Order</param>
        public NodeBase(GameUI myGameUI, int myDepth)
        {
            if (myGameUI == null) throw new ArgumentNullException("myGameUI");

            gameUI = myGameUI;
            depth = myDepth;
            dockPoint = DockPoint.Centre;
            size = new SizeInt(0, 0);
            currentAbsolute = VectorInt.Zero;
            isRemoved = false;
        }
示例#7
0
        /// <summary>
        /// Strong Constructor. Start with the dead map including all walls.
        /// </summary>
        /// <param name="goalMap"></param>
        /// <param name="wallMap"></param>
        public DeadMapState(Bitmap goalMap, Bitmap wallMap, DeadMapAnalysis deadMapAnalysis)
            : base("Dead Map", wallMap.Size)
        {
            this.goalMap = goalMap;
            this.wallMap = wallMap;
            this.deadMapAnalysis = deadMapAnalysis;

            this.mapSize = wallMap.Size;

            if (goalMap == null) throw new ArgumentNullException("goalMap");
            if (wallMap == null) throw new ArgumentNullException("goalMap");
            if (deadMapAnalysis == null) throw new ArgumentNullException("deadMapAnalysis");
        }
        public NodeUIDialogHelp(GameUI myGameUI, int myDepth)
            : base(myGameUI, myDepth)
        {
            Text =
                @"Place all crates/gem on the goal positions.
            You can push but never pull crates, you can only push one crate at a time.

            Use the arrow keys to move. [U] for Undo, [R] for Restart. [ESC] to exit.

            Click on a floor to move there. Drag a crate to a new position.";
            TextTitle = "Sokoban Help";

            CurrentAbsolute = GameUI.GameCoords.PuzzleRegion.Center.Subtract(100, 100);
            Size = new SizeInt(500, 200);
        }
示例#9
0
        /// <summary>
        /// Strong Construction
        /// </summary>
        /// <param name="myGameUI"></param>
        /// <param name="myDepth"></param>
        /// <param name="PositionAbs"></param>
        /// <param name="resImage">Resource of the UI button image</param>
        /// <param name="ClickCommand">Command string passed back in the click event</param>
        public NodeUIButton(GameUI myGameUI, int myDepth, VectorInt PositionAbs, ResourceID resImage, string ClickCommand)
            : base(myGameUI, myDepth)
        {
            imageNormal = myGameUI.ResourceFactory[resImage].DataAsImage;
            imageBack = myGameUI.ResourceFactory[ResourceID.GameButtonBackGround].DataAsImage;
            Size = new SizeInt(imageBack.Size);
            CurrentAbsolute = PositionAbs;
            clickCommand = ClickCommand;

            mouseOverBrush = myGameUI.ResourceFactory[ResourceID.GameButtonMouseOverBrush].DataAsBrush;
            maskEffect = null;
            toolTip = null;

            if (GameUI.Cursor != null)
            {
                GameUI.Cursor.OnClick += new EventHandler<NodeCursorEventArgs>(cursor_OnClick);
            }
        }
示例#10
0
        /// <summary>
        /// Strong Construction
        /// </summary>
        /// <param name="myGameUI"></param>
        /// <param name="myDepth"></param>
        /// <param name="PositionAbs"></param>
        /// <param name="FileImage">Filename</param>
        /// <param name="ClickCommand">Command string passed back in the click event</param>
        public NodeUIButton(GameUI myGameUI, int myDepth, VectorInt PositionAbs, string FileImage, string ClickCommand)
            : base(myGameUI, myDepth)
        {
            imageNormal = new Bitmap(FileManager.getContent(FileImage));
            imageBack = new Bitmap(FileManager.getContent("$Graphics\\Icons\\BasicButtonBK.png"));
            Size = new SizeInt(imageBack.Size);
            CurrentAbsolute = PositionAbs;
            clickCommand = ClickCommand;

            mouseOverBrush = new SolidBrush(Color.FromArgb(60, Color.Yellow));
            maskEffect = null;
            toolTip = null;

            if (GameUI.Cursor != null)
            {
                GameUI.Cursor.OnClick += new EventHandler<NodeCursorEventArgs>(cursor_OnClick);
            }
        }
示例#11
0
        public override void Render()
        {
            if (imageBack != null)
            {
                VectorInt pos = CurrentRect.Center.Subtract(imageBack.Width / 2 + 2, imageBack.Height / 2 + 2);
                GameUI.Graphics.DrawImage(imageBack, pos.X, pos.Y);
            }

            if (imageNormal != null)
            {
                DrawBitmapCentered(GameUI.Graphics, CurrentRect, imageNormal);
            }

            if (isMouseOver)
            {
                if (mouseOverBrush != null)
                {
                    RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(1, 1), CurrentRect.BottomRight.Add(1, 1));
                    GameUI.Graphics.FillEllipse(mouseOverBrush, over.ToDrawingRect());
                }

                if (toolTip != null)
                {
                    Font ttFont = new Font("Arial", 10f);
                    SizeF ffSizeF = GameUI.Graphics.MeasureString(toolTip, ttFont);
                    SizeInt ffSize = new SizeInt((int) ffSizeF.Width, (int) ffSizeF.Height);

                    RectangleInt posTT = new RectangleInt(CurrentRect.BottomLeft.Subtract(ffSize.Width/2, -5 ), ffSize);

                    if (posTT.TopLeft.X < GameUI.GameCoords.WindowRegion.TopLeft.X)
                        posTT.TopLeft.X = GameUI.GameCoords.WindowRegion.TopLeft.X;
                    if (posTT.TopLeft.Y < GameUI.GameCoords.WindowRegion.TopLeft.Y)
                        posTT.TopLeft.Y = GameUI.GameCoords.WindowRegion.TopLeft.Y;

                    if (posTT.BottomRight.X > GameUI.GameCoords.WindowRegion.BottomRight.X)
                        posTT.BottomRight.X = GameUI.GameCoords.WindowRegion.BottomRight.X;
                    if (posTT.BottomRight.Y < GameUI.GameCoords.WindowRegion.BottomRight.Y)
                        posTT.BottomRight.Y = GameUI.GameCoords.WindowRegion.BottomRight.Y;

                    Brush ttBrush = new SolidBrush(Color.Cyan);
                    Brush ttBrushShadow = new SolidBrush(Color.DarkCyan);

                    NodeEffectText nodeTT = new NodeEffectText(GameUI, 10000, toolTip, ttFont, ttBrush, ttBrushShadow, posTT.TopLeft);
                    nodeTT.BrushBackGround = new SolidBrush(Color.DarkSlateGray);
                    nodeTT.Path = new Paths.StaticPath(posTT.TopLeft, 1);
                    GameUI.Add(nodeTT);
                }
            }

            if (maskEffect != null)
            {
                RectangleInt over = new RectangleInt(CurrentAbsolute.Subtract(5, 5), CurrentRect.BottomRight.Add(10, 10));
                GameUI.Graphics.FillEllipse(maskEffect, over.ToDrawingRect());
            }
        }
示例#12
0
 public static SizeInt Min(SizeInt A, SizeInt B)
 {
     return new SizeInt(System.Math.Min(A.X, B.X), System.Math.Min(A.Y, B.Y));
 }
        /// <summary>
        /// Initialise
        /// </summary>
        private void Init()
        {
            segments = new TreeSegmenter<SolverNode>(tree, maxDepth, maxMembers);
            segments.PerformSegment();

            regions = new List<SegmentRegion>(segments.Segments.Count);

            int height = 0;
            foreach (TreeSegmenter<SolverNode>.TreeSegment segment in segments.Segments)
            {
                SegmentRegion region = new SegmentRegion();
                region.owner = this;
                region.MaxRegionNodeWidth = maxWidth;
                SizeInt regionSize = new SizeInt(maxWidth*CellSize.Width + 50, (segment.Count/maxWidth +1)*CellSize.Height);
                region.RenderRegion = new RectangleInt(renderCanvas.TopLeft.Add(0, height), regionSize);
                region.treeSegment = segment;
                region.treeSegment.Nodes.Sort(delegate(TreeNode<SolverNode> lhs, TreeNode<SolverNode> rhs) { return rhs.Data.Weighting.CompareTo(lhs.Data.Weighting); });

                regions.Add(region);

                height += regionSize.Height;
            }
        }
 /// <summary>
 /// Strong constuctor
 /// </summary>
 /// <param name="cellSize"></param>
 /// <param name="controller"></param>
 public RootPathVisualisation(SizeInt cellSize, SolverController controller)
 {
     this.cellSize = cellSize;
     this.controller = controller;
     this.Display = new CommonDisplay(controller);
 }
示例#15
0
        /// <summary>
        /// Create a BitMap from a string map of '0' and '1'.
        /// Generally this constructor is for test purposes.
        /// </summary>
        /// <param name="StringMap"></param>
        public Bitmap(string[] StringMap)
        {
            // calc max length
            int sz = 0;
            foreach (String s in StringMap)
            {
                if (s.Length > sz) sz = s.Length;
            }
            if (sz > 32) throw new NotSupportedException("Only 32bit sizes are excepted");

            size = new SizeInt(sz, StringMap.Length);
            map = new uint[StringMap.Length];

            Clear();

            // Set the strings
            for (int yy = 0; yy < Size.Y; yy++)
                for (int xx = 0; xx < Size.X; xx++)
                {
                    if (StringMap[yy] != null && StringMap[yy].Length > xx)
                    {
                        this[xx, yy] = StringMap[yy][xx] == '1';
                    }
                }
        }
示例#16
0
 /// <summary>
 /// Initialise the puzzle to a set size.
 /// </summary>
 /// <param name="s"></param>
 /// <remarks>
 /// Create an empty puzzle with a wall around the edges
 /// </remarks>
 public void Init(SizeInt s)
 {
     if (s.X <= 0 || s.Y <= 0) throw new ArgumentOutOfRangeException("s");
     map = new CellStates[s.X, s.Y];
     Fill(CellStates.Floor);
     FillBox(Rectangle, CellStates.Wall);
 }
示例#17
0
 public VectorInt Add(SizeInt value)
 {
     return new VectorInt(x + value.X, y + value.Y);
 }
示例#18
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="size"></param>
 public Matrix(SizeInt size)
 {
     Size = size;
 }
示例#19
0
        /// <summary>
        /// Init the puzzle from a simple string map
        /// </summary>
        public void SetFromStrings(string[] StrMap, string[] ValidChars)
        {
            int maxx = 0;

            // Clean up
            List<string> InputMap = new List<string>(StrMap.Length);
            foreach (string row in StrMap)
            {
                if ( row == null) continue;
                string cleanRow = row.TrimEnd();
                if (cleanRow.Length == 0) continue;
                if (cleanRow.Length > maxx) maxx = cleanRow.Length;
                InputMap.Add(cleanRow);
            }

            SizeInt sz = new SizeInt(maxx, InputMap.Count);
            Init(sz);

            for(int cx=0; cx<sz.X; cx++)
                for (int cy = 0; cy < sz.Y; cy++)
                {
                    // Default value
                    this[cx, cy] = CellStates.Void;

                    if (InputMap.Count <= cy) continue;
                    if (InputMap[cy].Length <= cx) continue;

                    for (int cell = 0; cell < CellStatesClass.Size; cell++)
                    {
                        if (ValidChars[cell].IndexOf(InputMap[cy][cx]) >= 0)
                        {
                            // Hit
                            this[cx, cy] = (CellStates)cell;
                        }
                    }
                }
        }
示例#20
0
 public Recess(string name, SizeInt aSize)
     : base(name, aSize)
 {
 }
 public RootPathVisualisation(SizeInt cellSize, SolverController controller)
 {
     this.cellSize = cellSize;
     this.controller = controller;
 }
示例#22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="roomID">Room name</param>
 /// <param name="aSize">MapSize</param>
 public Room(string roomID, SizeInt aSize)
     : base(roomID, aSize)
 {
     this.roomID = roomID;
     doors = new List<Door>();
 }
示例#23
0
        /// <summary>
        /// Resize the puzzle
        /// </summary>
        /// <param name="newSize"></param>
        public void Resize(SizeInt newSize)
        {
            if (newSize.Equals(Size)) return;
            CellStates[,] old = map;

            // Min common size
            SizeInt minMap = SizeInt.Min(Size, newSize);
            Init(newSize);

            for (int cx=0; cx<minMap.X; cx++)
                for (int cy = 0; cy < minMap.Y; cy++)
                {
                    this[cx, cy] = old[cx, cy];
                }
        }
示例#24
0
 public VectorInt Multiply(SizeInt value)
 {
     return new VectorInt(x * value.X, y * value.Y);
 }
示例#25
0
 /// <summary>
 /// Overloaded Constructor
 /// </summary>
 /// <param name="aSize"></param>
 public Bitmap(SizeInt aSize)
     : this(aSize.X, aSize.Y)
 {
 }
示例#26
0
 public VectorInt Subtract(SizeInt value)
 {
     return new VectorInt(x - value.X, y - value.Y);
 }
示例#27
0
 public RectangleInt(VectorInt aTopLeft, SizeInt aSize)
 {
     TopLeft = aTopLeft;
     BottomRight = aTopLeft.Add(aSize);
 }
示例#28
0
 public SizeInt(SizeInt copy)
     : this(copy.X, copy.Y)
 {
 }
示例#29
0
 public VectorInt Divide(SizeInt value)
 {
     return new VectorInt(x / value.X, y / value.Y);
 }
 public BitmapViewerVisualisation(Dictionary<string, BitmapViewer.Layer> layers, SizeInt size)
 {
     GridSize = size;
     CellSize = new SizeInt(16, 16);
     this.layers = layers;
 }