本文整理汇总了C#中Actor.startDying方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.startDying方法的具体用法?C# Actor.startDying怎么用?C# Actor.startDying使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.startDying方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collideWith
public override void collideWith(Actor other)
{
if (other is Shark)
{
die();
}
else if (other is Penguin)
{
if (((Penguin)other).PowerupState != powerupstate.SpearDeflection)
die();
}
else if (other is Fish)
{
other.startDying();
}
}
示例2: collideWith
//.........这里部分代码省略.........
// get physics rotation to p's rotation,
// normalize that, and magnify by the amount
Vector2 pRotation = Physics.AngleToVector(other.Rotation);
pRotation.Normalize();
// give us an acceleration in that direction
this.Position += pRotation * Actor.SPEAR_DISPLACEMENT;
}
}
else if (other is Shark)
{
if (!other.Bounds.isCollision(this.Bounds))
return;
// gain health
if (other.CurrState == state.Dying)
{
if (other.Powerup != null)
this.calories += 2 * SHARK_CALORIES;
else
this.calories += SHARK_CALORIES;
other.die();
}
// take damage
else if (other.CurrState == state.Dashing)
{
// we must not be dying and we must be colliding with
// the mouth of the shark
if (CurrState != state.Dying &&
this.Bounds.isCollision(((Shark)other).mouthCircle))
{
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
getHit();
this.calories -= SHARK_DAMAGE;
}
}
}
else if (other is Fish)
{
if (other.CurrState == state.Moving)
{
AudioManager.getSound("Fish_Eat").Play();
this.calories += FISH_CALORIES;
other.startDying();
if (other.Powerup != null)
applyPowerup(other.Powerup);
}
}
else if (other is Penguin)
{
Penguin p = (Penguin)other;
if (p.CurrState == state.MeleeAttack &&
this.Bounds.isCollision(p.spearCircle) &&
!isBeingKnockedBack)
{
isBeingKnockedBack = true;
knockbackTime = KNOCKBACK_DURATION;
getHit();
this.calories -= p.MeleeDamage;
// get physics rotation to p's rotation,
// normalize that, and magnify by the amount
Vector2 pRotation = Physics.AngleToVector(p.Rotation);
pRotation.Normalize();
// give us an acceleration in that direction
this.velocity += pRotation * p.KnockbackAmount;
this.Position += pRotation * (Actor.MELEE_DISPLACEMENT + p.calories / 10.0f);
}
}
}
示例3: collideWith
public override void collideWith(Actor other)
{
if (other is Spear)
{
if (other.CurrentSize == Size.Small)
this.calories -= SPEAR_SMALL_DAMAGE;
else if (other.CurrentSize == Size.Medium)
this.calories -= SPEAR_MED_DAMAGE;
else
this.calories -= SPEAR_MAX_DAMAGE;
Random rnd = new Random();
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble()*3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
ParticleManager.Instance.createParticle(ParticleType.HitSpark,
new Vector2(this.Position.X + rnd.Next(-20, 20), this.Position.Y + rnd.Next(-20, 20)),
new Vector2(0, 0), (float)(rnd.NextDouble() * 6.29f), 0.1f,
(float)rnd.NextDouble(), -(float)rnd.NextDouble() * 3, 1, 1 + (float)rnd.NextDouble() * 2f, 1f);
isBeingKnockedBack = true;
knockbackTime = KNOCKBACK_DURATION;
// get physics rotation to p's rotation,
// normalize that, and magnify by the amount
Vector2 pRotation = Physics.AngleToVector(other.Rotation);
pRotation.Normalize();
this.Position += pRotation * Actor.SPEAR_DISPLACEMENT;
getHit();
}
else if (other is Fish)
{
if (other.CurrState == state.Moving &&
this.CurrState != state.Dying &&
this.IsAlive)
{
AudioManager.getSound("Fish_Eat").Play();
this.calories += SHARK_FISH_CALORIES;
other.startDying();
if (other.Powerup != null)
applyPowerup(other.Powerup);
}
}
else if (other is Penguin)
{
Penguin p = (Penguin)other;
if (p.CurrState == state.MeleeAttack &&
this.Bounds.isCollision(p.spearCircle)
&& !isBeingKnockedBack)
{
isBeingKnockedBack = true;
knockbackTime = KNOCKBACK_DURATION;
getHit();
this.calories -= p.MeleeDamage;
// get physics rotation to p's rotation,
// normalize that, and magnify by the amount
Vector2 pRotation = Physics.AngleToVector(p.Rotation);
pRotation.Normalize();
this.velocity = pRotation * p.KnockbackAmount;
this.acceleration = Vector2.Zero;
this.Position += pRotation * Actor.MELEE_DISPLACEMENT;
}
else if (other.CurrState == state.Dying)
{
this.calories += PENGUIN_CALORIES;
other.die();
}
else if (this.Bounds.isCollision(other.Bounds))
this.acceleration = Vector2.Zero;
}
}