当前位置: 首页>>代码示例>>C#>>正文


C# OpenRA.float2类代码示例

本文整理汇总了C#中OpenRA.float2的典型用法代码示例。如果您正苦于以下问题:C# float2类的具体用法?C# float2怎么用?C# float2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


float2类属于OpenRA命名空间,在下文中一共展示了float2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindUnitsInCircle

        public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
        {
            using (new PerfSample("FindUnitsInCircle"))
            {
                var min = a - new float2(r, r);
                var max = a + new float2(r, r);

                var actors = world.FindUnits(min, max);

                var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);

                var inBox = actors.Where(x => x.GetBounds(false).IntersectsWith(rect));

                return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
            }
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:16,代码来源:WorldUtils.cs

示例2: Play2D

 public ISound Play2D(ISoundSource sound, bool loop, bool relative, float2 pos, float volume)
 {
     int source = GetSourceFromPool();
     return new OpenAlSound(source, (sound as OpenAlSoundSource).buffer, loop, relative, pos, volume);
 }
开发者ID:JamesDunne,项目名称:OpenRA,代码行数:5,代码来源:Sound.cs

示例3: SetListenerPosition

 public void SetListenerPosition(float2 position)
 {
 }
开发者ID:JamesDunne,项目名称:OpenRA,代码行数:3,代码来源:Sound.cs

示例4: Constrain

 public float2 Constrain(float2 min, float2 max)
 {
     return new float2(
         Constrain(X, min.X, max.X),
         Constrain(Y, min.Y, max.Y));
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:6,代码来源:float2.cs

示例5: Min

 public static float2 Min(float2 a, float2 b)
 {
     return new float2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y));
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:4,代码来源:float2.cs

示例6: Dot

 public static float Dot(float2 a, float2 b)
 {
     return a.X * b.X + a.Y * b.Y;
 }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:4,代码来源:float2.cs

示例7: TickPaletteAnimation

		void TickPaletteAnimation()
		{		
			if (!paletteAnimating)
				return;

			// Increment frame
			if (paletteOpen)
				paletteAnimationFrame++;
			else
				paletteAnimationFrame--;
			
			// Calculate palette position
			if (paletteAnimationFrame <= paletteAnimationLength)
				paletteOrigin = float2.Lerp(paletteClosedOrigin, paletteOpenOrigin, paletteAnimationFrame * 1.0f / paletteAnimationLength);

			var eva = Game.world.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
			
			// Play palette-open sound at the start of the activate anim (open)
			if (paletteAnimationFrame == 1 && paletteOpen)
				Sound.Play(eva.BuildPaletteOpen);

			// Play palette-close sound at the start of the activate anim (close)
			if (paletteAnimationFrame == paletteAnimationLength + -1 && !paletteOpen)
				Sound.Play(eva.BuildPaletteClose);

			// Animation is complete
			if ((paletteAnimationFrame == 0 && !paletteOpen)
					|| (paletteAnimationFrame == paletteAnimationLength && paletteOpen))
			{
				paletteAnimating = false;
			}
		}
开发者ID:comradpara,项目名称:OpenRA,代码行数:32,代码来源:Chrome.cs

示例8: DrawButtons

		void DrawButtons( World world )
		{
			var origin = new int2(Game.viewport.Width - 200, 2);
			
			foreach (var cb in world.WorldActor.traits.WithInterface<IChromeButton>())
			{
				var state = cb.Enabled ? cb.Pressed ? "pressed" : "normal" : "disabled";
				var image = ChromeProvider.GetImage(renderer, cb.Image + "-button", state);
				
				origin.X -= (int)image.size.X + chromeButtonGap;
				rgbaRenderer.DrawSprite(image, origin, "chrome");

				var button = cb;
				AddButton(new RectangleF(origin.X, origin.Y, image.size.X, image.size.Y),
					_ => { if (button.Enabled) button.OnClick(); });
			}
			
			//Options
			Rectangle optionsRect = new Rectangle(0,0, optionsButton.Image.bounds.Width, 
				optionsButton.Image.bounds.Height);
			
			var optionsDrawPos = new float2(optionsRect.Location);
			
			optionsButton.ReplaceAnim(optionsPressed ? "left-pressed" : "left-normal");
			
			AddButton(optionsRect, isLmb => optionsPressed = !optionsPressed);
			shpRenderer.DrawSprite(optionsButton.Image, optionsDrawPos, "chrome");
			shpRenderer.Flush();

			renderer.RegularFont.DrawText(rgbaRenderer, "Options", new int2((int)(optionsButton.Image.size.X - renderer.RegularFont.Measure("Options").X) / 2, -2), Color.White);
		}
开发者ID:comradpara,项目名称:OpenRA,代码行数:31,代码来源:Chrome.cs

示例9: DrawPower

		void DrawPower( World world )
		{
			// Nothing to draw
			if (world.LocalPlayer.PowerProvided == 0 && world.LocalPlayer.PowerDrained == 0)
				return;
			
			// Draw bar horizontally
			var barStart = powerOrigin + radarOrigin;
			var barEnd = barStart + new float2(powerSize.Width, 0);

			float powerScaleBy = 100;
			var maxPower = Math.Max(world.LocalPlayer.PowerProvided, world.LocalPlayer.PowerDrained);
			while (maxPower >= powerScaleBy) powerScaleBy *= 2;
			
			// Current power supply
			var powerLevelTemp = barStart.X + (barEnd.X - barStart.X) * (world.LocalPlayer.PowerProvided / powerScaleBy);
			lastPowerProvidedPos = float2.Lerp(lastPowerProvidedPos.GetValueOrDefault(powerLevelTemp), powerLevelTemp, .3f);
			float2 powerLevel = new float2(lastPowerProvidedPos.Value, barStart.Y);

			var color = Color.LimeGreen;
			if (world.LocalPlayer.GetPowerState() == PowerState.Low)
				color = Color.Orange;
			if (world.LocalPlayer.GetPowerState() == PowerState.Critical)
				color = Color.Red;
		
			var colorDark = Graphics.Util.Lerp(0.25f, color, Color.Black);
			for (int i = 0; i < powerSize.Height; i++)
			{
				color = (i-1 < powerSize.Height/2) ? color : colorDark;
				float2 leftOffset = new float2(0,i);
				float2 rightOffset = new float2(0,i);
				// Indent corners
				if ((i == 0 || i == powerSize.Height - 1) && powerLevel.X - barStart.X > 1)
				{
					leftOffset.X += 1;
					rightOffset.X -= 1;
				}
				lineRenderer.DrawLine(Game.viewport.Location + barStart + leftOffset, Game.viewport.Location + powerLevel + rightOffset, color, color);
			}
			lineRenderer.Flush();

			// Power usage indicator
			var indicator = ChromeProvider.GetImage(renderer, radarCollection, "power-indicator");
			var powerDrainedTemp = barStart.X + (barEnd.X - barStart.X) * (world.LocalPlayer.PowerDrained / powerScaleBy);
			lastPowerDrainedPos = float2.Lerp(lastPowerDrainedPos.GetValueOrDefault(powerDrainedTemp), powerDrainedTemp, .3f);
			float2 powerDrainLevel = new float2(lastPowerDrainedPos.Value-indicator.size.X/2, barStart.Y-1);
		
			rgbaRenderer.DrawSprite(indicator, powerDrainLevel, "chrome");
			rgbaRenderer.Flush();
		}
开发者ID:comradpara,项目名称:OpenRA,代码行数:50,代码来源:Chrome.cs

示例10: TickRadarAnimation

		public void TickRadarAnimation()
		{
			if (!radarAnimating)
				return;

			// Increment frame
			if (hasRadar)
				radarAnimationFrame++;
			else
				radarAnimationFrame--;

			// Calculate radar bin position
			if (radarAnimationFrame <= radarSlideAnimationLength)
				radarOrigin = float2.Lerp(radarClosedOrigin, radarOpenOrigin, radarAnimationFrame * 1.0f / radarSlideAnimationLength);

			var eva = Game.world.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
			
			// Play radar-on sound at the start of the activate anim (open)
			if (radarAnimationFrame == radarSlideAnimationLength && hasRadar)
				Sound.Play(eva.RadarUp);

			// Play radar-on sound at the start of the activate anim (close)
			if (radarAnimationFrame == radarSlideAnimationLength + radarActivateAnimationLength - 1 && !hasRadar)
				Sound.Play(eva.RadarDown);

			// Minimap height
			if (radarAnimationFrame >= radarSlideAnimationLength)
				radarMinimapHeight = float2.Lerp(0, 192, (radarAnimationFrame - radarSlideAnimationLength) * 1.0f / radarActivateAnimationLength);

			// Animation is complete
			if ((radarAnimationFrame == 0 && !hasRadar)
					|| (radarAnimationFrame == radarSlideAnimationLength + radarActivateAnimationLength && hasRadar))
			{
				radarAnimating = false;
			}
		}
开发者ID:comradpara,项目名称:OpenRA,代码行数:36,代码来源:Chrome.cs

示例11: DrawSupportPowers

		void DrawSupportPowers( World world )
		{
			var powers = world.LocalPlayer.PlayerActor.traits.WithInterface<SupportPower>();
			var numPowers = powers.Count(p => p.IsAvailable);

			if (numPowers == 0) return;

			rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, chromeCollection, "specialbin-top"), new float2(0, 14), "chrome");
			for (var i = 1; i < numPowers; i++)
				rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, chromeCollection, "specialbin-middle"), new float2(0, 14 + i * 51), "chrome");
			rgbaRenderer.DrawSprite(ChromeProvider.GetImage(renderer, chromeCollection, "specialbin-bottom"), new float2(0, 14 + numPowers * 51), "chrome");

			rgbaRenderer.Flush();

			var y = 24;

			SupportPower tooltipItem = null;
			int2 tooltipPos = int2.Zero;

			foreach (var sp in powers)
			{
				var image = spsprites[sp.Info.Image];
				if (sp.IsAvailable)
				{
					var drawPos = new float2(5, y);
					shpRenderer.DrawSprite(image, drawPos, "chrome");

					clock.PlayFetchIndex("idle",
						() => (sp.TotalTime - sp.RemainingTime)
							* (clock.CurrentSequence.Length - 1) / sp.TotalTime);
					clock.Tick();

					shpRenderer.DrawSprite(clock.Image, drawPos, "chrome");

					var rect = new Rectangle(5, y, 64, 48);
					if (sp.IsReady)
					{
						ready.Play("ready");
						shpRenderer.DrawSprite(ready.Image, 
							drawPos + new float2((64 - ready.Image.size.X) / 2, 2), 
							"chrome");
					}

					AddButton(rect, HandleSupportPower(sp));

					if (rect.Contains(lastMousePos.ToPoint()))
					{
						tooltipItem = sp;
						tooltipPos = drawPos.ToInt2() + new int2(72, 0);
					}

					y += 51;
				}
			}

			shpRenderer.Flush();

			if (tooltipItem != null)
				DrawSupportPowerTooltip(world, tooltipItem, tooltipPos);
		}
开发者ID:comradpara,项目名称:OpenRA,代码行数:60,代码来源:Chrome.cs

示例12: FindUnits

 public static IEnumerable<Actor> FindUnits(this World world, float2 a, float2 b)
 {
     var u = float2.Min(a, b).ToInt2();
     var v = float2.Max(a, b).ToInt2();
     return world.WorldActor.traits.Get<SpatialBins>().ActorsInBox(u,v);
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:6,代码来源:WorldUtils.cs

示例13: SelectActorsInBox

 public static IEnumerable<Actor> SelectActorsInBox(this World world, float2 a, float2 b)
 {
     return world.FindUnits(a, b)
         .Where( x => x.traits.Contains<Selectable>() && x.IsVisible() )
         .GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
         .OrderByDescending(g => g.Key)
         .Select( g => g.AsEnumerable() )
         .DefaultIfEmpty( new Actor[] {} )
         .FirstOrDefault();
 }
开发者ID:comradpara,项目名称:OpenRA,代码行数:10,代码来源:WorldUtils.cs

示例14: PlayToPlayer

 public static ISound PlayToPlayer(Player player, string name, float2 pos)
 {
     return Play(player, name, false, pos, 1);
 }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:4,代码来源:Sound.cs

示例15: Play

        static ISound Play(Player player, string name, bool headRelative, float2 pos, float volumeModifier)
        {
            if (player != null && player != player.World.LocalPlayer)
                return null;
            if (name == "" || name == null)
                return null;

            return soundEngine.Play2D(sounds[name],
                false, headRelative, pos,
                InternalSoundVolume * volumeModifier);
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:11,代码来源:Sound.cs


注:本文中的OpenRA.float2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。