Example #1
0
        private void DrawManaBar(Graphics g, Player player)
        {
            int borderWidth = 300;
            int borderHeight = 15;
            int manaWidth = (int)(borderWidth / (100d / player.Energy.Percentage)) - 1;

            g.DrawString("Mana", hudFont, hudBrush, 0, 60);
            g.FillRectangle(Brushes.Blue, new Rectangle(5, 80, manaWidth, borderHeight));
            g.DrawRectangle(new Pen(Color.Black, 3f), new Rectangle(5, 80, borderWidth, borderHeight));
        }
 public override void gameWorld_Collision(ref IGameObject object1, ref IGameObject object2)
 {
     if ((object1 == GameWorld.Player || object2 == GameWorld.Player) && (object1 == this || object2 == this))
     {
         p = GameWorld.Player as Player;
         Duration = 5;
         Interval = 100;
         Start();
         GameWorld.Remove(this);
     }
 }
Example #3
0
        private void DrawExpBar(Graphics g, Player player)
        {
            string xp = player.Experience.Current.ToString();
            string maxXp = player.Experience.Max.ToString();
            string level = player.Level.ToString();

            g.DrawString("Level: " + level, hudFont, hudBrush, 0, 100);
            g.DrawString("XP: " + maxXp + " / " + xp, hudFont, hudBrush, 0, 120);

            int borderWidth = 300;
            int borderHeight = 15;
            int expWidth = (int)(borderWidth / (100d / player.Experience.Percentage));

            g.FillRectangle(Brushes.White, new Rectangle(5, 140, expWidth, borderHeight));
            g.DrawRectangle(new Pen(Color.Black, 3f), new Rectangle(5, 140, borderWidth, borderHeight));
        }
Example #4
0
        private void DrawLifeBar(Graphics g, Player player)
        {
            Brush healthColor;

            if (player.Health.Percentage < 15)
                healthColor = Brushes.Red;
            else if (player.Health.Percentage < 50)
                healthColor = Brushes.Yellow;
            else
                healthColor = Brushes.Green;

            int borderBrushWidth = 3;
            int borderWidth = 300;
            int hpWidth = (int)(borderWidth / (100d / player.Health.Percentage));
            int borderHeight = 15;

            g.DrawString("Health", hudFont, hudBrush, 0, 20);
            g.FillRectangle(healthColor, new Rectangle(5, 40, hpWidth, borderHeight));
            g.DrawRectangle(new Pen(Color.Black, borderBrushWidth), new Rectangle(5, 40, borderWidth, borderHeight));
        }
        private void Init()
        {
            Tile t = new Tile(Resources.Grass, 0);
            TileRepository.Add(t);
            t = new Tile(Resources.Rock, 1);
            t.IsSolid = true;
            TileRepository.Add(t);
            Tile brick = new Tile(Properties.Resources.BrickWall, 2);
            brick.IsSolid = true;
            TileRepository.Add(brick);
            Tile grassstone = new Tile(Properties.Resources.FloorsMedieval, 3);
            grassstone.IsSolid = false;
            TileRepository.Add(grassstone);

            Player = CreatePlayer();
            gameWorld.Player = Player;
            gameWorld.GameObjects.Add(Player);
            Random r = new Random();

            for (int i = 0; i < 5; i++)
            {
                DecimalPoint loc;
                int x;
                int y;
                do
                {
                    x = r.Next(2000);
                    y = r.Next(2000);
                    loc = new DecimalPoint(x, y);
                } while (gameWorld.GetTile(x / Tile.Width, y / Tile.Height).IsSolid);
                Enemy monster = new Monster(gameWorld, loc);
                gameWorld.GameObjects.Add(monster);
            }

            if(Loaded != null) Loaded(this, EventArgs.Empty);
        }
        private Player CreatePlayer()
        {
            var p = new Player(gameWorld, new DecimalPoint(1000, 2000));
            p.Killed += p_Killed;

            return p;
        }