コード例 #1
0
ファイル: StaticObject.cs プロジェクト: androidejl/Telerik
 public override void RespondToCollision(CollisionData collisionData)
 {
     if (collisionData.ObjectCollisionGroupString == "bullet")
     {
         this.IsDestroyed = true;
     }
 }
コード例 #2
0
ファイル: ScoreBlock.cs プロジェクト: androidejl/Telerik
 public override void RespondToCollision(CollisionData collisionData)
 {
     this.IsDestroyed = true;
 }
コード例 #3
0
ファイル: Player.cs プロジェクト: androidejl/Telerik
        public override void RespondToCollision(CollisionData collisionData)
        {
            //If there is a collision the player must stop moving.
            this.Direction = new GridPosition(0, 0);

            //If the player is hit by a bullet
            if (collisionData.ObjectCollisionGroupString == "bullet")
            {
                //If the player has more health than the damage which the bullet does.
                if (this.Health > Bullet.Damage)
                {
                    this.Health -= Bullet.Damage;
                }
                    //Otherwise the player dies.
                else
                {
                    this.IsDestroyed = true;
                }
            }
                //If the player hits a score block, the score bonus is added to the player's score.
            else if (collisionData.ObjectCollisionGroupString == "scoreBlock")
            {
                this.Score += (int)(collisionData.ObjectImage - '0');
            }
                //If the player hits a health block, the health bonus is added to the player's health.
                //The current health of the player + the health bonus must not exceed the maximum health a player can have.
            else if (collisionData.ObjectCollisionGroupString == "healthBlock")
            {
                this.Health = Math.Min(Player.PlayerMaxHealth, this.Health + HealthBlock.HealthBonus);
            }
        }
コード例 #4
0
ファイル: Bullet.cs プロジェクト: androidejl/Telerik
 public override void RespondToCollision(CollisionData collisionData)
 {
     this.Direction = new GridPosition(0, 0);
     this.IsDestroyed = true;
 }
コード例 #5
0
 public virtual void RespondToCollision(CollisionData collisionData)
 {
 }
コード例 #6
0
 public override void RespondToCollision(CollisionData collisionData)
 {
     this.IsDestroyed = true;
 }