示例#1
0
        public CannonStub CanInsertCannonStub(FPoint center, ILeveleditorStub ign)
        {
            var s2 = CanInsertCannonStub(center, CannonStub.SCALES[2], ign);

            if (s2 != null)
            {
                return(s2);
            }

            var s3 = CanInsertCannonStub(center, CannonStub.SCALES[1], ign);

            if (s3 != null)
            {
                return(s3);
            }

            var s4 = CanInsertCannonStub(center, CannonStub.SCALES[0], ign);

            if (s4 != null)
            {
                return(s4);
            }

            return(null);
        }
示例#2
0
        public CannonStub CanInsertCannonStub(FPoint center, float scale, ILeveleditorStub ign)
        {
            if (center.X <= 0)
            {
                return(null);
            }
            if (center.Y <= 0)
            {
                return(null);
            }
            if (center.X >= LevelData.Width * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (center.Y >= LevelData.Height * GDConstants.TILE_WIDTH)
            {
                return(null);
            }

            CannonStub s = new CannonStub(this, center, scale);

            foreach (var stub in GetEntities <ILeveleditorStub>().Where(stub => stub != ign))
            {
                if (stub.CollidesWith(s))
                {
                    return(null);
                }
            }

            return(s);
        }
示例#3
0
        public WallStub CanInsertWallStub(FPoint p1, float width, ILeveleditorStub ign)
        {
            WallStub w0 = CanInsertWallStub(p1, p1 + new Vector2(width, 0), ign);

            if (w0 != null)
            {
                return(w0);
            }

            WallStub w1 = CanInsertWallStub(p1, p1 + new Vector2(width, width), ign);

            if (w1 != null)
            {
                return(w1);
            }

            WallStub w2 = CanInsertWallStub(p1, p1 + new Vector2(0, width), ign);

            if (w2 != null)
            {
                return(w2);
            }

            return(null);
        }
示例#4
0
        public PortalStub CanInsertPortalStub(FPoint center, float len, float norm, ILeveleditorStub ign)
        {
            PortalStub s = new PortalStub(this, center, len, norm);

            foreach (var stub in GetEntities <ILeveleditorStub>().Where(stub => stub != ign))
            {
                if (stub.CollidesWith(s))
                {
                    return(null);
                }
            }

            return(s);
        }
        public void Recreate(ILeveleditorStub selection)
        {
            ClearChildren();
            if (selection == null)
            {
                IsVisible = false;
                return;
            }

            IsVisible = true;

            int i = 0;

            foreach (var opt in selection.AttrOptions)
            {
                AddElement(new AttributeButton
                {
                    RelativePosition = new FPoint(32 + i * (128 + 64), 32),
                    Size             = new FSize(128, 128),
                    Alignment        = HUDAlignment.BOTTOMLEFT,

                    Data = opt,
                });
                i++;
            }

            AddElement(new HUDTextButton
            {
                RelativePosition = new FPoint(32, 32),
                Size             = new FSize(192, 64),
                Alignment        = HUDAlignment.BOTTOMRIGHT,

                L10NText      = L10NImpl.STR_LVLED_BTN_DEL,
                TextColor     = Color.White,
                Font          = Textures.HUDFontRegular,
                FontSize      = 48,
                TextAlignment = HUDAlignment.CENTER,
                TextPadding   = 8,

                Click = DeleteSelected,

                BackgroundNormal  = HUDBackgroundDefinition.CreateSimpleOutline(FlatColors.Pomegranate, Color.Black, HUD.PixelWidth),
                BackgroundPressed = HUDBackgroundDefinition.CreateSimpleOutline(FlatColors.Alizarin, Color.Black, HUD.PixelWidth),
            });
        }
示例#6
0
        public void SelectStub(ILeveleditorStub stub)
        {
            Selection = stub;

            GDHUD.AttrPanel.Recreate(Selection);
        }
示例#7
0
        public ObstacleStub CanInsertObstacleStub(FPoint center, ObstacleStub.ObstacleStubType t, float w, float h, float r, ILeveleditorStub ign)
        {
            if (center.X <= 0)
            {
                return(null);
            }
            if (center.Y <= 0)
            {
                return(null);
            }
            if (center.X >= LevelData.Width * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (center.Y >= LevelData.Height * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (FloatMath.IsEpsilonZero(w))
            {
                return(null);
            }
            if (FloatMath.IsEpsilonZero(h))
            {
                return(null);
            }

            ObstacleStub s = new ObstacleStub(this, center, t, w, h, r);

            foreach (var stub in GetEntities <ILeveleditorStub>().Where(stub => stub != ign))
            {
                if (stub.CollidesWith(s))
                {
                    return(null);
                }
            }

            return(s);
        }
示例#8
0
        public WallStub CanInsertWallStub(FPoint p1, FPoint p2, ILeveleditorStub ign)
        {
            if (p1.X <= 0 && p2.X <= 0)
            {
                return(null);
            }
            if (p1.Y <= 0 && p2.Y <= 0)
            {
                return(null);
            }
            if (p1.X >= LevelData.Width * GDConstants.TILE_WIDTH && p2.X >= LevelData.Width * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p1.Y >= LevelData.Height * GDConstants.TILE_WIDTH && p2.Y >= LevelData.Height * GDConstants.TILE_WIDTH)
            {
                return(null);
            }

            if (p1 == p2)
            {
                return(null);
            }

            if (p1.X <= (-4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p1.Y <= (-4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p1.X >= (LevelData.Width + 4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p1.Y >= (LevelData.Height + 4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }

            if (p2.X <= (-4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p2.Y <= (-4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p2.X >= (LevelData.Width + 4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }
            if (p2.Y >= (LevelData.Height + 4) * GDConstants.TILE_WIDTH)
            {
                return(null);
            }


            WallStub s = new WallStub(this, p1, p2);

            foreach (var stub in GetEntities <ILeveleditorStub>().Where(stub => stub != ign))
            {
                if (stub.CollidesWith(s))
                {
                    return(null);
                }
            }

            return(s);
        }
        protected override void OnUpdate(LevelEditorScreen screen, SAMTime gameTime, InputState istate)
        {
            const float raster = (GDConstants.TILE_WIDTH / 2f);
            var         x      = raster * FloatMath.Round(istate.GamePointerPositionOnMap.X / raster);
            var         y      = raster * FloatMath.Round(istate.GamePointerPositionOnMap.Y / raster);

            if (_gdScreen.Mode == LevelEditorMode.AddCannon && istate.IsExclusiveJustDown)
            {
                istate.Swallow(InputConsumer.GameBackground);

                var stub = _gdScreen.CanInsertCannonStub(new FPoint(x, y), null);
                if (stub != null)
                {
                    _preview = stub;
                    _gdScreen.Entities.AddEntity(stub);
                    _gdScreen.SelectStub(_preview);
                    _gdScreen.DragAgent.ManualStartCannonMove(istate);
                }
            }

            if (_gdScreen.Mode == LevelEditorMode.AddObstacle && istate.IsExclusiveJustDown)
            {
                istate.Swallow(InputConsumer.GameBackground);

                var stub = _gdScreen.CanInsertObstacleStub(
                    new FPoint(x, y),
                    ObstacleStub.ObstacleStubType.VoidVircle,
                    GDConstants.TILE_WIDTH * 2f,
                    GDConstants.TILE_WIDTH * 2f,
                    0,
                    null);

                if (stub != null)
                {
                    _preview = stub;
                    _gdScreen.Entities.AddEntity(stub);
                    _gdScreen.SelectStub(_preview);
                    _gdScreen.DragAgent.ManualStartObstacleMove(istate);
                }
            }

            if (_gdScreen.Mode == LevelEditorMode.AddWall && istate.IsExclusiveJustDown)
            {
                istate.Swallow(InputConsumer.GameBackground);

                var stub = _gdScreen.CanInsertWallStub(new FPoint(x, y), GDConstants.TILE_WIDTH * 2, null);

                if (stub != null)
                {
                    _preview = stub;
                    _gdScreen.Entities.AddEntity(stub);
                    _gdScreen.SelectStub(_preview);
                    _gdScreen.DragAgent.ManualStartWallDragP2(istate);
                }
            }

            if (_gdScreen.Mode == LevelEditorMode.AddPortal && istate.IsExclusiveJustDown)
            {
                istate.Swallow(InputConsumer.GameBackground);

                var stub = _gdScreen.CanInsertPortalStub(new FPoint(x, y), GDConstants.TILE_WIDTH * 2, 0, null);

                if (stub != null)
                {
                    _preview = stub;
                    _gdScreen.Entities.AddEntity(stub);
                    _gdScreen.SelectStub(_preview);
                    _gdScreen.DragAgent.ManualStartPortalMove(istate);
                }
            }
        }