Пример #1
0
        private void InstantiateAndShowView()
        {
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                GameData.InitialMessages());

            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();
        }
Пример #2
0
        /// <summary>
        /// Create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            //INSTANTIATE the view model and INITIALIZE the data set
            _gameSessionViewModel = new GameSessionViewModel(_player, _messages);
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();

            _playerSetupView.Close();
        }
Пример #3
0
        /// <summary>
        /// create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            //
            // instantiate the view model and initialize the data set
            //
            _gameSessionViewModel = new GameSessionViewModel(_player, _messages);
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();
        }
Пример #4
0
        private void InstantiateAndShowView()
        {
            _gameSessionViewModel = new GameSessionViewModel(_player,
                                                             GameData.InitialMessages(),
                                                             GameData.GameMap(),
                                                             GameData.InitialGameMapLocation(), _currentEnemies
                                                             );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();
        }
        private void InstantiateAndShowView()
        {
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                _gameMap,
                _initialLocationCoordinates
                );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();
        }
Пример #6
0
        private void InstantiateAndShowView()
        {
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                _messages,
                GameData.GameMapData(),
                GameData.InitialGameMapLocation()
                );

            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();
        }
Пример #7
0
        /// <summary>
        /// Method that instantiates the initial view model and data set.
        /// </summary>
        private void InstantiateAndShowView()
        {
            // Instantiate the view model and initialize the initial data set
            _gameSessionViewModel = new GameViewModel(_player, _messages, _gameMap, _currentLocation);
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel)
            {
                DataContext = _gameSessionViewModel
            };

            // Display main gameplay window.
            gameSessionView.Show();

            // Closes the set-up window if open.
            _playerSetupView.Close();
        }
Пример #8
0
        /// <summary>
        /// create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            // instantiate the view model and initialize the data set
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                _gameMap
                );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();

            _playerSetupView.Close();
        }
 public BasicHealingPotion(GameSessionViewModel gsm, GameSessionView gsv)
 {
     this.gsv = gsv;
     this.gsm = gsm;
     this.HealingIncrement = 3.5;
     this.Name             = "Basic Healing Potion";
     this.PicturePath      = "/Images/BloodPot.png";
     this.PictureSource    = gsv.getPictureSource(this.PicturePath);
     this.SpecialObject    = false;
     this.Consumable       = true;
     this.CanEquip         = false;
     this.Value            = 35;
     this.ItemStackCount  += 1;
     gsm._gameData.itemID += 1;
     this.ConsumableUsed   = false;
 }
Пример #10
0
 public void CheckPlayerDeathEvent(GameSessionViewModel gsm, GameSessionView gsv)
 {
     if (gsm.PlayerHealth <= 0)
     {
         gsm.Player.IsAlive            = false;
         gsv.AttackButton.IsEnabled    = false;
         gsv.InventoryButton.IsEnabled = false;
         gsv.SkillsButton.IsEnabled    = false;
         gsv.DialogueBox.Foreground    = Brushes.Red;
         gsv.DialogueBox.FontWeight    = FontWeights.Bold;
         gsv.DialogueBox.Text          = "YOU HAVE FALLEN!";
         gsv.TipsBox.FontWeight        = FontWeights.Bold;
         gsv.TipsBox.Text = "{ GAVE OVER }: Load last save or restart the game.";
         Location.disableControls(gsv);
     }
 }
Пример #11
0
        /// <summary>
        /// Methodd that instantiates the initial view model and data set.
        /// </summary>
        private void InstantiateAndShowView()
        {
            // instantiate the view model and initialize the data set
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                GameData.InitialMessages()
                );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel)
            {
                DataContext = _gameSessionViewModel
            };

            gameSessionView.Show();


            _playerSetupView.Close();
        }
Пример #12
0
        public Bandit(bool isBoss, GameSessionViewModel _gameSessionViewModel, GameSessionView GSV) : base(_gameSessionViewModel, GSV)
        {
            //
            // Can possibly move most of this stuff into the enemy class constructor
            //
            this.Level   = _level;
            this.IsAlive = true;
            double newHealth = Level + (Level * 2.6);

            this.Health    = newHealth;
            this.MaxHealth = newHealth;
            GSV.EnemyHealthDisplay.Value   = newHealth;
            GSV.EnemyHealthDisplay.Maximum = newHealth;
            Random lvlRan = new Random();

            this.Level = lvlRan.Next(15, 18);
            Random ran = new Random();

            this.GoldDrop     = ran.Next(10, 19);
            this._imageString = "Bandit.png";
            Random ranXPDrop = new Random();

            this.XPDrop     = ranXPDrop.Next(20, 35);
            this.Name       = "Bandit";
            this.BaseAttack = this.BaseAttack += (this.Level / 100) + .75;
            _gameSessionViewModel.CurrentEnemyID += 1;
            this.ID = _gameSessionViewModel.CurrentEnemyID;

            //
            // Lootable items
            //
            BasicHealingPotion potion    = new BasicHealingPotion(_gameSessionViewModel, GSV);
            Excalibur          excalibur = new Excalibur(_gameSessionViewModel, GSV);
            RubySword          rubySword = new RubySword(_gameSessionViewModel, GSV);

            this.ItemDrop.Add(potion);
            this.ItemDrop.Add(excalibur);

            this.ItemDrop.Add(rubySword);

            //
            // if passed isBoss bool value is true, then set the property to true, otherwise set the property to false
            //
            isBoss = true ? IsBoss = isBoss : IsBoss = isBoss;
        }
Пример #13
0
        /// <summary>
        /// create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            // instantiate the view model and initialize the data set

            _gameSessionViewModel = new GameSessionViewModel(_player, _messages
                                                             //GameData.InitialMessages(),
                                                             //GameData.GameMap(),
                                                             //GameData.InitialGameMapLocation()
                                                             );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();


            _playerSetupView.Close();
        }
Пример #14
0
        public VestOfProtection(GameSessionViewModel gsm, GameSessionView gsv)
        {
            this.ProtectionBoost = 35;
            this.Consumable      = false;
            this.Collected       = false;
            this.CanEquip        = true;
            this.ArmorEquipped   = false;
            this.SpecialObject   = false;
            this.Equipped        = false;
            this.PicturePath     = "/Images/swendivericon.png";
            this.PictureSource   = gsv.getPictureSource(this.PicturePath);

            this.ID               = gsm._gameData.itemID += 1;
            this.ItemStackCount  += 1;
            this.Value            = 66;
            this.LevelRequirement = 1;
            this.Name             = "Vest of Protection";
            this.IsArmor          = true;
        }
Пример #15
0
        private void InstantiateAndShowView()
        {
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                _messages,
                _gameMap,
                _currentLocation
                );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();

            if (_playerSetupView.ShowActivated)
            {
                _playerSetupView.Close();
            }
        }
Пример #16
0
        /// <summary>
        /// create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            //
            // instantiate the view model and initialize the data set
            //
            _gameSessionViewModel = new GameSessionViewModel(
                _player,
                _messages
                );
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);


            gameSessionView.Show();

            //
            // dialog window is initially hidden to mitigate issue with
            // main window closing after dialog window closes
            _playerSetupView.Close();
        }
Пример #17
0
        /// <summary>
        /// create view model with data set
        /// </summary>
        private void InstantiateAndShowView()
        {
            //
            // instantiate the view model and initialize the data set
            //
            _gameSessionViewModel = new GameSessionViewModel(_player, _messages, _gameMap, _currentLocation);
            GameSessionView gameSessionView = new GameSessionView(_gameSessionViewModel);

            gameSessionView.DataContext = _gameSessionViewModel;

            gameSessionView.Show();

            //
            // dialog window is initially hidden to mitigate issue with
            // main window closing after dialog window closes
            //
            // commented out because the player setup window is disabled
            //
            //_playerSetupView.Close();
        }
        public Warrior(bool isBoss, GameSessionViewModel _gameSessionViewModel, GameSessionView GSV) : base(_gameSessionViewModel, GSV)
        {
            this.Health    = health;
            this.Level     = _level;
            this.IsAlive   = true;
            this.MaxHealth = 125;
            Random ran = new Random();

            this.GoldDrop     = ran.Next(10, 19);
            this._imageString = "warrior-icon.png";
            Random ranXPDrop = new Random();

            this.XPDrop     = ranXPDrop.Next(20, 35);
            this.Name       = "Warrior";
            this.BaseAttack = this.BaseAttack += (this.Level / 100) + .75;
            _gameSessionViewModel.CurrentEnemyID += 1;
            this.ID = _gameSessionViewModel.CurrentEnemyID;
            //
            // if passed isBoss bool value is true, then set the property to true, otherwise set the property to false
            //
            isBoss = true ? IsBoss = isBoss : IsBoss = isBoss;
        }
        public BlackKnight(bool isBoss, GameSessionViewModel _gameSessionViewModel, GameSessionView GSV) : base(_gameSessionViewModel, GSV)
        {
            this.Health     = health;
            this.Level      = _level;
            this.IsAlive    = true;
            this.MaxHealth  = 155;
            this.BaseAttack = this.BaseAttack += (this.Level / 100) + .50;
            Random ranXPDrop = new Random();

            this.XPDrop = ranXPDrop.Next(35, 60);
            Random goldRan = new Random();

            this.GoldDrop     = goldRan.Next(8, 14);
            this._imageString = "warrior-black.png";
            this.Name         = "Black Knight";
            _gameSessionViewModel.CurrentEnemyID += 1;
            this.ID = _gameSessionViewModel.CurrentEnemyID;
            //
            // if passed isBoss bool value is true, then set the property to true, otherwise set the property to false
            //
            isBoss = true ? IsBoss = isBoss : IsBoss = isBoss;
        }
Пример #20
0
        public Wizard(bool isBoss, GameSessionViewModel _gameSessionViewModel, GameSessionView GSV) : base(_gameSessionViewModel, GSV)
        {
            Random levelRan = new Random();

            this.Level = levelRan.Next(30, 60);;
            double newHealth = Level + (Level * 2.6);

            this.Health    = newHealth;
            this.IsAlive   = true;
            this.MaxHealth = newHealth;
            GSV.EnemyHealthDisplay.Maximum = newHealth;
            GSV.EnemyHealthDisplay.Value   = newHealth;
            this.BaseAttack = this.BaseAttack += (this.Level / 100) + .50;

            Random ranXPDrop = new Random();

            this.XPDrop = ranXPDrop.Next(35, 60);
            Random goldRan = new Random();

            this.GoldDrop     = goldRan.Next(25, 66);
            this._imageString = "mage-icon.png";
            this.Image        = "mage-icon.png";
            this.Name         = "Wizard";
            _gameSessionViewModel.CurrentEnemyID += 1;
            this.ID = _gameSessionViewModel.CurrentEnemyID;

            BasicHealingPotion potion = new BasicHealingPotion(_gameSessionViewModel, GSV);

            this.ItemDrop.Add(potion);
            Staff staff = new Staff(_gameSessionViewModel, GSV);

            this.ItemDrop.Add(potion);
            //
            // if passed isBoss bool value is true, then set the property to true, otherwise set the property to false
            //
            isBoss = true ? IsBoss = isBoss : IsBoss = isBoss;
        }
Пример #21
0
        public Bow(GameSessionViewModel gsm, GameSessionView gsv)
        {
            //Mid Level Sword : Moderate damage
            this.Damage        = 3.1;
            this.Consumable    = false;
            this.Collected     = false;
            this.CanEquip      = true;
            this.SpecialObject = false;
            this.Equipped      = false;
            this.PicturePath   = "/Images/thickbow2.png";
            this.PictureSource = gsv.getPictureSource(this.PicturePath);

            /* if (gsm.Player.Level >= 3) {
             *   this.CanEquip = true;
             * }else{
             *   this.CanEquip = false;
             * }*/
            this.ID              = gsm._gameData.itemID += 1;
            this.ItemStackCount += 1;
            this.Value           = 22;
            // this.LevelRequirement = 3;
            this.LevelRequirement = 0;
            this.Name             = "Bow";
        }
Пример #22
0
 public TraderSid(GameSessionViewModel gsm, GameSessionView gsv)
 {
     this.gsv = gsv;
     this.gsm = gsm;
 }
Пример #23
0
        public bool Alive(GameSessionView gsv, GameSessionViewModel gsm, Enemy enemy)
        {
            if (enemy.RemovedFromActiveEnemiesList == false)
            {
                if (enemy.Health > 0)
                {
                    enemy.IsAlive = true;
                }
                else if (enemy.Health <= 0)
                {
                    enemy.Health  = 0;
                    enemy.IsAlive = false;
                    if (enemy.SelectedToFight == true)
                    {
                        enemy.stopAttackingPlayer();
                    }
                    // Remove from ActiveEnemies ListBox List (using listPlacement) The index position returned from currentEnemies

                    gsv.ActiveEnemies.Items.RemoveAt(listPlacement);

                    // Remove from currentEnemies list with placementID (Current index position in the list)
                    if (gsm.CurrentEnemies.Count > 0)
                    {
                        //
                        // After removing dead NPC, the currentFightingEnemyID is set to the next-in-line NPC
                        //
                        gsm.CurrentFightingEnemyID = gsm.CurrentEnemies[listPlacement].ID;
                        //
                        // Setting alive to true if it's the next enemy
                        //
                        if (gsm.CurrentEnemies[listPlacement].ID == gsm.CurrentFightingEnemyID)
                        {
                            gsm.CurrentEnemies[listPlacement].IsAlive = true;
                            gsm.CurrentEnemies[listPlacement].Health  = gsm.CurrentEnemies[listPlacement].Health;
                        }
                        //
                        // Removes the killed enemy from the list
                        //

                        gsm.CurrentEnemies.RemoveAt(listPlacement);
                        enemy.RemovedFromActiveEnemiesList = true;
                        gsm.EnemySelected = false;
                        //
                        // Only enemies that are alive are in the list at this point
                        //
                        gsv.ActiveEnemies.SelectedItem = listPlacement;
                        //
                        // If there is another enemy next-in-line and the previous has been slain, then make the
                        // current enemy the next-in-line
                        //
                        if (gsm.CurrentEnemies.Count > 0)
                        {
                            // Setting the current attacking enemy in the player's class to the next-in-line enemy
                            if (gsm.Player.currentlyAttacking.listPlacement != gsm.CurrentEnemies.Count)
                            {
                                gsm.Player.currentlyAttacking = gsm.CurrentEnemies[listPlacement];
                                // Setting the enemy picture in the view to the next-in-line enemy's PictureSource property
                                gsv.EnemyPicture.Source = gsm.CurrentEnemies[listPlacement].PictureSource;
                                // Setting the next-in-line enemy's SelectedToFight property to true
                                gsm.CurrentEnemies[listPlacement].SelectedToFight = true;
                                // Setting the GameSessionviewModel's CurrentFightingEnemyID property to equal the next-in-line enemy's ID
                                gsm.CurrentFightingEnemyID = gsm.CurrentEnemies[listPlacement].ID;
                                // Refreshing/Resetting all enemies in the list's listPlacement positions
                                refreshAllEnemiesPositions();
                                // CurrentFightingEnemyListPlacement is set to the next-in-line enemy's listPlacement property/position
                                gsm.CurrentFightingEnemyListPlacement = gsm.CurrentEnemies[listPlacement].listPlacement;
                            }
                            else
                            {
                                gsm.Player.currentlyAttacking = gsm.CurrentEnemies[listPlacement - 1];
                                // Setting the enemy picture in the view to the next-in-line enemy's PictureSource property
                                gsv.EnemyPicture.Source = gsm.CurrentEnemies[listPlacement - 1].PictureSource;
                                // Setting the next-in-line enemy's SelectedToFight property to true
                                gsm.CurrentEnemies[listPlacement - 1].SelectedToFight = true;
                                // Setting the GameSessionviewModel's CurrentFightingEnemyID property to equal the next-in-line enemy's ID
                                gsm.CurrentFightingEnemyID = gsm.CurrentEnemies[listPlacement - 1].ID;
                                // Refreshing/Resetting all enemies in the list's listPlacement positions
                                refreshAllEnemiesPositions();
                                // CurrentFightingEnemyListPlacement is set to the next-in-line enemy's listPlacement property/position
                                gsm.CurrentFightingEnemyListPlacement = gsm.CurrentEnemies[listPlacement - 1].listPlacement;
                            }
                            refreshAllEnemiesPositions();

                            gsm.EnemySelected = true;
                        }
                    }
                    else if (gsm.CurrentEnemies.Count <= 0)
                    {
                        gsm.CurrentEnemies.RemoveAt(listPlacement);
                        gsv.AttackButton.IsEnabled = false;
                    }
                    if (gsm.CurrentEnemies.Count <= 0)
                    {
                        gsv.EnemyPicture.Source = null;
                    }
                    // Updating the listPlacement to their actual current positions
                    refreshAllEnemiesPositions();
                }
            }
            return(IsAlive);
        }
Пример #24
0
        public void AttackEnemy(GameSessionViewModel gsm, GameSessionView GSV, AttackType typeOfAttack)
        {
            // setting fightingEnemy to the enemy with position in currentEnemies of
            // Send id of currentfightingenemy and set fightingenemy to currentenemieswiththat position
            // What if current fighting id is 15 and the list is only 4 big, then it would be out of bounds error
            // Need to look for enemy with a specific listPlacement
            Enemy fightingEnemy = gsm.Player.currentlyAttacking;

            attackType = typeOfAttack;
            //
            // ADD IN, IF NOT SELECTED THEN AUTOMATICALLY ATTACK FIRST ENEMY IN LIST
            //
            if (gsm.CurrentEnemies.Count > 0)
            {
                //If current enemy is alive/has more than 0 health
                if (PlayersCurrentState == PlayerState.Fighting)
                {
                    bool anEnemyHasSelection = false;
                    for (int enemy = 0; enemy < gsm.CurrentEnemies.Count; enemy++)
                    {
                        if (gsm.CurrentEnemies[enemy].SelectedToFight == true)
                        {
                            anEnemyHasSelection = true; break;
                        }
                        else if (gsm.CurrentEnemies[enemy].SelectedToFight == false)
                        {
                            anEnemyHasSelection = false;
                        }
                    }

                    /*
                     * foreach (Enemy enemy in gsm.CurrentEnemies)
                     * {
                     *  if (enemy.SelectedToFight == true)
                     *  {
                     *      anEnemyHasSelection = true; break;
                     *  }
                     *  else if (enemy.SelectedToFight == false)
                     *  {
                     *      anEnemyHasSelection = false;
                     *  }
                     * }
                     */

                    if (anEnemyHasSelection == false)
                    {
                        gsm.Player.currentlyAttacking         = gsm.CurrentEnemies[0];
                        gsm.CurrentEnemies[0].SelectedToFight = true;
                        gsm.CurrentEnemies[0].AttackingPlayer = true;
                        gsm.CurrentEnemies[0].startAttackingPlayer();
                        gsm.CurrentEnemyID = gsm.CurrentEnemies[0].ID;
                        gsm.CurrentFightingEnemyListPlacement = gsm.CurrentEnemies[0].listPlacement;
                        fightingEnemy = gsm.CurrentEnemies[0];
                        GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Visible;
                        GSV.EnemyHealthDisplay.Maximum    = fightingEnemy.MaxHealth;
                        GSV.EnemyHealthDisplay.Value      = fightingEnemy.Health;
                        gsm.EnemyDamage         = fightingEnemy.BaseAttack;
                        gsm.EnemyHealth         = fightingEnemy.Health;
                        gsm.EnemyLevel          = fightingEnemy.Level;
                        gsm.EnemyName           = fightingEnemy.Name;
                        GSV.EnemyPicture.Source = gsm.Player.currentlyAttacking.PictureSource;
                        GSV.enemyStatsWindow.EnemyStatsPicture.Source     = gsm.Player.currentlyAttacking.PictureSource;
                        GSV.enemyStatsWindow.EnemyStatsPicture.Visibility = System.Windows.Visibility.Visible;
                    }
                    if (fightingEnemy.IsAlive == true)
                    {
                        switch (attackType)
                        {
                        case AttackType.BasicAttack:
                            GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Visible;
                            if (gsm.Player.EquippedWeapon != null)
                            {
                                fightingEnemy.Health -= gsm.Player.EquippedWeapon.Damage;
                            }
                            else if (gsm.Player.EquippedWeapon == null)
                            {
                                fightingEnemy.Health -= gsm.Player.BasicAttack;
                            }
                            GSV.EnemyHealthDisplay.Value = fightingEnemy.Health;
                            // GSV.DialogueBox.Text = fightingEnemy.Health.ToString();
                            gsm.EnemyDamage         = fightingEnemy.BaseAttack;
                            gsm.EnemyHealth         = fightingEnemy.Health;
                            gsm.EnemyLevel          = fightingEnemy.Level;
                            gsm.EnemyName           = fightingEnemy.Name;
                            GSV.EnemyPicture.Source = fightingEnemy.PictureSource;
                            GSV.enemyStatsWindow.EnemyStatsPicture.Source = fightingEnemy.PictureSource;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                //deals with removal of enemy from lists
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                                fightingEnemy.stopAttackingPlayer();
                                if (fightingEnemy.IsBoss == true)
                                {
                                    GSV.TipsBox.Foreground = Brushes.LightBlue;
                                    GSV.TipsBox.FontSize   = 15;
                                    GSV.TipsBox.Text       = "Congratulations, you have slain the boss!";
                                }
                                if (gsm.GameMap.CurrentLocation.BossFightRoom == true && gsm.CurrentEnemies.Count <= 0)
                                {
                                    GSV.DialogueBox.Foreground = Brushes.LightBlue;
                                    GSV.DialogueBox.FontSize   = 15;
                                    GSV.DialogueBox.FontWeight = FontWeights.Bold;
                                    GSV.DialogueBox.HorizontalContentAlignment = HorizontalAlignment.Center;
                                    GSV.DialogueBox.VerticalContentAlignment   = VerticalAlignment.Center;
                                    GSV.DialogueBox.Text = "You have cleared the boss room!";
                                }
                                //GSV.DialogueBox.Text = fightingEnemy.Health.ToString();
                                fightingEnemy.onDeathRewardPlayer(gsm, fightingEnemy);
                                GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Hidden;
                                fightingEnemy.AttackingPlayer     = false;
                                GSV.enemyStatsWindow.EnemyStatsPicture.Visibility = System.Windows.Visibility.Hidden;
                                //
                                // On enemy death, add enemy loot drop items to the current location's inventory
                                //
                                foreach (Item itemDrop in fightingEnemy.ItemDrop)
                                {
                                    bool hasItem = false;
                                    //
                                    // Search the current location's lootable items inventory
                                    //
                                    for (int item = 0; item < gsm.GameMap.CurrentLocation.LootableItems.Count; item++)
                                    {
                                        //
                                        // If the current location's lootable items inventory has an item with the name
                                        // that is the same as the item drop's name, then increment it's stack count
                                        //
                                        if (gsm.GameMap.CurrentLocation.LootableItems[item].Name == itemDrop.Name && itemDrop.SpecialObject == false)
                                        {
                                            hasItem = true;
                                            gsm.GameMap.CurrentLocation.LootableItems[item].ItemStackCount += 1;
                                            break;
                                        }
                                        else if (gsm.GameMap.CurrentLocation.LootableItems[item].Name == itemDrop.Name && itemDrop.SpecialObject == true)
                                        {
                                            hasItem = true;
                                            gsm.GameMap.CurrentLocation.LootableItems.Add(itemDrop);
                                            break;
                                        }
                                        //
                                        // If the current location's lootable items inventory does not have an item with the same
                                        // name as the item drop item then set hasItem to false
                                        //
                                        else if (gsm.GameMap.CurrentLocation.LootableItems[item].Name != itemDrop.Name)
                                        {
                                            hasItem = false;
                                        }
                                    }
                                    //
                                    // OUT OF THE FOR LOOP
                                    // If hasItem = false then add the item to the lootable item's inventory
                                    //
                                    if (hasItem == false)
                                    {
                                        gsm.GameMap.CurrentLocation.LootableItems.Add(itemDrop);
                                    }
                                }
                                for (int enemy = 0; enemy < gsm.CurrentEnemies.Count; enemy++)
                                {
                                    if (gsm.CurrentEnemies[enemy].SelectedToFight == true)
                                    {
                                        gsm.CurrentEnemies[enemy].SelectedToFight = false;
                                    }
                                }/*
                                  * foreach (Enemy enemy in gsm.CurrentEnemies)
                                  * {
                                  *     if (enemy.SelectedToFight == true)
                                  *     {
                                  *         enemy.SelectedToFight = false;
                                  *     }
                                  * }
                                  */
                                fightingEnemy.SelectedToFight = false;

                                if (gsm.PlayerXP >= gsm.MaxPlayerXP)
                                {
                                    playerLevelUp(gsm, GSV);
                                }
                                if (gsm.CurrentEnemies.Count == 0)
                                {
                                    Location.enableControls(GSV);
                                    gsm.EnemyDamage = 0;
                                    gsm.EnemyHealth = 0;
                                    gsm.EnemyName   = "Currently Not Fighting";
                                    gsm.EnemyLevel  = 0;
                                }
                            }

                            break;

                        case AttackType.SkillOneAttack:
                            fightingEnemy.Health -= SkillOneAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.SkillTwoAttack:
                            fightingEnemy.Health -= SkillTwoAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.SkillThreeAttack:
                            fightingEnemy.Health -= SkillThreeAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.ThirdEyeAttack:


                            if (fightingEnemy.IsAlive == true)
                            {
                                fightingEnemy.Health -= ThirdEyeAttack;
                            }
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            #endregion
        }
Пример #25
0
        public void AttackEnemy(GameSessionViewModel gsm, GameSessionView GSV, AttackType typeOfAttack)
        {
            // setting fightingEnemy to the enemy with position in currentEnemies of
            // Send id of currentfightingenemy and set fightingenemy to currentenemieswiththat position
            // What if current fighting id is 15 and the list is only 4 big, then it would be out of bounds error
            // Need to look for enemy with a specific listPlacement
            Enemy fightingEnemy = currentlyAttacking;

            attackType = typeOfAttack;
            //
            // ADD IN, IF NOT SELECTED THEN AUTOMATICALLY ATTACK FIRST ENEMY IN LIST
            //
            if (gsm.CurrentEnemies.Count > 0)
            {
                //If current enemy is alive/has more than 0 health
                if (PlayersCurrentState == PlayerState.Fighting)
                {
                    bool anEnemyHasSelection = false;
                    foreach (Enemy enemy in gsm.CurrentEnemies)
                    {
                        if (enemy.SelectedToFight == true)
                        {
                            anEnemyHasSelection = true; break;
                        }
                        else if (enemy.SelectedToFight == false)
                        {
                            anEnemyHasSelection = false;
                        }
                    }
                    if (anEnemyHasSelection == false)
                    {
                        gsm.Player.currentlyAttacking         = gsm.CurrentEnemies[0];
                        gsm.CurrentEnemies[0].SelectedToFight = true;
                        gsm.CurrentEnemies[0].AttackingPlayer = true;
                        gsm.CurrentEnemies[0].startAttackingPlayer();
                        gsm.CurrentEnemyID = gsm.CurrentEnemies[0].ID;
                        gsm.CurrentFightingEnemyListPlacement = gsm.CurrentEnemies[0].listPlacement;
                        fightingEnemy = gsm.CurrentEnemies[0];
                        GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Visible;
                        gsm.EnemyDamage = fightingEnemy.BaseAttack;
                        gsm.EnemyHealth = fightingEnemy.Health;
                        gsm.EnemyLevel  = fightingEnemy.Level;
                        gsm.EnemyName   = fightingEnemy.Name;
                    }
                    if (fightingEnemy.IsAlive == true)
                    {
                        switch (attackType)
                        {
                        case AttackType.BasicAttack:
                            GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Visible;
                            fightingEnemy.Health        -= BasicAttack;
                            GSV.EnemyHealthDisplay.Value = fightingEnemy.Health;
                            GSV.DialogueBox.Text         = fightingEnemy.Health.ToString();
                            gsm.EnemyDamage = fightingEnemy.BaseAttack;
                            gsm.EnemyHealth = fightingEnemy.Health;
                            gsm.EnemyLevel  = fightingEnemy.Level;
                            gsm.EnemyName   = fightingEnemy.Name;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                                fightingEnemy.stopAttackingPlayer();
                                GSV.DialogueBox.Text = fightingEnemy.Health.ToString();
                                fightingEnemy.onDeathRewardPlayer(gsm, fightingEnemy);
                                GSV.EnemyHealthDisplay.Visibility = System.Windows.Visibility.Hidden;

                                if (gsm.PlayerXP >= gsm.MaxPlayerXP)
                                {
                                    playerLevelUp(gsm, GSV);
                                }
                                if (gsm.CurrentEnemies.Count == 0)
                                {
                                    Location.enableControls(GSV);
                                    gsm.EnemyDamage = 0;
                                    gsm.EnemyHealth = 0;
                                    gsm.EnemyName   = "Currently Not Fighting";
                                    gsm.EnemyLevel  = 0;
                                }
                            }
                            break;

                        case AttackType.SkillOneAttack:
                            fightingEnemy.Health -= SkillOneAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.SkillTwoAttack:
                            fightingEnemy.Health -= SkillTwoAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.SkillThreeAttack:
                            fightingEnemy.Health -= SkillThreeAttack;
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        case AttackType.ThirdEyeAttack:


                            if (fightingEnemy.IsAlive == true)
                            {
                                fightingEnemy.Health -= ThirdEyeAttack;
                            }
                            if (fightingEnemy.Health <= 0)
                            {
                                fightingEnemy.Health = 0;
                                fightingEnemy.Alive(GSV, gsm, fightingEnemy);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            #endregion
        }
 public GameSessionViewMediator(GameSessionView _view) : base(NAME, _view)
 {
     m_gameSessionView.OnShow += TryRequestForGameSessions;
     m_gameSessionView.OnNextButtonClicked += SubmitSelectedGameID;
 }