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


C# PlayerCharacter.Hit方法代码示例

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


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

示例1: checkSpecialCollisions

        public static void checkSpecialCollisions(PlayerCharacter pc, EBossS1 boss, Rectangle fieldBounds)
        {
            // This is a pretty hackey way to do this and I'll re-write this system in a bit but I'm in a hurry now because it's 2AM on Monday.
            foreach (ExplodingBullet b in boss.getExplodingBullets())
            {
                Rectangle bulletRect = b.getRect();

                // If the bullet is exploded, check the shards.
                if (b.isExploded())
                {
                    foreach (Bullet bullet in b.getShards())
                    {
                        Rectangle shardRect = bullet.getRect();
                        if (shardRect.Intersects(pc.getRect()) && bullet.inPlay && pc.alive && !pc.respawning)
                        {
                            pc.Hit();
                            bullet.inPlay = false;
                        }
                    }
                }
                // Otherwise check the main bullet and not the shards.
                else
                {
                    if (bulletRect.Intersects(pc.getRect()) && b.inPlay && pc.alive && !pc.respawning)
                    {
                        pc.Hit();
                        b.inPlay = false;
                    }
                }
            }
        }
开发者ID:ebshimizu,项目名称:Parchment-Dragon,代码行数:31,代码来源:Collisions.cs

示例2: Main

        static void Main()
        {
            var playerOne = new PlayerCharacter(new DiamondSkinDefense())
            {
                Name = "Jeremy"
            };

            var playerTwo = new PlayerCharacter(new IronBonesDefence()){
                Name = "Jac",
                DateOfBirth =  DateTime.Now,
                DaysSinceLastLogin = 5,
                Health = 100,
                IsNoob = true
            };

            var playerThree = new PlayerCharacter(SpecialDefense.Null)
            {
                Name = "John"
            };

            playerOne.Hit(10);
            playerTwo.Hit(10);
            playerThree.Hit(10);

            PlayerDisplayer.Write(playerOne);
            PlayerDisplayer.Write(playerTwo);
            PlayerDisplayer.Write(playerThree);
        }
开发者ID:Jac21,项目名称:GistsCollection,代码行数:28,代码来源:Program.cs

示例3: updateCollisions

        // Currently implementing basic rectangular collisions. May implement more complex collisions later. Basics first.
        public static void updateCollisions(PlayerCharacter pc, List<Enemy> enemyList, List<Food> foodList, FoodList foods, Rectangle fieldBound)
        {
            // Checks for fireballs hitting enemies.
            foreach (Enemy enemy in enemyList)
            {
                foreach (Bullet bullet in pc.getBullets())
                {
                    Rectangle bulletRect = bullet.getRect();
                    // If the fireball rectangle intersects the enemy rectangle hit the enemy.
                    if(bulletRect.Intersects(enemy.getRect()) &&
                        bullet.inPlay && enemy.alive)
                    {
                        enemy.Hit(pc, foods, foodList);
                        bullet.inPlay = false;
                    }
                }

                foreach (Bullet bullet in enemy.getBullets())
                {
                    Rectangle bulletRect = bullet.getRect();

                    // If an enemy hits the player character while the player is not respawning then you're dead. :(
                    if (bulletRect.Intersects(pc.getRect()) && bullet.inPlay && pc.alive && !pc.respawning)
                    {
                        pc.Hit();
                        bullet.inPlay = false;
                    }
                }

                // Don't run into enemies. You'll die.
                if(enemy.getRect().Intersects(pc.getRect()) && enemy.alive && pc.alive)
                {
                    enemy.Die();
                    pc.Hit();
                    pc.PlayEnemyDeath();
                }
            }

            // Check food collisions.
            foreach (Food food in foodList)
            {
                if (food.getRect().Intersects(pc.getRect()) & (pc.alive | pc.respawning))
                {
                    pc.eatFood(food);
                }
            }
        }
开发者ID:ebshimizu,项目名称:Parchment-Dragon,代码行数:48,代码来源:Collisions.cs


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