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


C# Sprite.GetY方法代码示例

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


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

示例1: HandleCollision

            /// <summary>
            /// Collision handling for each sprite on the screen.
            /// </summary>
            /// <param name="sprite">Sprite to check collision with.</param>
            private void HandleCollision(Sprite sprite)
            {
            Rectangle itemBounds = new Rectangle(sprite.GetX(), sprite.GetY(), sprite.GetWidth(), sprite.GetHeight());
            String name = sprite.GetName();
            if (IntersectPixels(playerBounds, playerData, itemBounds, sprite.GetColorData()))
            {
                if (!sprite.GetTransparent())
                {
                    if (name.Equals("level1") || name.Equals("level2") || name.Equals("level3"))
                    {
                        if (IsAbove(playerBounds, itemBounds) && ((player.CheckJump() && sprite.GetY() == 399) || (jumping && sprite.GetY() == 499)))
                            sprite.KillVirus();
                        else
                        {
                            if (Constants.isSwappingHand && player.HasSword() && sprite.GetY() == 399)
                            {
                                swordUsed=true;
                                sprite.SlashVirus();
                            }
                            else
                            {
                                if (!Constants.isPunching)
                                    sprite.HitVirus();
                            }
                        }

                    }

                    ApplyEffect(name, sprite);
                    PlaySoundEffects(name, sprite);

                    if (!name.Equals("gym") && !name.Contains("boss"))
                        sprite.Collide(name);
                    else
                    {
                        if (Constants.isSteppingRight)
                        {
                            screenPaused = true;
                            ScreenManager.AddScreen(new ExcercisesScreen(this));
                            this.FreezeScreen();
                        }
                    }

                    if (name.Contains("boss"))
                    {
                        if (playerBounds.Right >= sprite.GetX() + 150)
                        {
                            //Add Boss Screen
                            screenPaused = true;
                            spriteCounter = 0;
                            currentSprite.Clear();
                            globalCounter = 600;
                            this.FreezeScreen();
                            currentSprite.Remove(sprite);
                            ScreenManager.AddScreen(new BossFightScreen(this, Int32.Parse((name.Substring(4)))));
                        }
                    }
                }
            }
            }
开发者ID:TheCoderPal,项目名称:terasoft-summer-reunited,代码行数:64,代码来源:PlayScreen.cs

示例2: PlaySoundEffects

 /// <summary>
 /// Plays the sound effect when colliding with a sprite.
 /// </summary>
 /// <param name="name">Sprite's name</param>
 /// <param name="sprite">Instance of the sprite</param>
 private void PlaySoundEffects(String name, Sprite sprite)
 {
 if (!sprite.GetCollided())
 {
     switch (name)
     {
         case "tomato":
         case "carrot":
         case "strawberry":
         case "orange":
         case "pineapple":
         case "broccoli":
         case "fries":
         case "hamburger":
         case "pizza":
         case "donut":
         case "muffin":
         case "hotdog": sprite.PlaySoundEffect(soundEffects[1]); break;
         case "level1":
         case "level2":
         case "level3":
             if (sprite.IsSlashed())
                 sprite.PlaySoundEffect(soundEffects[6]);
             else
             {
                 if (sprite.GetKilled())
                     sprite.PlaySoundEffect(soundEffects[8]);
                 else
                 {
                     if (sprite.IsHit())
                         sprite.PlaySoundEffect(soundEffects[5]);
                     else
                     {
                         if (Constants.isPunching && sprite.GetY() == 399)
                             sprite.PlaySoundEffect(soundEffects[7]);
                         else
                             sprite.PlaySoundEffect(soundEffects[5]);
                     }
                 }
             }
             break;
         case "sheild": sprite.PlaySoundEffect(soundEffects[2]); break;
         case "sword": sprite.PlaySoundEffect(soundEffects[3]); break;
     }
 }
 }
开发者ID:TheCoderPal,项目名称:terasoft-summer-reunited,代码行数:51,代码来源:PlayScreen.cs

示例3: ApplyEffect

            /// <summary>
            /// Applies the effect of collision on sprite and player.
            /// </summary>
            /// <param name="name">Sprite name.</param>
            /// <param name="sprite">Instance of the sprite.</param>
            private void ApplyEffect(String name, Sprite sprite)
            {
            if (!sprite.GetCollided())
            {
                switch (name)
                {
                    case "tomato": player.Collided(Constants.healthy1); break;
                    case "carrot": player.Collided(Constants.healthy2); break;
                    case "strawberry": player.Collided(Constants.healthy3); break;
                    case "orange": player.Collided(Constants.healthy4); break;
                    case "pineapple": player.Collided(Constants.healthy5); break;
                    case "broccoli": player.Collided(Constants.healthy6); break;
                    case "fries": player.Collided(Constants.unhealthy1); break;
                    case "hamburger": player.Collided(Constants.unhealthy2); break;
                    case "pizza": player.Collided(Constants.unhealthy3); break;
                    case "donut": player.Collided(Constants.unhealthy4); break;
                    case "muffin": player.Collided(Constants.unhealthy5); break;
                    case "hotdog": player.Collided(Constants.unhealthy6); break;
                    case "level1":
                        if (!sprite.GetKilled())
                        {
                            if (!player.HasShield())
                            {
                                if (!player.HasSword() || !Constants.isSwappingHand)
                                {
                                    if (!Constants.isPunching)
                                        player.Collided(Constants.level1);
                                    else
                                    {
                                        if (sprite.GetY() != 399)
                                            player.Collided(Constants.level1);
                                    }
                                }
                                else
                                {
                                    if (sprite.GetY() != 399)
                                        player.Collided(Constants.level1);
                                }
                            }
                            else
                                player.AcquireShield(false);

                        }
                        break;
                    case "level2":
                        if (!sprite.GetKilled())
                        {
                            if (!player.HasShield())
                            {
                                if (!player.HasSword() || !Constants.isSwappingHand)
                                {
                                    if (!Constants.isPunching)
                                        player.Collided(Constants.level2);
                                    else
                                    {
                                        if (sprite.GetY() == 399)
                                            player.Collided((int)(Constants.level2 / 2));
                                        else
                                            player.Collided(Constants.level2);
                                    }
                                }
                                else
                                {
                                    if (sprite.GetY() != 399)
                                        player.Collided(Constants.level2);
                                }
                            }
                            else
                                player.AcquireShield(false);
                        }
                        break;
                    case "level3":
                        if (!sprite.GetKilled())
                        {
                            if (!player.HasShield())
                            {
                                if (!player.HasSword() || !Constants.isSwappingHand)
                                {
                                    if (!Constants.isPunching)
                                        player.Collided(Constants.level3);
                                    else
                                    {
                                        if (sprite.GetY() == 399)
                                            player.Collided((int)(Constants.level3 / 4));
                                        else
                                            player.Collided(Constants.level3);
                                    }
                                }
                                else
                                {
                                    if (sprite.GetY() == 399)
                                        player.Collided((int)(Constants.level3 / 2));
                                    else
                                        player.Collided(Constants.level3);
                                }
//.........这里部分代码省略.........
开发者ID:TheCoderPal,项目名称:terasoft-summer-reunited,代码行数:101,代码来源:PlayScreen.cs


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