Exemplo n.º 1
0
        public void MapTest()
        {
            var map = new HuntTheWumpus.Map();
            int mem = map.Wumpus;

            map.WumpusGoAway();
            Assert.False(mem == map.Wumpus, "Wumpus come back");
            map.WumpusGoAway(1);
            map.WumpusGoAway(4);
            for (int i = 0; i < 6; ++i)
            {
                map.PushArrow(i);
            }
            for (int i = 0; i < 6; ++i)
            {
                map.Move(i);
            }
            map.Respaw();
            Assert.True(map.danger == Danger.Empty, "Don't update map.danger");
            for (int i = 0; i < 10; ++i)
            {
                var bat = map.GetBat();
                var pit = map.GetPit();
                Assert.True(bat != pit, "Bat in pit");
            }
        }
Exemplo n.º 2
0
 public void MouseDown(object sender, MouseEventArgs e)
 {
     if (state == ControlState.Cave && !MiniGameEnd)
     {
         minigame.Down(e);
     }
     if (state == ControlState.Cave && MiniGameEnd && view.IsEndAnimation())
     {
         view.StopAnimation();
         RegionCave rg = view.GetRegionCave(e.X, e.Y);
         if (rg >= 0 && (int)rg < 6 && map.isActive[map.Room][(int)rg])
         {
             if (e.Button == MouseButtons.Left)
             {
                 int WumpusRun = Utily.Next() % 8;
                 if (WumpusRun < Difficulty)
                 {
                     map.WumpusGoAway(1);
                 }
                 int add = map.Move((int)rg);
                 player.AddCoins(add);
                 score.AddScores(5 * add);
                 view.StartAddCoinAnimation(add);
                 if (map.danger == Danger.Bat)
                 {
                     view.StartBatAnimation();
                 }
                 view.StartMoveAnimation((int)rg);
                 CheckDanger = false;
             }
             else
             {
                 player.PushArrow();
                 map.PushArrow((int)rg);
                 view.StartArrowAnimation((int)rg);
                 List <string> achiv = new List <string>();
                 player.GetAchievement(achiv);
                 score.getAchievement(achiv);
             }
         }
         if (rg == RegionCave.BuyArrow)
         {
             if (player.CanBuyArrow())
             {
                 StoryMiniGame     = StoryMG.BuyArrow;
                 MiniGameEnd       = false;
                 minigame          = new MiniGame(Width, Height);
                 minigame.HintText = Messages.ArrowHintText;
                 minigame.InitializeMiniGame(ArroDiff[Difficulty]);
                 UseMiniGame = true;
                 player.BuyArrows();
             }
             else
             {
                 view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyArrows()), true, false);
             }
         }
         if (rg == RegionCave.BuyHint)
         {
             if (player.CanBuyHint())
             {
                 StoryMiniGame     = StoryMG.BuyHint;
                 MiniGameEnd       = false;
                 minigame          = new MiniGame(Width, Height);
                 minigame.HintText = Messages.HintHintText;
                 minigame.InitializeMiniGame(HintDiff[Difficulty]);
                 UseMiniGame = true;
                 player.BuyHint();
             }
             else
             {
                 view.AddComand(string.Format(Messages.NotEnoughCoins, player.NeedForBuyHint()), true, false);
             }
         }
         if (rg == RegionCave.UpConsole)
         {
             view.ChangeIndex(1);
         }
         if (rg == RegionCave.DownConsole)
         {
             view.ChangeIndex(-1);
         }
     }
     if (state == ControlState.MainMenu)
     {
         RegionMenu rg = view.GetRegionMainMenu(e.X, e.Y);
         if (rg == RegionMenu.NewGame)
         {
             NewGame();
         }
         if (rg == RegionMenu.Continue)
         {
             ContinueMenu();
         }
         if (rg == RegionMenu.ScoreList)
         {
             score = new Scores(Width, Height);
             score.LoadLeaders(false);
             state = ControlState.ScoreList;
         }
         if (rg == RegionMenu.Exit)
         {
             Application.Exit();
         }
     }
     if (state == ControlState.PickCave)
     {
         RegionPickCave rg    = view.GetRegionPickCave(e.X, e.Y);
         int            Intrg = (int)rg;
         if (Intrg < 5)
         {
             numPickCave = Intrg;
         }
         if (Intrg >= (int)RegionPickCave.Diff1 && Intrg <= (int)RegionPickCave.Diff3)
         {
             numDiff = Intrg - (int)RegionPickCave.Diff1;
         }
         if (rg == RegionPickCave.Play)
         {
             StartAfterPick();
         }
     }
 }