public void TestStartingLives()
        {
            var trigger = new StartingLives("5");

            Assert.AreEqual(5, trigger.Lives);
            var player = new Player();

            GameTrigger.OnGameStarting();
            Assert.AreEqual(trigger.Lives, player.LivesLeft);
        }
Exemplo n.º 2
0
        public void AddPlayers(List <Player> players)
        {
            foreach (var p in players)
            {
                var e     = new Entity();
                var lives = new Text(StartingLives.ToString());
                lives.Italicized = true;
                lives.Size       = 18;
                lives.X          = 10;
                lives.Y          = 15;
                lives.ScrollX    = lives.ScrollY = 0;

                var head = new Image(Library.GetTexture("players/" + p.ImageName + "_head.png"));
                head.CenterOO();
                head.X       = -10;
                head.Y       = 25;
                head.ScrollX = head.ScrollY = 0;

                var graphics = new Graphiclist(lives, head);
                graphics.ScrollX = graphics.ScrollY = 0;
                e.AddComponent(graphics);

                if (StartingHealth != 0 && PunchDamage != 0)
                {
                    var health = new Text(string.Format("{0}/{0}", StartingHealth));
                    health.Bold    = true;
                    health.Size    = 18;
                    health.X       = head.X - head.Width / 2;
                    health.Y       = lives.Y + 30;
                    health.ScrollX = health.ScrollY = 0;
                    graphics.Add(health);

                    e.AddResponse(HUD.Message.UpdateDamage, OnDamage(p, health));
                }

                e.AddResponse(Player.Message.Die, OnDeath(p, lives, head));
                e.AddResponse(Player.Message.UpgradeAcquired, OnUpgradeAcquired(p, lives, head));
                e.AddResponse(Upgrade.Message.Used, OnUpgradeUsed());

                Players.Add(e);
                upgradeIcons.Add(new Stack <Image>());
            }
        }