Exemple #1
0
        private bool TryWumpusGoAway(int step)
        {
            int nowWumpus = Wumpus;
            int lastdir   = -1;

            for (int i = 0; i < step; i++)
            {
                List <int> good = new List <int>();
                for (int j = 0; j < 6; ++j)
                {
                    if (isActive[nowWumpus][j] && lastdir != j)
                    {
                        good.Add(j);
                    }
                }
                if (good.Count == 0)
                {
                    return(false);
                }
                int dir = good[Utily.Next() % good.Count];
                lastdir   = (dir + 3) % 6;
                nowWumpus = graph[nowWumpus][dir];
            }
            if (!RoomIsDanger(nowWumpus) && Room != nowWumpus)
            {
                Wumpus = nowWumpus;
                return(true);
            }
            return(false);
        }
Exemple #2
0
 public void UpdateImage()
 {
     //new image for new cave
     for (int i = 0; i < 30; ++i)
     {
         TypeImageRoom[i] = Utily.Next() % CountImageRoom;
     }
 }
Exemple #3
0
        public int GetPit()
        {
            int rnd = Utily.Next();

            if (rnd % 2 == 0)
            {
                return(PitRoom.Item1);
            }
            return(PitRoom.Item2);
        }
Exemple #4
0
 public void StartBatAnimation()
 {
     IsBatAnimated = true;
     MinimizeBat   = true;
     for (int i = 0; i < StarX.Count; ++i)
     {
         StarX[i]    = Utily.Next() % Width;
         StarY[i]    = Utily.Next() % Height;
         StarTime[i] = 2500;
     }
 }
        public void StartAfterPick()
        {
            Difficulty = numDiff;
            long nowseed = seeds[numPickCave];

            if (seed != "")
            {
                nowseed = long.Parse(seed);
            }
            Utily.ChangeSeed(nowseed);
            map   = new Map();
            state = ControlState.Cave;
            view.ClearConsole();
            view.AddComand(String.Format(Messages.MapSeedString, nowseed), false);
        }
Exemple #6
0
        public void Respaw()
        {
            int[] a = new int[27];
            int   j = 0;

            for (int i = 0; i < 30; i++)
            {
                if (i != PitRoom.Item1 && i != PitRoom.Item2 && i != Wumpus)
                {
                    a[j] = i;
                    int rnd = Utily.Next() % (j + 1);
                    Utily.Swap <int>(ref a[rnd], ref a[j]);
                    ++j;
                }
            }
            BatRoom = Tuple.Create(a[0], a[1]);
            Room    = a[2];
            danger  = Danger.Empty;
        }
Exemple #7
0
 public Map()
 {
     graph      = new List <int> [30];
     isActive   = new List <bool> [30];
     CountVisit = new int[30];
     VisitRoom  = 1;
     GenGraph();
     int[] a = new int[30];
     for (int i = 0; i < 30; i++)
     {
         a[i] = i;
         int rnd = Utily.Next() % (i + 1);
         Utily.Swap <int>(ref a[rnd], ref a[i]);
     }
     BatRoom          = Tuple.Create(a[0], a[1]);
     PitRoom          = Tuple.Create(a[2], a[3]);
     Wumpus           = a[4];
     Room             = a[5];
     CountVisit[Room] = 1;
     Turn             = 0;
     IsWin            = false;
     danger           = Danger.Empty;
 }
 void NewGame()
 {
     for (int i = 0; i < 5; ++i)
     {
         seeds[i] = Utily.Next();
         Utily.ChangeSeed(seeds[i]);
         MapForPiсk[i] = new Map();
     }
     numPickCave   = 0;
     numDiff       = 1;
     MiniGameEnd   = true;
     minigame      = new MiniGame(Width, Height);
     player        = new Player();
     score         = new Scores(Width, Height);
     score.active  = ScoreState.Achievements;
     CheckDanger   = false;
     IsWin         = false;
     StoryMiniGame = StoryMG.Empty;
     view.UpdateImage();
     view.ClearConsole();
     seed        = "";
     state       = ControlState.PickCave;
     UseMiniGame = false;
 }
Exemple #9
0
        /// Read and apply info about figure
        private void Set_Figure(string filename)
        {
            //* Clear memory about last drawing figure... *//
            Scale_Distance = 20.0f;
            CircleCoordinateX.Clear();
            CircleCoordinateY.Clear();
            MousePositionsX.Clear();
            MousePositionsY.Clear();
            List <double> MainX = new List <double>(), MainY = new List <double>();

            //* ...and read info about new figure */
            StreamReader file = new StreamReader(@"./data/MiniGame/" + filename);
            string       line = "";
            int          rot = Utily.Next() % 4, simetr = 1 - 2 * (Utily.Next() % 2);
            int          cos = 1, sin = 0;

            if (rot % 2 == 1)
            {
                cos = 0;
                sin = 1;
            }
            if (rot > 1)
            {
                cos = -cos;
                sin = -sin;
            }
            while ((line = file.ReadLine()) != null)
            {
                string[] points = line.Split(' ').ToArray();
                int      x1 = -int.Parse(points[0]), y1 = -int.Parse(points[1]);
                MainX.Add((x1 * cos - y1 * sin) * simetr + (Utily.Next() % 21 - 10) / 10.0);
                MainY.Add(x1 * sin + y1 * cos + (Utily.Next() % 21 - 10) / 10.0);
            }
            for (int i = 0; i < MainX.Count; ++i)
            {
                CircleCoordinateX.Add(MainX[i]);
                CircleCoordinateY.Add(MainY[i]);
                int j = (i + 1) % MainX.Count;
                int UseI = i, UseJ = j;
                int type = Utily.Next() % 3;
                if (type == 1)
                {
                    type = 0;
                    UseI = j;
                    UseJ = i;
                }
                //type = 2;
                if (type == 0)
                {
                    double Cos60 = 0.5;
                    double Sin60 = Math.Sin(Math.PI / 3);
                    double midX  = (MainX[UseI] - MainX[UseJ]) * Cos60 - (MainY[UseI] - MainY[UseJ]) * Sin60 + MainX[UseJ];
                    double midY  = (MainX[UseI] - MainX[UseJ]) * Sin60 + (MainY[UseI] - MainY[UseJ]) * Cos60 + MainY[UseJ];
                    double Cos15 = Math.Cos(Math.PI / 12);
                    double Sin15 = Math.Sin(Math.PI / 12);
                    double hX    = MainX[UseJ];
                    double hY    = MainY[UseJ];
                    for (int k = 0; k < 3; ++k)
                    {
                        double cX = hX;
                        double cY = hY;
                        hX = (cX - midX) * Cos15 - (cY - midY) * Sin15 + midX;
                        hY = (cX - midX) * Sin15 + (cY - midY) * Cos15 + midY;
                        CircleCoordinateX.Add(hX);
                        CircleCoordinateY.Add(hY);
                    }
                }
                if (type == 2)
                {
                    for (int k = 1; k < 4; ++k)
                    {
                        CircleCoordinateX.Add((MainX[i] * k + MainX[j] * (4 - k)) / 4);
                        CircleCoordinateY.Add((MainY[i] * k + MainY[j] * (4 - k)) / 4);
                    }
                }
            }
            Scale_Distance = 20.0f;
        }
Exemple #10
0
        void GenGraph()
        {
            List <Tuple <int, int> >[] g = new List <Tuple <int, int> > [30];
            for (int i = 0; i < 6; ++i)
            {
                for (int j = 0; j < 5; ++j)
                {
                    int now = cell(i, j).Item1;
                    g[now] = new List <Tuple <int, int> >();
                    g[now].Add(cell(i, j - 1));
                    if (i % 2 == 1)
                    {
                        g[now].Add(cell(i - 1, j));
                        g[now].Add(cell(i - 1, j + 1));
                        g[now].Add(cell(i, j + 1));
                        g[now].Add(cell(i + 1, j + 1));
                        g[now].Add(cell(i + 1, j));
                    }
                    else
                    {
                        g[now].Add(cell(i - 1, j - 1));
                        g[now].Add(cell(i - 1, j));
                        g[now].Add(cell(i, j + 1));
                        g[now].Add(cell(i + 1, j));
                        g[now].Add(cell(i + 1, j - 1));
                    }
                }
            }
            int[,] ok = new int[30, 30];
            for (int i = 0; i < 30; ++i)
            {
                for (int j = 0; j < 30; ++j)
                {
                    ok[i, j] = 0;
                }
            }
            int[] ctv = new int[30];
            SortedSet <Tuple <int, int, int> > st = new SortedSet <Tuple <int, int, int> >();
            int startvert = Utily.Next() % 30;

            st.Add(Tuple.Create(0, startvert, startvert));
            bool[] b = new bool[30];
            for (int i = 0; i < 30; ++i)
            {
                while (st.Count > 0 && (b[st.Min.Item2] || ctv[st.Min.Item3] == 3))
                {
                    st.Remove(st.Min);
                }
                if (st.Count == 0)
                {
                    GenGraph();
                    return;
                }
                int start  = st.Min.Item2;
                int finish = st.Min.Item3;
                b[start] = true;
                if (finish != start)
                {
                    ok[start, finish] = ok[finish, start] = 1;
                    ++ctv[finish];
                }
                ++ctv[start];

                int cnt = 0;
                for (int j = 0; j < g[start].Count; ++j)
                {
                    if (!b[g[start][j].Item1])
                    {
                        ++cnt;
                    }
                }
                int okcnt = 0;
                for (int j = 0; j < g[start].Count; ++j)
                {
                    if (!b[g[start][j].Item1])
                    {
                        int rn = Utily.Next() % cnt;
                        if (rn < 3 - okcnt)
                        {
                            ++okcnt;
                            st.Add(Tuple.Create(g[start][j].Item1, g[start][j].Item1, start));
                        }
                        --cnt;
                    }
                }
            }
            int cntfail = 0;

            while (cntfail < 10)
            {
                int v = Utily.Next() % 30, i = Utily.Next() % 6;
                int fin = g[v][i].Item1;
                if (ctv[v] == 3 || ctv[fin] == 3 || ok[v, fin] == 1)
                {
                    ++cntfail;
                }
                else
                {
                    ok[v, fin] = ok[fin, v] = 1;
                    ++ctv[v];
                    ++ctv[fin];
                }
            }
            coins = new List <int> [30];
            for (int i = 0; i < 30; ++i)
            {
                coins[i]    = new List <int>();
                isActive[i] = new List <bool>();
                graph[i]    = new List <int>();
                for (int j = 0; j < 6; j++)
                {
                    graph[i].Add(g[i][j].Item1);
                    if (j < 3)
                    {
                        coins[i].Add(Utily.Next() % 4 + 1);
                    }
                    else
                    {
                        coins[i].Add(0);
                    }
                    if (ok[i, g[i][j].Item1] == 1)
                    {
                        isActive[i].Add(true);
                    }
                    else
                    {
                        isActive[i].Add(false);
                    }
                }
            }
            for (int i = 0; i < 30; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    coins[graph[i][j]][j + 3] = coins[i][j];
                }
            }
        }
Exemple #11
0
 Tuple <int, int> cell(int x, int y)
 {
     return(Tuple.Create((x + 6) % 6 + 6 * ((y + 5) % 5), Utily.Next() % 100000));
 }
Exemple #12
0
        private bool TryWumpusGoAway()
        {
            int step = Utily.Next() % 3 + 2;

            return(TryWumpusGoAway(step));
        }
Exemple #13
0
        public void DrawCave(List <int>[] graph, List <bool>[] isActive, List <Danger> DangerList, Danger danger, int CurrentRoom)
        {
            Clear(Color.Black);
            int deltaStar = (int)StarTimer.ElapsedMilliseconds;

            StarTimer.Restart();
            for (int i = 0; i < StarX.Count; ++i)
            {
                StarTime[i] -= deltaStar;
                if (StarTime[i] <= 0)
                {
                    StarX[i]    = Utily.Next() % Width;
                    StarY[i]    = Utily.Next() % Height;
                    StarTime[i] = Utily.Next() % 200 + 500;
                }
                Graphics.FillRectangle(Brushes.White, StarX[i], StarY[i], 1, 1);
            }
            if (!IsAnimated)
            {
                DrawAllFriends(graph, isActive, DangerList, danger, CurrentRoom, Width / 2 - length / 2, (Height - length) / 2 - deltaY);
                isActiveLast    = isActive;
                DangerListLast  = DangerList;
                dangerLast      = danger;
                CurrentRoomLast = CurrentRoom;
            }
            if (IsAnimated)
            {
                long Milliseconds = moveTimerAnimation.ElapsedMilliseconds;
                Progress = Milliseconds / 2500.0f;
                int TargetCenterX = Width / 2 - length / 2;
                int TargetCenterY = (Height - length) / 2 - deltaY;
                //coordinates for animation room
                DrawRegion(-ScaleRoomX[numberstone], -ScaleRoomY[numberstone], TargetCenterX - (int)(length * ScaleRoomX[numberstone] * Progress) + (int)(2 * length * ScaleRoomX[numberstone]) - (int)(length * ScaleRoomX[numberstone] * Progress), TargetCenterY - (int)(length * ScaleRoomY[numberstone] * Progress) + (int)(2 * length * ScaleRoomY[numberstone]) - (int)(length * ScaleRoomY[numberstone] * Progress));
                DrawAllFriends(graph, isActiveLast, DangerListLast, dangerLast, CurrentRoomLast, TargetCenterX - (int)(length * ScaleRoomX[numberstone] * Progress), TargetCenterY - (int)(length * ScaleRoomY[numberstone] * Progress));
                if (Progress >= 1.0f)
                {
                    Progress = 0.0f;
                    moveTimerAnimation.Stop();
                    IsAnimated = false;
                }
            }
            if ((IsBatAnimated || MaximizateBat) && !IsAnimated)
            {
                if (batTimerAnimation == null)
                {
                    batTimerAnimation = new Stopwatch();
                    batTimerAnimation.Start();
                }
                else
                {
                    long  Milliseconds = batTimerAnimation.ElapsedMilliseconds;
                    float progress     = Milliseconds / 2500.0f;
                    length = (int)(normallength * (1.0f - progress));
                    if (progress >= 1.0f)
                    {
                        progress     -= 1;
                        MaximizateBat = true;
                        MinimizeBat   = false;
                        length        = (int)(normallength * progress);
                    }
                    if (Milliseconds > 5000)
                    {
                        IsBatAnimated     = false;
                        MaximizateBat     = false;
                        MinimizeBat       = false;
                        batTimerAnimation = null;
                        length            = normallength;
                    }
                }
            }
            if (IsArrowAnimation && !IsBatAnimated && !IsAnimated)
            {
                long ms       = ArrowTimerAnimation.ElapsedMilliseconds;
                int  WaitTime = 500;
                if (ms < WaitTime)
                {
                    Pen pn = new Pen(Color.Gold, 5);
                    //sin and cos alpha. alpha-angle left-upper and upper
                    double cos       = 3 / Utily.Hypot(3, 2);
                    double sin       = 2 / Utily.Hypot(3, 2);
                    int    UseHeight = Height - 120;
                    //draw arrow
                    //for every Direction
                    if (ArrowDirection == 0)
                    {
                        Graphics.DrawLine(pn, Width / 2, UseHeight / 2 - ms * length / 2 / WaitTime, Width / 2, UseHeight / 2 - ms * length / 2 / WaitTime - 50);
                    }
                    if (ArrowDirection == 3)
                    {
                        Graphics.DrawLine(pn, Width / 2, UseHeight / 2 + ms * length / 2 / WaitTime, Width / 2, UseHeight / 2 + ms * length / 2 / WaitTime + 50);
                    }
                    if (ArrowDirection == 1)
                    {
                        Graphics.DrawLine(pn, Width / 2 - length * ms / 3 / WaitTime, UseHeight / 2 - ms * length / 4 / WaitTime, Width / 2 - length * ms / 3 / WaitTime - (int)(50 * cos), UseHeight / 2 - ms * length / 4 / WaitTime - (int)(50 * sin));
                    }
                    if (ArrowDirection == 2)
                    {
                        Graphics.DrawLine(pn, Width / 2 - length * ms / 3 / WaitTime, UseHeight / 2 + ms * length / 4 / WaitTime, Width / 2 - length * ms / 3 / WaitTime - (int)(50 * cos), UseHeight / 2 + ms * length / 4 / WaitTime + (int)(50 * sin));
                    }
                    if (ArrowDirection == 5)
                    {
                        Graphics.DrawLine(pn, Width / 2 + length * ms / 3 / WaitTime, UseHeight / 2 - ms * length / 4 / WaitTime, Width / 2 + length * ms / 3 / WaitTime + (int)(50 * cos), UseHeight / 2 - ms * length / 4 / WaitTime - (int)(50 * sin));
                    }
                    if (ArrowDirection == 4)
                    {
                        Graphics.DrawLine(pn, Width / 2 + length * ms / 3 / WaitTime, UseHeight / 2 + ms * length / 4 / WaitTime, Width / 2 + length * ms / 3 / WaitTime + (int)(50 * cos), UseHeight / 2 + ms * length / 4 / WaitTime + (int)(50 * sin));
                    }
                }
                else
                {
                    IsArrowAnimation = false;
                    ArrowTimerAnimation.Stop();
                }
            }
        }
Exemple #14
0
        public View(int width, int height)
        {
            Bitmap      = new System.Drawing.Bitmap(width, height);
            Graphics    = System.Drawing.Graphics.FromImage(Bitmap);
            Width       = width;
            Height      = height;
            length      = Height * 8 / 12;
            ConsoleList = new List <string>();
            BanerTimer  = new Stopwatch();
            StarTimer   = new Stopwatch();
            StarTimer.Start();
            StarX    = new List <int>();
            StarY    = new List <int>();
            StarTime = new List <int>();
            //Coorinate Stars
            for (int i = 0; i < 200; ++i)
            {
                StarX.Add(Utily.Next() % Width);
                StarY.Add(Utily.Next() % Height);
                StarTime.Add(Utily.Next() % 200 + 100);
            }
            ArrowTimerAnimation = new Stopwatch();
            normallength        = length;
            #region setted images
            room[0] = new CompressionImage("data/Cave/TryTop1.png", length / 3, length / 3);
            room[1] = new CompressionImage("data/Cave/TryUpperLeft1.png", length / 3, length / 3);
            room[2] = new CompressionImage("data/Cave/TryBottomLeft1.png", length / 3, length / 3);
            room[3] = new CompressionImage("data/Cave/TryTop1.png", length / 3, length / 3);
            room[4] = new CompressionImage("data/Cave/TryUpperLeft1.png", length / 3, length / 3);
            room[5] = new CompressionImage("data/Cave/TryBottomLeft1.png", length / 3, length / 3);

            for (int i = 0; i < 6; ++i)
            {
                room[i].ScreenWidth  = width;
                room[i].ScreenHeight = height;
            }
            CaveRoom = new CompressionImage[CountImageRoom];
            for (int i = 0; i < CountImageRoom; ++i)
            {
                CaveRoom[i] = new CompressionImage("data/Cave/ColorRoom" + (i + 1) + ".png", length, length, Width, Height);
            }
            PitRoom       = new CompressionImage("data/Cave/PitRoom.png", length, length, Width, Height);
            TypeImageRoom = new int[30];
            UpdateImage();
            DarkRoom   = new CompressionImage("data/Cave/DarkRoom.png", length, length, Width, Height);
            BackGround = new CompressionImage("data/Cave/background.png", width, 120);
            WumpusImg  = new CompressionImage("data/Cave/wumpus.png", length / 2, length / 2, Width, Height);
            DiffImg    = new CompressionImage[3];
            DiffImg[1] = new CompressionImage("./data/Sprites/Bow.png", 200, 200, Width, Height);
            DiffImg[2] = new CompressionImage("./data/Sprites/CrossBow.png", 200, 200, Width, Height);
            DiffImg[0] = new CompressionImage("./data/Sprites/Spear.png", 200, 200, Width, Height);
            #endregion
            #region setted constants
            // const for drawing bridge
            StownPosX.Add(1.0f / 3.0f - 1.0f / 70.0f); // 0 item
            StownPosY.Add(-1.0f / 6.0f);
            StownPosX.Add(0);                          // 1 item
            StownPosY.Add(1.0f / 9.0f);
            StownPosX.Add(0);                          // 2 item
            StownPosY.Add(1.0f / 9.0f + 1.0f / 2.0f);
            StownPosX.Add(StownPosX[0]);               // 3 item
            StownPosY.Add(StownPosY[0] + 1);
            StownPosX.Add(StownPosX[1] + 2.0f / 3.0f); // 4 item
            StownPosY.Add(StownPosY[1] + 1.0f / 2.0f);
            StownPosX.Add(StownPosX[2] + 2.0f / 3.0f); // 5 item
            StownPosY.Add(StownPosY[2] - 1.0f / 2.0f);
            // for animation
            ScaleRoomX.Add(0);          // 0 item
            ScaleRoomY.Add(-1);
            ScaleRoomX.Add(-0.67f);     // 1 item
            ScaleRoomY.Add(-0.5f);
            ScaleRoomX.Add(-0.67f);     // 2 item
            ScaleRoomY.Add(0.5f);
            ScaleRoomX.Add(0);          // 3 item
            ScaleRoomY.Add(1);
            ScaleRoomX.Add(0.67f);      // 4 item
            ScaleRoomY.Add(0.5f);
            ScaleRoomX.Add(0.67f);      // 5 item
            ScaleRoomY.Add(-0.5f);
            #endregion
            MainMenuImage = Image.FromFile(@".\data\Sprites\Menu.png");
            MainForm      = new Form1(Drawing, width, height);
            MainForm.Show();
            deltaY = height / 36 + 30;
        }
        public void UpDate(long time)
        {
            if (state == ControlState.Cave)
            {
                List <string> listachiv = new List <string>();
                map.GetAchievement(listachiv);
                if (minigame != null)
                {
                    minigame.GetAchievement(listachiv);
                }
                player.GetAchievement(listachiv);
                score.getAchievement(listachiv);
                view.DrawCave(map.graph, map.isActive, map.GetDangerList(), map.danger, map.Room);
                if (!MiniGameEnd)
                {
                    minigame.TickTime();
                    minigame.DrawMiniGame(view.Graphics);
                    if (!minigame.Is_playing)
                    {
                        if (!minigame.Is_Winner && StoryMiniGame != StoryMG.BuyArrow && StoryMiniGame != StoryMG.BuyHint)
                        {
                            IsWin = false;
                            EndGame();
                        }
                        if (minigame.Is_Winner && StoryMiniGame == StoryMG.BuyHint)
                        {
                            int  rnd      = Utily.Next() % HintMessage.Count;
                            Hint NowHint  = (Hint)rnd;
                            int  HintData = 0;
                            if (NowHint == Hint.Bat)
                            {
                                HintData = map.GetBat() + 1;
                            }
                            if (NowHint == Hint.Pit)
                            {
                                HintData = map.GetPit() + 1;
                            }
                            if (NowHint == Hint.Wumpus)
                            {
                                HintData = map.Wumpus + 1;
                            }
                            if (NowHint != Hint.NoLuck)
                            {
                                view.AddComand(HintMessage[(int)NowHint] + HintData, true);
                            }
                            else
                            {
                                view.AddComand(HintMessage[(int)NowHint], true);
                            }
                        }
                        if (minigame.Is_Winner && StoryMiniGame == StoryMG.BuyArrow)
                        {
                            player.GiveArrows();
                            view.AddComand(Messages.GiveArrowsString, true, false);
                        }
                        if (minigame.Is_Winner && StoryMG.Wumpus == StoryMiniGame)
                        {
                            map.WumpusGoAway();
                            view.AddComand(Messages.WumpusRunString, true);
                        }
                        if (minigame.Is_Winner)
                        {
                            score.AddScores(50);
                        }
                        MiniGameEnd = true;
                    }
                }
                else
                {
                    view.DrawInterface(player.Coins, player.Arrow, map.Room, player.CanBuyArrow(), player.CanBuyHint());
                }
                if (!CheckDanger && !view.MinimizeBat && !view.IsAnimated)
                {
                    CheckDanger = true;
                    if (map.danger == Danger.Pit)
                    {
                        minigame          = new MiniGame(Width, Height);
                        StoryMiniGame     = StoryMG.Pit;
                        minigame.HintText = Messages.PitHintText;
                        minigame.InitializeMiniGame(PitDiff[Difficulty]);
                        UseMiniGame = true;
                        MiniGameEnd = false;
                    }
                    if (map.danger == Danger.Bat)
                    {
                        view.AddComand(Messages.MetBatString, true);
                        map.Respaw();
                    }
                    if (map.danger == Danger.Wumpus)
                    {
                        minigame          = new MiniGame(Width, Height);
                        StoryMiniGame     = StoryMG.Wumpus;
                        minigame.HintText = Messages.WumpusHintText;
                        MiniGameEnd       = false;
                        UseMiniGame       = true;
                        minigame.InitializeMiniGame(WumpusDiff[Difficulty]);
                    }
                    Danger dangerabout = map.GetDangerAbout();
                    if (dangerabout == Danger.Bat)
                    {
                        view.AddComand(String.Format(Messages.BatWarning, map.Room + 1), true);
                    }
                    if (dangerabout == Danger.Pit)
                    {
                        view.AddComand(String.Format(Messages.PitWarning, map.Room + 1), true);
                    }
                    if (dangerabout == Danger.Wumpus)
                    {
                        string strout = String.Format(Messages.WumpusWarning, map.Room + 1);
                        if (!player.IsShotArrow)
                        {
                            strout += Messages.HintRightClick;
                        }
                        view.AddComand(strout, true);
                    }
                }
                if (map.IsWin && view.IsEndAnimation())
                {
                    IsWin = true;
                    EndGame();
                }
                else if (player.Arrow == 0 && view.IsEndAnimation())
                {
                    IsWin = false;
                    EndGame();
                }
            }

            if (state == ControlState.MainMenu)
            {
                view.DrawMainMenu();
            }

            if (state == ControlState.PickCave)
            {
                view.DrawPickCave(MapForPiсk[numPickCave].graph, MapForPiсk[numPickCave].isActive, numPickCave, numDiff, seed);
            }
            if (time > 0)
            {
                view.DrawText((1000 / time).ToString(), 5, 5, 10, "Arial", Color.White);
            }
            if (score != null)
            {
                score.TickTime();
                score.Draw(view.Graphics);
            }
        }
 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();
         }
     }
 }