Exemplo n.º 1
0
 /// <summary>
 /// Changes the currently selected quadrant in the QuadrantPanel when
 /// a tile is selected in TileView.
 /// That is, fires
 ///   TopView.Control.SelectQuadrant()
 /// and
 ///   TopRouteView.ControlTop.SelectQuadrant()
 /// through 'TileSelectedEvent_Observer0'.
 /// </summary>
 /// <param name="part"></param>
 private void SelectQuadrant(TilepartBase part)
 {
     if (TileSelectedEvent_Observer0 != null)
     {
         TileSelectedEvent_Observer0(part);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Changes the selected quadrant in the QuadrantPanel when a tilepart
 /// is selected in TileView.
 /// </summary>
 /// <param name="part"></param>
 private static void OnTileSelected_Observer0(TilepartBase part)
 {
     if (part != null && part.Record != null)
     {
         TopView.Control.SelectQuadrant(part.Record.TileType);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Changes the currently selected quadrant in the QuadrantPanel when
        /// a tile is selected in TileView.
        /// That is, fires 'TopView.Control.SelectQuadrant' through
        /// 'TileSelectedEvent_Observer0'.
        /// </summary>
        /// <param name="part"></param>
        private void SelectQuadrant(TilepartBase part)
        {
            var handler = TileSelectedEvent_Observer0;

            if (handler != null)
            {
                handler(part);
            }
        }
Exemplo n.º 4
0
//		private static bool CheckAnyIsLoft(int[] necessary)
//		{
//			foreach (var loft in _loftList)
//				foreach (var gottfried in necessary)
//					if (gottfried == loft)
//						return true;
//
//			return false;
//		}

        /// <summary>
        /// Checks if a tilepart is either a standard door or a ufo door.
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        internal static bool IsDoor(TilepartBase part)
        {
            var record = part.Record;

            if (record != null &&
                (record.HumanDoor || record.UfoDoor))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
 internal XCMapTile(
     TilepartBase ground,
     TilepartBase west,
     TilepartBase north,
     TilepartBase content)
 {
     _ground  = ground;
     _west    = west;
     _north   = north;
     _content = content;
 }
Exemplo n.º 6
0
        private void SetQuadrantPart(QuadrantType quad, TilepartBase part)
        {
            switch (quad)
            {
            case QuadrantType.Ground:  _ground = part; break;

            case QuadrantType.West:    _west = part; break;

            case QuadrantType.North:   _north = part; break;

            case QuadrantType.Content: _content = part; break;
            }
        }
Exemplo n.º 7
0
        public XCMapTile(
            TilepartBase ground,
            TilepartBase west,
            TilepartBase north,
            TilepartBase content)
        {
            _ground  = ground;             // NOTE: Don't even try ... don't even think about it.
            _west    = west;
            _north   = north;
            _content = content;

            Vacancy();
        }
        private static void Count(
            TilepartBase part,
            IDictionary recordsTable,
            IDictionary spritesTable)
        {
            if (part != null)
            {
                recordsTable[part.Record.SetId] = true;

                var sprites = part.Anisprites;
                foreach (PckImage sprite in sprites)
                {
                    spritesTable[sprite.SetId] = true;
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Fires when a tile is selected. Passes an event to
        /// 'TileSelectedEvent_Observer0'.
        /// </summary>
        /// <param name="part"></param>
        private void OnTileSelected(TilepartBase part)
        {
            var f = FindForm();

            McdRecord record = null;

            if (part != null)
            {
                f.Text = BuildTitleString(part.SetId, part.TerId);
                record = part.Record;
            }
            else
            {
                f.Text = "TileView";
            }

            if (_mcdInfoForm != null)
            {
                _mcdInfoForm.UpdateData(record);
            }

            SelectQuadrant(part);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the terrain-type given a tile-part.
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public string GetTerrainLabel(TilepartBase part)
        {
            int id = -1;

            foreach (var tile1 in Parts)
            {
                if (tile1.Id == 0)
                {
                    ++id;
                }

                if (tile1 == part)
                {
                    break;
                }
            }

            if (id != -1 && id < Terrains.Count)
            {
                return(Terrains[id]);
            }

            return(null);
        }
Exemplo n.º 11
0
        public Tuple <string, string> GetTerrain(TilepartBase part)
        {
            int id = -1;

            foreach (var part_ in Parts)
            {
                if (part_.TerId == 0)
                {
                    ++id;
                }

                if (part_ == part)
                {
                    break;
                }
            }

            if (id != -1 && id < Terrains.Count)
            {
                return(Terrains[id]);
            }

            return(null);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Draws the tileparts in the Tile.
        /// </summary>
        /// <param name="tile"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="isGray"></param>
        private void DrawTile(
            XCMapTile tile,
            int x, int y,
            bool isGray)
        {
            // NOTE: The width and height args are based on a sprite that's 32x40.
            // Going back to a universal sprite-size would do this:
            //   (int)(sprite.Width  * Globals.Scale)
            //   (int)(sprite.Height * Globals.Scale)
            // with its attendent consequences.

            TilepartBase part = null;

            var topView = ViewerFormsManager.TopView.Control;

            if (topView.GroundVisible)
            {
                if ((part = tile.Ground) != null)
                {
                    var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray
                                                                                  : part[MainViewUnderlay.AniStep].Image;
                    DrawSprite(
                        sprite,
                        new Rectangle(
                            x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst,
                            HalfWidth * 2, HalfHeight * 5));
                }
            }

            if (topView.WestVisible)
            {
                if ((part = tile.West) != null)
                {
                    var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray
                                                                                  : part[MainViewUnderlay.AniStep].Image;
                    DrawSprite(
                        sprite,
                        new Rectangle(
                            x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst,
                            HalfWidth * 2, HalfHeight * 5));
                }
            }

            if (topView.NorthVisible)
            {
                if ((part = tile.North) != null)
                {
                    var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray
                                                                                  : part[MainViewUnderlay.AniStep].Image;
                    DrawSprite(
                        sprite,
                        new Rectangle(
                            x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst,
                            HalfWidth * 2, HalfHeight * 5));
                }
            }

            if (topView.ContentVisible)
            {
                if ((part = tile.Content) != null)
                {
                    var sprite = (isGray) ? part[MainViewUnderlay.AniStep].SpriteGray
                                                                                  : part[MainViewUnderlay.AniStep].Image;
                    DrawSprite(
                        sprite,
                        new Rectangle(
                            x, y - part.Record.TileOffset * HalfHeight / HalfHeightConst,
                            HalfWidth * 2, HalfHeight * 5));
                }
            }
        }
Exemplo n.º 13
0
        private const int Offset = 4;         // offset the blobs from the grid-lines a bit.

        /// <summary>
        /// Draws wall- and content- blobs for RouteView and TopView.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="tool"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="part"></param>
        internal void DrawContent(
            Graphics g,
            ColorTools tool,
            int x, int y,
            TilepartBase part)
        {
            var ptTop = new Point(
                x,
                (y > Int32.MaxValue - Offset) ? Int32.MaxValue : y + Offset);                                                 // <- FxCop ...
            var ptBot = new Point(
                x,
                y + (HalfHeight * 2) - Offset);
            var ptLeft = new Point(
                x - HalfWidth + (Offset * 2),
                y + HalfHeight);
            var ptRight = new Point(
                x + HalfWidth - (Offset * 2),
                y + HalfHeight);

            switch (BlobTypeService.GetBlobType(part))
            {
            // content ->
            case BlobType.Content:
                PathContent(x, y);
                g.FillPath(
                    tool.Brush,
                    _content);
                break;

            // floor ->
            case BlobType.Floor:
                PathContent(x, y);
                g.FillPath(
                    tool.BrushLight,
                    _content);
                break;

            // walls ->
            case BlobType.NorthWallFence:
                g.DrawLine(
                    tool.PenLight,
                    ptTop,
                    ptRight);
                break;

            case BlobType.NorthWall:
                g.DrawLine(
                    tool.Pen,
                    ptTop,
                    ptRight);

                if (BlobTypeService.IsDoor(part))
                {
                    g.DrawLine(
                        tool.Pen,
                        x + HalfWidth, y,
                        x, y + HalfHeight);
                }
                break;

            case BlobType.WestWallFence:
                g.DrawLine(
                    tool.PenLight,
                    ptTop,
                    ptLeft);
                break;

            case BlobType.WestWall:
                g.DrawLine(
                    tool.Pen,
                    ptTop,
                    ptLeft);

                if (BlobTypeService.IsDoor(part))
                {
                    g.DrawLine(
                        tool.Pen,
                        x - HalfWidth, y,
                        x, y + HalfHeight);
                }
                break;

            case BlobType.NorthWallWindow:
                DrawWindow(
                    g,
                    tool,
                    ptTop,
                    ptRight);
                break;

            case BlobType.WestWallWindow:
                DrawWindow(
                    g,
                    tool,
                    ptTop,
                    ptLeft);
                break;

            case BlobType.SouthWall:
                g.DrawLine(
                    tool.Pen,
                    ptLeft,
                    ptBot);
                break;

            case BlobType.EastWall:
                g.DrawLine(
                    tool.Pen,
                    ptBot,
                    ptRight);
                break;

            // diagonals ->
            case BlobType.NorthwestSoutheast:
                g.DrawLine(
                    tool.Pen,
                    ptTop,
                    ptBot);
                break;

            case BlobType.NortheastSouthwest:
                g.DrawLine(
                    tool.Pen,
                    ptLeft,
                    ptRight);
                break;

            // corners ->
            case BlobType.NorthwestCorner:
                g.DrawLine(
                    tool.Pen,
                    Point.Add(ptTop, new Size(-Offset - Offset / 2, 0)),
                    Point.Add(ptTop, new Size(Offset + Offset / 2, 0)));
                break;

            case BlobType.NortheastCorner:
                g.DrawLine(
                    tool.Pen,
                    Point.Add(ptRight, new Size(0, -Offset)),
                    Point.Add(ptRight, new Size(0, Offset)));
                break;

            case BlobType.SoutheastCorner:
                g.DrawLine(
                    tool.Pen,
                    Point.Add(ptBot, new Size(-Offset - Offset / 2, 0)),
                    Point.Add(ptBot, new Size(Offset + Offset / 2, 0)));
                break;

            case BlobType.SouthwestCorner:
                g.DrawLine(
                    tool.Pen,
                    Point.Add(ptLeft, new Size(0, -Offset)),
                    Point.Add(ptLeft, new Size(0, Offset)));
                break;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the BlobType of a given tile for drawing its blob in TopView
        /// and/or RouteView.
        /// NOTE: The checks are not robust; the return BlobType is just a guess
        /// based on what LoFTs have been assigned (externally) to a given tile.
        /// </summary>
        /// <remarks>http://www.ufopaedia.org/index.php/LOFTEMPS.DAT</remarks>
        /// <param name="part"></param>
        /// <returns></returns>
        internal static BlobType GetBlobType(TilepartBase part)
        {
            var record = part.Record;

            if (record != null)
            {
                _loftList = record.GetLoftList();

                // Floor
                if (CheckFloor())
                {
                    return(BlobType.Floor);
                }


                // East
                if (CheckAllAreInGroup(new[] { 24, 26 }))               //, 28, 30, 32, 34 }))
                {
                    return(BlobType.EastWall);
                }

                // South
                if (CheckAllAreInGroup(new[] { 23, 25 }))               //, 27, 29, 31, 33 }))
                {
                    return(BlobType.SouthWall);
                }


                // North ->
                if (CheckAnyIsLoft(38) &&
                    CheckAllAreInGroup(new[] { 8, 10, 12, 14, 38 }))
                {
                    return(BlobType.NorthWallWindow);
                }

                if (CheckAnyIsLoft(0) &&
                    CheckAllAreInGroup(new[] { 0, 8, 10, 12, 14, 38, 39, 77 }))                       // 40,41
                {
                    return(BlobType.NorthWallFence);
                }

                if (CheckAllAreInGroup(new[] { 8, 10, 12, 14 }))               //, 16, 18, 20, 21 }))
                {
                    return(BlobType.NorthWall);
                }


                // West ->
                if (CheckAnyIsLoft(37) &&
                    CheckAllAreInGroup(new[] { 7, 9, 11, 13, 37 }))
                {
                    return(BlobType.WestWallWindow);
                }

                if (CheckAnyIsLoft(0) &&
                    CheckAllAreInGroup(new[] { 0, 7, 9, 11, 13, 37, 39, 76 }))                       // 40,41
                {
                    return(BlobType.WestWallFence);
                }

                if (CheckAllAreInGroup(new[] { 7, 9, 11, 13 }))               //, 15, 17, 19, 22 }))
                {
                    return(BlobType.WestWall);
                }


                // diagonals ->
//				if (CheckAllAreLoftExcludeFloor(35))
                if (CheckAllAreLoft(35))
                {
                    return(BlobType.NorthwestSoutheast);
                }

//				if (CheckAllAreLoftExcludeFloor(36))
                if (CheckAllAreLoft(36))
                {
                    return(BlobType.NortheastSouthwest);
                }


                // corners ->
                if (CheckAllAreInGroup(new[] { 39, 40, 41, 103 }))                // 102,101
                {
                    return(BlobType.NorthwestCorner);
                }

                if (CheckAllAreLoft(100))                 // 99,98
                {
                    return(BlobType.NortheastCorner);
                }

                if (CheckAllAreLoft(106))                 // 105,104
                {
                    return(BlobType.SouthwestCorner);
                }

                if (CheckAllAreLoft(109))                 // 108,107
                {
                    return(BlobType.SoutheastCorner);
                }
            }
            return(BlobType.Content);
        }