Esempio n. 1
0
        public override void RespondToCollision(GameObject hitObject)
        {
            if (hitObject is Character || hitObject is Wall)
            {
                this.Rectangle = new Rectangle(
                    (int)this.PreviousPosition.X,
                    (int)this.PreviousPosition.Y,
                    this.Rectangle.Width,
                    this.Rectangle.Height);
            }

            var player = hitObject as PlayerCharacter;

            if (player != null)
            {

                player.HealthPoints -= this.Attack;
                player.State = GameObjectState.Damaged;
            }

            if (this.HealthPoints <= 0)
            {
                this.State = GameObjectState.Destroyed;
            }
        }
        public static GameObject GetCollisionInfo(GameObject obj)
        {
            var collidingObject = GameEngine.GameObjects
                .FirstOrDefault(gameObject => (!gameObject.Equals(obj) && gameObject.Rectangle.Intersects(obj.Rectangle)));

            if (obj is Wall)
            {
                collidingObject = GameEngine.GameObjects.FirstOrDefault(gameObject => (gameObject is StoneWall) && gameObject.Rectangle.Intersects(obj.Rectangle));
            }

            return collidingObject;
        }
Esempio n. 3
0
        public override void RespondToCollision(GameObject hitObject)
        {
            var currentType = this.GetType().Name;
            var enemyType = "";
            switch (currentType)
            {
                case "Minion":
                    enemyType = "Player";
                    break;
                case "Player":
                    enemyType = "Warrior";
                    break;
                case "Boyko":
                    enemyType = "Player";
                    break;

                default:
                    break;
            }

            if (hitObject is BaseBullet)
            {
                BaseBullet bullet = (BaseBullet)hitObject;
                if (enemyType.Equals("Minion"))
                {
                    var warrior = GameEngine.GameObjects.FirstOrDefault(w => w is Minion) as Minion;
                    if (warrior != null) this.HealthPoints -= warrior.Attack;
                }
                if (enemyType.Equals("Boyko"))
                {
                    var boyko = GameEngine.GameObjects.FirstOrDefault(w => w is Boyko) as Boyko;
                    if (boyko != null) this.HealthPoints -= boyko.Attack;
                }
                else if (enemyType.Equals("Player"))
                {
                    var player = GameEngine.GameObjects.FirstOrDefault(w => w is Player) as Player;
                    if (player != null) this.HealthPoints -= player.Attack;
                }
                this.State = GameObjectState.Damaged;
            }

            if (this.HealthPoints <= 0)
            {
                this.State = GameObjectState.Destroyed;
            }
        }
Esempio n. 4
0
 public override void RespondToCollision(GameObject hitObject)
 {
     if (hitObject is Character)
     {
         this.State = GameObjectState.Destroyed;
     }
 }
Esempio n. 5
0
 public abstract void RespondToCollision(GameObject hitObject);
Esempio n. 6
0
 public override void RespondToCollision(GameObject hitObject)
 {
     throw new System.NotImplementedException();
 }