public RegionCave GetRegionCave(int x, int y) { RegionCave result = RegionCave.Empty; //upper-bound interface int yup = Height - 120; //find room, which was clicked if (isLeftUpper(Width / 2 - length / 2 + length / 3, (Height - length) / 2 - deltaY, Width / 2 - length / 2, (Height - length) / 2 + length / 2 - deltaY, x, y)) { return(RegionCave.UpLeft); } if (isRightUpper(Width / 2 + length / 2 - length / 3, (Height - length) / 2 - deltaY, Width / 2 + length / 2, (Height - length) / 2 + length / 2 - deltaY, x, y)) { return(RegionCave.UpRight); } if (isLeftDown(Width / 2 - length / 2, (Height - length) / 2 + length / 2 - deltaY, Width / 2 - length / 2 + length / 3, (Height - length) / 2 + length - deltaY, x, y)) { return(RegionCave.DownLeft); } if (isRightDown(Width / 2 + length / 2, (Height - length) / 2 + length / 2 - deltaY, Width / 2 + length / 2 - length / 3, (Height - length) / 2 + length - deltaY, x, y)) { return(RegionCave.DownRight); } if (isUnder(Width / 2 - length / 2 + length / 3, Width / 2 + length / 2 - length / 3, (Height - length) / 2 - deltaY, x, y)) { return(RegionCave.Up); } if (isDown(Width / 2 - length / 2 + length / 3, Width / 2 + length / 2 - length / 3, (Height - length) / 2 + length - deltaY, x, y)) { return(RegionCave.Down); } //region for buton on Interface if (x >= 168 && x <= 326 && y - yup >= 16 && y - yup <= 56) { return(RegionCave.BuyArrow); } if (x >= 168 && x <= 326 && y - yup >= 71 && y - yup <= 104) { return(RegionCave.BuyHint); } if (x >= 692 && x <= 718 && y >= yup + 26 && y <= yup + 45) { return(RegionCave.UpConsole); } if (x >= 692 && x <= 718 && y >= yup + 65 && y <= yup + 82) { return(RegionCave.DownConsole); } return(result); }
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(); } } }