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


C# Geom.Dispose方法代码示例

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


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

示例1: OnCollision

        public bool OnCollision(Geom g1, Geom g2, ContactList contactList)
        {
            Sprite s1 = (Sprite)g1.Tag;
            Sprite s2 = (Sprite)g2.Tag;

            if (g1.Tag.GetType() == typeof(Player) && (g2.Tag.GetType() == typeof(Sprite) || g2.Tag.GetType() == typeof(QuarkPlatform)))
            {
                foreach (MovingPlatform m in movingPlatforms)
                {                                 //this is to detatch the player if he crashes into a tile
                    if (m.attachedPlayer != null)
                    {
                        m.dettachPlayer();
                        playerSprite.CanJump = true;

                    }
                }
            }
            if (g2.Tag.GetType() == typeof(Pickup))
            {
                s2.Body.Dispose();
                g2.Dispose();               //pickup should be destroyed disapear and increase energy
                quarkEnergy = gameParam.PickupEnergy + quarkEnergy;
            }

            if (g2.Tag.GetType() == typeof(MovingPlatform))
            {
               //attaches player to platform via a join to stop player sliding
               MovingPlatform platform = (MovingPlatform)s2;
               platform.attachPlayer(playerSprite);
            }

            if (g2.Tag.GetType() == typeof(BouncyTile))
            {
                Cue cue = soundBank.GetCue("Bouncing platform"); //sound should play when player bounces
                cue.Play();

                int maxBounceHeight = 10000; //so if the player lands on multiple bounce tiles at once,
                                             //the force doesnt accumulate

                //code below to set bounce height

                if (playerSprite.Body.LinearVelocity.Y < 0)
                {
                    playerSprite.Body.ApplyImpulse(new Vector2(0, maxBounceHeight));
                }

                if (playerSprite.Body.LinearVelocity.Y > 0)
                {
                    playerSprite.Body.ApplyImpulse(new Vector2(0, -maxBounceHeight));
                }

                playerSprite.Body.LinearVelocity.Y = 0; // this line is incase the sprite hits more than one tile
            }

            if (g1.Tag.GetType() == typeof(Player) && (g2.Tag.GetType() == typeof(Sprite) || g2.Tag.GetType() == typeof(QuarkPlatform) || g2.Tag.GetType() == typeof(MovingPlatform)))
            {
                TicksCollision = Ticks;
                playerSprite.CanJump = true;

            }

            //collision for teleport
            if (g2.Tag.GetType() == typeof(Teleport))
            {
                Cue cue = soundBank.GetCue("Teleport");
                cue.Play();

                if (HasTeleport == true)
                {
                    //transport player to other portal
                    playerSprite.Body.Position = place.Position;
                    HasTeleport = false;
                }

                return false;
            }
            return true;
        }
开发者ID:ninetailsdev,项目名称:Quark,代码行数:78,代码来源:GameplayScreen.cs


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