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


C# int2类代码示例

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


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

示例1: CalculateActorSelectionPriority

        static long CalculateActorSelectionPriority(ActorInfo info, Rectangle bounds, int2 selectionPixel)
        {
            var centerPixel = new int2(bounds.X, bounds.Y);
            var pixelDistance = (centerPixel - selectionPixel).Length;

            return ((long)-pixelDistance << 32) + info.SelectionPriority();
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:SelectableExts.cs

示例2: Draw

		public override void Draw()
		{
			SpriteFont font;
			if (!Game.Renderer.Fonts.TryGetValue(Font, out font))
				throw new ArgumentException("Requested font '{0}' was not found.".F(Font));

			var text = GetText();
			if (text == null)
				return;

			var textSize = font.Measure(text);
			var position = RenderOrigin;

			if (VAlign == TextVAlign.Middle)
				position += new int2(0, (Bounds.Height - textSize.Y) / 2);

			if (VAlign == TextVAlign.Bottom)
				position += new int2(0, Bounds.Height - textSize.Y);

			if (Align == TextAlign.Center)
				position += new int2((Bounds.Width - textSize.X) / 2, 0);

			if (Align == TextAlign.Right)
				position += new int2(Bounds.Width - textSize.X, 0);

			if (WordWrap)
				text = WidgetUtils.WrapText(text, Bounds.Width, font);

			var color = GetColor();
			var contrast = GetContrastColor();
			if (Contrast)
				font.DrawTextWithContrast(text, position, color, contrast, 2);
			else
				font.DrawText(text, position, color);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:35,代码来源:LabelWidget.cs

示例3: MoveFlash

 public MoveFlash( World world, int2 cell )
 {
     this.pos = Game.CellSize * (cell + new float2(0.5f, 0.5f));
     anim.PlayThen( "idle",
         () => world.AddFrameEndTask(
             w => w.Remove( this ) ) );
 }
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:MoveFlash.cs

示例4: Building

 public Building(ActorInitializer init)
 {
     this.self = init.self;
     this.topLeft = init.Get<LocationInit,int2>();
     this.Info = self.Info.Traits.Get<BuildingInfo>();
     this.PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
 }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:7,代码来源:Building.cs

示例5: GetUnitsAt

        public IEnumerable<Actor> GetUnitsAt( int2 a )
        {
            if (!map.IsInMap(a)) yield break;

            for( var i = influence[ a.X, a.Y ] ; i != null ; i = i.next )
                yield return i.actor;
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:7,代码来源:UnitInfluence.cs

示例6: IssueOrder

        public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
        {
            if (mi.Button == MouseButton.Right && self == underCursor)
                return new Order("DeployTransform", self);

            return null;
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:7,代码来源:TransformsOnDeploy.cs

示例7: GetBridge

        // Used to check for neighbouring bridges
        public Bridge GetBridge(int2 cell)
        {
            if (!world.Map.IsInMap(cell.X, cell.Y))
                return null;

            return Bridges[ cell.X, cell.Y ];
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:8,代码来源:BridgeLayer.cs

示例8: Order

        public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
        {
            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(
                    a =>
                    a.Info.Traits.Contains<SelectableInfo>()
                        ? a.Info.Traits.Get<SelectableInfo>().Priority
                        : int.MinValue)
                .FirstOrDefault();

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            var actorsInvolved = orders.Select(o => o.self).Distinct();
            if (actorsInvolved.Any())
                yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false)
                {
                    TargetString = string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray())
                };

            foreach (var o in orders)
                yield return CheckSameOrder(o.iot, o.trait.IssueOrder(o.self, o.iot, o.target, mi.Modifiers.HasModifier(Modifiers.Shift)));
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:26,代码来源:UnitOrderGenerator.cs

示例9: AddSmudge

        public void AddSmudge(int2 loc)
        {
            if (!world.GetTerrainInfo(loc).AcceptSmudge)
                return;

            if (Game.CosmeticRandom.Next(0,100) <= Info.SmokePercentage)
                world.AddFrameEndTask(w => w.Add(new Smoke(w, Traits.Util.CenterOfCell(loc), Info.SmokeType)));

            // No smudge; create a new one
            if (!tiles.ContainsKey(loc))
            {
                byte st = (byte)(1 + world.SharedRandom.Next(Info.Types.Length - 1));
                tiles.Add(loc, new TileReference<byte,byte>(st,(byte)0));
                return;
            }

            var tile = tiles[loc];
            // Existing smudge; make it deeper
            int depth = Info.Depths[tile.type-1];
            if (tile.index < depth - 1)
            {
                tile.index++;
                tiles[loc] = tile;	// struct semantics.
            }
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:25,代码来源:SmudgeLayer.cs

示例10: DrawInner

        public override void DrawInner(World world)
        {
            int margin = 5;
            var font = (Bold) ? Game.Renderer.BoldFont : Game.Renderer.RegularFont;
            var cursor = (showCursor && Focused) ? "|" : "";
            var textSize = font.Measure(Text + "|");
            var pos = RenderOrigin;

            WidgetUtils.DrawPanel("dialog3",
                new Rectangle(pos.X, pos.Y, Bounds.Width, Bounds.Height));

            // Inset text by the margin and center vertically
            var textPos = pos + new int2(margin, (Bounds.Height - textSize.Y) / 2 - VisualHeight);

            // Right align when editing and scissor when the text overflows
            if (textSize.X > Bounds.Width - 2 * margin)
            {
                if (Focused)
                    textPos += new int2(Bounds.Width - 2 * margin - textSize.X, 0);

                Game.Renderer.Device.EnableScissor(pos.X + margin, pos.Y, Bounds.Width - 2 * margin, Bounds.Bottom);
            }

            font.DrawText(Text + cursor, textPos, Color.White);

            if (textSize.X > Bounds.Width - 2 * margin)
            {
                Game.Renderer.RgbaSpriteRenderer.Flush();
                Game.Renderer.Device.DisableScissor();
            }
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:31,代码来源:TextFieldWidget.cs

示例11: SetPreview

		public void SetPreview(ActorInfo actor, TypeDictionary td)
		{
			var init = new ActorPreviewInitializer(actor, worldRenderer, td);
			preview = actor.TraitInfos<IRenderActorPreviewInfo>()
				.SelectMany(rpi => rpi.RenderPreview(init))
				.ToArray();

			// Calculate the preview bounds
			PreviewOffset = int2.Zero;
			IdealPreviewSize = int2.Zero;

			var r = preview
				.SelectMany(p => p.Render(worldRenderer, WPos.Zero))
				.OrderBy(WorldRenderer.RenderableScreenZPositionComparisonKey)
				.Select(rr => rr.PrepareRender(worldRenderer));

			if (r.Any())
			{
				var b = r.First().ScreenBounds(worldRenderer);
				foreach (var rr in r.Skip(1))
					b = Rectangle.Union(b, rr.ScreenBounds(worldRenderer));

				IdealPreviewSize = new int2(b.Width, b.Height);
				PreviewOffset = -new int2(b.Left, b.Top) - IdealPreviewSize / 2;
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:ActorPreviewWidget.cs

示例12: Initialize

		public override void Initialize(WidgetArgs args)
		{
			base.Initialize(args);

			var width = world.Map.Bounds.Width;
			var height = world.Map.Bounds.Height;
			var size = Math.Max(width, height);
			var rb = RenderBounds;

			previewScale = Math.Min(rb.Width * 1f / width, rb.Height * 1f / height);
			previewOrigin = new int2((int)(previewScale * (size - width) / 2), (int)(previewScale * (size - height) / 2));
			mapRect = new Rectangle(previewOrigin.X, previewOrigin.Y, (int)(previewScale * width), (int)(previewScale * height));

			// Only needs to be done once
			using (var terrainBitmap = Minimap.TerrainBitmap(world.Map.Rules.TileSets[world.Map.Tileset], world.Map))
			{
				var r = new Rectangle(0, 0, width, height);
				var s = new Size(terrainBitmap.Width, terrainBitmap.Height);
				var terrainSheet = new Sheet(s, false);
				terrainSheet.Texture.SetData(terrainBitmap);
				terrainSprite = new Sprite(terrainSheet, r, TextureChannel.Alpha);

				// Data is set in Tick()
				customTerrainSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
				actorSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
				shroudSprite = new Sprite(new Sheet(s, false), r, TextureChannel.Alpha);
			}
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:28,代码来源:RadarWidget.cs

示例13: Draw

        public override void Draw()
        {
            if (world == null) return;
            if( world.LocalPlayer.WinState != WinState.Undefined ) return;

            var o = new float2(mapRect.Location.X, mapRect.Location.Y + world.Map.Bounds.Height * previewScale * (1 - radarMinimapHeight)/2);
            var s = new float2(mapRect.Size.Width, mapRect.Size.Height*radarMinimapHeight);
            var rsr = Game.Renderer.RgbaSpriteRenderer;
            rsr.DrawSprite(terrainSprite, o, s);
            rsr.DrawSprite(customTerrainSprite, o, s);
            rsr.DrawSprite(actorSprite, o, s);
            rsr.DrawSprite(shroudSprite, o, s);

            // Draw viewport rect
            if (hasRadar && !animating)
            {
                var wr = Game.viewport.WorldRect;
                var wro = new int2(wr.X, wr.Y);
                var tl = CellToMinimapPixel(wro);
                var br = CellToMinimapPixel(wro + new int2(wr.Width, wr.Height));

                Game.Renderer.EnableScissor((int)mapRect.Left, (int)mapRect.Top, (int)mapRect.Width, (int)mapRect.Height);
                Game.Renderer.LineRenderer.DrawRect(tl, br, Color.White);
                Game.Renderer.DisableScissor();
            }
        }
开发者ID:kekekeks,项目名称:OpenRA,代码行数:26,代码来源:RadarWidget.cs

示例14: R8Frame

			public R8Frame(Stream s)
			{
				// Scan forward until we find some data
				var type = s.ReadUInt8();
				while (type == 0)
					type = s.ReadUInt8();

				var width = s.ReadInt32();
				var height = s.ReadInt32();
				var x = s.ReadInt32();
				var y = s.ReadInt32();

				Size = new Size(width, height);
				Offset = new int2(width / 2 - x, height / 2 - y);

				/*var imageOffset = */
				s.ReadInt32();
				var paletteOffset = s.ReadInt32();
				var bpp = s.ReadUInt8();
				if (bpp != 8)
					throw new InvalidDataException("Error: {0} bits per pixel are not supported.".F(bpp));

				var frameHeight = s.ReadUInt8();
				var frameWidth = s.ReadUInt8();
				FrameSize = new Size(frameWidth, frameHeight);

				// Skip alignment byte
				s.ReadUInt8();

				Data = s.ReadBytes(width * height);

				// Ignore palette
				if (type == 1 && paletteOffset != 0)
					s.Seek(520, SeekOrigin.Current);
			}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:35,代码来源:R8Loader.cs

示例15: Viewport

        public Viewport(WorldRenderer wr, Map map)
        {
            worldRenderer = wr;
            var grid = Game.ModData.Manifest.Get<MapGrid>();

            // Calculate map bounds in world-px
            if (wr.World.Type == WorldType.Editor)
            {
                // The full map is visible in the editor
                var width = map.MapSize.X * grid.TileSize.Width;
                var height = map.MapSize.Y * grid.TileSize.Height;
                if (wr.World.Map.Grid.Type == MapGridType.RectangularIsometric)
                    height /= 2;

                mapBounds = new Rectangle(0, 0, width, height);
                CenterLocation = new int2(width / 2, height / 2);
            }
            else
            {
                var tl = wr.ScreenPxPosition(map.ProjectedTopLeft);
                var br = wr.ScreenPxPosition(map.ProjectedBottomRight);
                mapBounds = Rectangle.FromLTRB(tl.X, tl.Y, br.X, br.Y);
                CenterLocation = (tl + br) / 2;
            }

            Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
            tileSize = grid.TileSize;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:28,代码来源:Viewport.cs


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