Exemple #1
0
 public bool CreateClass(ClassDetailsDTO newClass, WorldDetailsDTO world)
 {
     try
     {
         using (HugoLANDContext context = new HugoLANDContext())
         {
             Monde monde  = context.Mondes.Find(world.ID);
             var   classe = new Classe()
             {
                 NomClasse        = newClass.ClassName,
                 Description      = newClass.Description,
                 StatBaseStr      = newClass.StatBaseStr,
                 StatBaseDex      = newClass.StatBaseDex,
                 StatBaseReg      = newClass.StatBaseReg,
                 StatBaseVitalite = newClass.StatBaseVitality,
                 Monde            = monde,
             };
             context.Entry(classe).State = EntityState.Added;
             context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemple #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            List <string> errorsStats = VerifyInfo();

            if (errorsStats.Count > 0)
            {
                ClassDetailsDTO newClass = new ClassDetailsDTO()
                {
                    ClassName        = txtName.Text,
                    Description      = txtDescription.Text,
                    StatBaseStr      = 0,
                    StatBaseDex      = 0,
                    StatBaseReg      = 0,
                    StatBaseVitality = 0
                };
                var result = createClassValidator.Validate(newClass);
                foreach (var item in result.Errors)
                {
                    errorsStats.Add(item.ErrorMessage);
                }

                MessageBox.Show(string.Join("\n", errorsStats), "Errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ClassDetailsDTO newClass = new ClassDetailsDTO()
                {
                    ClassName        = txtName.Text,
                    Description      = txtDescription.Text,
                    StatBaseStr      = int.Parse(txtStr.Text),
                    StatBaseDex      = int.Parse(txtDex.Text),
                    StatBaseReg      = int.Parse(txtReg.Text),
                    StatBaseVitality = int.Parse(txtVitality.Text)
                };

                var             result = createClassValidator.Validate(newClass);
                WorldDetailsDTO world  = worldsList.FirstOrDefault(w => w.Description == comboWorlds.Text);

                if (!result.IsValid)
                {
                    MessageBox.Show(string.Join("\n", result.Errors.ToList()), "Errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    bool isSuccess = classServiceClient.CreateClass(newClass, world);
                    if (isSuccess)
                    {
                        MessageBox.Show("The class has been created", "Success!", MessageBoxButtons.OK, MessageBoxIcon.None);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("An error has occured with the creation of the class", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
 public HugoWorld(HeroDetailsDTO hero)
 {
     //Setup the form
     //Startup the game state
     currHero      = hero;
     _currentWorld = wsc.GetWorldByName(hero.World);
     if (_currentWorld != null)
     {
         InitializeComponent();
         SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
         _gameState = new GameState(ClientSize, hero);
         initialize();
     }
     else
     {
         MessageBox.Show("An error has occured while loading the map.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #4
0
        public World(GameState gameState, Dictionary <string, Tile> tiles)
        {
            _gameState    = gameState;
            _tiles        = tiles;
            _currentWorld = WorldService.GetWorldByName(_gameState.Hero.World);

            //Read in the map file


            //Find the start point
            //_currentArea = _world[_startArea];

            _currentArea = new Area(_tiles, _gameState.Hero.World, GetBeginPos(_gameState.Hero.x), GetBeginPos(_gameState.Hero.y), _gameState.Hero.Id);
            VerifyHeroPosition();

            //Create and position the hero character
            _heroPosition = new Point(_gameState.Hero.x % 8, _gameState.Hero.y % 8);
            _heroSprite   = new Sprite(null, _heroPosition.X * Tile.TileSizeX + Area.AreaOffsetX,
                                       _heroPosition.Y * Tile.TileSizeY + Area.AreaOffsetY,
                                       _tiles["Hero"].Bitmap, _tiles["Hero"].Rectangle, _tiles["Hero"].NumberOfFrames);
            _heroSprite.Flip     = true;
            _heroSprite.ColorKey = Color.FromArgb(75, 75, 75);
        }