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


C# FarseerPhysics.IsTouching方法代码示例

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


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

示例1: die

 public bool die(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
 {
     if (fixtureA.Body.Equals(this._body) || fixtureB.Body.Equals(this._body)
         && contact.IsTouching())
     {
         health -= 10;
         if (this.health <= 0)
         {
             float x = _body.LinearVelocity.X;
             float y = _body.LinearVelocity.Y * 1.7f;
             _body.Inertia = 0f;
             _body.AngularVelocity = 0f;
             _body.ApplyLinearImpulse(new Vector2(-x, -y));
             _body.CollisionCategories = Category.None;
             this.health = 0;
             GameplayScreen.getInstance().showRetryScreen();
         }
         return false;
     }
     else return false;
 }
开发者ID:res09ggm,项目名称:ucimobile,代码行数:21,代码来源:Player.cs

示例2: HandleContact

        /// <summary>
        /// Handle contact interactions.
        /// </summary>
        /// <param name="contact">Contact point.</param>
        private void HandleContact(Physics.Dynamics.Contacts.Contact contact)
        {
            if (!contact.IsTouching()) return;

            // Get Entities from both shapes.
            Entity entA = (Entity) contact.FixtureA.Body.UserData;
            Entity entB = (Entity) contact.FixtureB.Body.UserData;

            entA.OnCollide(entB, contact);
            entB.OnCollide(entA, contact);
        }
开发者ID:jwmcglynn,项目名称:TeamQ,代码行数:15,代码来源:GameEnvironment.cs

示例3: take10Damage

        public bool take10Damage(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (contact.IsTouching() && (fixtureA.Body == _body || fixtureB.Body == _body))
            {
                //only take away 10 hitpoints for every 1 second fixtures are touching.
                health -= 5;
                _body.Inertia = 0f;
                _body.Rotation = 0f;
                _body.AngularVelocity = 0f;
                _body.LinearVelocity = new Vector2(0f, _body.LinearVelocity.Y);
                _body.ApplyLinearImpulse(new Vector2(-5f, 0f));

            }
            // Always touch
            return true;
        }
开发者ID:res09ggm,项目名称:ucimobile,代码行数:16,代码来源:Player.cs

示例4: PickupsForPlayer

        public bool PickupsForPlayer(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (contact.IsTouching())
            {
                try
                {

                    if ((fixtureA.UserData.ToString() == "athyl" && fixtureB.UserData.ToString() == "player") ||
                        (fixtureA.UserData.ToString() == "athyl" && fixtureB.UserData.ToString() == "playerwheel"))
                    {
                        playerz.playerAthyl += 50;
                        ethanolDrop = true;
                        return true;
                    }

                    else if ((fixtureA.UserData.ToString() == "hpBox" && fixtureB.UserData.ToString() == "player") ||
                        (fixtureA.UserData.ToString() == "hpBox" && fixtureB.UserData.ToString() == "playerwheel"))
                    {
                        playerz.playerHP += 35;
                        hpDrop = true;
                        return true;
                    }

                    else
                    {
                        ethanolDrop = false;
                        hpDrop = false;
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message + "  " + ex.TargetSite + "  " + ex.StackTrace);
                }
            }
            return false;
        }
开发者ID:settrbrg,项目名称:ethanolpunk,代码行数:36,代码来源:drops.cs

示例5: body_OnCollision

        /// <summary>
        /// Kollision med kulor, tar bort något träffas
        /// olika logik beroende på om det är fiende eller spelare som krockar
        /// </summary>
        /// <param name="fixtureA"></param>
        /// <param name="fixtureB"></param>
        /// <param name="contact"></param>
        /// <returns></returns>
        bool body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (contact.IsTouching())
            {
                try
                {
                    if (fixtureA.UserData.ToString() == "shot" && fixtureB.UserData.ToString() == "enemy" ||
                        fixtureA.UserData.ToString() == "shot" && fixtureB.UserData.ToString() == "boss" ||
                        fixtureA.UserData.ToString() == "shot" && fixtureB.UserData.ToString() == "enemywheel" ||
                        fixtureA.UserData.ToString() == "shot" && fixtureB.UserData.ToString() == "bosswheel")
                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
                            {
                                if (!removeList.Contains(i))
                                    removeList.Add(i);
                                game.damageList.Add(new Damage(fixtureB.Body.BodyId, i.Damage));
                            }
                        }
                        return true;
                    }

                    else if (fixtureA.UserData.ToString() == "melee" && fixtureB.UserData.ToString() == "enemy" ||
                        fixtureA.UserData.ToString() == "melee" && fixtureB.UserData.ToString() == "boss" ||
                        fixtureA.UserData.ToString() == "melee" && fixtureB.UserData.ToString() == "enemywheel" ||
                        fixtureA.UserData.ToString() == "melee" && fixtureB.UserData.ToString() == "bosswheel")
                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
                            {
                                if (!removeList.Contains(i))
                                    removeList.Add(i);
                            }
                            game.damageList.Add(new Damage(fixtureB.Body.BodyId, i.Damage));
                        }

                        return true;
                    }

                    else if (fixtureA.UserData.ToString() == "fire" && fixtureB.UserData.ToString() == "enemy" ||
                    fixtureA.UserData.ToString() == "fire" && fixtureB.UserData.ToString() == "boss" ||
                        fixtureA.UserData.ToString() == "fire" && fixtureB.UserData.ToString() == "enemywheel" ||
                        fixtureA.UserData.ToString() == "fire" && fixtureB.UserData.ToString() == "bosswheel")
                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
                            {
                                if (!removeList.Contains(i))
                                    removeList.Add(i);
                                game.damageList.Add(new Damage(fixtureB.Body.BodyId, i.Damage));
                            }
                        }

                        return true;
                    }

                    else if ((fixtureA.UserData.ToString() == "hostile" && fixtureB.UserData.ToString() == "player") ||(fixtureA.UserData.ToString() == "hostile" && fixtureB.UserData.ToString() == "shield"))

                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
                            {
                                if (!removeList.Contains(i))
                                    removeList.Add(i);
                                game.damageList.Add(new Damage(fixtureB.Body.BodyId, i.Damage, player.skillTree.playerDmg));
                            }
                        }
                        return true;
                    }

                    else if (fixtureA.UserData.ToString() == "shot" && fixtureB.UserData.ToString() == "ground")
                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
                            {
                                if (!removeList.Contains(i))
                                    removeList.Add(i);
                            }
                        }
                        return true;
                    }

                    else if (fixtureA.UserData.ToString() == "fire" && fixtureB.UserData.ToString() == "ground")
                    {
                        foreach (Bullet i in newbullets)
                        {
                            if (i.Obj.body.BodyId == fixtureA.Body.BodyId)
//.........这里部分代码省略.........
开发者ID:settrbrg,项目名称:ethanolpunk,代码行数:101,代码来源:Projectile.cs

示例6: makeShieldStatic

        public bool makeShieldStatic(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            if (contact.IsTouching())
            {
                if ((fixtureA.UserData.ToString() == "shield" && fixtureB.UserData.ToString() == "ground"))
                {
                    JointFactory.CreateFixedDistanceJoint(world, shieldGfx.body, ConvertUnits.ToSimUnits(Vector2.Zero), ConvertUnits.ToSimUnits(shieldGfx.Position));
                }

                if ((fixtureA.UserData.ToString() == "shield" && fixtureB.UserData.ToString() == "hostile") || (fixtureA.UserData.ToString() == "hostile" && fixtureB.UserData.ToString() == "shield"))
                {
                    shieldHP -= 10;
                    Console.WriteLine(shieldHP);
                }

                return true;
            }

            return false;
        }
开发者ID:settrbrg,项目名称:ethanolpunk,代码行数:20,代码来源:ActiveSkills.cs

示例7: PreSolve

        /// <summary>
        /// Farseer Physics callback.  Handles the case where two objects collide.
        /// </summary>
        /// <param name="contact">Contact point.</param>
        /// <param name="oldManifold">Manifold from last update.</param>
        protected void PreSolve(Physics.Dynamics.Contacts.Contact contact, ref Physics.Collision.Manifold oldManifold)
        {
            if (!contact.IsTouching()) return;

            // Attempt to get Entities from both shapes.
            Entity entA = (Entity) contact.FixtureA.Body.UserData;
            Entity entB = (Entity) contact.FixtureB.Body.UserData;

            // Determine if shapes agree to collide.
            bool shouldCollide = entA.ShouldCollide(entB);
            shouldCollide &= entB.ShouldCollide(entA);

            contact.Enabled = shouldCollide;

            if (shouldCollide && contact.IsTouching()) {
                entA.OnCollide(entB, contact);
                entB.OnCollide(entA, contact);
            }
        }
开发者ID:Projektsnake,项目名称:TeamQ,代码行数:24,代码来源:GameEnvironment.cs


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