예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (gameOver)
        {
            return;
        }
        time += Time.deltaTime;
        float   gameProgress   = time / timeLimit;
        Vector3 newEulerAngles = sunSource.transform.eulerAngles;

        newEulerAngles.x = Mathf.Lerp(initialAngle, targetAngle, gameProgress);
        sunSource.transform.eulerAngles = newEulerAngles;
        float maxScore = PlayerScores.GetMaxScore();

        for (int i = 0; i < stars.Length; i++)
        {
            float newProximity = maxScore > 0 ? (PlayerScores.GetScore(i) / maxScore) * gameProgress : 0;
            stars[i].GetComponent <StarPosition>().UpdateProximity(newProximity);
        }
        if (gameProgress >= 1 && !gameOver)
        {
            gameOver = true;
            IngameGUI.Instance.ShowFinalScreen();
        }
        int secondsLeft = Mathf.FloorToInt(timeLimit - time);

        if (secondsLeft > 0 && secondsLeft < 11 && countdown > secondsLeft)
        {
            countdown = secondsLeft;
            IngameGUI.Instance.CountdownNumber(countdown);
        }
    }
        public GamesSummary ComputeGamesSummary(List <MatchDto> matchHistory, long accountId)
        {
            GamesSummary gamesSummary  = new GamesSummary();
            DamageDealt  byPlayer      = new DamageDealt();
            DamageDealt  highestInTeam = new DamageDealt();
            PlayerScores playerScores  = new PlayerScores();

            ScoreService scoreService = new ScoreService();

            DamageService damageService = new DamageService();

            matchHistory.ForEach(delegate(MatchDto match)
            {
                int participantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);
                int teamId        = Retrieve.PlayerTeamId(match.participants, participantId);

                Boolean hasWon = HasWon(match.participants, participantId);

                playerScores.ReplaceScores(scoreService.GetPlayerScoresForCurrentMatch(match.participants, participantId));

                byPlayer.ReplaceDamage(damageService.ComputeDamageDealtByPlayer(match.participants, participantId));
                highestInTeam.ReplaceDamage(damageService.GetHighestDamageDealerInTeam(match.participants, teamId, participantId));
                gamesSummary.Add(
                    HasCarried(byPlayer, highestInTeam, hasWon) ? 1 : 0,
                    HasFed(playerScores) ? 1 : 0,
                    HasGottenCarried(playerScores, byPlayer, highestInTeam, hasWon) ? 1 : 0
                    );
            });

            return(gamesSummary);
        }
예제 #3
0
        // PRAGMA MARK - Public Interface
        public void Init(Player player)
        {
            player_ = player;

            var inGamePlayerView = ObjectPoolManager.Create <InGamePlayerView>(GamePrefabs.Instance.InGamePlayerViewPrefab, parent: playerViewContainer_);

            inGamePlayerView.InitWith(player, enableNudge: true);

            statsContainer_.Init(player_);
            statsContainer_.gameObject.SetActive(true);

            int   rank      = PlayerScores.GetRankFor(player_);
            Color rankColor = Color.clear;

            if (rank == 1)
            {
                rankColor = ColorUtil.HexStringToColor("EAD94FFF");
            }
            else if (rank == 2)
            {
                rankColor = ColorUtil.HexStringToColor("B6B6B6FF");
            }
            else if (rank == 3)
            {
                rankColor = ColorUtil.HexStringToColor("A79376FF");
            }
            else
            {
                rankColor = ColorUtil.HexStringToColor("B08A76FF");
            }
            rankBannerImage_.color = rankColor;
            rankText_.Text         = string.Format("{0}", rank);

            crownObject_.SetActive(PlayerScores.Winner == player_);
        }
예제 #4
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/playerScores.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/playerScores.dat", FileMode.Open);
            PlayerScores    data = (PlayerScores)bf.Deserialize(file);


            P1SCR         = data.P1SCR;
            P2SCR         = data.P2SCR;
            P1Boost       = data.P1Boost;
            P2Boost       = data.P2Boost;
            ArenaNum      = data.ArenaNum;
            VehicleNum    = data.VehicleNum;
            VehicleNumTwo = data.VehicleNumTwo;
            file.Close();
            StartMenu.GetComponent <StartMenuScript>().UpdateScoreText();
            Debug.Log("Loaded");
        }
        else
        {
            FirstPlay();
            Debug.Log("LOAD_Saved");
        }
    }
예제 #5
0
        public void UpdatePlayers()
        {
            foreach (var playerInfo in Players)
            {
                if (playerInfo.Id == 0)
                {
                    playerInfo.Id = Players.Select(x => x.Id).Max() + 1;
                }
            }

            var medianScore = !PlayerScores.Any() ? 0 : PlayerScores.Values.Aggregate(0, (x, y) => x + y) / PlayerScores.Count;

            var removedPlayers = PlayerScores.Keys.ToList();

            foreach (var playerInfo in Players)
            {
                if (!PlayerScores.ContainsKey(playerInfo.Id))
                {
                    PlayerScores.Add(playerInfo.Id, medianScore);
                }
                else
                {
                    removedPlayers.Remove(playerInfo.Id);
                }
            }

            foreach (var removedPlayer in removedPlayers)
            {
                PlayerScores.Remove(removedPlayer);
            }
        }
예제 #6
0
    public void OnPlayerScoresChanged()
    {
        Debug.Log("OnPlayerScoreChanged");
        PlayerScores playerScores = roomPropertyAgent.GetPropertyWithName("PlayerScores").GetValue <PlayerScores>();

        Debug.Log(playerScores);

        if (playerScores != null && playerScores.scores != null)
        {
            foreach (Score s in playerScores.scores)
            {
                if (s.score >= 3)
                {
                    if (s.playerRemoteId == NetworkClient.Instance.PlayerId)
                    {
                        winnerPanel.gameObject.SetActive(true);
                    }
                    else
                    {
                        gameOverPanel.gameObject.SetActive(true);
                    }
                    break;
                }
            }
        }
    }
예제 #7
0
        public static void IsInTheTop(int totalScore)
        {
            string path  = "../../Imports/HighScores.txt";
            int    score = totalScore;
            string name  = Reader.ReadNameCharLimit(20);

            string[] highScores = File.ReadAllLines(path);

            PlayerScores[] arr    = new PlayerScores[4];
            PlayerScores   holder = new PlayerScores();

            holder.Name  = name;
            holder.Score = score;
            arr[3]       = holder;

            for (int i = 0; i < highScores.Length; i++)
            {
                holder       = new PlayerScores();
                holder.Name  = highScores[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1];
                holder.Score = int.Parse(highScores[i].Split()[0]);
                arr[i]       = holder;
            }

            arr = arr.OrderByDescending(x => x.Score).ToArray();

            string[] newHighScores = new string[]
            {
                arr[0].Score + " " + arr[0].Name,
                arr[1].Score + " " + arr[1].Name,
                arr[2].Score + " " + arr[2].Name,
                arr[3].Score + " " + arr[3].Name
            };

            File.WriteAllLines(path, newHighScores.Take(3));
        }
예제 #8
0
    public void SaveScore()
    {
        initialTextField = FindObjectOfType <TMP_InputField>();
        if (initialTextField.text.Length == 3)
        {
            var initials = initialTextField.text.ToString();

            PlayerScore playerScore = new PlayerScore();
            playerScore.initials = initials;
            playerScore.score    = score;

            scores.Add(playerScore);
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Create(Application.persistentDataPath + "/playerScores.dat");

            PlayerScores playerScores = new PlayerScores();
            playerScores.scores = scores;

            bf.Serialize(file, playerScores);
            file.Close();

            LoadHighScores();

            Debug.Log("Saved!");
            saveScoreButton.SetActive(false);
        }
    }
예제 #9
0
        private void HandleSpawnedPlayerRemoved()
        {
            int?teamIndexLeft = null;

            for (int i = 0; i < teams_.Length; i++)
            {
                HashSet <Player> team      = teams_[i];
                bool             teamAlive = team.Any(p => PlayerSpawner.IsAlive(p));
                if (teamAlive)
                {
                    // if multiple teams still alive
                    if (teamIndexLeft != null)
                    {
                        return;
                    }

                    teamIndexLeft = i;
                }
            }

            Finish();
            // possible that no teams are left alive
            if (teamIndexLeft != null)
            {
                foreach (Player player in teams_[(int)teamIndexLeft].Where(p => PlayerSpawner.IsAlive(p)))
                {
                    PlayerScores.IncrementPendingScoreFor(player);
                }
            }
        }
예제 #10
0
        public async Task <PlayersWithScoresDto> GetPlayerWithScores(int id)
        {
            var player = await _content.Players.FirstOrDefaultAsync(p => p.PlayerId == id);

            PlayersWithScoresDto dto = new PlayersWithScoresDto();

            dto.FirstName     = player.FirstName;
            dto.Id            = player.Id;
            dto.PlayerId      = player.PlayerId;
            dto.PositionOne   = player.PositionOne;
            dto.PositionTwo   = player.PositionTwo;
            dto.PositionThree = player.PositionThree;
            dto.Price         = player.Price;
            dto.Surname       = player.Surname;
            dto.Team          = player.Team;

            //  Now need to get the average
            dto.AverageScore = GetAverageScoreForPlayer(id);
            dto.TotalScore   = GetTotalScoreForPlayer(id);

            PlayerScores lastPS = _content.PlayerScores.OrderByDescending(x => x.GameDate).FirstOrDefault(p => p.PlayerId == player.PlayerId);

            if (lastPS != null)
            {
                dto.LastScore = lastPS.Score;
            }
            else
            {
                dto.LastScore = 0;
            }


            return(dto);
        }
예제 #11
0
    public void PlayerScored(string playerId)
    {
        // Read the current value of the "PlayerScores" SyncProperty.
        PlayerScores playerScores = roomPropertyAgent.GetPropertyWithName("PlayerScores").GetValue <PlayerScores>();

        // Initialize the playerScores object.
        if (playerScores == null)
        {
            playerScores = new PlayerScores();
        }

        bool foundPlayerScore = false;

        // If player already have a score, increase it by 1.
        foreach (Score s in playerScores.scores)
        {
            if (s.playerRemoteId == playerId)
            {
                s.score++;
                foundPlayerScore = true;
            }
        }

        // If player has not scored yet, add a new score for the player and set its value to 1.
        if (!foundPlayerScore)
        {
            Score ps = new Score();
            ps.playerRemoteId = playerId;
            ps.score          = 1;
            playerScores.scores.Add(ps);
        }

        // Modify the "PlayerScores" SyncProperty
        roomPropertyAgent.Modify <PlayerScores>("PlayerScores", playerScores);
    }
예제 #12
0
    public void AddPlayerScore(string nick, int score)
    {
        PlayerScores ps;

        if (File.Exists("highscore"))
        {
            string jsonString = File.ReadAllText("highscore");
            if (jsonString == string.Empty)
            {
                ps = new PlayerScores();
            }
            else
            {
                ps = JsonUtility.FromJson <PlayerScores>(jsonString);
            }
        }
        else
        {
            File.WriteAllText("highsore", "");
            ps = new PlayerScores();
        }

        ps.playerScores.Add(new PlayerScore(nick, score));
        string json = JsonUtility.ToJson(ps);

        File.WriteAllText("highscore", json);
    }
예제 #13
0
    void Update()
    {
        if (health < 0)
        {
            // Add the # points to the *other* team
            PlayerScores.AddTeamScore(1 - team, pointsValue);

            if (GetComponent <PlayerTankForceMovement>() != null)
            {
                // Treat the player specially... since things can get a bit awkward otherwise

                // Any respawn / reassignment logic would need to happen here;
                GetComponent <PlayerRespawner>().enabled = true;

                health = 100; // So that the player doesn't keep adding score.

                CameraFollowPlayer cam = CameraFollowPlayer.GetCameraForPlayer(GetComponent <PlayerTankForceMovement>());
                if (cam == null)
                {
                    Debug.Log("Couldn't find camera for the player... awkward.");
                }                                                                                  // TIDYME: 2018-07-07 Use assertion
                cam.GetComponent <PlayerDeathCamera>().enabled = true;
            }
            else
            {
                // // added explosion effect
                // if (this.tag == "Tank") {
                //     var explosion : GameObject = Instantiate(Resources.Load("Explosion"), transform.position, transform.rotation);
                // }
                // var explosion : GameObject = Instantiate(Resources.Load("Explosion"), transform.position, transform.rotation) as GameObject;
                Destroy(gameObject);
            }
        }
    }
예제 #14
0
    public void LoadScores(PlayerScores highScoreEntry)
    {
        //Loading scores for leaderBoard
        var rowString = Instantiate(RowString);

        rowString.transform.parent     = ScrollContent.transform;
        rowString.transform.localScale = new Vector3(1f, 1f);

        int    rank = ScrollContent.transform.childCount - 1;
        string rankString;

        //defining ranking
        switch (rank)
        {
        default: rankString = rank + "TH"; break;

        case 1:
            rankString = "1ST";
            break;

        case 2:
            rankString = "2ND";
            break;

        case 3:
            rankString = "3RD";
            break;
        }

        rowString.gameObject.GetComponent <RowStringContent>().place.text = rankString;
        rowString.gameObject.GetComponent <RowStringContent>().time.text  = highScoreEntry.time.ToString("00.0");
        rowString.gameObject.GetComponent <RowStringContent>().name.text  = highScoreEntry.name;
        rowString.SetActive(true);
    }
예제 #15
0
        public CreateInputModel CreatePlayerScore(CreateInputModel model, string userIdentity)
        {
            var member = _memberRepository.FindBy(x => x.EmailAddress == userIdentity).
                         SingleOrDefault();

            var reservation = _reservationRepository.GetWithGolfCourse(model.ReservationID);

            var golfCourse = reservation.TeeTime.GolfCourse;

            var calculatedScore = model.Score - (golfCourse.Rating / golfCourse.Slope * 113);



            var playerScoreModel = new PlayerScores
            {
                ReservationID = model.ReservationID,
                MemberID      = member.ID,
                Score         = calculatedScore,
                HoleId        = model.HoleID,
                HandicapId    = model.HandicapID,
                DateCreated   = DateTime.UtcNow,
                DatePlayed    = model.DatePlayed,
            };

            _playerScoreRepository.Add(playerScoreModel);
            _playerScoreRepository.SaveChanges();

            return(model);
        }
예제 #16
0
        public bool AddPlayerScore(PlayerScore NewPlayerScore)
        {
            PlayerScores PlayerScoreManager = new PlayerScores();
            bool         confirmation;

            confirmation = PlayerScoreManager.AddPlayerScore(NewPlayerScore);
            return(confirmation);
        }
예제 #17
0
        public int AddGameScore(GolfGame newScoreCard)
        {
            int          code;
            PlayerScores scoreManager = new PlayerScores();

            code = scoreManager.InsertGolfGame(newScoreCard, "", "");
            return(code);
        }
예제 #18
0
        public string GetMemberName(int memberNumber)
        {
            string       name;
            PlayerScores teeTimeManager = new PlayerScores();

            name = teeTimeManager.GetMemberName(memberNumber, "", "");
            return(name);
        }
예제 #19
0
        public decimal GetHandicapIndex(int memberNumber)
        {
            decimal      handicap;
            PlayerScores teeTimeManager = new PlayerScores();

            handicap = teeTimeManager.GetHandicap(memberNumber, "", "");
            return(handicap);
        }
예제 #20
0
        public List <int> GetLast20Scores(int memberNumber)
        {
            List <int>   itemList       = new List <int>();
            PlayerScores teeTimeManager = new PlayerScores();

            itemList = teeTimeManager.GetLast20Scores(memberNumber, "", "");
            return(itemList);
        }
예제 #21
0
        public List <HandicapReport> GetHandicapReport(DateTime Time)
        {
            PlayerScores          PlayerScoreManager = new PlayerScores();
            List <HandicapReport> handicapReport     = new List <HandicapReport>();

            handicapReport = PlayerScoreManager.GetHandicapReport(Time);
            return(handicapReport);
        }
예제 #22
0
 //Mesh meshCollider;
 void Start()
 {
     mesh                         = GetComponent <MeshFilter>().sharedMesh;
     myCollider                   = GetComponent <Collider>();
     myMat                        = GetComponent <Renderer>().material;
     characterMovement            = GetComponent <CharacterMovement>();
     playerScores                 = GetComponent <PlayerScores>();
     playerScores.ThisPlayerScore = 25;
 }
예제 #23
0
        public PlayerScores ComputePlayerScore(List <MatchDto> matches, long accountId)
        {
            PlayerScores playerScores = ComputePlayerKDA(matches, accountId);

            playerScores.averageKda         = ComputeAverageKda(playerScores);
            playerScores.averageCsPerMinute = ComputeAverageCreeps(matches, accountId);
            playerScores.averageCreeps      = ComputeAverageCreepsCount(matches, accountId);
            return(playerScores);
        }
예제 #24
0
    public void AddMedal(AwardedMedalReadModel awardedMedal)
    {
        if (PlayerScores.ContainsKey(awardedMedal.Player) == false)
        {
            throw new ApplicationException($"No player with id {awardedMedal.Player} found");
        }

        PlayerScores[awardedMedal.Player].AddMedal(awardedMedal);
    }
예제 #25
0
    public static void SaveHighScore(string gamemode, float highScore)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/playerScores.bin";
        FileStream      stream    = new FileStream(path, FileMode.Create);
        PlayerScores    scores    = new PlayerScores(gamemode, highScore);

        formatter.Serialize(stream, scores);
        stream.Close();
    }
예제 #26
0
        private void CheckIfPlayerWon(Player player)
        {
            float percentage = GetPercentageScoreFor(player);

            if (percentage >= 1.0f)
            {
                PlayerScores.IncrementPendingScoreFor(player);
                Finish();
            }
        }
예제 #27
0
    private void SetupPlayerScores(Player player, PlayerScores playerScoreDetails)
    {
        InitPlayerLabel(player, playerScoreDetails);
        UpdateScoreDisplay(player, playerScoreDetails);

        if (!_playersScores.Contains(playerScoreDetails))
        {
            _playersScores.Add(playerScoreDetails);
        }
    }
예제 #28
0
        public async Task LynxTitanTest()
        {
            var lynxTitan = await PlayerScores.FindAsync("Lynx Titan", Mode.Classic);

            if (lynxTitan.Overall.Rank == 1)
            {
                Assert.Pass();
            }

            Assert.Fail();
        }
예제 #29
0
        protected override void OnStateExited()
        {
            if (view_ != null)
            {
                ObjectPoolManager.Recycle(view_);
                view_ = null;
            }

            PlayerScores.Clear();
            StatsManager.ClearAllStats();
        }
예제 #30
0
        private void AddPlayerScoreToList(Player player)
        {
            PlayerScore item = new PlayerScore();

            item.PlayerScoreId = Guid.NewGuid().ToString();
            item.MarkerId      = Preferences.Get("PlayerId", null);
            item.RoundId       = Round.RoundId;
            item.HCAP          = player.LastHCAP;
            item.PlayerId      = player.PlayerId;
            PlayerScores.Add(item);
        }
예제 #31
0
        /// <summary>
        /// Metoden tar hand om valen inom menyval 2 (Highscores)
        /// </summary>
        /// <param name="playerDB"></param>
        private static void HighScore(PlayerScores playerDB)
        {

            var svar = MenuHelper.AskFromAlternative("Väj vad du vill göra",
                new List<string>() { "sök på namn", "Visa topplista" });

            switch (svar)
            {
                case 0:
                    Console.Clear();
                    var answ = MenuHelper.Ask("Skriv namn som du vill söka på");
                    var result = playerDB.SearchPlayers(answ);
                    for (int i = 0; i < result.Length; i++)
                    {
                        Console.WriteLine("{0}. {1} : {2} : {3}", i + 1, result[i].PlayerName, result[i].Score, result[i].Game);
                    }
                    break;
                case 1:
                    Console.Clear();
                    Console.WriteLine("===================== Top 5 Highscores ==================");
                    var all = playerDB.GetAllPlayerScores();
                    for (int i = 0; i < all.Length; i++)
                    {
                        Console.WriteLine("{0}. {1} : {2} : {3}", i + 1, all[i].PlayerName, all[i].Score, all[i].Game);
                    }
                    break;

            }


        }
예제 #32
0
        /// <summary>
        /// Metoden tar hand om Menyvalen som programmet erbjuder
        /// Menyvalen hanteras med en switch case 
        /// </summary>
        private static void MainMeny()
        {
            //Instaniserar databasen för att ha samma conext genom hela applicationen.
            var playerDB = new PlayerScores();

            var running = true;
            while (running)
            {

                Console.Clear();
                Console.WriteLine(" =======================================================");
                Console.WriteLine(" =========           Welcome Player!           =========");
                Console.WriteLine(" =======================================================");

                Console.WriteLine(" =========     Välj ett alternativen nedan:    =========");
                Console.WriteLine(" =======================================================");
                Console.WriteLine(" ");
                Console.WriteLine(" 1. Spela   2. Visa Highscore    3. Avsluta ");
                var menyVal = 0;
                while (menyVal < 1 || menyVal > 3)
                {
                    if (!int.TryParse(Console.ReadLine(), out menyVal))
                    {
                        Console.Out.WriteLine("Det är inget menyval, skriv med menysiffra");
                        
                    }
                }

                
                switch (menyVal)
                {
                    case 1:
                        Console.Clear();
                        MenyVal1(playerDB);
                        break;

                    case 2:
                        HighScore(playerDB);
                        Console.ReadKey();

                        break;

                    case 3:
                        running = false;
                        EndProgram();
                        break;
                    default:
                        Console.Clear();
                        Console.WriteLine(" ===================================");
                        Console.WriteLine(" Du angav fel menyval, försök igen!");
                        Console.WriteLine(" ===================================");
                        Console.ReadKey();

                        MainMeny();
                        break;

                }
            }

        }
예제 #33
0
    public static void Main()
    {
        string command = string.Empty;
        char[,] gameField = CreateGameField();
        char[,] theMines = PutTheMines();
        int counter = 0;
        bool mineExploded = false;
        List<PlayerScores> champions = new List<PlayerScores>(6);
        int row = 0;
        int column = 0;
        bool startGame = true;
        const int MAXTURNS = 35;
        bool startNextLevel = false;

        do
        {
            if (startGame)
            {
                Console.WriteLine("Let's play “MineSweeper”. Try your luck to find fields without mines." +
                "\nCommand \"top\" shows the rating\n\"restart\" start new game\n\"exit\" stop the game and bye!");
                DisplayGameBoard(gameField);
                startGame = false;
            }

            Console.Write("Enter row and column: ");
            command = Console.ReadLine().Trim();
            if (command.Length >= 3)
            {
                if (int.TryParse(command[0].ToString(), out row) &&
                int.TryParse(command[2].ToString(), out column) &&
                    row <= gameField.GetLength(0) && column <= gameField.GetLength(1))
                {
                    command = "turn";
                }
            }

            switch (command)
            {
                case "top":
                    Rating(champions);
                    break;
                case "restart":
                    gameField = CreateGameField();
                    theMines = PutTheMines();
                    DisplayGameBoard(gameField);
                    mineExploded = false;
                    startGame = false;
                    break;
                case "exit":
                    Console.WriteLine("Chao, Chao, Chao!");
                    break;
                case "turn":
                    if (theMines[row, column] != '*')
                    {
                        if (theMines[row, column] == '-')
                        {
                            YourTurn(gameField, theMines, row, column);
                            counter++;
                        }

                        if (counter == MAXTURNS)
                        {
                            startNextLevel = true;
                        }
                        else
                        {
                            DisplayGameBoard(gameField);
                        }
                    }
                    else
                    {
                        mineExploded = true;
                    }

                    break;
                default:
                    Console.WriteLine("\nError! Invalid command.\n");
                    break;
            }

            if (mineExploded)
            {
                DisplayGameBoard(theMines);
                Console.Write("Hrrrrr! Died heroically with {0} points. " + " Enter the nickname: ", counter);
                string nickName = Console.ReadLine();
                PlayerScores personalScores = new PlayerScores(nickName, counter);
                if (champions.Count < 5)
                {
                    champions.Add(personalScores);
                }
                else
                {
                    for (int i = 0; i < champions.Count; i++)
                    {
                        if (champions[i].Scores < personalScores.Scores)
                        {
                            champions.Insert(i, personalScores);
                            champions.RemoveAt(champions.Count - 1);
                            break;
                        }
                    }
                }

                champions.Sort((PlayerScores player1, PlayerScores player2) => player2.Name.CompareTo(player1.Name));
                champions.Sort((PlayerScores player1, PlayerScores player2) => player2.Scores.CompareTo(player1.Scores));
                Rating(champions);

                gameField = CreateGameField();
                theMines = PutTheMines();
                counter = 0;
                mineExploded = false;
                startGame = true;
            }

            if (startNextLevel)
            {
                Console.WriteLine("\nBRAVOOOOS! 35 holes open without a drop of blood cells.");
                DisplayGameBoard(theMines);
                Console.WriteLine("Enter your name, brother: ");
                string currentPlayer = Console.ReadLine();
                PlayerScores currentPlayerScores = new PlayerScores(currentPlayer, counter);
                champions.Add(currentPlayerScores);
                Rating(champions);
                gameField = CreateGameField();
                theMines = PutTheMines();
                counter = 0;
                startNextLevel = false;
                startGame = true;
            }
        }
        while (command != "exit");
        Console.WriteLine("Made in Bulgaria - Wowhahahaha!");
        Console.WriteLine("Gooooooooooooo.");
        Console.Read();
    }
예제 #34
0
        /// <summary>
        /// Metoden tar hand om alternativen inom menyval 1 (spela)
        /// kontrolleras med en switch case
        /// </summary>
        
        public static void MenyVal1(PlayerScores playerDB)
        {
            Console.Clear();
            Console.WriteLine(" =================================");
            Console.WriteLine(" Välj ett av följande alternativ: ");
            Console.WriteLine(" =================================" + Environment.NewLine);
            Console.WriteLine(" 1. Spela ");
            Console.WriteLine(" 2. Se end credit ");


            int menyVal1 = 0;


            while (menyVal1 < 1 || menyVal1 > 2)
            {
                if (!int.TryParse(Console.ReadLine(), out menyVal1))
                {
                    Console.Out.WriteLine("Du skrev fel, välj mellan siffrorna på menyvalet! ");
                    
                  
                }
            }


            switch (menyVal1)
            {
                case 1:
                    Console.Clear();
                    Console.WriteLine(" ===========================");
                    Console.WriteLine("    Ange ett spelarnamn ");
                    Console.WriteLine(" ===========================" + Environment.NewLine);
                    Console.Write(" Namn:       ");
                    string playername = Console.ReadLine();
                    var newPlayer = new Player(playername);
                    Console.WriteLine(" Hej " + playername + ", vad vill du spela? (Svara 1 eller 2)");
                    Console.WriteLine("1. Tetris" + Environment.NewLine + "2. Snake ");
                    string gamechoice = Console.ReadLine();

                    if (gamechoice == "1")
                    {
                        newPlayer.Score = TetrisGame.Play();
                        newPlayer.Game = Player.GameType.Tetris;
                        playerDB.AddPlayer(newPlayer);
                    }
                    else if (gamechoice == "2")
                    {
                        newPlayer.Score = SnakeGame.Play();
                        newPlayer.Game = Player.GameType.Snake;
                        playerDB.AddPlayer(newPlayer);


                    }
                    else
                    {
                        Console.WriteLine(" Du matade in fel, försök igen!");

                        Console.ReadKey();
                        MenyVal1(playerDB);
                    }

                    break;

                case 2:
                    Console.Clear();
                    EndCredit.Start();

                    break;
               
                default:
                    Console.Clear();
                    Console.WriteLine(" ===================================");
                    Console.WriteLine(" Du angav fel menyval, försök igen!");
                    Console.WriteLine(" ===================================");
                    Console.ReadKey();

                    MenyVal1(playerDB);
                    break;

            }
        }