Ejemplo n.º 1
0
        public static Map loadWrl(string name)
        {
            Map map = new Map();
            System.IO.FileStream str1 = new System.IO.FileStream(name, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);

            BinaryReader inf = new System.IO.BinaryReader(str1);
            map.name = new string(inf.ReadChars(5));
            map.w = inf.ReadInt16();
            map.h = inf.ReadInt16();
            map.minimap = inf.ReadBytes(map.w * map.h);
            byte[] bytes = inf.ReadBytes(map.w * map.h * 2);
            map.map = new short[map.w * map.h];
            Buffer.BlockCopy(bytes, 0, map.map, 0, map.w * map.h * 2);
            map.elementCount = inf.ReadInt16();
            map.mapElements = new byte[map.elementCount][];
            for (int i = 0; i < map.elementCount; i++)
                map.mapElements[i] = inf.ReadBytes(64 * 64);

            map.palette = inf.ReadBytes(pal_size);
            map.groundType = inf.ReadBytes(map.elementCount);

            return map;
        }
Ejemplo n.º 2
0
        public Camera(Map map)
        {
            scale = 1.0f;
            mapBounds.X = mapBounds.Y = 0;
            mapBounds.Width = map.w * 64;
            mapBounds.Height = map.h * 64;

            w = map.w;
            h = map.h;

            //FIXME- add scale
            visibleMapBounds.Width = visibleMapBounds.X + (int)GameConfiguration.ScreenResolution.X;
            visibleMapBounds.Height = visibleMapBounds.Y + (int)GameConfiguration.ScreenResolution.Y;

            basicVisibleMapBounds.Width = (int)GameConfiguration.ScreenResolution.X;
            basicVisibleMapBounds.Height = (int)GameConfiguration.ScreenResolution.Y;

            float scaleMinBoundX,scaleMinBoundY;
            scaleMinBoundX = GameConfiguration.ScreenResolution.X / (map.w * 64);
            scaleMinBoundY = GameConfiguration.ScreenResolution.Y / (map.h * 64);
            scaleMinBound = scaleMinBoundX > scaleMinBoundY ? scaleMinBoundX : scaleMinBoundY;
            scaleMinBound = scaleMinBound < GameConfiguration.scaleFullMin ? GameConfiguration.scaleFullMin : scaleMinBound;
            correctScreen();
        }
Ejemplo n.º 3
0
        protected override void Initialize()
        {
            GameConfiguration.ScreenBounds = this.Window.ClientBounds;
            GameConfiguration.ScreenResolution = new Vector2(this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height);
            // TODO: Add your initialization logic here
            base.Initialize();

            //graphics.IsFullScreen = true;

            device = this.GraphicsDevice;

            mouseManager = new MouseManager();

            map = Tools.MaxRes.loadWrl(SystemConfiguration.AppPath + "\\data\\maps\\Snow_5.wrl");
            map.mapDraw = new GraphicMap(map);
            Animator.Instance.AddAObject(map, map.AddFrame, 150.0);
            GraphicMap.mapShader.Parameters["ViewportSize"].SetValue(GameConfiguration.ScreenResolution);
            map.clearLoadData();

            AIREXPLD = maxres.loadMultiImage("TANK");
            camera = new Camera(map);
            userInterface = new UI.UIManager(Game1.device);

            CashedTexture2D t2d = ImageCache.Instance.GetImage("ENDGAME6",TextureType.Paletted);

            UI.UIMenu menu = new UI.UIMenu(new Rectangle(100, 100, 55, 32));
            userInterface.maincontrol.AddChild(menu);
            UI.UIFixedStateButton button = new UI.UIFixedStateButton(new Rectangle(0, 0, 55, 16), menu);
            button.SetIdleImage(new ImagePart(ImageCache.Instance.GetImage("AMMO_OF", TextureType.Simple), null));
            button.SetPressedImage(new ImagePart(ImageCache.Instance.GetImage("AMMO_ON", TextureType.Simple), null));

            UI.UIButton button1 = new UI.UIButton(new Rectangle(0, 16, 55, 16), menu);
            button1.SetIdleImage(new ImagePart(ImageCache.Instance.GetImage("AMMO_OF", TextureType.Simple), null));
            button1.SetPressedImage(new ImagePart(ImageCache.Instance.GetImage("AMMO_ON", TextureType.Simple), null));

            UI.UILabel label = new UI.UILabel(new Rectangle(52, 33, 100, 100));
            label.Font = UI.UIFontHelper.CourierNew12RegularBold;
            label.Text = "test text";
            label.Color = Color.Red;
            userInterface.maincontrol.AddChild(label);
        }