Esempio n. 1
0
        /// <summary>
        ///		Executes when a collison occurs with another GameObject
        /// </summary>
        /// <param name="collisonName"></param>
        /// <param name="other"></param>
        /// <returns>
        ///		<c>true</c> if the object is to be deleted
        ///	</returns>
        public override bool OnCollide(CollisionPairEvaluator.Name collisonName, GameObject other)
        {
            bool willBeDeleted = false;

            // PlayerLaser vs AlienLaser
            if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_AlienLaser)
            {
                willBeDeleted = true;
            }
            // Player vs AlienLaser
            else if (collisonName == CollisionPairEvaluator.Name.Player_vs_AlienLaser)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
                smallExplosion.SetColor(Colors.Green);

                // Move up. This is important!
                // Removing this line will make the Aliens rain laser everywhere!
                GameObject parent = this.Parent as GameObject;
                parent.SetPosition(parent.X, parent.Y + this.Height);
            }
            // AlienLaser vs Shields
            else if (collisonName == CollisionPairEvaluator.Name.AlienLaser_vs_Shield)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
                smallExplosion.SetColor(Colors.Green);
            }
            // AlienLaser vs WallBottom
            else if (collisonName == CollisionPairEvaluator.Name.AlienLaser_vs_WallBottom)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
                smallExplosion.SetColor(Colors.Green);
            }


            return(willBeDeleted);
        }
        /// <summary>
        ///		Executes when a collison occurs with another GameObject
        /// </summary>
        /// <param name="collisonName"></param>
        /// <param name="other"></param>
        /// <returns>
        ///		<c>true</c> if the object is to be deleted
        ///	</returns>
        public override bool OnCollide(CollisionPairEvaluator.Name collisonName, GameObject other)
        {
            bool willBeDeleted = false;

            // Laser vs. Aliens
            if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_Alien)
            {
                willBeDeleted = true;
            }
            // Laser vs. Top Wall
            else if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_WallTop)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
            }
            // Laser vs Shield
            else if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_Shield)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
                smallExplosion.SetColor(Colors.Green);
            }
            // Laser vs. UFO
            else if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_UFO)
            {
                willBeDeleted = true;
            }
            // PlayerLaser vs AlienLaser
            else if (collisonName == CollisionPairEvaluator.Name.PlayerLaser_vs_AlienLaser)
            {
                willBeDeleted = true;

                // Create small explosion
                DeadPlayerLaser smallExplosion = new DeadPlayerLaser(this.X, this.Y);
                smallExplosion.SetColor(Colors.White);
            }

            return(willBeDeleted);
        }