Beispiel #1
0
        public WorldScreen(Game Game)
            : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY)
        {
            GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80);
            GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000);

            DebugWindow.Visible = false;
            DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow);
            AddGUI(DebugWindow);

            LE = new LightingEngine();
            Color a = new Color(ambient, ambient, ambient);
            LE.SetAmbient(a, a);
            //LE.SetAmbient(Color.Gray, Color.Gray);
            Renderer.AddRendererEffect(LE, "LightingEngine");

            LoadContent();

            Map = new Map(this, tileSize, mapSize);
            //Renderer.AddPostProcess(new BlurEffect(), "Blur");
            SE = new BlurSwitchEffect();
            SE.MaxTime = 1f;
            SE.TurnOffAction = delegate () {Renderer.RemovePostProcess("Switch");};
            Renderer.AddPostProcess(SE, "Switch");

            Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize));

            PlayerLight = new SpotLight()
            {
                IsEnabled = true,
                Color = new Vector4(0.9f, .7f, .7f, 1f),
                Power = .6f,
                LightDecay = 600,
                Position = new Vector3(500, 400, 20),
                SpotAngle = 1.5f,
                SpotDecayExponent = 3,
                Direction = new Vector3(0.244402379f, 0.969673932f, 0)
            };
            LE.AddLight(PlayerLight);

            Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            Debug.DefaultShapeColor = Color.White;
            Debug.SleepingShapeColor = Color.LightGray;
            Debug.LoadContent(Parent.GraphicsDevice, Parent.Content);

            //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10);
            //Serializer.Serialize<Weapon>("weapon.xml", w);
        }
        public void Load(string TexName, Vector2 FrameSize, int MaxFrames, int MsPerFrame, LightingEngine LE)
        {
            this.FrameSize = FrameSize;
            CurrentFrame = 0;
            this.MaxFrames = MaxFrames;
            BaseTex = GeneralManager.Content.Load<Texture2D>("Textures/Animations/" + TexName);
            MilisecondsPerFrame = MsPerFrame;
            Regions = new List<Rectangle>();

            int SizeX = (BaseTex.Width / (int)FrameSize.X);
            int SizeY = (BaseTex.Height / (int)FrameSize.Y);

            for (int i = 0; i < MaxFrames; i++)
            {
                Regions.Add(new Rectangle((i % SizeX) * (int)FrameSize.X, (i / SizeX) * (int)FrameSize.Y, (int)FrameSize.X, (int)FrameSize.Y));
            }

            this.LE = LE;
        }
Beispiel #3
0
        public void Load(string TexName, Vector2 FrameSize, int MaxFrames, int MsPerFrame, LightingEngine LE)
        {
            this.FrameSize      = FrameSize;
            CurrentFrame        = 0;
            this.MaxFrames      = MaxFrames;
            BaseTex             = GeneralManager.Content.Load <Texture2D>("Textures/Animations/" + TexName);
            MilisecondsPerFrame = MsPerFrame;
            Regions             = new List <Rectangle>();

            int SizeX = (BaseTex.Width / (int)FrameSize.X);
            int SizeY = (BaseTex.Height / (int)FrameSize.Y);

            for (int i = 0; i < MaxFrames; i++)
            {
                Regions.Add(new Rectangle((i % SizeX) * (int)FrameSize.X, (i / SizeX) * (int)FrameSize.Y, (int)FrameSize.X, (int)FrameSize.Y));
            }

            this.LE = LE;
        }