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


C# Character.getX方法代码示例

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


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

示例1: InRange

 public static bool InRange(Character c, CameraComponent cam)
 {
     return Math.Abs(c.getX() - cam.Position.X) < Constants.TILE_SIZE * 30;
 }
开发者ID:bmaxwell921,项目名称:LandOfAmbrosia,代码行数:4,代码来源:Constants.cs

示例2: findTilePoint

 //Returns the Vector3 of the point that we need to move the character to
 private Vector3 findTilePoint(Character c, Tile intersectingTile, float newX, float newY, bool leftRight)
 {
     Vector3 tilePt = Vector3.Zero;
     if (leftRight)
     {
         float tileLeft = intersectingTile.getX() - Constants.BUFFER;
         float tileRight = intersectingTile.getX() + intersectingTile.width + Constants.BUFFER;
         //If we are moving to the left, ie newX < curX, the tile point we need is the right side
         tilePt.X = (newX < c.getX()) ? tileRight : tileLeft;
     }
     else
     {
         float tileTop = intersectingTile.getY() + Constants.BUFFER;
         float tileBottom = intersectingTile.getY() - intersectingTile.height - Constants.BUFFER;
         tilePt.Y = (newY < c.getY()) ? tileTop : tileBottom;
     }
     return tilePt;
 }
开发者ID:bmaxwell921,项目名称:LandOfAmbrosia,代码行数:19,代码来源:LevelManager.cs

示例3: UpdateCharacter

        //Updates the player position and handles collisions
        private void UpdateCharacter(Character character, GameTime gameTime)
        {
            if (!character.isFlying() && !character.onGround)
            {
                //update force of gravity
                character.setVelocityY(character.getVelocityY() + Constants.GRAVITY);
            }

            float dx = character.getVelocityX();
            float oldX = character.getX();
            float newX = oldX + dx;
            bool hasCollision;
            Vector3 posFix = getTileCollision(character, newX, character.getY(), true, out hasCollision);
            if (!hasCollision)
            {
                character.setX(newX);
            }
            else
            {
                //posFix will be the vector needed to fix the collision, so just add the fix to the vector that's messing everything up
                character.setX(newX + posFix.X);
                character.collideHorizontal();
            }

            float dy = character.getVelocityY();
            float oldY = character.getY();
            float newY = oldY + dy;
            posFix = getTileCollision(character, character.getX(), newY, false, out hasCollision);
            if (!hasCollision)
            {
                character.setY(newY);
            }
            else
            {
                character.setY(newY + posFix.Y);
                character.collideVertical();
            }

            if (character.getY() < -20)
            {
                if (character is UserControlledCharacter)
                {
                    --levels[curLevelInfo].numLives;
                    //resetCharacterPositions();
                    resetCharacters();
                }
                else
                {
                    //character.stats.changeCurrentStat(Constants.HEALTH_KEY, -character.stats.getStatCurrentVal(Constants.HEALTH_KEY));
                    ((Minion)character).respawn();
                }
            }

            //Check if they attacked with a projectile and add it if they did
            if (character.WantsRangeAttack())
            {
                //Ai characters will handle knowing who to attack, so don't bother passing in a value.
                //TODO now that the players have a reference to the level they can find the closest enemy themselves
                Projectile proj = character.rangeAttack(gameTime, character is AICharacter ? null : GetClosestEnemy(character));
                if (proj != null)
                {
                    projectiles.Add(proj);
                }
            }
        }
开发者ID:bmaxwell921,项目名称:LandOfAmbrosia,代码行数:66,代码来源:LevelManager.cs

示例4: CheckTurnOnGravity

 private void CheckTurnOnGravity(Character c)
 {
     Vector2 belowTile = new Vector2(currentLevel.GetTileIndexFromXPos(c.getX() + Constants.BUFFER), currentLevel.GetTileIndexFromYPos(c.getY() - Constants.BUFFER)) - new Vector2(0, 1);
     Tile curTile = currentLevel.GetTile((int)belowTile.X, (int)belowTile.Y);
     if (curTile == null && c.onGround == true)
     {
         c.onGround = false;
     }
 }
开发者ID:bmaxwell921,项目名称:LandOfAmbrosia,代码行数:9,代码来源:LevelManager.cs


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