public void AddObject(IServiceProvider serviceProvider, GraphicsDevice graphicsDevice, Options options, string iObjectName, float[] iObjectParameters,Vector2 position)
 {
     InteractiveObject iObject;
     CultureInfo info = CultureInfo.CreateSpecificCulture("en-us");
     switch (iObjectName)
     {
         case "JumpPad":
             Vector2 force = new Vector2(iObjectParameters[1], 0).Rotate(iObjectParameters[0], true);
             iObject = new JumpPad();
             iObject.Initialize(serviceProvider, options, graphicsDevice,
                 (int)position.X+ "," + (int)position.Y + ",32,32," +
                 force.X.ToString(info) + "," +
                 force.Y.ToString(info) + "," +
                 iObjectParameters[2].ToString(info));
             interactiveObjects.Add(iObject);
             break;
     }
 }
Beispiel #2
0
        protected void Initialize(Options options,GraphicsDevice graphics)
        {
            basicTarget = new RenderTarget2D(graphics,
                graphics.PresentationParameters.BackBufferWidth,
                graphics.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,
                graphics.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);
            player = new Player(new Vector2(100, 100), Content);
            blur = content.Load<Effect>("Stuff/Effects/Blur");
            waether = content.Load<Effect>("Stuff/Effects/Weather");
            waether.CurrentTechnique = waether.Techniques["Technique1"];
            motionblur = content.Load<Effect>("Stuff/Effects/MotionBlur");
            waether.Parameters["effectTexture"].SetValue(content.Load<Texture2D>("Stuff/Effects/Rain"));
            level = new Level();
            level.LoadLevel(content.ServiceProvider,graphics,options);
            InitializeLayer(options,graphics);
            player.Pos = level.Startpos;
            bg_rect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);

            gamelogic = new GameLogic();
            gamelogic.Initialize(content.ServiceProvider,graphics, level.LevelVariables, options);
            camera = new Camera(options.ScreenWidth,
                options.ScreenHeight,
                level.Startpos,
                (float)options.ScaleFactor);
            debugscreen = new DebugScreen(Content, level.Startpos);
            Matrix viewMatrix = Matrix.CreateLookAt(
                   new Vector3(0.0f, 0.0f, 1.0f),
                   Vector3.Zero,
                   Vector3.Up
                   );

            Matrix projectionMatrix = Matrix.CreateOrthographicOffCenter(
                0,
                (float)options.ScreenWidth,
                (float)options.ScreenHeight,
                0,
                1.0f, 1000.0f);

            effect = new BasicEffect(graphics);
            effect.Alpha = 1.0f;
            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;
            effect.VertexColorEnabled = true;

            colorizePost = new ColorizeLUT();
            colorizeBackground = new ColorizeLUT();
            JumpPad pad = new JumpPad();
            pad.Initialize(content.ServiceProvider, options, graphics, "0,0,32,32,0,-5000,0.95");
            iObjectManager.AddObject(pad);
            target = new RenderTarget2D(graphics,
                graphics.PresentationParameters.BackBufferWidth,
                graphics.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,
                graphics.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);

            toonShader = new ToonShader();
            toonShader.Initialize(Content.ServiceProvider, graphics, options);
            toonShader.Enabled = true;
        }
        public void Initialize(IServiceProvider serviceProvider, LevelVariables variables, GraphicsDevice graphicsDevice,Options options)
        {
            this.options = options;
            string[] data = variables.Dictionary[LV.InteractiveObjects].Split(':');
            foreach (string iObject in data)
            {
                if (!string.IsNullOrEmpty(iObject.Trim()))
                {
                    string[] temp = iObject.Split(',');
                    try
                    {
                        InteractiveObjectsIDs id = (InteractiveObjectsIDs)Enum.Parse(typeof(InteractiveObjectsIDs), temp[0]);

                        string objectData = "";
                        for (int i = 1; i < temp.Length - 1; i++)
                        {
                            objectData += temp[i] + ",";
                        }
                        objectData += temp[temp.Length - 1];
                        switch (id)
                        {
                            case InteractiveObjectsIDs.JumpPad:
                                JumpPad pad = new JumpPad();
                                pad.Initialize(serviceProvider, options, graphicsDevice, objectData);
                                interactiveObjects.Add(pad);
                                break;
                        }
                    }
                    catch (Exception e)
                    {
                        DebugManager.AddItem("Failed to load InteractiveObject: " + iObject + "\n" + e.Message, this.ToString(), new StackTrace(e), System.Drawing.Color.Red);
                        FileManager.WriteInErrorLog(this.ToString(), "Failed to load InteractiveObject: " + iObject + "\n" + e.Message, e.GetType());
                    }
                }
            }
        }