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


C# Rectangle.Intersects方法代码示例

本文整理汇总了C#中Rectangle.Intersects方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Intersects方法的具体用法?C# Rectangle.Intersects怎么用?C# Rectangle.Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle.Intersects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AtXY

 public static bool AtXY(int x, int y, QPlayer Player, int radius = 1)
 {
     Rectangle rec, playerrec;
     rec = new Rectangle(x - radius, y - radius, radius * 2, radius * 2);
     playerrec = new Rectangle((int)Player.TSPlayer.X / 16, (int)Player.TSPlayer.Y / 16, 1, 1);
     return rec.Intersects(playerrec);
 }
开发者ID:Olink,项目名称:Twitchys-Quest-Mod,代码行数:7,代码来源:QFunctions.cs

示例2: CanPlace

 public bool CanPlace(Rectangle area, bool[] validTiles, int padding = 0)
 {
     if (area.X < 0 || area.Y < 0 || area.X + area.Width > Main.maxTilesX - 1 || area.Y + area.Height > Main.maxTilesY - 1)
     {
         return false;
     }
     Rectangle rectangle = new Rectangle(area.X - padding, area.Y - padding, area.Width + padding * 2, area.Height + padding * 2);
     for (int i = 0; i < this._structures.Count; i++)
     {
         if (rectangle.Intersects(this._structures[i]))
         {
             return false;
         }
     }
     for (int j = rectangle.X; j < rectangle.X + rectangle.Width; j++)
     {
         for (int k = rectangle.Y; k < rectangle.Y + rectangle.Height; k++)
         {
             if (Main.tile[j, k].active() && !validTiles[Main.tile[j, k].type])
             {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:26,代码来源:StructureMap.cs

示例3: ListQuest

        public static void ListQuest(CommandArgs args)
        {
            QPlayer Player = QTools.GetPlayerByID(args.Player.Index);
            if (Player.IsLoggedIn)
            {
                Rectangle ply = new Rectangle((int)args.Player.X / 16, (int)args.Player.Y / 16, 1, 1);
                string availquests = "Available Quests: ";
                foreach (QuestRegion qr in QMain.QuestRegions)
                {
                    if (ply.Intersects(qr.Area))
                    {
                        foreach (Quest q in qr.Quests)
                        {
                            QuestPlayerData data = QTools.GetPlayerQuestData(q.Name, Player);

                            if (QTools.AbleToRunQuest(q) && (q.MinQuestsNeeded == 0 || q.MinQuestsNeeded <= QTools.GetQuestsCompleted(Player.MyDBPlayer.QuestPlayerData)) && (q.MaxAttemps == 0 || data == null || QTools.GetPlayerQuestData(q.Name, Player).Attempts < q.MaxAttemps))
                            {
                                availquests = availquests + q.Name + ", ";
                            }
                        }
                    }
                }

                if (availquests != "Available Quests: ")
                {
                    availquests = availquests.Substring(0, availquests.Length - 2);
                    Player.TSPlayer.SendMessage(availquests, Color.Magenta);
                    Player.TSPlayer.SendMessage("Use /startquest [Quest Name], to begin that quest", Color.Magenta);
                }
                else
                    Player.TSPlayer.SendMessage("No Available Quests", Color.Red);
            }
            else
                Player.TSPlayer.SendMessage("You are not Logged in", Color.Red);
        }
开发者ID:Olink,项目名称:Twitchys-Quest-Mod,代码行数:35,代码来源:QCommands.cs

示例4: addCloud

        public static void addCloud()
        {
            int num = -1;
            for (int i = 0; i < 100; i++)
            {
                if (!Main.cloud[i].active)
                {
                    num = i;
                    break;
                }
            }
            if (num >= 0)
            {
                Main.cloud[num].rSpeed = 0f;
                Main.cloud[num].sSpeed = 0f;
                Main.cloud[num].type = Cloud.rand.Next(4);
                Main.cloud[num].scale = (float)Cloud.rand.Next(70, 131) * 0.01f;
                Main.cloud[num].rotation = (float)Cloud.rand.Next(-10, 11) * 0.01f;
                float num2 = Main.windSpeed;
                if (!Main.gameMenu)
                {
                    num2 = Main.windSpeed - Main.player[Main.myPlayer].velocity.X * 0.1f;
                }
                if (num2 > 0f)
                {

                }
                else
                {

                }
                Main.cloud[num].position.Y = (float)Cloud.rand.Next((int)((float)(-(float)Main.screenHeight) * 0.25f), (int)((float)Main.screenHeight * 0.25f));
                Cloud expr_210_cp_0 = Main.cloud[num];
                expr_210_cp_0.position.Y = expr_210_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.15f));
                Cloud expr_240_cp_0 = Main.cloud[num];
                expr_240_cp_0.position.Y = expr_240_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.15f));
                if ((double)Main.cloud[num].scale > 1.3)
                {
                    Main.cloud[num].scale = 1.3f;
                }
                if ((double)Main.cloud[num].scale < 0.7)
                {
                    Main.cloud[num].scale = 0.7f;
                }
                Main.cloud[num].active = true;
                Rectangle rectangle = new Rectangle((int)Main.cloud[num].position.X, (int)Main.cloud[num].position.Y, Main.cloud[num].width, Main.cloud[num].height);
                for (int j = 0; j < 100; j++)
                {
                    if (num != j && Main.cloud[j].active)
                    {
                        Rectangle value = new Rectangle((int)Main.cloud[j].position.X, (int)Main.cloud[j].position.Y, Main.cloud[j].width, Main.cloud[j].height);
                        if (rectangle.Intersects(value))
                        {
                            Main.cloud[num].active = false;
                        }
                    }
                }
            }
        }
开发者ID:RogerPaladin,项目名称:TerrariaAPI-Server,代码行数:59,代码来源:Cloud.cs

示例5: addCloud

 public static void addCloud()
 {
     int num = -1;
     for (int i = 0; i < 100; i++)
     {
         if (!Main.cloud[i].active)
         {
             num = i;
             break;
         }
     }
     if (num >= 0)
     {
         Main.cloud[num].rSpeed = 0f;
         Main.cloud[num].sSpeed = 0f;
         Main.cloud[num].type = Cloud.rand.Next(4);
         Main.cloud[num].scale = (float)Cloud.rand.Next(8, 13) * 0.1f;
         Main.cloud[num].rotation = (float)Cloud.rand.Next(-10, 11) * 0.01f;
         Main.cloud[num].width = (int)((float)Main.cloudTexture[Main.cloud[num].type].Width * Main.cloud[num].scale);
         Main.cloud[num].height = (int)((float)Main.cloudTexture[Main.cloud[num].type].Height * Main.cloud[num].scale);
         if (Main.windSpeed > 0f)
         {
             Main.cloud[num].position.X = (float)(-(float)Main.cloud[num].width - Main.cloudTexture[Main.cloud[num].type].Width - Cloud.rand.Next(Main.screenWidth * 2));
         }
         else
         {
             Main.cloud[num].position.X = (float)(Main.screenWidth + Main.cloudTexture[Main.cloud[num].type].Width + Cloud.rand.Next(Main.screenWidth * 2));
         }
         Main.cloud[num].position.Y = (float)Cloud.rand.Next((int)((float)(-(float)Main.screenHeight) * 0.25f), (int)((double)Main.screenHeight * 1.25));
         Cloud expr_207_cp_0 = Main.cloud[num];
         expr_207_cp_0.position.Y = expr_207_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.25f));
         Cloud expr_237_cp_0 = Main.cloud[num];
         expr_237_cp_0.position.Y = expr_237_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.25f));
         Cloud cloud = Main.cloud[num];
         cloud.scale *= 2.2f - (float)((double)(Main.cloud[num].position.Y + (float)Main.screenHeight * 0.25f) / ((double)Main.screenHeight * 1.5) + 0.699999988079071);
         if ((double)Main.cloud[num].scale > 1.4)
         {
             Main.cloud[num].scale = 1.4f;
         }
         if ((double)Main.cloud[num].scale < 0.6)
         {
             Main.cloud[num].scale = 0.6f;
         }
         Main.cloud[num].active = true;
         Rectangle rectangle = new Rectangle((int)Main.cloud[num].position.X, (int)Main.cloud[num].position.Y, Main.cloud[num].width, Main.cloud[num].height);
         for (int i = 0; i < 100; i++)
         {
             if (num != i && Main.cloud[i].active)
             {
                 Rectangle value = new Rectangle((int)Main.cloud[i].position.X, (int)Main.cloud[i].position.Y, Main.cloud[i].width, Main.cloud[i].height);
                 if (rectangle.Intersects(value))
                 {
                     Main.cloud[num].active = false;
                 }
             }
         }
     }
 }
开发者ID:pandabear41,项目名称:tLinux,代码行数:58,代码来源:Cloud.cs

示例6: TestIntersectPacked

    public static void TestIntersectPacked () {
        Results.Clear();
        var testRect = new Rectangle(16, 16, 32, 32);

        for (var i = 0; i < BufferSize; i++) {
            if (testRect.Intersects(ref PackedRectangles[i]))
                Results.Add(i);
        }
    }
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:9,代码来源:RectangleIntersects.cs

示例7: CheckCollisions

    /// <summary>Check and handle the collisions.</summary>
    public void CheckCollisions()
    {
        TileField tiles = GameWorld.Find("tiles") as TileField;
        int x_floor = (int)position.X / tiles.CellWidth;
        int y_floor = (int)position.Y / tiles.CellHeight;

        // tile collisions
        for (int y = y_floor - 2; y <= y_floor + 1; ++y)
            for (int x = x_floor - 1; x <= x_floor + 1; ++x)
            {
                if (y < 0 || y >= tiles.Rows || x < 0 || x >= tiles.Columns)
                    continue;

                TileType tileType = tiles.GetTileType(x, y);
                if (tileType == TileType.Normal || tileType == TileType.Platform)
                {
                    Rectangle tileBounds = new Rectangle(x * tiles.CellWidth, y * tiles.CellHeight,
                                                            tiles.CellWidth, tiles.CellHeight);
                    if (tileBounds.Intersects(BoundingBox))
                    {
                        Reset();
                        return;
                    }
                }
            }

        Player player = GameWorld.Find("player") as Player;

        // projectile collisions
        foreach (Projectile projectile in player.Projectiles)
            if (BoundingBox.Intersects(projectile.BoundingBox) && projectile.Active)
            {
                projectile.Hit = true;
                hp--;
                if (hp <= 0)
                {
                    Reset();
                    return;
                }
            }

        // player collision
        if (CollidesWith(player))
        {
            Vector2 depth = Collision.CalculateIntersectionDepth(BoundingBox, player.BoundingBox);
            if (player.BoundingBox.Y < BoundingBox.Y && player.Velocity.Y > 0 &&  depth.X > depth.Y )
            { velocity.Y = 600; player.Jump(); }
            else
            {
                player.LowerHP(50);
                Reset();
            }
        }
    }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:55,代码来源:Rocket.cs

示例8: HandleCollisions

    /// <summary>Handle the player collisions.</summary>
    private void HandleCollisions()
    {
        isOnTheGround = false;
        walkingOnIce = false;
        walkingOnHot = false;

        TileField tiles = GameWorld.Find("tiles") as TileField;
        int x_floor = (int)position.X / tiles.CellWidth;
        int y_floor = (int)position.Y / tiles.CellHeight;

        for (int y = y_floor - 2; y <= y_floor + 1; ++y)
            for (int x = x_floor - 1; x <= x_floor + 1; ++x)
            {
                TileType tileType = tiles.GetTileType(x, y);
                if (tileType == TileType.Background)
                    continue;
                // solid tile
                Tile currentTile = tiles.Get(x, y) as Tile;
                Rectangle tileBounds = new Rectangle(x * tiles.CellWidth, y * tiles.CellHeight,
                                                        tiles.CellWidth, tiles.CellHeight);
                Rectangle boundingBox = BoundingBox;
                boundingBox.Height += 1;
                if (((currentTile != null && !currentTile.CollidesWith(this)) || currentTile == null) && !tileBounds.Intersects(boundingBox))
                    continue;
                // colliding
                Vector2 depth = Collision.CalculateIntersectionDepth(boundingBox, tileBounds);
                if (Math.Abs(depth.X) < Math.Abs(depth.Y))
                {
                    if (tileType == TileType.Normal)
                        position.X += depth.X;
                    continue;
                }
                if (previousYPosition <= tileBounds.Top && tileType != TileType.Background)
                {
                    if (velocity.Y > 1250) // fall damage
                        LowerHP(((int)velocity.Y - 1250) / 100);
                    isOnTheGround = true;
                    velocity.Y = 0;
                    if (currentTile != null) // update status effects
                    {
                        walkingOnIce = currentTile.Ice;
                        walkingOnHot = currentTile.Hot;
                    }
                }
                if (tileType == TileType.Normal || isOnTheGround)
                    position.Y += depth.Y + 1; // make sure we stand on top of the tile
            }
        position = new Vector2((int)position.X, (int)position.Y);
        previousYPosition = position.Y;
    }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:51,代码来源:PlayerPhysics.cs

示例9: HandleCollisions

    //Kijkt waarmee de speler allemaal in contact is (de grond)
    private void HandleCollisions()
    {
        isOnTheGround = false;
        walkingOnIce = false;
        walkingOnHot = false;

        TileField tiles = GameWorld.Find("tiles") as TileField;
        int x_floor = (int)position.X / tiles.CellWidth;
        int y_floor = (int)position.Y / tiles.CellHeight;

        for (int y = y_floor - 2; y <= y_floor + 1; ++y)
            for (int x = x_floor - 1; x <= x_floor + 1; ++x)
            {
                TileType tileType = tiles.GetTileType(x, y);
                if (tileType == TileType.Background)
                    continue;
                Tile currentTile = tiles.Get(x, y) as Tile;
                Rectangle tileBounds = new Rectangle(x * tiles.CellWidth, y * tiles.CellHeight,
                                                        tiles.CellWidth, tiles.CellHeight);
                Rectangle boundingBox = this.BoundingBox;
                boundingBox.Height += 1;
                if (((currentTile != null && !currentTile.CollidesWith(this)) || currentTile == null) && !tileBounds.Intersects(boundingBox))
                    continue;
                if (currentTile != null)
                    if (currentTile.Lever && !currentTile.Visible)
                        continue;
                Vector2 depth = Collision.CalculateIntersectionDepth(boundingBox, tileBounds);
                if (Math.Abs(depth.X) < Math.Abs(depth.Y))
                {
                    if (tileType == TileType.Normal)
                        position.X += depth.X;
                    continue;
                }
                if (previousYPosition <= tileBounds.Top && tileType != TileType.Background)
                {
                    isOnTheGround = true;
                    velocity.Y = 0;
                    if (currentTile != null)
                    {
                        walkingOnIce = walkingOnIce || currentTile.Ice;
                        walkingOnHot = walkingOnHot || currentTile.Hot;
                    }
                }
                if (tileType == TileType.Normal || isOnTheGround)
                    position.Y += depth.Y + 1;
            }
        position = new Vector2((float)Math.Floor(position.X), (float)Math.Floor(position.Y));
        previousYPosition = position.Y;
    }
开发者ID:TheHappyCow,项目名称:TickTick,代码行数:50,代码来源:PlayerPhysics.cs

示例10: Update

    public override void Update(GameTime gameTime)
    {
        this.velocity.X = 600;
            Rocket rocket = GameWorld.Find("rocket") as Rocket;

            if (this.CollidesWith(rocket) && this.Visible)
                rocket.Reset();
            Rectangle screenBox = new Rectangle(0, 0, GameEnvironment.Screen.X, GameEnvironment.Screen.Y);
            if (!screenBox.Intersects(this.BoundingBox))
            this.Reset();
            if (can_shoot > 0)
            {
                can_shoot -= gameTime.ElapsedGameTime.TotalSeconds;
                return;
            }
    }
开发者ID:FranssZ,项目名称:TickTick_Roel_Frans,代码行数:16,代码来源:Bullet.cs

示例11: Update

 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     if (spawnTime > 0)
     {
         spawnTime -= gameTime.ElapsedGameTime.TotalSeconds;
         return;
     }
     this.Visible = true;
     this.velocity.X = 600;
     if (Mirror)
         this.velocity.X *= -1f;
     CheckPlayerCollision();
     // check if we are outside the screen
     Rectangle screenBox = new Rectangle(0, 0, GameEnvironment.Screen.X, GameEnvironment.Screen.Y);
     if (!screenBox.Intersects(this.BoundingBox))
         this.Reset();
 }
开发者ID:MiloBuwalda,项目名称:ticktack,代码行数:18,代码来源:Rocket.cs

示例12: Update

    /// <summary>Update the rocket.</summary>
    public override void Update(GameTime gameTime)
    {
        base.Update(gameTime);
        if (spawnTime > 0)
        {
            spawnTime -= gameTime.ElapsedGameTime.TotalSeconds;
            return;
        }
        Visible = true;
        velocity.X = Mirror ? -600 : 600;
        CheckCollisions();

        // check if we are outside the level
        Level level = parent.Parent as Level; // level > enemies > rocket
        Rectangle levelBox = new Rectangle(0, 0, level.Width, level.Height);
        if (!levelBox.Intersects(BoundingBox))
            Reset();
    }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:19,代码来源:Rocket.cs

示例13: Update

    /// <summary>Update the projectile.</summary>
    /// <param name="tiles">The field of the level.</param>
    public void Update(GameTime gameTime, TileField tiles)
    {
        if (!active)
            return;
        base.Update(gameTime);

        // check bounds 
        int x_floor = (int)position.X / tiles.CellWidth;
        int y_floor = (int)position.Y / tiles.CellHeight;
        for (int y = y_floor - 1; y <= y_floor + 1; y++)
            for (int x = x_floor - (mirrored ? 1 : 0); x <= x_floor + (mirrored ? 0 : 1); x++)
            {
                TileType tileType = tiles.GetTileType(x, y);
                if (tileType == TileType.Normal || tileType == TileType.Platform)
                {
                    Rectangle tileBounds = new Rectangle(x * tiles.CellWidth, y * tiles.CellHeight,
                                                            tiles.CellWidth, tiles.CellHeight);
                    if (tileBounds.Intersects(BoundingBox))
                    { hit = true; }
                }
            }
        if (hit)
            active = false;
    }
开发者ID:alikimoko,项目名称:Practicum3.Platformer,代码行数:26,代码来源:Projectile.cs

示例14: AI


//.........这里部分代码省略.........
                if (!flag33)
                {
                    for (int num347 = num343; num347 < num344; num347++)
                    {
                        for (int num348 = num345; num348 < num346; num348++)
                        {
                            if (Main.tile[num347, num348] != null && ((Main.tile[num347, num348].nactive() && (Main.tileSolid[(int)Main.tile[num347, num348].type] || (Main.tileSolidTop[(int)Main.tile[num347, num348].type] && Main.tile[num347, num348].frameY == 0))) || Main.tile[num347, num348].liquid > 64))
                            {
                                Vector2 vector37;
                                vector37.X = (float)(num347 * 16);
                                vector37.Y = (float)(num348 * 16);
                                if (this.position.X + (float)this.width > vector37.X && this.position.X < vector37.X + 16f && this.position.Y + (float)this.height > vector37.Y && this.position.Y < vector37.Y + 16f)
                                {
                                    flag33 = true;
                                    if (Main.rand.Next(100) == 0 && this.type != NPCID.LeechHead && Main.tile[num347, num348].nactive())
                                    {
                                        WorldGen.KillTile(num347, num348, true, true, false);
                                    }
                                }
                            }
                        }
                    }
                }
                if (!flag33 && (this.type == NPCID.DevourerHead || this.type == NPCID.GiantWormHead || this.type == NPCID.EaterofWorldsHead || this.type == NPCID.BoneSerpentHead || this.type == NPCID.DiggerHead || this.type == NPCID.SeekerHead || this.type == NPCID.LeechHead || this.type == NPCID.TruffleWormDigger || this.type == NPCID.CultistDragonHead || this.type == NPCID.DuneSplicerHead || this.type == NPCID.TombCrawlerHead))
                {
                    Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, this.width, this.height);
                    int num349 = 1000;
                    bool flag34 = true;
                    for (int num350 = 0; num350 < 255; num350++)
                    {
                        if (Main.player[num350].active)
                        {
                            Rectangle rectangle2 = new Rectangle((int)Main.player[num350].position.X - num349, (int)Main.player[num350].position.Y - num349, num349 * 2, num349 * 2);
                            if (rectangle.Intersects(rectangle2))
                            {
                                flag34 = false;
                                break;
                            }
                        }
                    }
                    if (flag34)
                    {
                        flag33 = true;
                    }
                }
                if ((this.type >= NPCID.WyvernHead && this.type <= NPCID.WyvernTail) || (this.type >= NPCID.CultistDragonHead && this.type <= NPCID.CultistDragonTail))
                {
                    if (this.velocity.X < 0f)
                    {
                        this.spriteDirection = 1;
                    }
                    else if (this.velocity.X > 0f)
                    {
                        this.spriteDirection = -1;
                    }
                }
                if (this.type == NPCID.SolarCrawltipedeTail)
                {
                    if (this.justHit)
                    {
                        this.localAI[3] = 3f;
                    }
                    if (this.localAI[2] > 0f)
                    {
                        this.localAI[2] -= 16f;
                        if (this.localAI[2] == 0f)
开发者ID:hastinbe,项目名称:TerrariaAPI-Server,代码行数:67,代码来源:NPC.cs

示例15: ItemCheck


//.........这里部分代码省略.........
                                }
                                rectangle.Width = (int)((double)rectangle.Width * 1.4);
                                rectangle.Y += (int)((double)rectangle.Height * 0.6);
                                rectangle.Height = (int)((double)rectangle.Height * 0.6);
                            }
                        }
                    }
                    if (!flag5)
                    {
            #if CLIENT_CODE
                        if (Main.myPlayer == i)
                        {
                            int dmgg = (int) (selectedItem.Damage * this.meleeDamage);
                            int num21 = rectangle.X / 16;
                            int num22 = (rectangle.X + rectangle.Width) / 16 + 1;
                            int num23 = rectangle.Y / 16;
                            int num24 = (rectangle.Y + rectangle.Height) / 16 + 1;
                            for (int k = num21; k < num22; k++)
                            {
                                for (int l = num23; l < num24; l++)
                                {
                                    if (Main.tile.At(k, l).Type == 3 || Main.tile.At(k, l).Type == 24 || Main.tile.At(k, l).Type == 28 || Main.tile.At(k, l).Type == 32 || Main.tile.At(k, l).Type == 51 || Main.tile.At(k, l).Type == 52 || Main.tile.At(k, l).Type == 61 || Main.tile.At(k, l).Type == 62 || Main.tile.At(k, l).Type == 69 || Main.tile.At(k, l).Type == 71 || Main.tile.At(k, l).Type == 73 || Main.tile.At(k, l).Type == 74)
                                    {
                                        WorldModify.KillTile(k, l, false, false, false);
                                    }
                                }
                            }
                            for (int j = 0; j < NPC.MAX_NPCS; j++)
                            {
                                var npc = Main.npcs[j];
                                if (npc.Active && npc.immune[i] == 0 && this.attackCD == 0 && !npc.friendly)
                                {
                                    Rectangle value = new Rectangle((int)npc.Position.X, (int)npc.Position.Y, npc.Width, npc.Height);
                                    if (rectangle.Intersects(value))
                                    {
                                        if (npc.noTileCollide || Collision.CanHit(this.Position, this.Width, this.Height, npc.Position, npc.Width, npc.Height))
                                        {
                                            bool crit = false;
                                            if (Main.rand.Next(1, 101) <= this.meleeCrit)
                                            {
                                                crit = true;
                                            }
                                            int dmggg = Main.DamageVar(dmgg);
                                            this.StatusNPC (selectedItem.Type, npc);
                                            npc.StrikeNPC (dmggg, selectedItem.KnockBack, this.direction, crit);
                                            npc.immune[i] = (ushort) this.itemAnimation;
                                            this.attackCD = (int)((double)this.itemAnimationMax * 0.33);
                                        }
                                    }
                                }
                            }
                            if (this.hostile)
                            {
                                for (int j = 0; j < 255; j++)
                                {
                                    var player = Main.players[j];
                                    if (j != i && player.Active && player.hostile && !player.immune && !player.dead)
                                    {
                                        if (this.team == 0 || this.team != player.team)
                                        {
                                            Rectangle value2 = new Rectangle((int)player.Position.X, (int)player.Position.Y, player.Width, player.Height);
                                            if (rectangle.Intersects(value2))
                                            {
                                                bool crit = false;
                                                if (Main.rand.Next(1, 101) <= 10)
                                                {
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:67,代码来源:Player.cs


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