• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Vector2i类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ControlNode

            public ControlNode(Vector2i pos, float[,] map, Vector2 position, float size)
                : base(position)
            {
                Active = map[pos.x, pos.y];

                if (pos.x == map.GetLength(0))
                {
                    Right = new Node(position + Vector2.right * size * 0.5f);
                }
                else
                {
                    Right = new Node(position + Vector2.right * size * 0.5f);
                }

                if (pos.y == map.GetLength(1))
                {
                    Up = new Node(position + Vector2.up * size * 0.5f);
                }
                else
                {
                    Up = new Node(position + Vector2.up * size * 0.5f);
                }

                //float right = pos.x <  ? map[pos.x + 1, pos.y] : Active;
                //float up = map[pos.x, pos.y + 1];
            }
开发者ID:mfagerlund,项目名称:MC-Ubes,代码行数:26,代码来源:MeshGenerator.cs


示例2: GetActualPosition

    private static Vector2i? GetActualPosition(Vector2 position)
    {
        NavigationField navigationField = NavigationField.Instance;
        Vector2i pos = Vector2i.FromVector2Round(position);
        if (!navigationField.fieldSize.ContainsAsSize(pos))
        {
            return null;
        }

        if (!float.IsPositiveInfinity(navigationField.Costs[pos.x, pos.y]))
        {
            return pos;
        }

        // Try to find a nice neighbour...
        for (int y = -1; y <= 1; y++)
        {
            for (int x = -1; x <= 1; x++)
            {
                Vector2i test = new Vector2i(pos.x + x, pos.y + y);
                if (!float.IsPositiveInfinity(navigationField.GetCost(test)))
                {
                    return test;
                }
            }
        }

        return null;
    }
开发者ID:mfagerlund,项目名称:LD33,代码行数:29,代码来源:NavigationTool.cs


示例3: Job_PlantSeed

 public Job_PlantSeed(Vector2i plantPos, VoxelTypes seedType, IGrowPattern growPattern)
     : base(Labors.Farm, "Plant Seed", "Planting seed")
 {
     PlantPos = plantPos;
     SeedType = seedType;
     GrowPattern = growPattern;
 }
开发者ID:heyx3,项目名称:Elve,代码行数:7,代码来源:Job_PlantSeed.cs


示例4: OnMouseButton

        public static bool OnMouseButton(Controls.Control hoveredControl, int x, int y, bool down)
        {
            if (!down)
            {
                m_LastPressedControl = null;

                // Not carrying anything, allow normal actions
                if (CurrentPackage == null)
                    return false;

                // We were carrying something, drop it.
                onDrop(x, y);
                return true;
            }

            if (hoveredControl == null)
                return false;
            if (!hoveredControl.DragAndDrop_Draggable())
                return false;

            // Store the last clicked on control. Don't do anything yet,
            // we'll check it in OnMouseMoved, and if it moves further than
            // x pixels with the mouse down, we'll start to drag.
            m_LastPressedPos = new Vector2i(x, y);
            m_LastPressedControl = hoveredControl;

            return false;
        }
开发者ID:chartly,项目名称:flood,代码行数:28,代码来源:DragAndDrop.cs


示例5: Cannon

        public Cannon(Direction2D direction, Vector2i index)
        {
            _direction = direction;
            _worldIndex = index;

            _readOnlyBullets = new ReadOnlyCollection<Bullet>(_bullets);
        }
开发者ID:JaakkoLipsanen,项目名称:WVVW,代码行数:7,代码来源:Cannon.cs


示例6: SetField

 public override void SetField(Vector2i vect, char value)
 {
     if (IsEntryPointInTheSize(vect))
     {
         VarField[vect.X, vect.Y] = value;
     }
 }
开发者ID:Postremus,项目名称:UniTTT,代码行数:7,代码来源:Brett.cs


示例7: Next

 public static Vector2i Next(this Random random, Vector2i min, Vector2i max)
 {
     return new Vector2i(
         random.Next(min.X, max.X + 1),
         random.Next(min.Y, max.Y + 1)
     );
 }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:7,代码来源:Extensions.cs


示例8: SendVector

 public void SendVector(Vector2i vect)
 {
     if (!(Player is Player.NetworkPlayer))
     {
         client.Send(string.Format("UniTTT!Vector:{0}", vect.ToString()));
     }
 }
开发者ID:Postremus,项目名称:UniTTT,代码行数:7,代码来源:NetworkGame.cs


示例9: ItemCollectedMessage

 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.ItemCollectedMessage"/> class.
 /// </summary>
 /// <param name="item">Item.</param>
 /// <param name="inventoryPosition">Inventory position.</param>
 /// <param name="entity">Entity.</param>
 public ItemCollectedMessage(Entity entity, ItemComponent item, Vector2i inventoryPosition)
 {
     Entity = entity;
     Item = item;
     InventoryPosition = inventoryPosition;
     MessageId = (int) Messaging.MessageId.ItemCollected;
 }
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:13,代码来源:ItemCollectedMessage.cs


示例10: DistanceEstimate

        public double DistanceEstimate(Vector2i a, Vector2i b)
        {
            if (UseManhattanMetric)
                return Math.Abs(b.X - a.X) + Math.Abs(b.Y - a.Y);

            return Utils.Distance(new Vector2f(a.X, a.Y), new Vector2f(b.X, b.Y));
        }
开发者ID:deanljohnson,项目名称:PathView,代码行数:7,代码来源:SquareGrid.cs


示例11: Exit

 public Exit(Vector2i _pos)
     : base(_pos)
 {
     CurrentTex = "exit";
     Movable = false;
     Open = false;
 }
开发者ID:starboxgames,项目名称:superstarbox,代码行数:7,代码来源:Exit.cs


示例12: Setup

 public void Setup(RL.Map _map, int[] _dir)
 {
     map = _map;
     directions = _dir;
     lineRenderers = new GameObject[directions.Length];
     for (int i = 0; i < directions.Length; i++) {
         lineRenderers [i] = new GameObject ();
         lineRenderers [i].transform.parent = transform;
         lineRenderers [i].transform.position = transform.position;
         LineRenderer lr = lineRenderers [i].AddComponent<LineRenderer> ();
         lr.renderer.sortingOrder = 2;
         lr.renderer.sortingLayerName = "Default";
         lr.SetColors(new Color(74/255f,63/255f,148/255f, 0.5f), new Color(113/255f,138/255f,145/255f, 0.5f));
         lr.SetWidth (0.05f, 0.05f);
         lr.material = (Material)Resources.Load ("trapParticle");
         lr.useWorldSpace = false;
         // move out on the direction until we hit a wall, this is our endpoint
         Vector2i ndir = new Vector2i (RL.Map.nDir[directions[i],0], RL.Map.nDir[directions[i],1]);
         Vector2i np = GetComponent<RLCharacter>().positionI;
         int distanceCount = 1;
         np += ndir;
         while (map.IsOpenTile (np.x, np.y)) {
             np += ndir;
         }
     //			np -= ndir*0.5f;
         lr.SetPosition (0, Vector3.zero);
         lr.SetPosition (1, new Vector3(np.x-ndir.x*0.5f, np.y-ndir.y*0.5f, 0)-transform.position);
     }
 }
开发者ID:jonbro,项目名称:nightmare_cooperative,代码行数:29,代码来源:TrapDisplay.cs


示例13: Window

        /// <summary>
        /// Initializes a new instance of the <see cref="FreezingArcher.Core.Window"/> class.
        /// </summary>
        /// <param name="size">Windowed size.</param>
        /// <param name="resolution">Resolution of the framebuffer.</param>
        /// <param name="title">Title.</param>
        public Window (Vector2i size, Vector2i resolution, string title)
        {
            Logger.Log.AddLogEntry (LogLevel.Info, ClassName, "Creating new window '{0}'", title);
	    MSize = size;
	    MResolution = resolution;
	    MTitle = title;
        }
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:13,代码来源:Window.cs


示例14: Stop

 public static void Stop(BHEntity mEntity, Vector2i mDirection, Rectangle mBounds, int mBoundsOffset)
 {
     if (mDirection.X == -1) mEntity.Position = new Vector2i(mBounds.X + mBoundsOffset, mEntity.Position.Y);
     if (mDirection.X == 1) mEntity.Position = new Vector2i(mBounds.X + mBounds.Width - mBoundsOffset, mEntity.Position.Y);
     if (mDirection.Y == -1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y + mBoundsOffset);
     if (mDirection.Y == 1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y - mBoundsOffset + mBounds.Height);
 }
开发者ID:SuperV1234,项目名称:VeeBulletHell,代码行数:7,代码来源:BHPresetOutOfBounds.cs


示例15: Update

        public override bool Update(Vector2i mouseS, IMapManager currentMap)
        {
            if (currentMap == null) return false;

            spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey);

            mouseScreen = mouseS;
            mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);

            var bounds = spriteToDraw.GetLocalBounds();
            var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height));
            var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f),
                                                 mouseWorld.Y - (spriteSize.Y / 2f),
                                                 spriteSize.X, spriteSize.Y);

            if (pManager.CurrentPermission.IsTile)
                return false;

            if (pManager.CollisionManager.IsColliding(spriteRectWorld))
                return false;

            //if (currentMap.IsSolidTile(mouseWorld)) return false;

            var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range;
            if (rangeSquared > 0)
                if (
                    (pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform)
                         .Position - mouseWorld).LengthSquared() > rangeSquared) return false;

            currentTile = currentMap.GetTileRef(mouseWorld);

            return true;
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:33,代码来源:AlignNone.cs


示例16: Sprite

 public Sprite(SpriteSheet spriteSheet, string name, Vector2i size, Box2 coordinates)
 {
     SpriteSheet = spriteSheet;
     Name = name;
     Size = size;
     Coordinates = coordinates;
 }
开发者ID:nicolas-repiquet,项目名称:Granite,代码行数:7,代码来源:Sprite.cs


示例17: ScrollableContainer

        public ScrollableContainer(string uniqueName, Vector2i size, IResourceManager resourceManager)
        {
            _resourceManager = resourceManager;

            Size = size;

            //if (RenderTargetCache.Targets.Contains(uniqueName))
            //    //Now this is an ugly hack to work around duplicate RenderImages. Have to fix this later.
            //    uniqueName = uniqueName + Guid.NewGuid();

            clippingRI = new RenderImage(uniqueName,(uint)Size.X,(uint) Size.Y);

            //clippingRI.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //clippingRI.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            //clippingRI.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //clippingRI.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;
            clippingRI.BlendSettings.ColorSrcFactor = BlendMode.Factor.SrcAlpha;
            clippingRI.BlendSettings.ColorDstFactor = BlendMode.Factor.OneMinusSrcAlpha;
            clippingRI.BlendSettings.AlphaSrcFactor = BlendMode.Factor.SrcAlpha;
            clippingRI.BlendSettings.AlphaDstFactor = BlendMode.Factor.OneMinusSrcAlpha;

            scrollbarH = new Scrollbar(true, _resourceManager);
            scrollbarV = new Scrollbar(false, _resourceManager);
            scrollbarV.size = Size.Y;

            scrollbarH.Update(0);
            scrollbarV.Update(0);

            Update(0);
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:30,代码来源:ScrollableContainer.cs


示例18: BlockInfo

 public BlockInfo(Vector2i position, BlockType type, float height, Vector3 normal)
 {
     Position = position;
     Type = type;
     Height = height;
     Normal = normal;
 }
开发者ID:Silentor,项目名称:InfluenceTerrainDemo,代码行数:7,代码来源:LandMap.cs


示例19: GenerateBlock

        protected override BlockType GenerateBlock(Vector2i worldPosition, Vector2i turbulence, Vector3 normal, ZoneRatio influence)
        {
            if (Vector3.Angle(Vector3.up, normal) > 65)
                return BlockType.Rock;

            return base.GenerateBlock(worldPosition, turbulence, normal, influence);
        }
开发者ID:Silentor,项目名称:InfluenceTerrainDemo,代码行数:7,代码来源:HillsGenerator.cs


示例20: GetIntermediatePoints

    /// <summary>
    /// Returns the indices of the squares on a grid that intersect a line 
    /// beginning at vector "start" and ending at vector "end".  Right now 
    /// uses Bresenham's algorithm which may be a bad choice.
    /// </summary>
    /// <param name="start"></param>
    /// <param name="end"></param>
    /// <returns></returns>
    public IEnumerable<Vector2i> GetIntermediatePoints(Vector2i start, Vector2i end)
    {
        // http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
        var x0 = start.X;
        var x1 = end.X;
        var y0 = start.Y;
        var y1 = end.Y;
        var dx = Math.Abs(x1 - x0);
        var dy = Math.Abs(y0 - y1);

        var sx = (x0 < x1)? 1 : -1;
        var sy = (y0 < y1)? 1 : -1;
        var err = dx - dy;

        while (x0 != x1 || y0 != y1)
        {
            yield return new Vector2i(x0, y0);
            var e2 = err * 2;
            if (e2 > -dy)
            {
                err -= dy;
                x0 += sx;
            }

            if (e2 < dx)
            {
                err += dx;
                y0 += sy;
            }
        }
    }
开发者ID:HaKDMoDz,项目名称:awayteam,代码行数:39,代码来源:LineOfSight.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Vector3类代码示例发布时间:2022-05-24
下一篇:
C# Vector2f类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap