本文整理汇总了C#中Player.GetCollRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Player.GetCollRectangle方法的具体用法?C# Player.GetCollRectangle怎么用?C# Player.GetCollRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.GetCollRectangle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsPlayerInSight
public static bool IsPlayerInSight(Enemy enemy, Player.Player player, GameWorld gameWorld, out List<Rectangle> rects)
{
Rectangle rect = new Rectangle(enemy.GetCollRectangle().Center.X, enemy.GetCollRectangle().Center.Y, 1, 1);
rects = new List<Rectangle>();
double xVector = (double)(player.GetCollRectangle().Center.X - rect.Center.X);
double yVector = (double)(player.GetCollRectangle().Center.Y - rect.Center.Y);
Vector2 maxVelocity = new Vector2(30, 30);
double magnitude = Math.Sqrt((Math.Pow(xVector, 2.0)) + (Math.Pow(yVector, 2.0)));
Vector2 newVelocity = new Vector2(maxVelocity.X * (float)(xVector / magnitude), maxVelocity.Y * (float)(yVector / magnitude));
for (int i = 0; i < 10; i++)
{
rects.Add(rect);
int index = (int)(rect.Y / Main.Tilesize * gameWorld.WorldData.LevelWidth) + (int)(rect.X / Main.Tilesize);
if (rect.Intersects(player.GetCollRectangle()))
return true;
if (index > GameWorld.Instance.TileArray.Length - 1 || index < 0)
return false;
if (gameWorld.TileArray[index].IsSolid)
return false;
rect.X += (int)newVelocity.X;
rect.Y += (int)newVelocity.Y;
}
return false;
}
示例2: PickedUp
public void PickedUp(Player.Player player, PopUp popUp)
{
if (player.GetCollRectangle().Intersects(Rectangle) && !ToDelete)
{
ToDelete = true;
popUp.IsVisible = true;
}
}
示例3: Update
public void Update(Player.Player player)
{
if (player.GetCollRectangle().Intersects(_rectangle) && Keyboard.GetState().IsKeyDown(Keys.W))
{
IsPickedUp = true;
_pickSound.Play();
ToDelete = true;
}
}
示例4: OnPunchFrameChange
private void OnPunchFrameChange(Player.Player player)
{
if(player.CurrentAnimationFrame == 2){
int speed = 2;
if (!player.IsFacingRight)
speed *= -1;
player.SetVelX(speed);
Rectangle punchHitBox = player.GetCollRectangle();
punchHitBox.Width += 50;
if (player.IsFacingRight)
punchHitBox.X += player.GetCollRectangle().Width / 2;
else punchHitBox.X -= (punchHitBox.Width + player.GetCollRectangle().Width / 2);
player.DealDamage(punchHitBox, 20);
player.AnimationFrameChanged -= OnPunchFrameChange;
}
}
示例5: OnJumpAction
public void OnJumpAction(Player.Player player)
{
if (!player.IsJumping)
{
player.Sounds.Get("jump").Play();
player.IsJumping = true;
player.SetVelY(JumpAcc);
player.ChangePosBy(0, -1);
player.AddAnimationToQueue("jump");
player.CollidedWithTileBelow += OnTouchGround;
for (int i = 0; i < 10; i++)
{
SmokeParticle par = new SmokeParticle(CalcHelper.GetRandomX(player.GetCollRectangle()),player.GetCollRectangle().Bottom,new Vector2(GameWorld.RandGen.Next((int)player.GetVelocity().X - 1,(int)player.GetVelocity().X + 1)/10f,-GameWorld.RandGen.Next(1,10)/10f));
GameWorld.ParticleSystem.Add(par);
}
}
if (_airTimer.TimeElapsedInMilliSeconds < 1000)
{
player.GravityStrength = Main.Gravity * .75f;
}
else
{
player.GravityStrength = Main.Gravity;
}
}
示例6: PlayerPacket
public PlayerPacket(Player.Player player)
{
_position = new Vector2(player.GetCollRectangle().X, player.GetCollRectangle().Y);
_velocity = player.GetVelocity();
}
示例7: Update
public void Update(GameTime gameTime, Player.Player player, PopUp popUp)
{
this._gameTime = gameTime;
_animation.Update(gameTime);
PickedUp(player, popUp);
_glowTimer+= gameTime.ElapsedGameTime.Milliseconds;
if (_radius.Intersects(player.GetCollRectangle()))
{
if (_glowTimer > 4000)
{
_glow.Play();
_glowTimer = 0;
}
}
}
示例8: CreateTileParticleEffect
public void CreateTileParticleEffect(Tile tile, Player.Player player)
{
CurrentParticle = ParticleType.TileParticle;
Texture = tile.Texture;
CollRectangle = new Rectangle(player.GetCollRectangle().Center.X - 2, player.GetCollRectangle().Y + player.GetCollRectangle().Height, 8, 8);
SourceRectangle = new Rectangle(tile.SourceRectangle.X, tile.SourceRectangle.Y, 4, 4);
SourceRectangle.X += (GameWorld.RandGen.Next(0, 4) * Main.Tilesize / 4);
Velocity.X = (-player.GetVelocity().X / 2) * (float)GameWorld.RandGen.NextDouble();
Velocity.Y = GameWorld.RandGen.Next(-1, 1);
Opacity = 1;
}
示例9: CreateJetPackSmokeParticle
public void CreateJetPackSmokeParticle(Player.Player player)
{
CurrentParticle = ParticleType.JetpackSmoke;
Texture = ContentHelper.LoadTexture("Effects/smoke");
CollRectangle = new Rectangle(player.GetCollRectangle().Center.X - 8, player.GetCollRectangle().Y + player.GetCollRectangle().Height, 16, 16);
SourceRectangle = new Rectangle(GameWorld.RandGen.Next(0, 4) * 16, 0, 16, 16);
Velocity.Y = 3f;
Velocity.X = GameWorld.RandGen.Next(-1, 2);
Position = new Vector2(CollRectangle.X, CollRectangle.Y);
Opacity = 1f;
}
示例10: CreateBloodEffect
public void CreateBloodEffect(Player.Player player, GameWorld map)
{
CurrentParticle = ParticleType.Blood;
Texture = ContentHelper.LoadTexture("Effects/blood");
CollRectangle = new Rectangle(player.GetCollRectangle().Center.X, player.GetCollRectangle().Center.Y, 8, 8);
SourceRectangle = new Rectangle(GameWorld.RandGen.Next(0, 4) * 8, 0, 8, 8);
CollRectangle = CollRectangle;
Velocity = new Vector2(GameWorld.RandGen.Next(-10, 10), GameWorld.RandGen.Next(-10, 10));
Position = new Vector2(CollRectangle.X, CollRectangle.Y);
}
示例11: Particle
public Particle(Player.Player player)
{
_randGen = new Random();
SourceRectangle = new Rectangle(0, 0, 14, 14);
CurrentParticle = ParticleType.GameZzz;
Texture = ContentHelper.LoadTexture("Effects/new_Z");
color = new Color(255, 255, 255, 255);
if (player.IsFacingRight)
Position = new Vector2(player.GetCollRectangle().X + _randGen.Next(-5, 5) + player.GetCollRectangle().Width - 8, player.GetCollRectangle().Y + _randGen.Next(-5, 5));
else Position = new Vector2(player.GetCollRectangle().Center.X + _randGen.Next(0, 20), player.GetCollRectangle().Y + _randGen.Next(-5, 5));
CollRectangle = new Rectangle((int)Position.X, (int)Position.Y, 8, 8);
}