コード例 #1
0
ファイル: Graph.cs プロジェクト: Ron-Sun/GolfGame
        /// <summary>
        /// Player log while playing. Only last 6 swing.
        /// </summary>
        /// <param name="Sw"></param>
        public void DisplayLog(Swing Sw)
        {
            int line    = 52;
            int col     = 20;
            int lineEnd = Sw.Log.Count - 1;
            int i       = Sw.Log.Count - 6;

            if (i < 0)
            {
                i = 0;
            }
            for (; i <= lineEnd; i++)
            {
                WriteAt(Sw.Log.ElementAt(i), col, line++);
            }
        }
コード例 #2
0
ファイル: Graph.cs プロジェクト: Ron-Sun/GolfGame
        /// <summary>
        /// Player animation
        /// </summary>
        /// <param name="Sw"></param>
        public void PlayerAnimation(Swing Sw)
        {
            ConsoleColor tmp = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.DarkYellow;

            if (Sw.Club == 1)
            {
                DriverPlayerAnimation();
            }
            else
            {
                PutterPlayerAnimation();
            }
            Console.ForegroundColor = tmp;
        }
コード例 #3
0
ファイル: Graph.cs プロジェクト: Ron-Sun/GolfGame
        /// <summary>
        /// Help text.
        /// </summary>
        /// <param name="Sw"></param>
        public void HelpText(Swing Sw)
        {
            int    line = menuline;
            int    col  = menucolumn;
            string s    = "Ditt uppdrag är att få bollen i koppen " + Sw.DistanceToCup.ToString("n0") + " meter bort.          ";

            WriteAt(s, col, line++);
            WriteAt(@"                                                                   ", col, line++);
            WriteAt(@"Du har 2 klubbor att välja mellan. Driver samt putter.             ", col, line++);
            WriteAt(@"Driver slår bollen 10 gånger längre än puttern.                    ", col, line++);
            WriteAt(@"Du anger styrka samt vinkel på slaget och trycker Enter.           ", col, line++);
            WriteAt(@"Därefter tar naturkrafterna över.   Lycka till.                    ", col, line++);
            WriteAt(@"                                                                   ", col, line++);
            WriteAt(@"Ps. Slå inte långt över green, det finns vattnet i närheten.       ", col, line++);
            s = "Det är ett par " + Sw.Par.ToString() + " hål. Du får max " + Sw.MaxSwingNr.ToString() + " försök.          ";
            WriteAt(s, col, line++);
            WriteAt(@"         Tryck Enter när du läst klart.                            ", col, line++);

            // WriteAt(@"                                                                   ", col, line++);
            Console.ReadKey();
        }
コード例 #4
0
ファイル: Graph.cs プロジェクト: Ron-Sun/GolfGame
        /// <summary>
        /// Simple but fun trajectory routine. use sinwave to simulate angle and strength.
        /// </summary>
        /// <param name="Sw"></param>
        /// <param name="dist"></param>
        public void BallTrajectory(Swing Sw, double dist)        // Not pretty ... But it works ;-)
        {
            double x = 16; double y;
            int    oldx = 1; int oldy = 1;
            double sin = 3.2; double add = 0.033;
            double str = (double)Sw.Strengt;

            if (Sw.Club != driver)
            {
                str /= 10;
            }
            str /= 100;                         // Fit trajectory
            Console.CursorVisible = false;

            for (int i = 0; i < 100; i++)
            {
                x   += str;
                y    = Math.Sin(sin) * Sw.Angle / 4;
                sin += add; // 0.033;

                WriteAt(" ", oldx, oldy);
                WriteAt("*", Convert.ToInt32(x), 43 + Convert.ToInt32(y));
                oldx = Convert.ToInt32(x); oldy = 43 + Convert.ToInt32(y);


                if (Sw.DistanceToCup - dist < -50)   // Shout... Fore!
                {
                    Fore();
                    Thread.Sleep(10);
                    RemoveText();
                    Thread.Sleep(10);
                }
                else
                {
                    Thread.Sleep(20);
                }
            }
            WriteAt(" ", oldx, oldy);
        }
コード例 #5
0
ファイル: Graph.cs プロジェクト: Ron-Sun/GolfGame
        /// <summary>
        /// User Menu
        /// </summary>
        /// <param name="Sw"></param>
        public void Menu(Swing Sw)
        {
            int line = menuline;
            int col  = menucolumn;

            WriteAt(@"      Nuvarande golfklubba [        ]                              ", col, line++);
            WriteAt(@"                                                                   ", col, line++);
            WriteAt(@"      [ S ] Styrka på slag.    [    ]  1 - 100 styrka.             ", col, line++);
            WriteAt(@"      [ V ] Vinkel på slag.    [    ]  0 -  90 grader.             ", col, line++);
            WriteAt(@"      [ B ] Byt golfklubba.                                        ", col, line++);
            WriteAt(@"                                                                   ", col, line++);
            WriteAt(@"      [ H ] Hjälp.             Du är ... meter från flaggan.       ", col, line++);
            WriteAt(@"                               Du har gjort .. försök.             ", col, line++);
            WriteAt(@"                                                                   ", col, line++);
            WriteAt(@"      [ ? ]                    Tryck Enter för att slå dit slag.   ", col, line++);

            ShowStengthValue(Sw.Strengt);
            ShowAngleValue(Sw.Angle);
            ShowDistanceToCup(Sw.DistanceToCup);
            ShowSwingAttempts(Sw.SwingNr);
            ShowSwingDirection(Sw.SwingDirection);
            FlagDistanceAway(Sw.DistanceToCup);
            GolfClub(Sw.Club);
        }