Наследование: System.DisposableBase
Пример #1
0
        /// <summary>
        /// Called after the ShooterDemoUserInterface is created,
        /// </summary>
        public override void Initialize()
        {
            uiLayer	=	new SpriteLayer(Game.RenderSystem, 1024);

            //	add console sprite layer to master view layer :
            Game.RenderSystem.SpriteLayers.Add( uiLayer );

            LoadContent();
            Game.Reloading += (s,e) => LoadContent();

            Game.GameClient.ClientStateChanged += GameClient_ClientStateChanged;
        }
Пример #2
0
 void SmallTextRJ( SpriteLayer layer, string text, int x, int y, Color color )
 {
     var r = hudFontSmall.MeasureStringF( text, -2 );
     hudFontSmall.DrawString( layer, text, x-r.Width, y, color, 0, -2 );
 }
Пример #3
0
 void MicroTextRJ( SpriteLayer layer, string text, int x, int y, Color color )
 {
     var r = hudFontMicro.MeasureStringF( text, -1 );
     hudFontMicro.DrawString( layer, text, x-r.Width, y, color, 0, -1 );
 }
Пример #4
0
 void BugTextRJ( SpriteLayer layer, string text, int x, int y, Color color )
 {
     var r = hudFont.MeasureStringF( text, -4 );
     hudFont.DrawString( layer, text, x-r.Width, y, color, -4 );
 }
Пример #5
0
 void BigTextLJ( SpriteLayer layer, string text, int x, int y, Color color )
 {
     var r = hudFont.MeasureStringF( text, -4 );
     hudFont.DrawString( layer, text, x, y, color, 0, -4, true, false );
 }
Пример #6
0
        /*Color EscColor ( char ch ) {
         *      if (ch=='0') return Color.White;
         *      if (ch=='1') return Color.Red;
         *      if (ch=='2') return Color.Orange;
         *      if (ch=='3') return Color.Yellow;
         *      if (ch=='4') return Color.Green;
         *      if (ch=='5') return Color.Cyan;
         *      if (ch=='6') return Color.Blue;
         *      if (ch=='7') return Color.Magenta;
         *      if (ch=='8') return Color.Black;
         *      if (ch=='9') return Color.Gray;
         *      return Color.White;
         * } */


        /// <summary>
        /// Draws the string
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="text"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="color"></param>
        public void DrawString(SpriteLayer spriteBatch, string text, float xPos, float yPos, Color color, int frameIndex = 0, float tracking = 0, bool useBaseLine = true, bool flip = false)
        {
            if (text == null)
            {
                return;
            }

            float x, y;

            if (!flip)
            {
                x = xPos;
                y = yPos;                // - fontInfo.baseLine;
                if (useBaseLine)
                {
                    y -= fontInfo.baseLine;
                }
            }
            else
            {
                x = yPos;
                y = xPos;                // - fontInfo.baseLine;
                if (useBaseLine)
                {
                    x -= fontInfo.baseLine;
                }
            }


            int length = text.Length;

            float w = fontTexture.Width;
            float h = fontTexture.Height;

            for (int i = 0; i < length; i++)
            {
                char ch0 = text[i];

                if (ch0 == '\n')
                {
                    y += fontInfo.lineHeight;
                    x  = xPos;
                }

                char ch1     = (i + 1) < length ? text[i + 1] : '\0';
                var  chi     = GetInfo(ch0);
                var  kerning = GetKerning(ch0, ch1);

                /*if (ch0=='^' && char.IsDigit(ch1)) {
                 *      i++;
                 *      color = EscColor(ch1);
                 *      continue;
                 * } */

                RectangleF dstRect = chi.dstRect;
                RectangleF srcRect = chi.srcRect;

                dstRect.X += x;
                dstRect.Y += y;

                /*dstRect.Right	+= x;
                 * dstRect.Bottom  += y;*/
                if (!flip)
                {
                    x += chi.xAdvance;
                    x += kerning;
                    x += tracking;
                }
                else
                {
                    x -= chi.xAdvance;
                    x -= kerning;
                    x -= tracking;
                }

                //spriteBatch.Draw( fontTexture, dstRect, srcRect, color );
                var c = color;                // * spriteBatch.ColorMultiplier;

                if (!flip)
                {
                    var v0 = new SpriteVertex(new Vector3(dstRect.X, dstRect.Y, 0), c, new Vector2((srcRect.X) / w, (srcRect.Y) / h), frameIndex);
                    var v1 = new SpriteVertex(new Vector3(dstRect.X + dstRect.Width, dstRect.Y, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y) / h), frameIndex);
                    var v2 = new SpriteVertex(new Vector3(dstRect.X + dstRect.Width, dstRect.Y + dstRect.Height, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y + srcRect.Height) / h), frameIndex);
                    var v3 = new SpriteVertex(new Vector3(dstRect.X, dstRect.Y + dstRect.Height, 0), c, new Vector2((srcRect.X) / w, (srcRect.Y + srcRect.Height) / h), frameIndex);
                    spriteBatch.DrawQuad(fontTexture, v0, v1, v2, v3);
                }
                else
                {
                    var v0 = new SpriteVertex(new Vector3(dstRect.Y, dstRect.X, 0), c, new Vector2((srcRect.X) / w, (srcRect.Y) / h), frameIndex);
                    var v1 = new SpriteVertex(new Vector3(dstRect.Y, dstRect.X - dstRect.Width, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y) / h), frameIndex);
                    var v2 = new SpriteVertex(new Vector3(dstRect.Y + dstRect.Height, dstRect.X - dstRect.Width, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y + srcRect.Height) / h), frameIndex);
                    var v3 = new SpriteVertex(new Vector3(dstRect.Y + dstRect.Height, dstRect.X, 0), c, new Vector2((srcRect.X) / w, (srcRect.Y + srcRect.Height) / h), frameIndex);
                    spriteBatch.DrawQuad(fontTexture, v0, v1, v2, v3);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes game
        /// </summary>
        public override void Initialize()
        {
            hudLayer	=	new SpriteLayer( Game.RenderSystem, 1024 );
            Game.RenderSystem.SpriteLayers.Add( hudLayer );

            Game.Keyboard.KeyDown += Keyboard_KeyDown;

            Game.RenderSystem.DisplayBoundsChanged += RenderSystem_DisplayBoundsChanged;
        }
Пример #8
0
		/// <summary>
		/// Inits view
		/// </summary>
		public override void Initialize()
		{
			 DefaultFont	=	Game.Content.Load<SpriteFont>(defaultFontPath);

			 spriteLayer	=	new SpriteLayer( Game.RenderSystem, 1024 );

			 mouseProcessor.Initialize();
		}
Пример #9
0
		/// <summary>
		/// Draws entire interface
		/// </summary>
		/// <param name="gameTime"></param>
		void Draw ( GameTime gameTime, SpriteLayer spriteLayer )
		{
			if (SkipUserInterface) {
				return;
			}

			spriteLayer.Clear();

			Frame.DrawNonRecursive( RootFrame, gameTime, spriteLayer );
		}
Пример #10
0
		/// <summary>
		/// 
		/// </summary>
		public override void Initialize ()
		{
			debugFont		=	Game.Content.Load<DiscTexture>("conchars");
			//videoPlayer	=	new VideoPlayer();
			//video		=	new Video(@"C:\infection_demo.wmv");//*/
			////video		=	GameEngine.Content.Load<Video>("infection_demo");
			//video		=	new Video(File.ReadAllBytes(@"C:\infection_demo.wmv"));//*/

			//var mtrl		=	GameEngine.Content.Load<Material>("testMtrl");

			var bounds		=	Game.RenderSystem.DisplayBounds;
			masterView		=	Game.RenderSystem.RenderWorld;

			Game.RenderSystem.DisplayBoundsChanged += (s,e) => {
				masterView.Resize( Game.RenderSystem.DisplayBounds.Width, Game.RenderSystem.DisplayBounds.Height );
				//Log.Warning("{0} {1}", GameEngine.GraphicsEngine.DisplayBounds.Width, GameEngine.GraphicsEngine.DisplayBounds.Height);
			};

			targetTexture		=	new TargetTexture(Game.RenderSystem, bounds.Width, bounds.Height, TargetFormat.LowDynamicRange );
			//masterView.Target	=	targetTexture;

			testLayer	=	new SpriteLayer( Game.RenderSystem, 1024 );
			uiLayer		=	new SpriteLayer( Game.RenderSystem, 1024 );
			texture		=	Game.Content.Load<DiscTexture>( "lena" );

			masterView.SkySettings.SunPosition			=	new Vector3(20,30,40);
			masterView.SkySettings.SunLightIntensity	=	50;
			masterView.SkySettings.SkyTurbidity			=	3;

			masterView.LightSet.SpotAtlas				=	Game.Content.Load<TextureAtlas>("spots/spots");
			masterView.LightSet.DirectLight.Direction	=	masterView.SkySettings.SunLightDirection;
			masterView.LightSet.DirectLight.Intensity	=	masterView.SkySettings.SunLightColor;
			masterView.LightSet.DirectLight.Enabled		=	true;
			masterView.LightSet.AmbientLevel			=	Color4.Zero;
			//masterView.LightSet.AmbientLevel			=	masterView.SkySettings.AmbientLevel;

			masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4,-10), 1,  500 ) );

			//masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4,-10), 1,  15 ) );
			//masterView.LightSet.EnvLights.Add( new EnvLight( new Vector3(0,4, 10), 1, 15 ) );


			var rand = new Random();

			/*for (int i=0; i<64; i++) {
				var light = new OmniLight();
				light.Position		=	new Vector3( 8*(i/8-4), 4, 8*(i%8-4) );
				light.RadiusInner	=	1;
				light.RadiusOuter	=	8;
				light.Intensity		=	rand.NextColor4() * 100;
				masterView.LightSet.OmniLights.Add( light );
			} //*/
														 
			/*for (int i=0; i<256; i++) {
				var light = new EnvLight();
				light.Position		=	new Vector3( 7*(i/16-8), 6, 7*(i%16-8) );
				light.RadiusInner	=	2;
				light.RadiusOuter	=	8;
				masterView.LightSet.EnvLights.Add( light );
			} //*/

			fireLight	=	new OmniLight();
			fireLight.Position	=	Vector3.UnitZ * (-10) + Vector3.UnitY * 5 + Vector3.UnitX * 20;
			fireLight.RadiusOuter	=	7;
			fireLight.Intensity		=	new Color4(249, 172, 61, 0)/2;

			masterView.LightSet.OmniLights.Add( fireLight );
			


			masterView.SpriteLayers.Add( console.ConsoleSpriteLayer );
			masterView.SpriteLayers.Add( uiLayer );
			masterView.SpriteLayers.Add( testLayer );


			Game.Keyboard.KeyDown += Keyboard_KeyDown;

			LoadContent();

			Game.Reloading += (s,e) => LoadContent();

			Game.Touch.Tap			+= vector2 => System.Console.WriteLine("You just perform tap gesture at point: " + vector2);
			Game.Touch.DoubleTap	+= vector2 => System.Console.WriteLine("You just perform double tap gesture at point: " + vector2);
			Game.Touch.SecondaryTap += vector2 => System.Console.WriteLine("You just perform secondary tap gesture at point: " + vector2);
			Game.Touch.Manipulate	+= (center, delta, scale) => System.Console.WriteLine("You just perform touch manipulation: " + center + "	" + delta + "	" + scale);
		}
Пример #11
0
		/*Color EscColor ( char ch ) {
			if (ch=='0') return Color.White;
			if (ch=='1') return Color.Red;
			if (ch=='2') return Color.Orange;
			if (ch=='3') return Color.Yellow;
			if (ch=='4') return Color.Green;
			if (ch=='5') return Color.Cyan;
			if (ch=='6') return Color.Blue;
			if (ch=='7') return Color.Magenta;
			if (ch=='8') return Color.Black;
			if (ch=='9') return Color.Gray;
			return Color.White;
		} */


		/// <summary>
		/// Draws the string
		/// </summary>
		/// <param name="sb"></param>
		/// <param name="text"></param>
		/// <param name="xPos"></param>
		/// <param name="yPos"></param>
		/// <param name="color"></param>
		public void DrawString( SpriteLayer spriteBatch, string text, float xPos, float yPos, Color color, int frameIndex=0, float tracking = 0, bool useBaseLine = true, bool flip = false ) 
		{
			if (text==null) {
				return;
			}

			float x, y;

			if (!flip) {
				x = xPos;
				y = yPos;// - fontInfo.baseLine;
				if (useBaseLine) {
					y -= fontInfo.baseLine;
				}
			} else {
				x = yPos;
				y = xPos;// - fontInfo.baseLine;
				if (useBaseLine) {
					x -= fontInfo.baseLine;
				}
			}


			int length = text.Length;

			float w	=	fontTexture.Width;
			float h	=	fontTexture.Height;

			for (int i=0; i<length; i++) {

				char ch0	= text[i];

				if (ch0 == '\n') {
					y += fontInfo.lineHeight;
					x =  xPos;
				}

				char ch1	= (i+1)<length ? text[i+1] : '\0';
				var chi		= GetInfo(ch0);
				var kerning = GetKerning( ch0, ch1 );

				/*if (ch0=='^' && char.IsDigit(ch1)) {
					i++;
					color = EscColor(ch1);
					continue;
				} */

				RectangleF	dstRect = chi.dstRect;
				RectangleF	srcRect = chi.srcRect;

				dstRect.X	+= x;
				dstRect.Y	+= y;
				/*dstRect.Right	+= x;
				dstRect.Bottom  += y;*/
				if (!flip) {
					x += chi.xAdvance;
					x += kerning;
					x += tracking;
				} else {
					x -= chi.xAdvance;
					x -= kerning;
					x -= tracking;
				}

				//spriteBatch.Draw( fontTexture, dstRect, srcRect, color );
				var c = color;// * spriteBatch.ColorMultiplier;

				if (!flip) {
					var v0	=	new SpriteVertex( new Vector3(dstRect.X,                 dstRect.Y                 , 0), c, new Vector2((srcRect.X                ) / w, (srcRect.Y                 ) / h), frameIndex );
					var v1	=	new SpriteVertex( new Vector3(dstRect.X + dstRect.Width, dstRect.Y                 , 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y                 ) / h), frameIndex );
					var v2	=	new SpriteVertex( new Vector3(dstRect.X + dstRect.Width, dstRect.Y + dstRect.Height, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y + srcRect.Height) / h), frameIndex );
					var v3	=	new SpriteVertex( new Vector3(dstRect.X,                 dstRect.Y + dstRect.Height, 0), c, new Vector2((srcRect.X                ) / w, (srcRect.Y + srcRect.Height) / h), frameIndex );
					spriteBatch.DrawQuad( fontTexture, v0, v1, v2, v3 );
				} else {																		                   
					var v0	=	new SpriteVertex( new Vector3(dstRect.Y                 , dstRect.X                , 0), c, new Vector2((srcRect.X                ) / w, (srcRect.Y                 ) / h), frameIndex );
					var v1	=	new SpriteVertex( new Vector3(dstRect.Y                 , dstRect.X - dstRect.Width, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y                 ) / h), frameIndex );
					var v2	=	new SpriteVertex( new Vector3(dstRect.Y + dstRect.Height, dstRect.X - dstRect.Width, 0), c, new Vector2((srcRect.X + srcRect.Width) / w, (srcRect.Y + srcRect.Height) / h), frameIndex );
					var v3	=	new SpriteVertex( new Vector3(dstRect.Y + dstRect.Height, dstRect.X                , 0), c, new Vector2((srcRect.X                ) / w, (srcRect.Y + srcRect.Height) / h), frameIndex );
					spriteBatch.DrawQuad( fontTexture, v0, v1, v2, v3 );
				}

			}
		}
Пример #12
0
		/// <summary>
		/// 
		/// </summary>
		public override void Initialize ()
		{
			debugFont		=	Game.Content.Load<DiscTexture>("conchars");

			var bounds		=	Game.RenderSystem.DisplayBounds;
			masterView		=	Game.RenderSystem.RenderWorld;


			Game.RenderSystem.RemoveLayer(masterView);

			viewLayer = new RenderLayer(Game);
			Game.RenderSystem.AddLayer(viewLayer);

			//Game.RenderSystem.DisplayBoundsChanged += (s,e) => {
			//	masterView.Resize( Game.RenderSystem.DisplayBounds.Width, Game.RenderSystem.DisplayBounds.Height );
			//};

			targetTexture		=	new TargetTexture(Game.RenderSystem, bounds.Width, bounds.Height, TargetFormat.LowDynamicRange );

			testLayer	=	new SpriteLayer( Game.RenderSystem, 1024 );
			uiLayer		=	new SpriteLayer( Game.RenderSystem, 1024 );

			tiles = new TilesGisLayer(Game, viewLayer.GlobeCamera);
			viewLayer.GisLayers.Add(tiles);

			text = new TextGisLayer(Game, 100, viewLayer.GlobeCamera);
			//masterView.GisLayers.Add(text);

			//masterView.SpriteLayers.Add( testLayer );
			//masterView.SpriteLayers.Add( text.TextSpriteLayer );
			viewLayer.SpriteLayers.Add(console.ConsoleSpriteLayer);

			
			text.GeoTextArray[0] = new TextGisLayer.GeoText {
				Color	= Color.Red,
				Text	= "Arrow",
				LonLat	= DMathUtil.DegreesToRadians(new DVector2(30.306473, 59.944082))
			};

			text.GeoTextArray[1] = new TextGisLayer.GeoText {
				Color	= Color.Teal,
				Text	= "Park",
				LonLat	= DMathUtil.DegreesToRadians(new DVector2(30.313897, 59.954623))
			};

			Game.Keyboard.KeyDown += Keyboard_KeyDown;

			LoadContent();

			Game.Reloading += (s,e) => LoadContent();


			var r = new Random();

			//pointsCPU = new PointsGisLayerCPU(Game, 8000000);
			//pointsCPU.TextureAtlas = Game.Content.Load<Texture2D>("Zombie");
			//
			//for (int i = 0; i < pointsCPU.PointsCountToDraw; i++) {
			//	pointsCPU.AddPoint(i, DMathUtil.DegreesToRadians(new DVector2(30.240383 + r.NextDouble(-1, 1) * 0.1, 59.944007 - r.NextDouble(-1, 1) * 0.05)), 0, 0.01f);
			//}
			//pointsCPU.UpdatePointsBuffer();
			//viewLayer.GisLayers.Add(pointsCPU);
			

			pointsGPU = new PointsGisLayer(Game, 1677000, true);
			pointsGPU.TextureAtlas = Game.Content.Load<Texture2D>("Zombie");
			pointsGPU.ImageSizeInAtlas = new Vector2(36, 36);
			
			for (int i = 0; i < pointsGPU.PointsCountToDraw; i++) {
				var pos = DMathUtil.DegreesToRadians(new DVector2(30.240383 + r.NextDouble(-1, 1)*0.2, 59.944007 - r.NextDouble(-1, 1)*0.1));
				pointsGPU.PointsCpu[i] = new Gis.GeoPoint {
					Lon = pos.X,
					Lat = pos.Y,
					Color = Color4.White,
					Tex0 = new Vector4(0, 0, 0.02f, 0)
				};
			}
			pointsGPU.UpdatePointsBuffer();
			viewLayer.GisLayers.Add(pointsGPU);


			viewLayer.GlobeCamera.GoToPlace(GlobeCamera.Places.SaintPetersburg_VO);
			viewLayer.GlobeCamera.CameraDistance = GeoHelper.EarthRadius + 5;
		}