public StarTrekGame(Random random) { _enterprise = new Enterprise(); _random = random; }
private void Initialize() { for (int i = 1; i <= 20; i++) { Console.WriteLine(); } Console.WriteLine(" STAR TREK "); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.Write("ENTER 1 OR 2 FOR INSTRUCTIONS (ENTER 2 TO PAGE) "); var instructionsCmd = ReadInteger(); if (1 == instructionsCmd || 2 == instructionsCmd) { PrintInstructions(2 == instructionsCmd); } Console.WriteLine(); Console.Write("ENTER SEED NUMBER "); var seedIter = ReadInteger(); seedIter = Math.Abs(seedIter); Console.WriteLine("INITIALIZING..."); for (int i = 0; i <= seedIter; i++) { _random.NextDouble(); } Console.WriteLine(); _enterprise = new Enterprise(); var date = (int)(_random.NextDouble() * 20 + 20) * 100; _currentDate = new Stardate(date); //_291: _T[1] = date; //_300: _T[2] = 30; D = 0; K = _enterprise.Engery; M = _enterprise.Torpedoes; _S[4] = 200; Q = 0; _Q[1] = (int)(_random.NextDouble() * 8) + 1; _Q[2] = (int)(_random.NextDouble() * 8) + 1; _S[1] = (int)(_random.NextDouble() * 8) + 1; _S[2] = (int)(_random.NextDouble() * 8) + 1; var position = new MapCoordinates((int)_Q[1], (int)_Q[2], (int)_S[1], (int)_S[2]); _enterprise.Position = position; _410: // C array numbers in X,Y notation/display _420: // dir 1 = X+1,Y right _421 : _C[1, 1] = 1; _422 : _C[1, 2] = 0; _423: // dir 2 = X+1,Y-1 right and up _424 : _C[2, 1] = 1; _425 : _C[2, 2] = -1; _426: // dir 3 = X, Y-1 up _427 : _C[3, 1] = 0; _428 : _C[3, 2] = -1; _429: // dir 4 = X-1,Y-1 left and up _430 : _C[4, 1] = -1; _431 : _C[4, 2] = -1; _432: // dir 5 = X-1,Y left _433 : _C[5, 1] = -1; _434 : _C[5, 2] = 0; _435: // dir 6 = X-1,Y+1 left and down _436 : _C[6, 1] = -1; _437 : _C[6, 2] = 1; _438: // dir 7 = X,Y+1 down _439 : _C[7, 1] = 0; _440 : _C[7, 2] = 1; _441: // dir 8 = X+1,Y+1 right and down _442 : _C[8, 1] = 1; _443 : _C[8, 2] = 1; _444: // dir 9 = same as dir 1 _445 : _C[9, 1] = 1; _446 : _C[9, 2] = 0; _450 : Fill(_D, 0); _490 : _B[2] = 0; _491 : _P[3] = 0; for (int i = 1; i <= 8; i++) { for (int j = 1; j <= 8; j++) { _520 : F = _random.NextDouble(); _530 : if (F > .98) { goto _580; } _540 : if (F > .95) { goto _610; } _550 : if (F > .8) { goto _640; } _560 : _P[1] = 0; _570 : goto _660; _580 : _P[1] = 3; _590 : _P[3] = _P[3] + 3; _600 : goto _660; _610 : _P[1] = 2; _620 : _P[3] = _P[3] + 2; _630 : goto _660; _640 : _P[1] = 1; _650 : _P[3] = _P[3] + 1; _660 : F = _random.NextDouble(); _670 : if (F > .96) { goto _700; } _680 : _B[1] = 0; _690 : goto _720; _700 : _B[1] = 1; _710 : _B[2] = _B[2] + 1; _720 : _S[3] = (int)(_random.NextDouble() * 8 + 1); _730 : _G[i, j] = _P[1] * 100 + _B[1] * 10 + _S[3]; _740 : _Z[i, j] = 0; _750 :; } } _770 : _P[2] = _P[3]; _775 : if (_B[2] <= 0 || _P[3] <= 0) { goto _490; } Console.Write("YOU MUST DESTROY {0} KINGONS IN {1} STARDATES WITH {2} STARBASE", _P[3], TIME_LIMIT, _B[2]); _791 : if (_B[2] == 1) { goto _793; } _792 : Console.Write("S"); _793 : Console.WriteLine(); _800 : Console.WriteLine(); _810 : _P[1] = 0; _811 : _B[1] = 0; _812 : _S[3] = 0; _820 : _Q[1] = Math.Min(8, Math.Max(1, _Q[1])); _Q[2] = Math.Min(8, Math.Max(1, _Q[2])); _S[1] = Math.Min(8, Math.Max(1, _S[1])); _S[2] = Math.Min(8, Math.Max(1, _S[2])); _830 : X = _G[(int)_Q[1], (int)_Q[2]] * 1.00000E-02; //X = _G[_enterprise.Position.Quadrant.X, _enterprise.Position.Quadrant.Y] * 1.00000E-02; _840 : _P[1] = (int)X; _850 : _B[1] = (int)((X - _P[1]) * 10); _860 : _S[3] = _G[(int)_Q[1], (int)_Q[2]] - (int)(_G[(int)_Q[1], (int)_Q[2]] * .1) * 10; //_S[3] = _G[_enterprise.Position.Quadrant.X, _enterprise.Position.Quadrant.Y] // - (int)(_G[_enterprise.Position.Quadrant.X, _enterprise.Position.Quadrant.Y] * .1) * 10; _870 : if (_P[1] == 0) { goto _910; } _880 : if (_enterprise.Shields > 200) { goto _910; } _890 : Console.WriteLine("COMBAT AREA CONDITION RED"); _900 : Console.WriteLine(" SHIELDS DANGEROUSLY LOW"); _910 : Fill(_K, 0); for (int i = 1; i <= 3; i++) { _K[i, 3] = 0; } _942: // A[x,y]: _943: // 0=" " _944: // 1="<*>" _945: // 2="+++" _946: // 3=">!<" _947: // 4=" * " _950 : Fill(_A, 0); _1000 : _A[(int)(_S[1] + .5), (int)(_S[2] + .5)] = 1; _1020 : for (I = 1; I <= (int)_P[1]; I += 1) { _1030 : _5380(); _1040 : _A[(int)F, (int)G] = 2; _1080 : _K[(int)I, 1] = F; _1090 : _K[(int)I, 2] = G; _1100 : _K[(int)I, 3] = _S[4]; _1110 :; } _1120 : for (I = 1; I <= (int)_B[1]; I += 1) { _1130 : _5380(); _1140 : _A[(int)F, (int)G] = 3; _1180 :; } _1190 : for (I = 1; I <= (int)_S[3]; I += 1) { _1200 : _5380(); _1210 : _A[(int)F, (int)G] = 4; _1250 :; } this.ShortRangeScan(); }