private void createGame() { if(debug) {MessageBox.Show(playerList.Count.ToString()); } Cube c = new Cube(playerList); c.ShowDialog(); this.pRED = c.getPlayer(false); try { MessageBox.Show(pRED.getName()); }catch (NullReferenceException ex) { MessageBox.Show(ex.Message); } this.pBLU = c.getPlayer(true); try { MessageBox.Show(c.getPlayer(true).getName()); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message); } this.redAvatar.BackgroundImage = pRED.getAvatarAsImage(); this.redName.Text = pRED.getName(); this.bluAvatar.BackgroundImage = pBLU.getAvatarAsImage(); this.bluName.Text = pBLU.getName(); turn = c.getStarter(); }
public ChoosePlayerUI(List<Player> playerList, List<Bot> botList, Button bSender, Player p1, Player p2) { InitializeComponent(); this.senderButton = bSender; this.playerList = playerList; this.botList = botList; this.p1 = p1; this.p2 = p2; }
private void button2_Click(object sender, EventArgs e) { Console.WriteLine("DEBUG--in button getoggled"); Config con = new Config(); /*con.getPlayers();*/ List<Player> pList = new List<Player>(); Player tmP = new Player(textBox2.Text, Convert.ToChar(textBox1.Text), 0, 0, colorBtn.BackColor , button1.BackgroundImage); pList.Add(tmP); con.saveConfig(pList); }
private List<Player> parsePlayers(String unparsedConfig) { List<Player> playerList = new List<Player>(); String[] playersRaw = unparsedConfig.Split(';'); foreach (String playerRaw in playersRaw) { Player tmpPlayer; String[] playerMeta = playerRaw.Split('-'); String metaName = null; Char metaIcon = ' '; Image metaAvatar = null; Color metaColor = new Color(); uint metaWins = 0; uint metaLoses = 0; foreach (String metaRaw in playerMeta) { //public Player(String name, Char icon, Image avatar, uint wins, uint loses, Color color) { if (metaRaw.Contains("%N%")) { //Name metaName = metaRaw.Replace("%N%", ""); if(debug) {Console.WriteLine(metaName); } } else if (metaRaw.Contains("%I%")) { metaIcon = Convert.ToChar(metaRaw.Replace("%I%", "")); if (debug) { Console.WriteLine(metaIcon); } } else if (metaRaw.Contains("%A%")) { metaAvatar = parseImage(metaRaw.Replace("%A%", "")); if(pictureDebug == true) {Console.WriteLine(metaRaw); } } else if (metaRaw.Contains("%W%")) { metaWins = Convert.ToUInt16(metaRaw.Replace("%W%", "")); if (debug) { Console.WriteLine(metaWins); } } else if (metaRaw.Contains("%L%")) { metaLoses = Convert.ToUInt16(metaRaw.Replace("%L%", "")); if (debug) { Console.WriteLine(metaLoses); } } else if (metaRaw.Contains("%C%")) { int r = 0, g = 0, b = 0; String[] colorRaw = metaRaw.Replace("%C%", "").Split(','); foreach (String metaColorRaw in colorRaw) { if (metaColorRaw.Contains("r")) { r = Convert.ToInt16(metaColorRaw.Replace("r", "")); } else if (metaColorRaw.Contains("g")) { g = Convert.ToInt16(metaColorRaw.Replace("g", "")); } else if (metaColorRaw.Contains("b")) { b = Convert.ToInt16(metaColorRaw.Replace("b", "")); } if (debug) { Console.WriteLine(metaColorRaw); } } metaColor = Color.FromArgb(r, g, b); } else { } } tmpPlayer = new Player(metaName, metaIcon, metaWins, metaLoses, metaColor, metaAvatar); playerList.Add(tmpPlayer); } return playerList; }
private void usersSet(Object sender, EventArgs e) { Button btnSender = (Button) sender; ChoosePlayerUI cpui = new ChoosePlayerUI(playerList, null, btnSender,p1,p2); cpui.ShowDialog(); if(cpui.DialogResult != DialogResult.Abort) { if (btnSender.Name == "red") { p1 = cpui.getPlayer(); } else { p2 = cpui.getPlayer(); } try { btnSender.BackgroundImage = cpui.getPlayer().getAvatarAsImage(); } catch (Exception ex) { Console.Write(ex.Message); } if (redSet && bluSet) { blu.Enabled = false; red.Enabled = false; } if (btnSender.BackgroundImage != null) { if (btnSender.Name == "red") { redSet = true; playingList.Add(cpui.getPlayer()); } else { bluSet = true; playingList.Add(cpui.getPlayer()); } } } }
private void newGame(Player pRED, Player pBLU, Bot bRED, Bot bBLU, String starter) { this.pRED = pRED; this.pBLU = pBLU; this.bRED = bRED; this.bBLU = bBLU; this.turn = starter; }