public Hit(int number, bool correct, Player player, long timestamp, bool isTempory = false) { this.number = number; this.correct = correct; this.player = player; this.timestamp = timestamp; this.isTempory = isTempory; }
/// <summary> /// Add new player to Game /// </summary> /// <param name="player">Object of new player</param> /// <returns></returns> public bool AddPlayer(Player player) { players.Add(player); var pControl = new PlayersStatsControl(); window.gridPlayers.RowDefinitions.Add(new RowDefinition { Height = new GridLength(pControl.MinHeight) }); window.gridPlayers.Children.Add(pControl); Grid.SetRow(pControl, players.Count-1); pControl.DataContext = player; playerControls.Add(player, pControl); return true; }
public QuestMenu(Quest[] quests, Player player) { // Location = new Point(MainForm.res.Width-Width,Map.StartPoint.Y);//Adjustable Location = new Point(0,SideMenu.EndPoint.Y);//Adjustable CurrentStartID = 0; if (MaxDisplayed>=quests.Length) { Add(new RelativeLabel(new Point (0,0), new Size(Width,Offset+quests.Length*(Height+Offset)+NameLabelHeight+Offset)), "BackgroundLabel"); for (int i=0;i<quests.Length;i++) { Add(CreateQuestGroupControl(quests[i],player,i,0)); } } else { Add(new RelativeLabel(new Point (0,0), new Size(Width,Offset+MaxDisplayed*(Height+Offset)+2*(ButtonHeight+Offset)+NameLabelHeight+Offset)), "BackgroundLabel"); for (int i=CurrentStartID;i<CurrentStartID+MaxDisplayed;i++) { Add(CreateQuestGroupControl(quests[i],player,i,Offset+ButtonHeight)); } Add(new RelativeLabel(new Point(Offset,NameLabelHeight+2*Offset), new Size(Width-2*Offset,ButtonHeight)),"UpButton"); GetControl("UpButton").Text = "^"; GetControl("UpButton").Click += delegate { if(CurrentStartID>0) CurrentStartID--; UpdateVisibleQuests(quests,player); }; Add(new RelativeLabel(new Point(Offset, SubGroups[MaxDisplayed-1].Location.Y+Offset+Height-SideMenu.EndPoint.Y), new Size(Width-2*Offset,ButtonHeight)),"DownButton"); GetControl("DownButton").Text = "v"; GetControl("DownButton").Click += delegate { if(CurrentStartID+MaxDisplayed<quests.Length) CurrentStartID++; UpdateVisibleQuests(quests,player); }; } GetControl("BackgroundLabel").BackColor = Color.Lime; Add(new RelativeLabel(new Point(Offset,Offset), new Size(Width - 2*Offset,NameLabelHeight)), "NameLabel"); GetControl("NameLabel").Text = "Quests"; }
protected override void Initialize() { graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Title = Title; map = new Map(); map.ReadSpriteData(); //wczytaj plik spritedata map.DrawData(); //losuj dane player = new Player(); viewport = new MyViewport(); player.pos_x = 6; player.pos_y = 6; player.direction = 1; viewport.Width = 800; viewport.Height = 600; viewport.Pos_X = 0; viewport.Pos_Y = 0; base.Initialize(); }
public void UpdatePlayerLocation(Player player, int newLocationID) { // if (player.LocationID != 0) // Places.AllPlaces[player.LocationID].Players --; // Places.AllPlaces[newLocationID].Players ++; player.LocationID = newLocationID; UpdatePlayerLocation(); }
public void EstablishConnection() { ConnectionForm InitForm1; WaitForConnectionForm InitForm2; ActionForm InitForm3; JoinCreateForm InitForm4; init: InitForm1 = new ConnectionForm(); InitForm1.ShowDialog(); try { Connection = new Connector(InitForm1.Host); Connection.Socket.MessageReceived += delegate (object sender, MessageReceivedEventArgs e) {HandleMessageWrapper(e);}; } catch (ArgumentException) { goto init; } InitForm2 = new WaitForConnectionForm(Connection); InitForm2.ShowDialog(); if (Connection.Socket.State != WebSocketState.Open) goto init; startgame: InitForm3 = new ActionForm(); InitForm3.ShowDialog(); if (InitForm3.Action == "") goto startgame; if (InitForm3.Action == "join") Connection.GameID = InitForm3.GameID; InitForm4 = new JoinCreateForm(Connection, InitForm3.Action); InitForm4.ShowDialog(); if (InitForm4.myIDs.Length == 0) goto startgame; Connection.ClientIDs = InitForm4.myIDs; Players = new Player[InitForm4.PlayerNames.Length]; for (int i = 0; i<InitForm4.PlayerNames.Length; i++) { if (InitForm4.PlayerNames[i] == null) //DEBUG?? InitForm4.PlayerNames[i] = "Player"+i.ToString(); Players[i] = new Player(i, InitForm4.PlayerNames[i]); } }
public ControlGroup CreateQuestGroupControl(Quest quest, Player player, int SlotNum, int SpecOffset) { ControlGroup c = new ControlGroup(new Point(Location.X,SlotNum*(Height+Offset)+SideMenu.EndPoint.Y+2*Offset+NameLabelHeight+SpecOffset)); c.Add(new RelativeLabel(new Point(Offset,0), new Size(Height,Height)), "ImageLabel"); c.Add(new RelativeLabel(new Point(Offset+Height+Offset,0),new Size(Width-3*Offset-Height,50)),"TextLabel"); c.Add(new RelativeLabel(new Point(Offset+Height+Offset,50),new Size(Width-3*Offset-Height,50)),"RequirementsLabel"); string[] TextBuf = QuestText(quest,player); c.GetControl("TextLabel").Text = TextBuf[0]; c.GetControl("RequirementsLabel").Text = TextBuf[1]; c.GetControl("ImageLabel").BackgroundImage = Character.GetCharacter(quest.CharacterID).CharacterImage; return c; }
public void UpdateVisibleQuests(Quest[] quests, Player player) { for (int i=0; i<MaxDisplayed;i++) { string [] TextBuf=QuestText(quests[i+CurrentStartID],player); SubGroups[i].GetControl("TextLabel").Text = TextBuf[0]; SubGroups[i].GetControl("RequirementsLabel").Text = TextBuf[1]; SubGroups[i].GetControl("ImageLabel").BackgroundImage = Character.GetCharacter(i+CurrentStartID).CharacterImage; } }
public string[] QuestText(Quest quest, Player player) { string TextBuf2 = Character.GetCharacter(0).Name+" "+"Charakter "+quest.CharacterID.ToString()+": "+quest.Text; string TextBuf = ""; TextBuf += "Location: " + player.LocationID + " =? " + quest.LocationID + " "; TextBuf += "Resources: "; if (quest.ResourcesNeeded > new Resources()) for (int i = 0; i<quest.ResourcesNeeded.All.Length;i++) TextBuf += player.Resources.All[i].ToString() + "/" + quest.ResourcesNeeded.All[i].ToString() +" "; else TextBuf += "none "; TextBuf += "Players: "; if (quest.PlayerIDs.Length == 0) TextBuf += "all "; else foreach (int i in quest.PlayerIDs) TextBuf += i.ToString() + " "; TextBuf += "Items: "; if (quest.NeededItems.Length == 0) TextBuf += "none "; else foreach (Item i in quest.NeededItems) TextBuf += i.Name + " "; return new string[2] {TextBuf2, TextBuf}; }
private void button1_Click(object sender, RoutedEventArgs e) { u = new Player(++i, "User #" + i); game.AddPlayer(u); u.test(); s = new Skill("Frost", Key.F, 5000); game.AddSkill(s); s = new Skill("Slice", Key.S, 3000); game.AddSkill(s); UpdateHitsList(); }
protected async void GoBtn_ClickAsync(object sender, EventArgs e) { //await AddTeamAsync(); client.BaseAddress = new Uri("https://localhost:44382/api/Team"); //Adding teams Team team1 = new Team { Name = tbteam1.Text, Score = 0, Wideball = 0, Noball = 0, Wickets = 0, Overs = 0, }; Team team2 = new Team { Name = tbteam2.Text, Score = 0, Wideball = 0, Noball = 0, Wickets = 0, Overs = 0, }; string se_team1 = JsonConvert.SerializeObject(team1); StringContent con_team1 = new StringContent(se_team1, Encoding.UTF8, "application/json"); string se_team2 = JsonConvert.SerializeObject(team2); StringContent con_team2 = new StringContent(se_team2, Encoding.UTF8, "application/json"); System.Net.ServicePointManager.Expect100Continue = false; var teamr1_id = await client.PostAsync(client.BaseAddress + "/insertTeam", con_team1); var teamr2_id = await client.PostAsync(client.BaseAddress + "/insertTeam", con_team2); int team1_id = Int32.Parse(teamr1_id.Content.ReadAsStringAsync().Result); int team2_id = Int32.Parse(teamr2_id.Content.ReadAsStringAsync().Result); Session["team1id"] = team1_id; Session["team2id"] = team2_id; //Adding matches //Ending time is after 1 year temporarily //Bat first team and toss comment is selected in toss.aspx DateTime dt = DateTime.Now; //DateTime is immutable dt = dt.AddYears(1); Match match = new Match { Name = tbmatchtitle.Text, Starttime = DateTime.Now, Endtime = dt, Overs = Int32.Parse(ddlovers.SelectedValue), Batfirstid = -1, WinnerId = -1, EndComment = "", TossComment = "", Team1Id = team1_id, Team2Id = team2_id }; var se_match = JsonConvert.SerializeObject(match); var con_match = new StringContent(se_match, Encoding.UTF8, "application/json"); var matchr_id =await client.PostAsync("https://localhost:44382/api/Team/insertMatch",con_match); int match_id = Int32.Parse(matchr_id.Content.ReadAsStringAsync().Result); Session["matchid"] = match_id; Player player11 = new Player { Name = t1p1.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p1type.SelectedValue) }; Player player12 = new Player { Name = t1p2.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p2type.SelectedValue) }; Player player13 = new Player { Name = t1p3.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p3type.SelectedValue) }; Player player14 = new Player { Name = t1p4.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p4type.SelectedValue) }; Player player15 = new Player { Name = t1p5.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p5type.SelectedValue) }; Player player16 = new Player { Name = t1p6.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p6type.SelectedValue) }; Player player17 = new Player { Name = t1p7.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p7type.SelectedValue) }; Player player18 = new Player { Name = t1p8.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p8type.SelectedValue) }; Player player19 = new Player { Name = t1p9.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p9type.SelectedValue) }; Player player110 = new Player { Name = t1p10.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p10type.SelectedValue) }; Player player111 = new Player { Name = t1p11.Text, Team_id = team1_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt1p11type.SelectedValue) }; Player player21 = new Player { Name = t2p1.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p1type.SelectedValue) }; Player player22 = new Player { Name = t2p2.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p2type.SelectedValue) }; Player player23 = new Player { Name = t2p3.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p3type.SelectedValue) }; Player player24 = new Player { Name = t2p4.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p4type.SelectedValue) }; Player player25 = new Player { Name = t2p5.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p5type.SelectedValue) }; Player player26 = new Player { Name = t2p6.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p6type.SelectedValue) }; Player player27 = new Player { Name = t2p7.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p7type.SelectedValue) }; Player player28 = new Player { Name = t2p8.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p8type.SelectedValue) }; Player player29 = new Player { Name = t2p9.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p9type.SelectedValue) }; Player player210 = new Player { Name = t2p10.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p10type.SelectedValue) }; Player player211 = new Player { Name = t2p11.Text, Team_id = team2_id, Wickets = 0, Strikerate = 0, Economy = 0, Overs = 0, Balls = 0, Fours = 0, Sixes = 0, Type = Int32.Parse(ddlt2p11type.SelectedValue) }; var se_player11 = JsonConvert.SerializeObject(player11); var con_player11 = new StringContent(se_player11, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player11); var se_player12 = JsonConvert.SerializeObject(player12); var con_player12 = new StringContent(se_player12, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player12); var se_player13 = JsonConvert.SerializeObject(player13); var con_player13 = new StringContent(se_player13, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player13); var se_player14 = JsonConvert.SerializeObject(player14); var con_player14 = new StringContent(se_player14, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player14); var se_player15 = JsonConvert.SerializeObject(player15); var con_player15 = new StringContent(se_player15, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player15); var se_player16 = JsonConvert.SerializeObject(player16); var con_player16 = new StringContent(se_player16, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player16); var se_player17 = JsonConvert.SerializeObject(player17); var con_player17 = new StringContent(se_player17, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player17); var se_player18 = JsonConvert.SerializeObject(player18); var con_player18 = new StringContent(se_player18, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player18); var se_player19 = JsonConvert.SerializeObject(player19); var con_player19 = new StringContent(se_player19, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player19); var se_player110 = JsonConvert.SerializeObject(player110); var con_player110 = new StringContent(se_player110, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player110); var se_player111 = JsonConvert.SerializeObject(player111); var con_player111 = new StringContent(se_player111, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player111); //client.insertPlayer(player11); //client.insertPlayer(player12); //client.insertPlayer(player13); //client.insertPlayer(player14); //client.insertPlayer(player15); //client.insertPlayer(player16); //client.insertPlayer(player17); //client.insertPlayer(player18); //client.insertPlayer(player19); //client.insertPlayer(player110); //client.insertPlayer(player111); var se_player21 = JsonConvert.SerializeObject(player21); var con_player21 = new StringContent(se_player21, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player21); var se_player22 = JsonConvert.SerializeObject(player22); var con_player22 = new StringContent(se_player22, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player22); var se_player23 = JsonConvert.SerializeObject(player23); var con_player23 = new StringContent(se_player23, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player23); var se_player24 = JsonConvert.SerializeObject(player24); var con_player24 = new StringContent(se_player24, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player24); var se_player25 = JsonConvert.SerializeObject(player25); var con_player25 = new StringContent(se_player25, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player25); var se_player26 = JsonConvert.SerializeObject(player26); var con_player26 = new StringContent(se_player26, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player26); var se_player27 = JsonConvert.SerializeObject(player27); var con_player27 = new StringContent(se_player27, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player27); var se_player28 = JsonConvert.SerializeObject(player28); var con_player28 = new StringContent(se_player28, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player28); var se_player29 = JsonConvert.SerializeObject(player29); var con_player29 = new StringContent(se_player29, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player29); var se_player210 = JsonConvert.SerializeObject(player210); var con_player210 = new StringContent(se_player210, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player210); var se_player211 = JsonConvert.SerializeObject(player211); var con_player211 = new StringContent(se_player211, Encoding.UTF8, "application/json"); await client.PostAsync("https://localhost:44382/api/Team/insertPlayer", con_player211); //client.insertPlayer(player21); //client.insertPlayer(player22); //client.insertPlayer(player23); //client.insertPlayer(player24); //client.insertPlayer(player25); //client.insertPlayer(player26); //client.insertPlayer(player27); //client.insertPlayer(player28); //client.insertPlayer(player29); //client.insertPlayer(player210); //client.insertPlayer(player211); Response.Redirect("toss.aspx",false); }