Example #1
0
        public GameState(SizeF gameArea)
        {
            GameArea = gameArea;

            //Load in all the tile definitions
            readTileDefinitions(@"gamedata\tilelookups.csv");

            //Create the sprites for the UI
            int y = 50;
            Bitmap expsprite = _tiles["Arrrow"].Bitmap;
            expsprite.MakeTransparent(Color.FromArgb(255, 0, 255));
            _experienceSprite = new Sprite(this, 880, y, expsprite, _tiles["Arrow"].Rectangle, _tiles["Arrow"].NumberOfFrames);
            _experienceSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _healthSprite = new Sprite(this, 880, y += 74, _tiles["Heart"].Bitmap, _tiles["Heart"].Rectangle, _tiles["Heart"].NumberOfFrames);
            _healthSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _attackSprite = new Sprite(this, 880, y += 74, _tiles["Sword"].Bitmap, _tiles["Sword"].Rectangle, _tiles["Sword"].NumberOfFrames);
            _attackSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _armourSprite = new Sprite(this, 880, y += 74, _tiles["Shield"].Bitmap, _tiles["Shield"].Rectangle, _tiles["Shield"].NumberOfFrames);
            _armourSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _treasureSprite = new Sprite(this, 880, y += 74, _tiles["Gem"].Bitmap, _tiles["Gem"].Rectangle, _tiles["Gem"].NumberOfFrames);
            _treasureSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _potionSprite = new Sprite(this, 880, y += 74, _tiles["Potion"].Bitmap, _tiles["Potion"].Rectangle, _tiles["Potion"].NumberOfFrames);
            _potionSprite.ColorKey = Color.FromArgb(75, 75, 75);
            _redKeySprite = new Sprite(this, 880, y += 74, _tiles["Key"].Bitmap, _tiles["Key"].Rectangle, _tiles["Key"].NumberOfFrames);
            _redKeySprite.ColorKey = Color.FromArgb(75, 75, 75);
        }
Example #2
0
        public int ObjectHealth; //A copy of the health of the tile so we remember how damage monsters are

        public void SetSprite(int x, int y)
        {
            //Update the sprite
            Sprite = new Sprite(null, Area.AreaOffsetX + x * Tile.TileSizeX,
                                      Area.AreaOffsetY + y * Tile.TileSizeY,
                                      Tile.Bitmap, Tile.Rectangle,
                                      Tile.NumberOfFrames);
        }
Example #3
0
 public void SetObjectSprite(int x, int y)
 {
     //Update the sprite
     ObjectSprite = new Sprite(null, Area.AreaOffsetX + x * Tile.TileSizeX,
                               Area.AreaOffsetY + y * Tile.TileSizeY,
                               ObjectTile.Bitmap, ObjectTile.Rectangle,
                               ObjectTile.NumberOfFrames);
     if (ObjectTile.IsTransparent)
     {
         ObjectSprite.ColorKey = Color.FromArgb(75, 75, 75);
     }
 }
Example #4
0
        public static bool Collision(Sprite sprite1, Sprite sprite2)
        {
            //See if the sprite rectangles overlap
            return ! ( sprite1.Location.X > sprite2.Location.X + sprite2.Size.Width
		            || sprite1.Location.X + sprite1.Size.Width < sprite2.Location.X
		            || sprite1.Location.Y > sprite2.Location.Y + sprite2.Size.Height
		            || sprite1.Location.Y + sprite1.Size.Height < sprite2.Location.Y);
        }
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();
        }