Пример #1
0
        public SandboxGame()
        {
            _deviceManager = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            _penumbra = new PenumbraComponent(this, Transforms.OriginCenter_XRight_YUp | Transforms.Custom)
            {
                AmbientColor = Color.Black
            };
            Components.Add(_penumbra);
            _penumbraController = new PenumbraControllerComponent(this, _penumbra);
            Components.Add(_penumbraController);
            _scenarios = new ScenariosComponent(this, _penumbra, _penumbraController, _consoleInterpreter);
            Components.Add(_scenarios);
            var ui = new UIComponent(this, _penumbraController)
            {
                DrawOrder = int.MaxValue
            };
            Components.Add(ui);
            _camera = new CameraMovementComponent(this, _penumbra);
            Components.Add(_camera);
            Components.Add(new FpsGarbageComponent(this));
            _console = new ConsoleComponent(this);
            Components.Add(_console);

            // There's a bug when trying to change resolution during window resize.
            // https://github.com/mono/MonoGame/issues/3572
            _deviceManager.PreferredBackBufferWidth = 1280;
            _deviceManager.PreferredBackBufferHeight = 720;
            Window.AllowUserResizing = false;
            IsMouseVisible = true;
        }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _light = new PointLight
            {
                Position = new Vector2(-100, 0),
                Color = Color.White,
                Scale = new Vector2(600),
                Radius = 20
            };
            penumbra.Lights.Add(_light);

            Vector2[] hullVertices =
            {
                new Vector2(0, 50),
                new Vector2(14, 20),
                new Vector2(47, 15),
                new Vector2(23, -7),
                new Vector2(29, -40),
                new Vector2(0, -25),
                new Vector2(-29, -40),
                new Vector2(-24, -7),
                new Vector2(-47, 15),
                new Vector2(-14, 20),
            };

            penumbra.Hulls.Add(new Hull(hullVertices)
            {
                Position = new Vector2(0, 0),
            });
        }
 public ScenariosComponent(SandboxGame game, PenumbraComponent penumbra, PenumbraControllerComponent penumbraController, PythonInterpreter interpreter)
     : base(game)
 {
     _penumbra = penumbra;
     _penumbraController = penumbraController;
     _interpreter = interpreter;
 }
Пример #4
0
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _hulls.Clear();
            _lights.Clear();
            _lights.Add(new Spotlight
            {                
                Color = Color.YellowGreen,
                Scale = new Vector2(400),
                Radius = 20,
                ConeDecay = 1.5f
            });
            _lights.Add(new Spotlight
            {
                Color = Color.Wheat,
                Scale = new Vector2(1000),
                Rotation = MathHelper.Pi - MathHelper.PiOver2 * 0.75f,                                
                ConeDecay = 0.5f
            });
            _lights.Add(new Spotlight
            {
                Color = Color.Turquoise,
                Scale = new Vector2(900),
                Rotation = MathHelper.Pi + MathHelper.PiOver2 * 0.75f,
                ConeDecay = 1f
            });
            _lights.ForEach(penumbra.Lights.Add);            

            GenerateHulls(penumbra);
        }
 public override void Activate(PenumbraComponent penumbra, ContentManager content)
 {
     _light = new PointLight
     {
         Position = new Vector2(-150, 0),
         Color = Color.White,
         Scale = new Vector2(700),
         Radius = 20
     };
     penumbra.Lights.Add(_light);
     _hull1 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos1,
         Scale = new Vector2(90f)
     };
     _hull2 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos2,
         Scale = new Vector2(70f)
     };
     _hull3 = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = HullPos3,
         Scale = new Vector2(80f)
     };
     penumbra.Hulls.Add(_hull1);
     penumbra.Hulls.Add(_hull2);
     penumbra.Hulls.Add(_hull3);
 }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _isMovingLeft = false;
            _progress = 0;

            _penumbra = penumbra;
            var vertices = new[]
            {
                new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f)
            };

            _light1 = new PointLight
            {
                //Color = Color.OrangeRed,
                Color = Color.White,
                Scale = new Vector2(700),
                //Radius = 20,
                Radius = 40,
                ShadowType = ShadowType.Illuminated
            };
            //_light2 = new PointLight
            //{
            //    Color = Color.LightBlue,
            //    Range = 300,
            //    Radius = 20,
            //    ShadowType = ShadowType.Illuminated
            //};
            _penumbra.Lights.Add(_light1);
            //_penumbra.Lights.Add(_light2);

            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(-HullSpacing, 0), Scale = new Vector2(50f) });
            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(0, 0), Scale = new Vector2(50f) });
            _penumbra.Hulls.Add(new Hull(vertices) { Position = new Vector2(HullSpacing, 0), Scale = new Vector2(50f) });
        }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _state = State.MovingInward;
            _progress = 0;

            penumbra.Lights.Add(new PointLight
            {
                Position = new Vector2(0, -100),
                Color = Color.White,
                Scale = new Vector2(600),
                Radius = 20
            });

            Vector2[] hullVertices =
            {
                new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f)
            };
            _hull1 = new Hull(hullVertices)
            {
                Position = new Vector2(0, 0),
                Scale = new Vector2(50f)
            };
            _hull2 = new Hull(hullVertices)
            {
                Position = new Vector2(0, 0),
                Scale = new Vector2(50f)
            };
            penumbra.Hulls.Add(_hull1);
            penumbra.Hulls.Add(_hull2);
        }
Пример #8
0
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _isRadiusIncreasing = true;
            _progress = 0;

            _light = new PointLight
            {
                Position = new Vector2(-100, 0),
                Color = Color.White,
                Intensity = 1.5f,
                Scale = new Vector2(1200),
                Radius = MinLightRadius
            };
            penumbra.Lights.Add(_light);

            var hullVertices = new[]
            {
                new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f)
            };
            penumbra.Hulls.Add(new Hull(hullVertices)
            {
                Position = new Vector2(100, 0),
                Scale = new Vector2(50f)
            });
        }
Пример #9
0
 private void GenerateHulls(PenumbraComponent penumbra)
 {
     const float increment = MathHelper.TwoPi / NumHulls;
     const float distance = 185;
     for (int i = 0; i < NumHulls; i++)
     {
         float angle = increment * i;                
         var hull = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
         {
             Position = Rotate(new Vector2(0, distance), angle),
             Scale = new Vector2(50f)
         };
         _hulls.Add(hull);
         penumbra.Hulls.Add(hull);
     }
 }
 public override void Activate(PenumbraComponent penumbra, ContentManager content)
 {
     _light = new PointLight
     {
         Position = new Vector2(-100, 0),
         Color = Color.White,
         Scale = new Vector2(600),
         Radius = 20                
     };
     penumbra.Lights.Add(_light);
     penumbra.Hulls.Add(new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = new Vector2(0, 0),
         Scale = new Vector2(50f)
     });
 }
 public override void Activate(PenumbraComponent penumbra, ContentManager content)
 {
     Texture2D tex = content.Load<Texture2D>("LightTexture");
     _light = new TexturedLight(tex)
     {
         Position = new Vector2(-penumbra.GraphicsDevice.Viewport.Width / 2f, 0),
         Origin = new Vector2(0.5f, 1),
         Color = Color.White,
         Radius = 150,
         Rotation = MathHelper.PiOver2
     };
     penumbra.Lights.Add(_light);
     _hull = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
     {
         Position = Vector2.Zero,
         Scale = new Vector2(50)
     };
     penumbra.Hulls.Add(_hull);
 }
        public override void Activate(PenumbraComponent penumbra, ContentManager content)
        {
            _hull = new Hull(new Vector2(-0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, -0.5f), new Vector2(-0.5f, -0.5f))
            {
                Position = new Vector2(0, 0),
                Scale = new Vector2(50f)
            };
            penumbra.Hulls.Add(_hull);

            _light1 = new PointLight
            {
                Position = new Vector2(-250, 0),
                Color = LightColors[0],
                Intensity = 1f,
                Scale = new Vector2(800),
                Radius = 20                
            };
            _light2 = new PointLight
            {
                Position = new Vector2(0, 150),
                Color = LightColors[1],
                Intensity = 1.2f,
                Scale = new Vector2(400),
                Radius = 30
            };
            _light3 = new PointLight
            {
                Position = new Vector2(0, -50),
                Color = LightColors[2],
                Scale = new Vector2(600),
                Radius = 25,
                Intensity = 0.8f
            };
            penumbra.Lights.Add(_light1);
            penumbra.Lights.Add(_light2);
            penumbra.Lights.Add(_light3);
        }
        public CameraMovementComponent(Game game, PenumbraComponent penumbra) : base(game)
        {
            _penumbra = penumbra;

            Enabled = true;
        }        
 public HullGenerationComponent(SandboxGame game, PenumbraComponent penumbra)
     : base(game)
 {
     _penumbra = penumbra;
 }
Пример #15
0
 public abstract void Activate(PenumbraComponent penumbra, ContentManager content);
Пример #16
0
 public GameLevel(World world, Penumbra.PenumbraComponent penumbra, Camera camera)
 {
     this.camera   = camera;
     this.world    = world;
     this.penumbra = penumbra;
 }
        public PlatformerGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            #if WINDOWS_PHONE
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            #endif

            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            IsMouseVisible = true;

            Accelerometer.Initialize();

            Penumbra = new PenumbraComponent(this)
            {
                AmbientColor = new Color(30, 20, 10),
                Visible = true,
                Debug = false
            };

            penumbraController = new PenumbraControllerComponent(this, Penumbra);
            Components.Add(penumbraController);

            Console = new ConsoleComponent(this);
            Components.Add(Console);
        }