Beispiel #1
0
        //Add Timer

        public void DecreaseTime(Object o)
        {
            Sdl.SDL_Color black = new Sdl.SDL_Color(255, 255, 255);
            Sdl.SDL_Color white = new Sdl.SDL_Color(0, 0, 0);
            if (characterA.Lives > 0)
            {
                characterA.Time--;
                textTimer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "TIME: " + characterA.Time, black);
            }
            else if (characterB.Lives > 0)
            {
                characterB.Time--;
                textTimer = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "TIME: " + characterB.Time, black);
            }
            else
            {
                string       line;
                StreamReader input = File.OpenText("hiscore.dat");
                line = input.ReadLine();
                string[]   info = line.Split(':');
                addhiscore num  = new addhiscore();
                info       = line.Split(':');
                num.name   = info[0];
                num.points = int.Parse(info[1]);

                if (points > num.points)
                {
                    top = true;
                    input.Close();
                }

                if (top == true) //Bool to activate/deactivate de HiScore Screen
                {
                    HiScore();
                    while (hardware.KeyPress() != Hardware.KEY_SPC)
                    {
                        ;
                    }
                }

                Image imgGameOver;
                imgGameOver = new Image("images/GameOverImage.png", 1200, 740);
                imgGameOver.MoveTo(0, 0);
                hardware.DrawImage(imgGameOver);
                hardware.UpdateScreen();
                textSpace = SdlTtf.TTF_RenderText_Solid(font.GetFontType(), "PRESS SPACE TO CONTINUE...", white);
                while (hardware.KeyPress() != Hardware.KEY_SPC)
                {
                    ;
                }
            }
        }
Beispiel #2
0
        //CLASS HI-SCORE VERSIONS
        //V 0.05 - Miguel Pastor (Added Point Screen Class)
        //V 0.01 - Miguel Pastor (Empty Skeleton)

        private void HiScore()
        {
            List <GameScreen> Top10 = new List <GameScreen>();
            Image             imgHiscore;

            audio.AddMusic("audio/[PointScreen].mp3");
            imgHiscore = new Image("images/backHiscore.gif", 1200, 940);
            imgHiscore.MoveTo(0, 0);
            hardware.DrawImage(imgHiscore);
            hardware.UpdateScreen();
            audio.PlayMusic(0, -1);

            if (!File.Exists("hiscore.dat"))
            {
                StreamWriter output = File.AppendText("hiscore.dat");
                output.Close();
            }
            else
            {
                try
                {
                    StreamWriter output = File.AppendText("hiscore.dat");
                    StreamReader input  = File.OpenText("hiscore.dat");
                    string       line;
                    int          ten = 10;


                    do
                    {
                        ;
                        addhiscore num = new addhiscore();
                        line = input.ReadLine();
                        string[] info = line.Split(':');
                        num.name   = info[0];
                        info[0]    = Console.ReadLine();
                        num.points = int.Parse(info[1]);
                        hardware.ClearScreen();

                        if (line != null)
                        {
                            info       = line.Split(':');
                            num.name   = info[0];
                            num.points = int.Parse(info[1]);

                            while (line != null)
                            {
                                num.last = int.Parse(info[2]);
                                if (num.points > num.last)
                                {
                                    output.WriteLine(num.name, ":", num.points);
                                }

                                output.WriteLine(line.ToUpper());
                            }


                            ten--;
                        }
                    }while ((line != null) || (ten == 0));

                    input.Close();
                    output.Close();
                }
                catch (PathTooLongException PE)
                {
                    throw PE;
                }
                catch (IOException IO)
                {
                    throw IO;
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            audio.StopMusic();
        }