private void PlayerRosterHandler(string evt, string msg) { Lobby.UpdatePlayers(evt, msg); // make the 8 gameplay player images but don't add them to UI Player1 = Script.Create <UIImage>("Player1"); Player2 = Script.Create <UIImage>("Player2"); Player3 = Script.Create <UIImage>("Player3"); Player4 = Script.Create <UIImage>("Player4"); Player5 = Script.Create <UIImage>("Player5"); Player6 = Script.Create <UIImage>("Player6"); Player7 = Script.Create <UIImage>("Player7"); Player8 = Script.Create <UIImage>("Player8"); var players = new UIImage[] { Player1, Player2, Player3, Player4, Player5, Player6, Player7, Player8 }; int playerNumber = 0; for (int index = 0; index < 8; index += 2) { var lobbyPlayerButton = Lobby.GetPlayerButton(playerNumber); if (lobbyPlayerButton == null) { if (Players[index] != null) { Remove(Players[index]); } if (Players[index + 1] != null) { Remove(Players[index + 1]); } Players[index] = null; Players[index + 1] = null; } else if (Players[index] == null || !Players[index].Equals(lobbyPlayerButton)) { if (Players[index] != null) { Remove(Players[index]); } if (Players[index + 1] != null) { Remove(Players[index + 1]); } // Make Person buttons for all players Players[index] = new UIVMPersonButton(lobbyPlayerButton.Avatar, lobbyPlayerButton.vm, true); Players[index].Position = players[index].Position; Add(Players[index]); Players[index + 1] = new UIVMPersonButton(lobbyPlayerButton.Avatar, lobbyPlayerButton.vm, true); Players[index + 1].Position = players[index + 1].Position; Add(Players[index + 1]); playerNumber++; } } // goto lobby if (ButtonBack != null) { GotoWaitForPlayerPhase(); } }
public void DrawPage() { Page = Math.Min(Page, (Display.Count / (Columns * Rows))); if (Page < 0) { Page = 0; } foreach (var icon in CurrentIcons) { Remove(icon); } CurrentIcons.Clear(); var startInd = Page * (Columns * Rows); for (int x = 0; x < Columns; x++) { for (int y = 0; y < Rows; y++) { var ind = startInd + x + Columns * y; if (ind < Display.Count) { var icon = new UIVMPersonButton(Display.ElementAt(ind), vm, false); CurrentIcons.Add(icon); Add(icon); icon.Position = new Vector2(x * (34 + 12), y * (34 + 11)); } } } }
public void P_Players(string evt, string txt) { var split = txt.Split('\n'); int[] items = new int[4]; var labels = new UILabel[] { labelStation1, labelStation2, labelStation3, labelStation4 }; for (int i = 0; i < 4; i++) { if (!int.TryParse(split[i], out items[i])) { return; } var avatar = (VMAvatar)Controller.Lot.vm.GetObjectById((short)items[i]); if (avatar == null) { if (Players[i] != null) { Remove(Players[i]); } Players[i] = null; } else if (Players[i] == null || Players[i].Avatar != avatar) { if (Players[i] != null) { Remove(Players[i]); } Players[i] = new UIVMPersonButton((VMAvatar)avatar, Controller.Lot.vm, true); var bgs = new UIImage[] { PersonBG1, PersonBG2, PersonBG3, PersonBG4 }; Players[i].Position = bgs[i].Position + new Microsoft.Xna.Framework.Vector2(2, 2); Add(Players[i]); } string caption = ""; if (avatar == null) { caption = Script.GetString("strNoContributor"); } else { if (i == 0) { caption = Script.GetString("strBody") + avatar.GetPersonData(VMPersonDataVariable.BodySkill) / 100; } else if (i == 2) { caption = Script.GetString("strCharisma") + avatar.GetPersonData(VMPersonDataVariable.CharismaSkill) / 100; } else { caption = Script.GetString("strCooking") + avatar.GetPersonData(VMPersonDataVariable.CookingSkill) / 100; } } labels[i].Caption = caption; } }
private void SetOtherPerson(uint persist) { if (OtherPerson != null) { if (OtherPerson.Avatar.PersistID == persist) { return; } Remove(OtherPerson); } OtherPerson = new UIVMPersonButton((VMAvatar)LotController.vm.GetObjectByPersist(persist), LotController.vm, true); OtherPerson.Position = new Vector2(43, 184); Add(OtherPerson); }
void DrawOpponentHandler(string evt, string opponentID) { // remove old opponent picture if (PlayerIsBlue) { if (Players[1] != null) { Remove(Players[1]); Players[1] = null; } } else { if (Players[0] != null) { Remove(Players[0]); Players[0] = null; } } short avatarID; if (Int16.TryParse(opponentID, out avatarID)) { var avatar = (VMAvatar)Controller.Lot.vm.GetObjectById(avatarID); if (PlayerIsBlue) { Players[1] = new UIVMPersonButton(avatar, Controller.Lot.vm, false) { Position = RedPlayerPos.Position }; Add(Players[1]); } else { Players[0] = new UIVMPersonButton(avatar, Controller.Lot.vm, false) { Position = BluePlayerPos.Position }; Add(Players[0]); } } }
private void SetMyPerson(uint persist) { if (MyPerson != null) { if (MyPerson.Avatar.PersistID == persist) { return; } Remove(MyPerson); } var ava = LotController.vm.GetObjectByPersist(persist); if (ava == null) { return; } MyPerson = new UIVMPersonButton((VMAvatar)ava, LotController.vm, true); MyPerson.Position = new Vector2(43, 134); Add(MyPerson); }
void InitHandler(string evt, string data) { var split = data.Split('%'); short avatarID; // place player Avatar into Players if (Int16.TryParse(split[0], out avatarID)) { var avatar = (VMAvatar)Controller.Lot.vm.GetObjectById(avatarID); if (split[1].Equals("blue")) { Players[0] = new UIVMPersonButton((VMAvatar)avatar, Controller.Lot.vm, false) { Position = BluePlayerPos.Position }; PlayerIsBlue = true; Add(Players[0]); } else { Players[1] = new UIVMPersonButton((VMAvatar)avatar, Controller.Lot.vm, false) { Position = RedPlayerPos.Position }; Add(Players[1]); } } // draw progressbar RemainingBluePieces = 5; RemainingRedPieces = 5; DrawProgressBar(RemainingBluePieces, RemainingRedPieces); // add the buttons as children to this, creating a new one if need be ArtilleryButton = Script.Create <UIButton>("ArtilleryButton"); if (Children.Contains(ArtilleryButton)) { Remove(ArtilleryButton); } Add(ArtilleryButton); CavalryButton = Script.Create <UIButton>("CavalryButton"); if (Children.Contains(CavalryButton)) { Remove(CavalryButton); } Add(CavalryButton); CommandButton = Script.Create <UIButton>("CommandButton"); if (Children.Contains(CommandButton)) { Remove(CommandButton); } Add(CommandButton); InfantryButton = Script.Create <UIButton>("InfantryButton"); if (Children.Contains(InfantryButton)) { Remove(InfantryButton); } Add(InfantryButton); IntelButton = Script.Create <UIButton>("IntelButton"); if (Children.Contains(IntelButton)) { Remove(IntelButton); } Add(IntelButton); // add defeated images beneath each button DefeatArtilleryPos = Script.Create <UIImage>("DefeatArtilleryPos"); AddBefore(DefeatArtilleryPos, ArtilleryButton); DefeatArtilleryPos.Visible = false; DefeatCavalryPos = Script.Create <UIImage>("DefeatCavalryPos"); AddBefore(DefeatCavalryPos, CavalryButton); DefeatCavalryPos.Visible = false; DefeatCommandPos = Script.Create <UIImage>("DefeatCommandPos"); AddBefore(DefeatCommandPos, CommandButton); DefeatCommandPos.Visible = false; DefeatInfantryPos = Script.Create <UIImage>("DefeatInfantryPos"); AddBefore(DefeatInfantryPos, InfantryButton); DefeatInfantryPos.Visible = false; DefeatIntelPos = Script.Create <UIImage>("DefeatIntelPos"); AddBefore(DefeatIntelPos, IntelButton); DefeatIntelPos.Visible = false; Controller.ShowEODMode(new EODLiveModeOpt { Buttons = 0, Height = EODHeight.Tall, Length = EODLength.Full, Tips = EODTextTips.None, Timer = EODTimer.None, }); }
public override void Update(FSO.Common.Rendering.Framework.Model.UpdateState state) { if (SelectedAvatar != null) { if (SelectedAvatar != LastSelected) { if (Thumb != null) { Remove(Thumb); } Thumb = new UIVMPersonButton(SelectedAvatar, LotController.vm, false); UpdateThumbPosition(); Add(Thumb); LastSelected = SelectedAvatar; } UpdateMotives(); } base.Update(state); var jobMode = JobUI != null; StatusBarTimerTextEntry.Visible = jobMode; StatusBarMsgWinStraight.Visible = jobMode; StatusBarMsgWinTextEntry.Visible = jobMode; StatusBarTimerStraight.Visible = jobMode; if (jobMode) { JobUI = LotController.vm.TSOState.JobUI; bool textDirty = false; if (StatusBarMsgWinTextEntry.Items.Count != JobUI.MessageText.Count) { textDirty = true; } else { for (int i = 0; i < JobUI.MessageText.Count; i++) { if (!StatusBarMsgWinTextEntry.Items[i].Columns[0].Equals(JobUI.MessageText[i])) { textDirty = true; break; } } } if (textDirty) { StatusBarMsgWinTextEntry.Items = JobUI.MessageText.Select(x => new UIListBoxItem(x, x)).ToList(); StatusBarMsgWinTextEntry.ScrollOffset = 0; StatusBarCycleTime = 0; } StatusBarTimerBreakIcon.Visible = JobUI.Mode == VMTSOJobMode.Intermission; StatusBarTimerWorkIcon.Visible = JobUI.Mode == VMTSOJobMode.Round; var timeText = " " + JobUI.Minutes + ":" + (JobUI.Seconds.ToString().PadLeft(2, '0')); if (StatusBarTimerTextEntry.CurrentText != timeText) { StatusBarTimerTextEntry.CurrentText = timeText; } if (StatusBarCycleTime++ > 60 * 4 && StatusBarMsgWinTextEntry.Items.Count > 0) { StatusBarMsgWinTextEntry.ScrollOffset = (StatusBarMsgWinTextEntry.ScrollOffset + 1) % StatusBarMsgWinTextEntry.Items.Count; StatusBarCycleTime = 0; } } else { StatusBarTimerBreakIcon.Visible = false; StatusBarTimerWorkIcon.Visible = false; JobUI = LotController.vm.TSOState.JobUI; } if (LastEODConfig != LotController.EODs.DisplayMode) { HideEOD = false; SetInEOD(LotController.EODs.DisplayMode, LotController.EODs.ActiveEOD); } if (LotController.EODs.EODMessage != (string)MsgWinTextEntry.Items[0].Data) { MsgWinTextEntry.Items[0].Data = LotController.EODs.EODMessage; MsgWinTextEntry.Items[0].Columns[0] = LotController.EODs.EODMessage; } if (LotController.EODs.EODTime != TimerTextEntry.CurrentText) { TimerTextEntry.CurrentText = LotController.EODs.EODTime; } }