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


C# Coordinates.getY方法代码示例

本文整理汇总了C#中Coordinates.getY方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinates.getY方法的具体用法?C# Coordinates.getY怎么用?C# Coordinates.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coordinates的用法示例。


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

示例1: getBlockAt

        public Block getBlockAt(Coordinates coordinates)
        {
            int x = (int)Math.Floor(coordinates.getX());
               int y = (int)Math.Floor(coordinates.getY());

               if(!blocks.ContainsKey(x.ToString() + "," + y.ToString())){
               if (coordinates.getY() > -1) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Air()));
               }
               else if (coordinates.getY() == -1) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Grass()));
               }
               else if (coordinates.getY() == -2) {
                   Random rnd = new Random();

                   if (rnd.Next(0, 2) == 0) {
                       blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Dirt()));
                   }
                   else {
                       blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
                   }
               }
               else if (coordinates.getY() < -2) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
               }
               blocks[x.ToString() + "," + y.ToString()].setCoordinates(coordinates);
               }

               return blocks[x.ToString() + "," + y.ToString()];
        }
开发者ID:patrickfreed,项目名称:SideCraft--Old-,代码行数:30,代码来源:World.cs

示例2: FindDistance

        /* DESCRIPTION:
         * Finds ditect distance between two cities
         */
        private static double FindDistance(Coordinates point1, Coordinates point2)
        {
            double distance;

            // Calculate the distance
            distance = Math.Sqrt(Math.Pow(point1.getX() - point2.getX(), 2) +
                                 Math.Pow(point1.getY() - point2.getY(), 2));

            return (distance);
        }
开发者ID:NikolaiSamteladze,项目名称:PathFinder,代码行数:13,代码来源:AAlgorithm.cs

示例3: update

        public void update(SpriteBatch spriteBatch)
        {
            updateSize();

               Coordinates upperExtreme = new Coordinates(Math.Floor(Game1.player.coordinates.getX()) + xLength, Math.Floor(Game1.player.coordinates.getY() + yLength));
               Coordinates lowerExtreme = new Coordinates(Math.Floor(Game1.player.coordinates.getX()) - xLength, Math.Floor(Game1.player.coordinates.getY() - yLength));

               int xDistance = (int)Math.Abs(upperExtreme.getX() - lowerExtreme.getX());
               int yDistance = (int)Math.Abs(upperExtreme.getY() - lowerExtreme.getY());

               for (int x = 0; x <= xDistance; x++) {
               for (int y = 0; y <= yDistance; y++) {
                   double xCoord = upperExtreme.getX() + increment(x, (int)upperExtreme.getX(), (int)lowerExtreme.getX());
                   double yCoord = upperExtreme.getY() + increment(y, (int)upperExtreme.getY(), (int)lowerExtreme.getY());

                   Block block = getBlockAt(new Coordinates(xCoord,yCoord));
                   block.draw(spriteBatch, null, util.getPosition(block.getCoordinates()));
               }
               }
        }
开发者ID:patrickfreed,项目名称:SideCraft--Old-,代码行数:20,代码来源:World.cs


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