Esempio n. 1
0
        /// <summary>
        /// Saves the consumable's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptConsumable_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(image))
                {
                    errorMessage = "You have to select an image for the consumable.";
                    throw new NullReferenceException();
                }

                if (effect == 0)
                {
                    errorMessage = "The effect/damage for the ability must be higher than 0.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(type))
                {
                    errorMessage = "You have to select the consumable type.";
                    throw new NullReferenceException();
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.Consumables.Remove(consumable);
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exists";
                    throw new NullReferenceException();
                }

                Consumable auxConsumable = new Consumable(name, type, effect, image);

                manager.Consumables.Add(auxConsumable);
                manager.Consumables.OrderBy(x => x.Name);

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Saves the npc's information and closes the window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptNPC_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(image))
                {
                    errorMessage = "You have to select an image for the non player charactcer.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(dialogImage))
                {
                    errorMessage = "You have to select an image for the dialog.";
                    throw new NullReferenceException();
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.NonPlayers.Remove(npc);
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exists";
                    throw new NullReferenceException();
                }

                NPC auxNPC = new NPC(name, image, dialogImage);

                manager.NonPlayers.Add(auxNPC);
                manager.NonPlayers.OrderBy(x => x.Name);

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Saves the wall's information and closes the window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptWall_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(image))
                {
                    errorMessage = "You have to select an image for the wall.";
                    throw new NullReferenceException();
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.BgItems.Remove(bgItem);
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exists";
                    throw new NullReferenceException();
                }

                BackgroundItem auxBgItem = new BackgroundItem(name, solid, bulletProof, image);

                manager.BgItems.Add(auxBgItem);
                manager.BgItems.OrderBy(x => x.Name);

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Saves the weapon's information and closes the window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptWeapon_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageWeapon))
                {
                    errorMessage = "You have to select an image for the weapon.";
                    throw new NullReferenceException();
                }

                if (damage == 0)
                {
                    errorMessage = "The damage must be higher than 0.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(type))
                {
                    errorMessage = "You have to select the type of the weapon.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(speed))
                {
                    errorMessage = "You have to select the speed of the weapon.";
                    throw new NullReferenceException();
                }

                if (type == "distance")
                {
                    if (String.IsNullOrEmpty(imageArrowUp) || String.IsNullOrEmpty(imageArrowDown) || String.IsNullOrEmpty(imageArrowLeft) || String.IsNullOrEmpty(imageArrowRight))
                    {
                        errorMessage = "You have to select all the arrow images.";
                        throw new NullReferenceException();
                    }
                }
                else
                {
                    imageArrowUp    = null;
                    imageArrowDown  = null;
                    imageArrowLeft  = null;
                    imageArrowRight = null;
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.Weapons.Remove(weapon);
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exits";
                    throw new NullReferenceException();
                }

                Weapon auxWeapon = new Weapon(name, type, damage, speed, imageWeapon, imageArrowUp, imageArrowDown,
                                              imageArrowLeft, imageArrowRight);
                manager.Weapons.Add(auxWeapon);
                manager.Weapons.OrderBy(x => x.Name);


                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Saves the door's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptDoor_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;

            try
            {
                if (String.IsNullOrEmpty(nameDoor))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageDoor))
                {
                    errorMessage = "You have to select an image for the door.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageKey))
                {
                    errorMessage = "You have to select an image for the key.";
                    throw new NullReferenceException();
                }

                nameDoor = nameDoor.Replace(" ", "_");
                nameKey  = nameKey.Replace(" ", "_");

                if (manager.CheckIfNumber(nameDoor))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    manager.Doors.Remove(door);
                    manager.Keys.Remove(key);
                }
                if (manager.NameRepeated(nameDoor))
                {
                    errorMessage = "This name already exists";
                    throw new NullReferenceException();
                }

                Door auxDoor = new Door(nameDoor, imageDoor, manager.DoorID);

                manager.Doors.Add(auxDoor);
                manager.Doors.OrderBy(x => x.Name);

                KeyItem auxKey = new KeyItem(nameKey, imageKey, manager.DoorID);

                manager.Keys.Add(auxKey);
                manager.Keys.OrderBy(x => x.Name);

                manager.DoorID++;

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Saves the character's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptCharacter_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;
            bool   isAlreadySet = false;
            string previewImage = "";

            PreviewImageWindowCharacter previewWindow = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageMovingUp) || String.IsNullOrEmpty(imageMovingDown) || String.IsNullOrEmpty(imageMovingLeft) || String.IsNullOrEmpty(imageMovingRight))
                {
                    errorMessage = "You have to select all the moving animation images.";
                    throw new NullReferenceException();
                }

                if (frameCount == 0)
                {
                    errorMessage = "You have to input the number of frames for the moving animation.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(speed))
                {
                    errorMessage = "You have to select the speed of the character.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(initialState))
                {
                    errorMessage = "You have to select the initial direction of the character.";
                    throw new NullReferenceException();
                }

                if ((bool)CanMelee.IsChecked)
                {
                    if (String.IsNullOrEmpty(imageAttackingUp) || String.IsNullOrEmpty(initialState) || String.IsNullOrEmpty(initialState) || String.IsNullOrEmpty(initialState))
                    {
                        errorMessage = "You have to select all the attacking animation images.";
                        throw new NullReferenceException();
                    }

                    if (frameAttackingCount == 0)
                    {
                        errorMessage = "You have to input the number of frames for the attacking animation.";
                        throw new NullReferenceException();
                    }

                    if (melee == null)
                    {
                        errorMessage = "You have to select an initial melee weapon.";
                        throw new NullReferenceException();
                    }
                }
                else
                {
                    imageAttackingUp    = null;
                    imageAttackingDown  = null;
                    imageAttackingLeft  = null;
                    imageAttackingRight = null;
                    frameAttackingCount = 0;
                    melee             = null;
                    attackSoundEffect = null;
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    previewWindow = new PreviewImageWindowCharacter(manager.Player, edit);
                    previewWindow.ShowDialog();

                    previewImage = manager.Player.PreviewImage;

                    isAlreadySet   = manager.Player.IsSet;
                    manager.Player = null;
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exits";
                    throw new NullReferenceException();
                }

                manager.Player = new Character(name, strenght, intelligence, dexterity, hitPoints, mana, imageMovingUp,
                                               imageMovingDown, imageMovingLeft, imageMovingRight, imageAttackingUp,
                                               imageAttackingDown, imageAttackingLeft, imageAttackingRight, melee, distance,
                                               frameCount, frameAttackingCount, attackSoundEffect, shootSoundEffect,
                                               castSoundEffect, initialState, speed);

                manager.Player.IsSet = isAlreadySet;

                if (edit)
                {
                    manager.Player.PreviewImage = previewImage;
                }
                else
                {
                    previewWindow = new PreviewImageWindowCharacter(manager.Player, edit);
                    previewWindow.ShowDialog();
                }

                if (manager.Player.PreviewImage == null)
                {
                    manager.Player = null;
                    errorMessage   = "You have to select a preview image.";
                    throw new NullReferenceException();
                }

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Saves the enemy's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AcceptEnemy_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;
            string previewImage = "";

            PreviewImageWindowEnemy previewWindow = null;

            try
            {
                if (String.IsNullOrEmpty(name))
                {
                    errorMessage = "You have to input a name.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(imageMovingUp) || String.IsNullOrEmpty(imageMovingDown) || String.IsNullOrEmpty(imageMovingLeft) || String.IsNullOrEmpty(imageMovingRight))
                {
                    errorMessage = "You have to select all the moving animation images.";
                    throw new NullReferenceException();
                }

                if (frameCount == 0)
                {
                    errorMessage = "You have to input the number of frames for the moving animation.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(initialState))
                {
                    errorMessage = "You have to select the initial direction of the character.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(behavoir))
                {
                    errorMessage = "You have to select the IA behavoir of the enemy.";
                    throw new NullReferenceException();
                }

                if (behavoir == "patrolling" && patrolZone == 0)
                {
                    errorMessage = "You have to input a number for the patrol zone.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(preference))
                {
                    errorMessage = "You have to select the IA preference of the enemy.";
                    throw new NullReferenceException();
                }

                if (String.IsNullOrEmpty(speed))
                {
                    errorMessage = "You have to select the speed of the enemy.";
                    throw new NullReferenceException();
                }

                if (detectZone == 0)
                {
                    errorMessage = "You have to input a number for the detection zone.";
                    throw new NullReferenceException();
                }

                if ((bool)CanShoot.IsChecked)
                {
                    if (String.IsNullOrEmpty(imageArrowUp) || String.IsNullOrEmpty(imageArrowDown) || String.IsNullOrEmpty(imageArrowLeft) || String.IsNullOrEmpty(imageArrowRight))
                    {
                        errorMessage = "You have to select all the arrow images.";
                        throw new NullReferenceException();
                    }
                }
                else
                {
                    imageArrowUp    = null;
                    imageArrowDown  = null;
                    imageArrowLeft  = null;
                    imageArrowRight = null;
                }

                name = name.Replace(" ", "_");

                if (manager.CheckIfNumber(name))
                {
                    errorMessage = "The name cannot be only numbers.";
                    throw new Exception();
                }

                if (edit)
                {
                    previewWindow = new PreviewImageWindowEnemy(enemy, edit);
                    previewWindow.ShowDialog();

                    previewImage = enemy.PreviewImage;

                    manager.Enemies.Remove(enemy);
                }
                if (manager.NameRepeated(name))
                {
                    errorMessage = "This name already exits";
                    throw new NullReferenceException();
                }

                Enemy auxEnemy = new Enemy(name, strenght, intelligence, dexterity, hitPoints, imageMovingUp,
                                           imageMovingDown, imageMovingLeft, imageMovingRight, frameCount, imageArrowUp,
                                           imageArrowDown, imageArrowLeft, imageArrowRight, loot, behavoir, preference,
                                           boss, initialState, patrolZone, detectZone, speed);

                if (edit)
                {
                    auxEnemy.PreviewImage = previewImage;
                }
                else
                {
                    previewWindow = new PreviewImageWindowEnemy(auxEnemy, edit);
                    previewWindow.ShowDialog();
                }

                if (auxEnemy.PreviewImage == null)
                {
                    errorMessage = "You have to select a preview image.";
                    throw new NullReferenceException();
                }
                else
                {
                    manager.Enemies.Add(auxEnemy);
                    manager.Enemies.OrderBy(x => x.Name);
                }

                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show(errorMessage, "Attention", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }