示例#1
0
        private Rectangle GetCellPosition(MapCell c)
        {
            Rectangle result = new Rectangle();

            int width = (int)(c.CurRectange.Width * GLOBAL.scale);
            int height = (int)(c.CurRectange.Height * GLOBAL.scale);

            result.X = width * c.Position.X + (int)GLOBAL.centreCamera.X;
            result.Y = height * c.Position.Y + (int)GLOBAL.centreCamera.Y;
            result.Width = width;
            result.Height = height;

            //result.X = curRectange.X + (int)GLOBAL.centreCamera.X;
            //result.Y = curRectange.Y + (int)GLOBAL.centreCamera.Y;
            //result.Width = (int)(curRectange.Width * GLOBAL.scale);
            //result.Height = (int)(curRectange.Height * GLOBAL.scale);
            return result;
        }
示例#2
0
        public MapCell GetSelectedMapCell(MouseState e)
        {
            MapCell result = new MapCell();
            foreach(MapRow row in Rows)
            {
                foreach(MapCell cell in row.Columns)
                {
                    //Rectangle cellPosition = GetCellPosition(cell.CurRectange);
                    Rectangle cellPos = GetCellPosition(cell);
                    if (GLOBAL.IsSelected(e, cellPos))
                    {
                        if (result.Depth <= cell.Depth && cell.TileSet != null)
                            result = cell;
                    }
                }
            }

            if (result.TileSet != null)
                return result;
            else return null;
        }
示例#3
0
        private MapCell FindTextureByGidData(int v)
        {
            MapCell result = new MapCell();
            foreach (TileSet ts in tileSet)
            {
                if (ts.Firstgrid <= v && (ts.Firstgrid + ts.Tilecount) >= v)
                {
                    result.TileSet = ts;

                    int dem = ts.Firstgrid;
                    for(int i = 0; i < ts.ImgHeight.First()/32; i++)
                        for (int j = 0;  j < ts.ImgWidth.First() / 32; j++)
                        {
                            if (dem == v)
                            {
                                Rectangle sourRectange = new Rectangle(j * 32, i * 32,  32, 32);
                                result.SourceRectange = sourRectange;
                            }
                            dem++;
                        }
                }
            }
            return result;
        }
示例#4
0
        public Soldier(MapCell pos)
        {
            curDirection = rand.Next(0, 4);
            position = pos;

            if (Characters == null)
            {
                Characters = new List<Texture2D>();
                Star = GLOBAL.Content.Load<Texture2D>(@"Characters\\star-icon");
                Texture2D Character2 = GLOBAL.Content.Load<Texture2D>(@"Characters\\DoomCharSergeant");
                Characters.Add(Character2);

                Texture2D Character1 = GLOBAL.Content.Load<Texture2D>(@"Characters\\DoomCharPrivate");
                Characters.Add(Character1);
            }

            width = Characters[GLOBAL.curSolid].Width / 4;
            height = Characters[GLOBAL.curSolid].Height / 4;
            float scaletemp = (float)width / 32;
            desRec = new Rectangle(0, 0, 32, (int)(height / scaletemp) + 1);
            curPos = new Point(position.CurRectange.X, position.CurRectange.Y + position.CurRectange.Height - desRec.Height);
            if (down == null)
            {
                Rectangle step1 = new Rectangle(0, 0, width, height);
                Rectangle step2 = new Rectangle(width, 0, width, height);
                Rectangle step3 = new Rectangle(width * 2, 0, width, height);
                Rectangle step4 = new Rectangle(width * 3, 0, width, height);
                down = new List<Rectangle>();
                down.Add(step1);
                down.Add(step2);
                down.Add(step3);
                down.Add(step4);
            }
            if (left == null)
            {
                Rectangle step1 = new Rectangle(0, height, width, height);
                Rectangle step2 = new Rectangle(width, height, width, height);
                Rectangle step3 = new Rectangle(width * 2, height, width, height);
                Rectangle step4 = new Rectangle(width * 3, height, width, height);
                left = new List<Rectangle>();
                left.Add(step1);
                left.Add(step2);
                left.Add(step3);
                left.Add(step4);
            }
            if (right == null)
            {
                Rectangle step1 = new Rectangle(0, 2 * height, width, height);
                Rectangle step2 = new Rectangle(width, 2 * height, width, height);
                Rectangle step3 = new Rectangle(width * 2, 2 * height, width, height);
                Rectangle step4 = new Rectangle(width * 3, 2 * height, width, height);
                right = new List<Rectangle>();
                right.Add(step1);
                right.Add(step2);
                right.Add(step3);
                right.Add(step4);
            }
            if (up == null)
            {
                Rectangle step1 = new Rectangle(0, 3 * height, width, height);
                Rectangle step2 = new Rectangle(width, 3 * height, width, height);
                Rectangle step3 = new Rectangle(width * 2, 3 * height, width, height);
                Rectangle step4 = new Rectangle(width * 3, 3 * height, width, height);
                up = new List<Rectangle>();
                up.Add(step1);
                up.Add(step2);
                up.Add(step3);
                up.Add(step4);
            }
        }