当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Equals方法代码示例

本文整理汇总了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";
        }
开发者ID:mellinja,项目名称:TD2,代码行数:44,代码来源:Tower.cs

示例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>();
        }
开发者ID:mellinja,项目名称:SQA-Tower-Defense,代码行数:24,代码来源:Tower.cs

示例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;
        }
开发者ID:mellinja,项目名称:SQA-Tower-Defense,代码行数:25,代码来源:Enemy.cs

示例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);
             }
         }
     }
 }
开发者ID:matthewkreutter,项目名称:mousegame,代码行数:18,代码来源:Game1.cs


注:本文中的Microsoft.Xna.Framework.Rectangle.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。