Example #1
0
        public Sprite(GameState gameState, float x, float y, string filename)
        {
            //Load the bitmap
            _frames.Add(new Bitmap(filename));

            //Set the location and use the height and width from the 1st frame
            initialize(gameState, x, y, _frames[0].Width, _frames[0].Height);
        }
Example #2
0
 private void initialize(GameState gameState, float x, float y, float width, float height)
 {
     _gameState = gameState;
     Location.X = x;
     Location.Y = y;
     Size.Width = width;
     Size.Height = height;
     CurrentFrame = 0;
 }
Example #3
0
        public HugoWorld()
        {
            //Setup the form
            InitializeComponent();
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            //Startup the game state
            _gameState = new GameState(ClientSize);
            
            initialize();
        }
Example #4
0
        public Sprite(GameState gameState, float x, float y, Bitmap bitmap, Rectangle rectangle, int numberAnimationFrames)
        {
            for (int i = 0; i < numberAnimationFrames; i++)
            {
                _frames.Add(bitmap);

                //Set the location and use the height and width from the 1st frame
                initialize(gameState, x, y, rectangle.Width / numberAnimationFrames, rectangle.Height);

                _rectangle.Add(new Rectangle(rectangle.X + i * rectangle.Width / numberAnimationFrames, rectangle.Y, 
                                              rectangle.Width / numberAnimationFrames, rectangle.Height));
            }
        }
Example #5
0
        public World(GameState gameState, Dictionary<string, Tile> tiles, int mondeid, bool dead)
        {
            _gameState = gameState;
            _tmrRefresh.Interval = 2000;
            _tmrRefresh.Enabled = true;
            _tmrRefresh.Elapsed += _tmrRefresh_Tick;
            _tiles = tiles;
            Classe currentclasse = Data.ClassController.GetListClasses(Data.WorldId).FirstOrDefault(c=> c.Id == Data.ClassId);
            _currentHero = Data.HeroController.GetListHero(Data.UserId).First(c => c.Id == Data.CurrentHeroId);
            _heroClasse = currentclasse.Description;
            //load la map
            CreerAreaDic(mondeid);
            //load les stat du hero
            UpdateGameState();

            //Find the start point
            _heroid = _currentHero.Id;
            //trouve l'area du hero
            int xarea = _currentHero.x / 8;
            int yarea = _currentHero.y / 8;

            _currentArea = _world[xarea.ToString() + "," + yarea.ToString()];
            
            _heroPosition = new Point(3, 3);

            //si mort, retourne debut full life
            if (dead)
            {
               _currentArea = _world["0,0"];

                Data.vie = Data.Stam * 10;
            }
            if (!dead)
            {
                //si pas mort, trouve pos
                _heroPosition.X = _currentHero.x % 8;
                _heroPosition.Y = _currentHero.y % 8;
            }

            //set sprite selon classe
            _heroSprite = new Sprite(null, _heroPosition.X * Tile.TileSizeX + Area.AreaOffsetX,
                                            _heroPosition.Y * Tile.TileSizeY + Area.AreaOffsetY,
                                            _tiles[_heroClasse].Bitmap, _tiles[_heroClasse].Rectangle, _tiles[_heroClasse].NumberOfFrames);
            
            //affiche nom
            _popups.Add(new textPopup((int)_heroSprite.Location.X, (int)_heroSprite.Location.Y +100, Data.HeroName));

            _heroSprite.Flip = true;
            _heroSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _tmrRefresh.Start();
        }