本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Equals方法的具体用法?C# Rectangle.Equals怎么用?C# Rectangle.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tower
//Contructs a tower. Throws exceptions for invalid ranges of values (18 lines)
public Tower(String name, int health, int damage, int cost, int range, Rectangle location)
{
if (location.Equals(new Rectangle()))
throw new ArgumentNullException();
if (range <= 0)
throw new ArgumentOutOfRangeException();
if (damage < 0)
throw new ArgumentOutOfRangeException();
if (health <= 0)
throw new ArgumentOutOfRangeException();
if (cost < 0)
throw new ArgumentOutOfRangeException();
this.name = name;
this.location = location;
this.health = health;
this.attackDamage = damage;
this.cost = cost;
this.range = range;
this.updateCounter = 0;
this.nearbyEnemies = new List<Enemy>();
this.color = Color.White;
switch (name)
{
case "path":
this.color = Color.Black;
break;
case "slow":
this.color = Color.Blue;
break;
case "dot":
this.color = Color.Red;
break;
case "sniper":
this.color = Color.Green;
break;
}
if (color == Color.White)
name = "basic";
}
示例2: Tower
//Contructs a tower. Throws exceptions for invalid ranges of values (18 lines)
public Tower(String name, int health, int damage, int cost, int range, Rectangle location)
{
if (location.Equals(new Rectangle()))
throw new ArgumentNullException();
if (range <= 0)
throw new ArgumentOutOfRangeException();
if (damage <= 0)
throw new ArgumentOutOfRangeException();
if (health <= 0)
throw new ArgumentOutOfRangeException();
if (cost <= 0)
throw new ArgumentOutOfRangeException();
this.name = name;
this.location = location;
this.health = health;
this.attackDamage = damage;
this.cost = cost;
this.range = range;
this.updateCounter = 0;
this.nearbyEnemies = new List<Enemy>();
}
示例3: Enemy
//Constructs the Enemy class, throws 2 exceptions (ArgumentOurOfRangeException and ArgumentNullArgument) (15 lines)
public Enemy(float health, double speed, String type, int gold, Rectangle location)
{
if (location.Equals(new Rectangle()))
throw new ArgumentNullException();
if (gold <= 0)
throw new ArgumentOutOfRangeException();
if (speed <= 0)
throw new ArgumentOutOfRangeException();
if (health <= 0)
throw new ArgumentOutOfRangeException();
if (type != "basic")
throw new ArgumentException();
this.maxHealth = health;
this.health = health;
this.speed = speed;
this.type = type;
this.gold = gold;
this.location = location;
this.inFiringRange = false;
}
示例4: UpdateEnemyCollisions
private void UpdateEnemyCollisions()
{
Rectangle rectangle1;
Rectangle rectangle2;
foreach (Enemy enemy1 in enemies.ToArray())
{
foreach (Enemy enemy2 in enemies.ToArray())
{
rectangle1 = new Rectangle((int)enemy1.getPosition.X, (int)enemy1.getPosition.Y, enemy1.Width, enemy1.Height);
rectangle2 = new Rectangle((int)enemy2.getPosition.X, (int)enemy2.getPosition.Y, enemy2.Width, enemy2.Height);
if (!rectangle1.Equals(rectangle2) && rectangle1.Intersects(rectangle2))
{
enemy1.setActive(false);
enemy2.setActive(false);
}
}
}
}