本文整理汇总了C#中Character.getY方法的典型用法代码示例。如果您正苦于以下问题:C# Character.getY方法的具体用法?C# Character.getY怎么用?C# Character.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Character
的用法示例。
在下文中一共展示了Character.getY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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);
}
}
}
示例3: 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;
}
}