/// <summary>
		/// 
		/// </summary>
		/// <param name="wallswitch"></param>
		/// <param name="maze"></param>
		public GeneratorControl(WallSwitch wallswitch, Maze maze)
		{
			InitializeComponent();
		}
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="wallswitch"></param>
 /// <param name="maze"></param>
 public GeneratorControl(WallSwitch wallswitch, Maze maze)
 {
     InitializeComponent();
 }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="wallswitch"></param>
		/// <param name="maze"></param>
		public LauncherControl(WallSwitch wallswitch, Maze maze)
		{
			InitializeComponent();
		}
Beispiel #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="wallswitch"></param>
 /// <param name="maze"></param>
 public LauncherControl(WallSwitch wallswitch, Maze maze)
 {
     InitializeComponent();
 }
Beispiel #5
0
        /// <summary>
        /// Renders the dungeon
        /// </summary>
        private void RenderDungeon()
        {
            if (SpriteBatch == null)
            {
                return;
            }

            glControl.MakeCurrent();
            Display.ClearBuffers();

            SpriteBatch.Begin();

            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, glControl.Size);

            SpriteBatch.Draw(CheckerBoard, dst, dst, Color.White);


            // Nom maze, bye bye
            if (Maze == null)
            {
                SpriteBatch.End();
                glControl.SwapBuffers();
                return;
            }


            #region Squares
            for (int y = 0; y < Maze.Size.Height; y++)
            {
                for (int x = 0; x < Maze.Size.Width; x++)
                {
                    Point  coord  = new Point(x, y);
                    Square block  = Maze.GetSquare(coord);
                    int    tileid = block.Type == SquareType.Ground ? 1 : 0;

                    // Location of the block on the screen
                    Point location = new Point(Offset.X + x * 25, Offset.Y + y * 25);


                    Color color = Color.White;
                    if (block.Type == SquareType.Illusion)
                    {
                        color = Color.LightGreen;
                    }

                    SpriteBatch.DrawTile(Icons, tileid, location, color);

                    if (block.ItemCount > 0)
                    {
                        SpriteBatch.DrawTile(Icons, 19, location);
                    }


                    #region Actor
                    if (block.Actor != null)
                    {
                        // Doors
                        if (block.Actor is Door)
                        {
                            Door door = block.Actor as Door;

                            if (Maze.IsDoorNorthSouth(block.Location))
                            {
                                tileid = 3;
                            }
                            else
                            {
                                tileid = 2;
                            }


                            // Door opened or closed
                            if (door.State == DoorState.Broken || door.State == DoorState.Opened || door.State == DoorState.Opening)
                            {
                                tileid += 2;
                            }

                            SpriteBatch.DrawTile(Icons, tileid, location);
                        }


                        else if (block.Actor is PressurePlate)
                        {
                            SpriteBatch.DrawTile(Icons, 18, location);
                        }

                        else if (block.Actor is Pit)
                        {
                            SpriteBatch.DrawTile(Icons, 9, location);
                        }

                        else if (block.Actor is Teleporter)
                        {
                            SpriteBatch.DrawTile(Icons, 11, location);
                        }

                        else if (block.Actor is ForceField)
                        {
                            ForceField field = block.Actor as ForceField;

                            if (field.Type == ForceFieldType.Spin)
                            {
                                tileid = 12;
                            }
                            else if (field.Type == ForceFieldType.Move)
                            {
                                tileid = 13 + (int)field.Direction;
                            }
                            else
                            {
                                tileid = 17;
                            }

                            SpriteBatch.DrawTile(Icons, tileid, location);
                        }

                        else if (block.Actor is Stair)
                        {
                            Stair stair = block.Actor as Stair;
                            tileid = stair.Type == StairType.Up ? 6 : 7;
                            SpriteBatch.DrawTile(Icons, tileid, location);
                        }

                        else if (block.Actor is EventSquare)
                        {
                            SpriteBatch.DrawTile(Icons, 26, location);
                        }
                        else if (block.Actor is WallSwitch)
                        {
                            // Display coords
                            Point[] sides = new Point[]
                            {
                                new Point(7, 0),
                                new Point(7, 19),
                                new Point(0, 7),
                                new Point(19, 7),
                            };

                            WallSwitch wall = block.Actor as WallSwitch;

                            tileid = (int)wall.Side > 1 ? 102 : 103;
                            SpriteBatch.DrawTile(Icons, tileid, new Point(
                                                     Offset.X + x * 25 + sides[(int)wall.Side].X,
                                                     Offset.Y + y * 25 + sides[(int)wall.Side].Y));
                        }
                    }
                    #endregion


                    #region Decoration
                    if (block.HasDecorations)
                    {
                        foreach (CardinalPoint side in Enum.GetValues(typeof(CardinalPoint)))
                        {
                            if (block.HasDecoration(side))
                            {
                                Point[] from = new Point[]
                                {
                                    new Point(1, 1),
                                    new Point(1, 24),
                                    new Point(1, 1),
                                    new Point(24, 1),
                                };

                                Point[] to = new Point[]
                                {
                                    new Point(24, 1),
                                    new Point(24, 24),
                                    new Point(1, 24),
                                    new Point(24, 24),
                                };

                                Point offset = new Point(Offset.X + x * 25, Offset.Y + y * 25);

                                SpriteBatch.DrawLine(
                                    new Point(from[(int)side].X + offset.X, from[(int)side].Y + offset.Y),
                                    new Point(to[(int)side].X + offset.X, to[(int)side].Y + offset.Y),
                                    Color.LightGreen);
                            }
                        }
                    }
                    #endregion


                    if (block.NoMonster)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X, location.Y, 25, 25), Color.FromArgb(128, Color.Blue));
                    }


                    if (block.NoGhost)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X, location.Y, 25, 25), Color.FromArgb(128, Color.Green));
                    }


                    // Monsters
                    if (block.Monsters[0] != null)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X + 4, location.Y + 4, 4, 4), Color.Red);
                    }
                    if (block.Monsters[1] != null)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X + 16, location.Y + 4, 4, 4), Color.Red);
                    }
                    if (block.Monsters[2] != null)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X + 4, location.Y + 16, 4, 4), Color.Red);
                    }
                    if (block.Monsters[3] != null)
                    {
                        SpriteBatch.FillRectangle(new Rectangle(location.X + 16, location.Y + 16, 4, 4), Color.Red);
                    }
                }
            }
            #endregion


            // Preview pos
            SpriteBatch.DrawTile(Icons, 22 + (int)PreviewLoc.Direction, new Point(Offset.X + PreviewLoc.Coordinate.X * 25, Offset.Y + PreviewLoc.Coordinate.Y * 25));


            // Starting point
            if (Dungeon.StartLocation.Maze == Maze.Name)
            {
                SpriteBatch.DrawTile(Icons, 20,
                                     new Point(Offset.X + Dungeon.StartLocation.Coordinate.X * 25, Offset.Y + Dungeon.StartLocation.Coordinate.Y * 25));
            }


            // Surround the selected object
            if (CurrentSquare != null)
            {
                SpriteBatch.DrawRectangle(new Rectangle(CurrentSquare.Location.X * 25 + Offset.X, CurrentSquare.Location.Y * 25 + Offset.Y, 25, 25), Color.White);
            }


            // If the current actor has scripts
            if (SquareUnderMouse != null && SquareUnderMouse.Actor != null)
            {
                SquareActor actor = SquareUnderMouse.Actor;
                foreach (DungeonLocation target in actor.GetTargets())
                {
                    if (target == null)
                    {
                        continue;
                    }

                    //DungeonLocation target = script.Action.Target;
                    if (target.Maze == Maze.Name)
                    {
                        Point from = new Point(BlockCoord.X * 25 + Offset.X + 12, BlockCoord.Y * 25 + Offset.Y + 12);
                        Point to   = new Point(target.Coordinate.X * 25 + Offset.X + 12, target.Coordinate.Y * 25 + Offset.Y + 12);
                        SpriteBatch.DrawLine(from, to, Color.Red);
                        SpriteBatch.DrawRectangle(new Rectangle(target.Coordinate.X * 25 + Offset.X, target.Coordinate.Y * 25 + Offset.Y, 25, 25), Color.Red);
                    }
                }
            }


            #region Display zones

            /*
             * if (DisplayZonesBox.Checked)
             * {
             *
             *      foreach (MazeZone zone in Maze.Zones)
             *      {
             *              Rectangle rect = new Rectangle(zone.Rectangle.X * 25, zone.Rectangle.Y * 25, zone.Rectangle.Width * 25, zone.Rectangle.Height * 25);
             *              Color color = Color.FromArgb(100, Color.Red);
             *
             *              if (CurrentZone == zone)
             *              {
             *                      color = Color.FromArgb(100, Color.Red);
             *                      SpriteBatch.DrawRectangle(rect, Color.White);
             *              }
             *
             *              SpriteBatch.FillRectangle(rect, color);
             *      }
             *
             *
             *      if (CurrentZone != null)
             *      {
             *              Rectangle rect = new Rectangle(CurrentZone.Rectangle.X * 25, CurrentZone.Rectangle.Y * 25, CurrentZone.Rectangle.Width * 25, CurrentZone.Rectangle.Height * 25);
             *              SpriteBatch.FillRectangle(rect, Color.FromArgb(128, Color.Blue));
             *      }
             * }
             */
            #endregion


            SpriteBatch.End();
            glControl.SwapBuffers();
        }