Esempio n. 1
0
        public void SavePlayerSlots(GameDatabase db)
        {
            List <PlayerClientInfo> list = db.GetPlayerClientInfos().ToList <PlayerClientInfo>();

            foreach (PlayerSetup player in this.Players)
            {
                PlayerSetup playerSetup = player;
                if (!playerSetup.AI)
                {
                    PlayerClientInfo playerClientInfo1 = list.FirstOrDefault <PlayerClientInfo>((Func <PlayerClientInfo, bool>)(x => x.PlayerID == playerSetup.databaseId));
                    if (playerClientInfo1 != null)
                    {
                        if (playerClientInfo1.UserName != playerSetup.Name)
                        {
                            playerClientInfo1.UserName = playerSetup.Name;
                            db.UpdatePlayerClientInfo(playerClientInfo1);
                        }
                    }
                    else
                    {
                        PlayerClientInfo playerClientInfo2 = new PlayerClientInfo()
                        {
                            PlayerID = playerSetup.databaseId,
                            UserName = playerSetup.Name
                        };
                        list.Add(playerClientInfo2);
                        db.InsertPlayerClientInfo(playerClientInfo2);
                    }
                }
            }
        }
Esempio n. 2
0
        public void SetEmpireColor(int slot, int?empireColorId)
        {
            int?nullable1;

            if (empireColorId.HasValue)
            {
                nullable1 = empireColorId;
                int num1 = -1;
                if (!(nullable1.GetValueOrDefault() == num1 & nullable1.HasValue))
                {
                    nullable1 = empireColorId;
                    int?empireColor = this.Players[slot].EmpireColor;
                    if (nullable1.GetValueOrDefault() == empireColor.GetValueOrDefault() & nullable1.HasValue == empireColor.HasValue)
                    {
                        this.AvailablePlayerFeatures.EmpireColors.Take(empireColorId.Value);
                        return;
                    }
                    if (this.AvailablePlayerFeatures.EmpireColors.IsTaken(empireColorId.Value))
                    {
                        return;
                    }
                    empireColor = this.Players[slot].EmpireColor;
                    if (empireColor.HasValue)
                    {
                        GrabBag <int> empireColors = this.AvailablePlayerFeatures.EmpireColors;
                        empireColor = this.Players[slot].EmpireColor;
                        int num2 = empireColor.Value;
                        empireColors.Replace(num2);
                    }
                    this.AvailablePlayerFeatures.EmpireColors.Take(empireColorId.Value);
                    this.Players[slot].EmpireColor = new int?(empireColorId.Value);
                    return;
                }
            }
            PlayerSetup player = this.Players[slot];

            nullable1 = new int?();
            int?nullable2 = nullable1;

            player.EmpireColor = nullable2;
        }