本文整理汇总了C#中ICollidable.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ICollidable.GetType方法的具体用法?C# ICollidable.GetType怎么用?C# ICollidable.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollidable
的用法示例。
在下文中一共展示了ICollidable.GetType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// @see AddAsteroid
/// @see CalculateNewRotations
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (_other.GetType() == typeof(MediumAsteroid))
{
if (isMergeable)
{
drawn = false;
MediumAsteroid other = (MediumAsteroid)_other;
other.isMergeable = false;
other.drawn = false;
foreach (IObjectAdderObserver observer in objectObservers)
{
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(1, position, RandomGenerator.GetRandomFloat(0, 6.283)));
}
}
}
else if (_other.GetType() == typeof(Bullet))
{
drawn = false;
float[] rotationsValue = CalculateNewRotations(this, (Bullet)_other);
foreach (IObjectAdderObserver observer in objectObservers)
{
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(3, position, rotationsValue[0] + Rotation));
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(3, position, rotationsValue[1] + Rotation));
}
}
}
示例2: StartTouch
/// <summary>
///
/// </summary>
/// <param name="collider"></param>
public override void StartTouch(ICollidable collider)
{
if (collider.GetType() != typeof(Player))
return;
if (State.WaterDropsLeft == 0)
State.End();
}
示例3: HandleCollision
/// <summary>
/// Handles a collision with a ball, removes a live from a player
/// </summary>
/// <param name="other"></param>
public void HandleCollision(ICollidable other)
{
if (other.GetType() != typeof(Ball))
return;
this.Player.Lives--;
this.Level.Reset();
}
示例4: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (_other.GetType() == typeof(Bullet))
{
if (((Bullet)_other).Shooter != this)
{
drawn = false;
}
}
}
示例5: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (_other.GetType() == typeof(Player))
{
foreach (IBonusObserver observer in bonusObservers)
{
observer.AddBonus(type);
}
drawn = false;
}
}
示例6: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// @see AddAsteroid
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if(_other.GetType() == typeof(SmallAsteroid))
{
if (isMergeable)
{
drawn = false;
SmallAsteroid other = (SmallAsteroid)_other;
other.isMergeable = false;
other.drawn = false;
foreach (IObjectAdderObserver observer in objectObservers)
{
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, RandomGenerator.GetRandomFloat(0, 6.283)));
}
}
}
if (_other.GetType() == typeof(Bullet))
{
drawn = false;
}
}
示例7: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// @see CalculateNewRotations
/// @see AddAsteroid
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (_other.GetType() == typeof(Bullet))
{
drawn = false;
float[] rotationsValue = CalculateNewRotations(this, (Bullet)_other);
foreach (IObjectAdderObserver observer in objectObservers)
{
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, rotationsValue[0] + Rotation));
observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, rotationsValue[1] + Rotation));
}
}
}
示例8: StartTouch
public override void StartTouch(ICollidable collider)
{
if (IsCollected)
return;
if (collider.GetType() != typeof(Player))
return;
State.WaterDropsLeft--;
IsCollected = true;
Visible = false;
Enabled = false;
}
示例9: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// </summary>
/// <param name="_other">The _other.</param>
public virtual void HasCollided(ICollidable _other)
{
if (_other.GetType() != typeof(Bonus))
{
drawn = false;
position.X = 0;
position.Y = 0;
}
}
示例10: Adjust
/// <summary>
/// Tries to move a unit out of the way by given vector,
/// but only if end position is passable. Tries this with
/// 1*vector, 1/2*vector and 1/4*vector and then gives up.
/// </summary>
/// <param name="unit"></param>
/// <param name="vector"></param>
private void Adjust(ICollidable unit, Vector2 vector)
{
for (int trials = 0; trials < 2; trials++)
{
Vector2 newPosition = unit.Position + vector / (float)Math.Pow(2, trials);
if (PathFinder.GetInstance().FreePoint(newPosition, unit.GetType()))
{
unit.Position = newPosition;
return;
}
}
// Still not free, we give up
}
示例11: CheckScore
/// <summary>
/// Checks the score.
/// @see NotifyScoreObserver
/// </summary>
/// <param name="_other">The _other.</param>
private void CheckScore(ICollidable _other)
{
if (_other.GetType() == typeof(Bonus))
{
NotifyScoreObserver(100);
}
if (_other.GetType() == typeof(LargeAsteroid))
{
NotifyScoreObserver(500);
}
if (_other.GetType() == typeof(MediumAsteroid))
{
NotifyScoreObserver(350);
}
if (_other.GetType() == typeof(SmallAsteroid))
{
NotifyScoreObserver(200);
}
if (_other.GetType() == typeof(SpecialEnemy))
{
NotifyScoreObserver(1500);
}
if (_other.GetType() == typeof(SmallEnemy))
{
NotifyScoreObserver(750);
}
if (_other.GetType() == typeof(LargeEnemy))
{
NotifyScoreObserver(1000);
}
}
示例12: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (_other != shooter && _other.GetType() != typeof(Bullet))
{
drawn = false;
}
CheckScore(_other);
}
示例13: HasCollided
/// <summary>
/// Determines whether the specified _other has collided.
/// </summary>
/// <param name="_other">The _other.</param>
public override void HasCollided(ICollidable _other)
{
if (!isInvulnerable)
{
if (_other.GetType() != typeof(Bonus))
{
if (_other.GetType() != typeof(Bullet))
{
drawn = false;
}
else if (((Bullet)_other).Shooter != this)
{
drawn = false;
}
}
if (drawn == false && lifeCount >= 1)
{
drawn = true;
lifeCount--;
CheckIfDead();
invulnerabilityStart = DateTime.Now;
isInvulnerable = true;
}
}
}