Exemple #1
0
        public Bitmap GetLayer2Image()
        {
            if (this.MapBuffer2 != null)
            {
                return(this.MapBuffer2);
            }

            this.MapBuffer2 = new Bitmap(this.MapWidth, this.MapHeight);
            var g2 = Graphics.FromImage(this.MapBuffer2);

            for (int HeightIdx = 0; HeightIdx < this.HeightPlan; ++HeightIdx)
            {
                for (int WidthIdx = 0; WidthIdx < this.WidthPlan; ++WidthIdx)
                {
                    int idx = 0;
                    if (HeightIdx == 0)
                    {
                        idx = WidthIdx;
                    }
                    else
                    {
                        idx = (HeightIdx * this.WidthPlan) + WidthIdx;
                    }


                    Plan _P = this.PlanLists[idx];
                    int  _X = 624 * (WidthIdx + HeightIdx);
                    int  _Y = 312 * (HeightIdx + this.HeightPlan - WidthIdx) - (_P.Info.UnknownShort4 >> 1);

                    if (_P.TileBlocks2 != null)
                    {
                        for (int m_Hidx = 0; m_Hidx < _P.TileBlocks2.Length; ++m_Hidx)
                        {
                            MapAttr _Ma = _P.TileBlocks2[m_Hidx];

                            for (int imgidx = 0; imgidx < this.ImgLists.Count; ++imgidx)
                            {
                                ImgInfo m = this.ImgLists[imgidx];
                                if (m.Img != null)
                                {
                                    if (_Ma.ImgIdx3 == m.ImgIdx)
                                    {
                                        int _Y2 = _Y + (_P.Info.UnknownShort4 >> 1) - (24 * (_Ma.ImgIdx - _Ma.ImgIdx2) - 24);
                                        int _X2 = _X + (48 * (_Ma.ImgIdx2 + _Ma.ImgIdx));
                                        g2.DrawImage(m.Img, new Point(_X2 + m.RelativeY, _Y2 + m.RelativeX));
                                        //Trace.WriteLine(string.Format("IMG: {0},{1} Idx {2} ", _X2, _Y2, idx));
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(this.MapBuffer2);
        }
Exemple #2
0
        public void CalculateSize()
        {
            this.MapWidth  = 0;
            this.MapHeight = 0;
            for (int HeightIdx = 0; HeightIdx < this.HeightPlan; ++HeightIdx)
            {
                for (int WidthIdx = 0; WidthIdx < this.WidthPlan; ++WidthIdx)
                {
                    int idx = 0;
                    if (HeightIdx == 0)
                    {
                        idx = WidthIdx;
                    }
                    else
                    {
                        idx = (HeightIdx * this.WidthPlan) + WidthIdx;
                    }

                    Plan _P = this.PlanLists[idx];

                    int _X = 624 * (WidthIdx + HeightIdx);
                    int _Y = 312 * (HeightIdx + this.HeightPlan - WidthIdx) - (_P.Info.UnknownShort4 >> 1);

                    for (int m_Hidx = 0; m_Hidx < _P.Info.MiniBlockHeight; ++m_Hidx)
                    {
                        for (int m_Widx = 0; m_Widx < _P.Info.MiniBlockWidth; ++m_Widx)
                        {
                            int idx2 = 0;
                            if (m_Hidx == 0)
                            {
                                idx2 = m_Widx;
                            }
                            else
                            {
                                idx2 = (m_Hidx * _P.Info.MiniBlockWidth) + m_Widx;
                            }

                            MapAttr _Ma = _P.TileBlocks[idx2];

                            if (_P.ImgLists.Count > 0)
                            {
                                for (int imgidx = 0; imgidx < _P.ImgLists.Count; ++imgidx)
                                {
                                    ImgInfo m = _P.ImgLists[imgidx];
                                    if (m.Img != null)
                                    {
                                        if (_Ma.ImgIdx == m.ImgIdx)
                                        {
                                            int _Y2 = _Y + (_P.Info.UnknownShort4 >> 1) - (24 * (m_Widx - m_Hidx) - 24) + m.RelativeY + m.Img.Height;
                                            int _X2 = _X + (48 * (m_Hidx + m_Widx)) + m.RelativeX + m.Img.Width;
                                            if (this.MapWidth < _X2)
                                            {
                                                this.MapWidth = _X2;
                                            }
                                            if (this.MapHeight < _Y2)
                                            {
                                                this.MapHeight = _Y2;
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int imgidx = 0; imgidx < this.ImgLists.Count; ++imgidx)
                                {
                                    ImgInfo m = this.ImgLists[imgidx];
                                    if (m.Img != null)
                                    {
                                        if (_Ma.ImgIdx == m.ImgIdx)
                                        {
                                            int _Y2 = _Y + (_P.Info.UnknownShort4 >> 1) - (24 * (m_Widx - m_Hidx) - 24) + m.RelativeY + m.Img.Height;
                                            int _X2 = _X + (48 * (m_Hidx + m_Widx)) + m.RelativeX + m.Img.Width;
                                            if (this.MapWidth < _X2)
                                            {
                                                this.MapWidth = _X2;
                                            }
                                            if (this.MapHeight < _Y2)
                                            {
                                                this.MapHeight = _Y2;
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        public Bitmap GetLayerImage()
        {
            if (this.MapBuffer != null)
            {
                return(this.MapBuffer);
            }
            this.MapBuffer = new Bitmap(this.MapWidth, this.MapHeight);
            var g = Graphics.FromImage(this.MapBuffer);

            for (int HeightIdx = 0; HeightIdx < this.HeightPlan; ++HeightIdx)
            {
                for (int WidthIdx = 0; WidthIdx < this.WidthPlan; ++WidthIdx)
                {
                    int idx = 0;
                    if (HeightIdx == 0)
                    {
                        idx = WidthIdx;
                    }
                    else
                    {
                        idx = (HeightIdx * this.WidthPlan) + WidthIdx;
                    }

                    Plan _P = this.PlanLists[idx];

                    int _X = 624 * (WidthIdx + HeightIdx);
                    int _Y = 312 * (HeightIdx + this.HeightPlan - WidthIdx) - (_P.Info.UnknownShort4 >> 1);

                    for (int m_Hidx = 0; m_Hidx < _P.Info.MiniBlockHeight; ++m_Hidx)
                    {
                        for (int m_Widx = 0; m_Widx < _P.Info.MiniBlockWidth; ++m_Widx)
                        {
                            int idx2 = 0;
                            if (m_Hidx == 0)
                            {
                                idx2 = m_Widx;
                            }
                            else
                            {
                                idx2 = (m_Hidx * _P.Info.MiniBlockWidth) + m_Widx;
                            }

                            MapAttr _Ma = _P.TileBlocks[idx2];

                            if (_P.ImgLists.Count > 0)
                            {
                                for (int imgidx = 0; imgidx < _P.ImgLists.Count; ++imgidx)
                                {
                                    ImgInfo m = _P.ImgLists[imgidx];
                                    if (m.Img != null)
                                    {
                                        if (_Ma.ImgIdx == m.ImgIdx)
                                        {
                                            int _Y2 = _Y + (_P.Info.UnknownShort4 >> 1) - (24 * (m_Widx - m_Hidx) - 24);
                                            int _X2 = _X + (48 * (m_Hidx + m_Widx));
                                            g.DrawImage(m.Img, new Point(_X2 + m.RelativeY, _Y2 + m.RelativeX));
                                            Rectangle r = new Rectangle(new Point(_X2 + m.RelativeY, _Y2 + m.RelativeX), new Size(m.Img.Width, m.Img.Height));
                                            g.DrawRectangle(Pens.AliceBlue, r);
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int imgidx = 0; imgidx < this.ImgLists.Count; ++imgidx)
                                {
                                    ImgInfo m = this.ImgLists[imgidx];
                                    if (m.Img != null)
                                    {
                                        if (_Ma.ImgIdx == m.ImgIdx)
                                        {
                                            int _Y2 = _Y + (_P.Info.UnknownShort4 >> 1) - (24 * (m_Widx - m_Hidx) - 24);
                                            int _X2 = _X + (48 * (m_Hidx + m_Widx));
                                            g.DrawImage(m.Img, new Point(_X2 + m.RelativeY, _Y2 + m.RelativeX));
                                            Rectangle r = new Rectangle(new Point(_X2 + m.RelativeY, _Y2 + m.RelativeX), new Size(m.Img.Width, m.Img.Height));
                                            g.DrawRectangle(Pens.AliceBlue, r);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(this.MapBuffer);
        }