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


C# ICollidable.GetType方法代码示例

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


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

示例1: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// @see AddAsteroid
 /// @see CalculateNewRotations
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if (_other.GetType() == typeof(MediumAsteroid))
     {
         if (isMergeable)
         {
             drawn = false;
             MediumAsteroid other = (MediumAsteroid)_other;
             other.isMergeable = false;
             other.drawn = false;
             foreach (IObjectAdderObserver observer in objectObservers)
             {
                 observer.AddAsteroid(AsteroidFactory.createNewAsteroid(1, position, RandomGenerator.GetRandomFloat(0, 6.283)));
             }
         }
     }
     else if (_other.GetType() == typeof(Bullet))
     {
         drawn = false;
         float[] rotationsValue = CalculateNewRotations(this, (Bullet)_other);
         foreach (IObjectAdderObserver observer in objectObservers)
         {
             observer.AddAsteroid(AsteroidFactory.createNewAsteroid(3, position, rotationsValue[0] + Rotation));
             observer.AddAsteroid(AsteroidFactory.createNewAsteroid(3, position, rotationsValue[1] + Rotation));
         }
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:33,代码来源:MediumAsteroid.cs

示例2: StartTouch

        /// <summary>
        /// 
        /// </summary>
        /// <param name="collider"></param>
        public override void StartTouch(ICollidable collider)
        {
            if (collider.GetType() != typeof(Player))
                return;

            if (State.WaterDropsLeft == 0)
                State.End();
        }
开发者ID:thexa4,项目名称:ticktick,代码行数:12,代码来源:Finish.cs

示例3: HandleCollision

        /// <summary>
        /// Handles a collision with a ball, removes a live from a player
        /// </summary>
        /// <param name="other"></param>
        public void HandleCollision(ICollidable other)
        {
            if (other.GetType() != typeof(Ball))
                return;

            this.Player.Lives--;
            this.Level.Reset();
        }
开发者ID:thexa4,项目名称:perfectpong,代码行数:12,代码来源:DeadZone.cs

示例4: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if (_other.GetType() == typeof(Bullet))
     {
         if (((Bullet)_other).Shooter != this)
         {
             drawn = false;
         }
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:14,代码来源:LargeEnemy.cs

示例5: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if (_other.GetType() == typeof(Player))
     {
         foreach (IBonusObserver observer in bonusObservers)
         {
             observer.AddBonus(type);
         }
         drawn = false;
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:15,代码来源:Bonus.cs

示例6: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// @see AddAsteroid
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if(_other.GetType() == typeof(SmallAsteroid))
     {
         if (isMergeable)
         {
             drawn = false;
             SmallAsteroid other = (SmallAsteroid)_other;
             other.isMergeable = false;
             other.drawn = false;
             foreach (IObjectAdderObserver observer in objectObservers)
             {
                 observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, RandomGenerator.GetRandomFloat(0, 6.283)));
             }
         }
     }
     if (_other.GetType() == typeof(Bullet))
     {
         drawn = false;
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:26,代码来源:SmallAsteroid.cs

示例7: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// @see CalculateNewRotations
 /// @see AddAsteroid
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if (_other.GetType() == typeof(Bullet))
     {
         drawn = false;
         float[] rotationsValue = CalculateNewRotations(this, (Bullet)_other);
         foreach (IObjectAdderObserver observer in objectObservers)
         {
             observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, rotationsValue[0] + Rotation));
             observer.AddAsteroid(AsteroidFactory.createNewAsteroid(2, position, rotationsValue[1] + Rotation));
         }
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:19,代码来源:LargeAsteroid.cs

示例8: StartTouch

        public override void StartTouch(ICollidable collider)
        {
            if (IsCollected)
                return;

            if (collider.GetType() != typeof(Player))
                return;

            State.WaterDropsLeft--;

            IsCollected = true;
            Visible = false;
            Enabled = false;
        }
开发者ID:thexa4,项目名称:ticktick,代码行数:14,代码来源:Water.cs

示例9: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// </summary>
 /// <param name="_other">The _other.</param>
 public virtual void HasCollided(ICollidable _other)
 {
     if (_other.GetType() != typeof(Bonus))
     {
         drawn = false;
         position.X = 0;
         position.Y = 0;
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:13,代码来源:Object2D.cs

示例10: Adjust

 /// <summary>
 /// Tries to move a unit out of the way by given vector,
 /// but only if end position is passable. Tries this with
 /// 1*vector, 1/2*vector and 1/4*vector and then gives up.
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="vector"></param>
 private void Adjust(ICollidable unit, Vector2 vector)
 {
     for (int trials = 0; trials < 2; trials++)
     {
         Vector2 newPosition = unit.Position + vector / (float)Math.Pow(2, trials);
         if (PathFinder.GetInstance().FreePoint(newPosition, unit.GetType()))
         {
             unit.Position = newPosition;
             return;
         }
     }
     // Still not free, we give up
 }
开发者ID:bethge,项目名称:GalaticChaos,代码行数:20,代码来源:CollisionManager.cs

示例11: CheckScore

 /// <summary>
 /// Checks the score.
 /// @see NotifyScoreObserver
 /// </summary>
 /// <param name="_other">The _other.</param>
 private void CheckScore(ICollidable _other)
 {
     if (_other.GetType() == typeof(Bonus))
     {
         NotifyScoreObserver(100);
     }
     if (_other.GetType() == typeof(LargeAsteroid))
     {
         NotifyScoreObserver(500);
     }
     if (_other.GetType() == typeof(MediumAsteroid))
     {
         NotifyScoreObserver(350);
     }
     if (_other.GetType() == typeof(SmallAsteroid))
     {
         NotifyScoreObserver(200);
     }
     if (_other.GetType() == typeof(SpecialEnemy))
     {
         NotifyScoreObserver(1500);
     }
     if (_other.GetType() == typeof(SmallEnemy))
     {
         NotifyScoreObserver(750);
     }
     if (_other.GetType() == typeof(LargeEnemy))
     {
         NotifyScoreObserver(1000);
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:36,代码来源:Bullet.cs

示例12: HasCollided

        /// <summary>
        /// Determines whether the specified _other has collided.
        /// </summary>
        /// <param name="_other">The _other.</param>
        public override void HasCollided(ICollidable _other)
        {
            if (_other != shooter && _other.GetType() != typeof(Bullet))
            {
                drawn = false;
            }

            CheckScore(_other);
        }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:13,代码来源:Bullet.cs

示例13: HasCollided

 /// <summary>
 /// Determines whether the specified _other has collided.
 /// </summary>
 /// <param name="_other">The _other.</param>
 public override void HasCollided(ICollidable _other)
 {
     if (!isInvulnerable)
     {
         if (_other.GetType() != typeof(Bonus))
         {
             if (_other.GetType() != typeof(Bullet))
             {
                 drawn = false;
             }
             else if (((Bullet)_other).Shooter != this)
             {
                 drawn = false;
             }
         }
         if (drawn == false && lifeCount >= 1)
         {
             drawn = true;
             lifeCount--;
             CheckIfDead();
             invulnerabilityStart = DateTime.Now;
             isInvulnerable = true;
         }
     }
 }
开发者ID:SamuelDaigle,项目名称:TP1-Asteroids,代码行数:29,代码来源:Player.cs


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