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


C# IMap.Collides方法代码示例

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


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

示例1: Update

 public virtual bool Update(IMap map, float seconds)
 {
     if (_info.Physics)
     {
         this.Movement.Y += Player.gravity * seconds;
         Move(new Vector2(0,Movement.Y*seconds));
         if (map.Collides(this))
         {
             Move(new Vector2(0, -Movement.Y*seconds));
             Movement.Y *= -_info.bounceFactor;
             Movement.X *= _info.bounceFactor;
             if (_info.CollisionDespawn)
                 return false;
         }
         Move(new Vector2(Movement.X*seconds, 0));
         if (map.Collides(this))
         {
             Move(new Vector2(-Movement.X*seconds,0));
             Movement.X *= -_info.bounceFactor;
             Movement.Y *= _info.bounceFactor;
             if (_info.CollisionDespawn)
                 return false;
         }
     }
     else
     {
         Move(Movement * seconds);
         if (_info.CollisionDespawn && map.Collides(this))
             return false;
     }
     lifeTime -= seconds;
     _angle = (float)Math.Atan2(Movement.Y, Movement.X);
     return lifeTime>0;
 }
开发者ID:MyEyes,项目名称:Igorr,代码行数:34,代码来源:Attack.cs

示例2: Update

 public void Update(IMap map, float secs)
 {
     if (_info.attractor != null)
     {
         Vector2 diff = (_info.attractor.MidPosition - _position);
         float length = diff.Length();
         _acceleration = diff*_info.attraction / (length);
         if (length < 8)
             _alive = false;
     }
     if (_info.collides)
     {
         _position.Y += _speed.Y * secs;
         if (map.Collides(_position))
         {
             _position.Y -= _speed.Y * secs;
             _speed.Y = -_speed.Y*dampening;
             if (_info.sticky)
                 _stuck = true;
         }
         _position.X += _speed.X * secs;
         if (map.Collides(_position))
         {
             _position.X -= _speed.X * secs;
             _speed.X = -_speed.X*dampening;
             if (_info.sticky)
                 _stuck = true;
         }
     }
     else
     {
         _position += _speed * secs;
     }
     _speed += _acceleration * secs;
     if (_info.maxSpeed > 0)
     {
         float len =_speed.Length();
         if (_speed.Length() > _info.maxSpeed)
             _speed /= len / _info.maxSpeed;
     }
     if (_stuck)
         _speed = Vector2.Zero;
     _lifeTime -= secs;
     _rotation += _rotSpeed * secs;
     if (_lifeTime <= 0)
         _alive = false;
 }
开发者ID:MyEyes,项目名称:Igorr,代码行数:47,代码来源:Particle.cs

示例3: TryMove

        void TryMove(Vector2 movement, IMap map)
        {
            Position += Vector2.UnitX * movement.X;
            if (map.Collides(this))
            {
                if (movement.X > 0)
                {
                    _position.X = (float)(16 * Math.Floor(_position.X / 16.0)+_collisionOffset.X);
                    Position = _position;
                }
                else
                {
                    _position.X = (float)(16 * Math.Ceiling(_position.X / 16.0)+_collisionOffset.Y);
                    Position = _position;
                }
                wallCollision = true;
                _speed.X = 0;
            }

            _onGround = false;
            Position += Vector2.UnitY * movement.Y;
            if (map.Collides(this))
            {
                if (_speed.Y > 0)
                {
                    _onGround = true;
                    _position.Y = (float)(16 * Math.Floor(_position.Y / 16.0)) + _collisionOffset.Z;
                    Position = _position;
                }
                else
                {
                    _position.Y = (float)(16 * Math.Ceiling(_position.Y / 16.0)) + _collisionOffset.W;
                    Position = _position;
                }
                _speed = Vector2.Zero;
            }
            if (!jump && !_onGround)
                flying = true;
        }
开发者ID:MyEyes,项目名称:Igorr,代码行数:39,代码来源:Player.cs

示例4: Update

 public void Update(IMap map, float ms)
 {
     _attacks.AddRange(_addAttack);
     _addAttack.Clear();
     for (int x = 0; x < _attacks.Count; x++)
     {
         _attacks[x].Update(ms);
         if ((!_attacks[x].Penetrates && map.Collides(_attacks[x])) || _attacks[x].lifeTime < 0)
         {
             _attacks.RemoveAt(x);
             x--;
         }
     }
 }
开发者ID:MyEyes,项目名称:Igorr,代码行数:14,代码来源:AttackManager.cs


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