Skip to content

Commit

Permalink
Merge pull request #79 from Sandrem/Roster-for-P2-is-not-collapsed-bug
Browse files Browse the repository at this point in the history
Unification for P1 and P2
  • Loading branch information
Sandrem authored Jun 13, 2017
2 parents b5512ba + 044badd commit 7232522
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions Assets/Scripts/View/UI/Roster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,37 +153,26 @@ private static int CalculateRosterPanelSize(GameObject panel)

private static void OrganizeRosterPositions()
{
Vector3 defaultPosition = Game.PrefabsList.RostersHolder.transform.Find("TeamPlayer1").Find("RosterHolder").transform.position + new Vector3(5f, 0f, 0f);
for (int i = 1; i < 3; i++)
{
Vector3 defaultPosition = Game.PrefabsList.RostersHolder.transform.Find("TeamPlayer" + i).Find("RosterHolder").transform.position + new Vector3(5f, 0f, 0f);

rosterPlayer1 = rosterPlayer1
.OrderByDescending(x => x.transform.Find("ShipInfo").Find("ShipPilotSkillText").GetComponent<Text>().text)
.ThenBy(x => x.transform.Find("ShipInfo").Find("ShipId").GetComponent<Text>().text)
.ToList();
List<GameObject> rosterPlayer = (i == 1) ? rosterPlayer1 : rosterPlayer2;
rosterPlayer = rosterPlayer
.OrderByDescending(x => x.transform.Find("ShipInfo").Find("ShipPilotSkillText").GetComponent<Text>().text)
.ThenBy(x => x.transform.Find("ShipInfo").Find("ShipId").GetComponent<Text>().text)
.ToList();

float offset = 5;
foreach (var item in rosterPlayer1)
{
if (item.activeSelf)
float offset = 5;
foreach (var item in rosterPlayer)
{
item.transform.position = defaultPosition + new Vector3(0f, -offset, 0f);
offset += item.transform.Find("ShipInfo").GetComponent<RectTransform>().sizeDelta.y + 5;
if (item.activeSelf)
{
item.transform.position = defaultPosition + new Vector3(0f, -offset, 0f);
offset += item.transform.Find("ShipInfo").GetComponent<RectTransform>().sizeDelta.y + 5;
}
}
}

/// Same for second player
defaultPosition = Game.PrefabsList.RostersHolder.transform.Find("TeamPlayer2").Find("RosterHolder").transform.position + new Vector3(5f, 0f, 0f);

rosterPlayer2 = rosterPlayer2
.OrderByDescending(x => x.transform.Find("ShipInfo").Find("ShipPilotSkillText").GetComponent<Text>().text)
.ThenBy(x => x.transform.Find("ShipInfo").Find("ShipId").GetComponent<Text>().text)
.ToList();

offset = 5;
foreach (var item in rosterPlayer2)
{
item.transform.position = defaultPosition + new Vector3(0f, -offset, 0f);
offset += item.transform.Find("ShipInfo").GetComponent<RectTransform>().sizeDelta.y + 5;
}
}

//TODO: rewrite to support TARGETSHIP
Expand Down

0 comments on commit 7232522

Please sign in to comment.