Ejemplo n.º 1
0
        // Remove a cached object from update loop, does not deallocate. Physics bodies crushed and moved to (-1,-1)
        protected void Deactivate(string key)
        {
            GameObject gameObject;

            if (!CachedGameObjects.ContainsKey(key))
            {
                Console.Error.WriteLine("Room : \"{0}\" : Remove() : Keyname \"{1}\" not found in loaded objects", Key, key);
                return;
            }
            gameObject = CachedGameObjects[key];
            if (gameObject.Active)
            {
                ActiveGameObjects.Remove(gameObject);
                gameObject.PreDeactivate();
                if (gameObject.Drawable)
                {
                    DrawableGameObjects.Remove(gameObject);
                }
                if (gameObject.Body != null)
                {
                    gameObject.Body.BoxCollider.Data = CollisionCategory.none;
                    foreach (Hitbox hitbox in gameObject.Body.ChildHitboxes.Values)
                    {
                        World.RemoveHitbox(hitbox);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public void MoveRegularEnemy(ActiveGameObjects activeGameObjects)
        {
            switch (activeGameObjects)
            {
            case TrackingEnemy:
                activeGameObjects.Cords =
                    new Point(
                        activeGameObjects.Cords.X + this.gameModel.BasicTrackingPath[activeGameObjects.Cords].X,
                        activeGameObjects.Cords.Y + this.gameModel.BasicTrackingPath[activeGameObjects.Cords].Y);
                break;

            case BossEnemy:
                activeGameObjects.Cords =
                    new Point(
                        activeGameObjects.Cords.X + this.gameModel.BasicTrackingPath[activeGameObjects.Cords].X,
                        activeGameObjects.Cords.Y + this.gameModel.BasicTrackingPath[activeGameObjects.Cords].Y);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        private void DisposeEnemy(ActiveGameObjects activeGameObject)
        {
            switch (activeGameObject)
            {
            case FlyingEnemy:
                this.gameModel.FlyingMonsters.Remove(activeGameObject as FlyingEnemy);
                break;

            case ShootingEnemy:
                this.gameModel.ShootingMonsters.Remove(activeGameObject as ShootingEnemy);
                break;

            case TrackingEnemy:
                this.gameModel.TrackingMonsters.Remove(activeGameObject as TrackingEnemy);
                break;

            case BossEnemy:
                this.gameModel.Boss = null;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        public void DamageActiveGameObject(ActiveGameObjects activeGameObjects, int damage)
        {
            switch (activeGameObjects)
            {
            case BossEnemy:
                if (activeGameObjects.Health - damage <= 0)
                {
                    this.gameModel.Boss.Health = 0;
                    break;
                }

                this.gameModel.Boss.Health -= damage;
                break;

            case FlyingEnemy:
                if (activeGameObjects.Health - damage <= 0)
                {
                    this.gameModel.FlyingMonsters.Find(x => x == activeGameObjects).Health = 0;
                    break;
                }

                this.gameModel.FlyingMonsters.Find(x => x == activeGameObjects).Health -= damage;
                break;

            case TrackingEnemy:
                if (activeGameObjects.Health - damage <= 0)
                {
                    this.gameModel.TrackingMonsters.Find(x => x == activeGameObjects).Health = 0;
                    break;
                }

                this.gameModel.TrackingMonsters.Find(x => x == activeGameObjects).Health -= damage;
                break;

            case ShootingEnemy:
                if (activeGameObjects.Health - damage <= 0)
                {
                    this.gameModel.ShootingMonsters.Find(x => x == activeGameObjects).Health = 0;
                    break;
                }

                this.gameModel.ShootingMonsters.Find(x => x == activeGameObjects).Health -= damage;
                break;

            case Player:
                if (activeGameObjects.Health - damage <= 0)
                {
                    this.gameModel.MyPlayer.Health = 0;
                    Thread soundPlayThread = new Thread(() =>
                    {
                        new System.Media.SoundPlayer(Assembly.LoadFrom("DungeonPenetrator").GetManifestResourceStream("DungeonPenetrator.Images.auh.wav")).Play();
                    });
                    soundPlayThread.IsBackground = true;
                    soundPlayThread.Start();
                    break;
                }

                this.gameModel.MyPlayer.Health -= damage;
                break;

            default:
                break;
            }
        }