public PlayerData(Position position, Gamestate gamestate, PlayersManager playersManager, StatisticsManager statisticsManager, int playerId) : base(position, gamestate) { if (playersManager.Players.ContainsKey(playerId)) { SelectPlayerButton = new SelectPlayerButton(Position, Gamestate, playersManager, playerId, Gamestate.PreviousScreen == ScreenType.MenuScreen ? ScreenType.Statistics : Gamestate.PreviousScreen); string nickname = playersManager.Players[playerId].Nickname; Statistic statistic = statisticsManager.LoadPlayersStatistics(playerId); string total = statistic.Total.ToString(); string won = statistic.Won.ToString(); Texts = new List <Text> { new Text(new Position(Position.X, Position.Y, Position.Width / 2, Position.Height), Gamestate, new Vector2f(10, 0), 30, TextPosition.Start, TextPosition.Middle, nickname), new Text(new Position(Position.X + Position.Width / 2, Position.Y, Position.Width / 4, Position.Height / 2), Gamestate, new Vector2f(0, 0), 30, TextPosition.Start, TextPosition.Middle, "Total:"), new Text(new Position(Position.X + Position.Width / 2, Position.Y + Position.Height / 2, Position.Width / 4, Position.Height / 2), Gamestate, new Vector2f(0, 0), 30, TextPosition.Start, TextPosition.Middle, total), new Text(new Position(Position.X + Position.Width / 2 + Position.Width / 4, Position.Y, Position.Width / 4, Position.Height / 2), Gamestate, new Vector2f(0, 0), 30, TextPosition.Start, TextPosition.Middle, "Won:"), new Text(new Position(Position.X + Position.Width / 2 + Position.Width / 4, Position.Y + Position.Height / 2, Position.Width / 4, Position.Height / 2), Gamestate, new Vector2f(0, 0), 30, TextPosition.Start, TextPosition.Middle, won) }; RecalculateComponentsPositions(); } else { throw new ArgumentException("Invalid ID", "playerId"); } }
public override void RecalculateComponentsPositions() { SelectPlayerButton.RecalculateComponentsPositions(); foreach (Text text in Texts) { text.RecalculateComponentsPositions(); } }
private void ResetSelectPlayer() { for (int i = 0; i < _selectPlayers.Length; i++) { _selectPlayers[i].Reset(); } _selectedPlayer = null; _startButton.image.color = new Color(1, 1, 1, 0); _newGameText.color = new Color(1, 1, 1, 0); }
public override List <IRenderObject> GetRenderObjects() { List <IRenderObject> renderObjects = new List <IRenderObject>(); renderObjects.AddRange(SelectPlayerButton.GetRenderObjects()); foreach (Text text in Texts) { renderObjects.AddRange(text.GetRenderObjects()); } return(renderObjects); }
//private void ResetSelect() //{ // for (int i = 0; i < _selectPlayers.Length; i++) // { // if (_selectPlayers[i] == _selectedPlayer) // continue; // _selectPlayers[i].Reset(); // } //} public void OnClick(SelectPlayerButton selectedButton) { for (int i = 0; i < _selectPlayers.Length; i++) { _selectPlayers[i].Reset(); } selectedButton.Select(); _selectedPlayer = selectedButton; GameMng.CharMng.HeroName = _selectedPlayer.name; //GameMng.Instance.SetHero(_selectedPlayer.name); if (_startButton.image.color != Color.white) { NewGameFade(); } }