// When we select a player, set the values to be his values, tag, role, etcetera public void FSetDropdownValues() { if (!ErrorFree()) { return; } PE_Role role = cSelector.rGuys[cSelector.mActivePlayer].GetComponent <PE_Role>(); DP_Tag.captionText.text = role.mTag; DP_Role.captionText.text = role.mRole; OnRoleChanged(); DP_Detail.captionText.text = role.mDetails; }
public void FDisplayPlayerDetails() { // Get a reference to the selector, find out if anyone is selected, if not, set these all to UN // if so, set them to what the player is. DPC_Selector selector = FindObjectOfType <DPC_Selector>(); if (selector.mActivePlayer == -1) { rTag.text = "UN"; rRole.text = "UN"; rDetail.text = "UN"; } else { PE_Role role = selector.rGuys[selector.mActivePlayer].GetComponent <PE_Role>(); rTag.text = role.mTag; rRole.text = role.mRole; rDetail.text = role.mDetails; } }
private void RepositionStart(Vector2 vMovement) { if (cSelector.mActivePlayer == -1) { Debug.Log("There is no active player"); return; } Debug.Log("Shift active player by: " + vMovement); PE_Role role = cSelector.rGuys[cSelector.mActivePlayer].GetComponent <PE_Role>(); role.mStartPos += vMovement; role.mStartPos.x = (float)System.Math.Round((double)role.mStartPos.x, 0); role.mStartPos.y = (float)System.Math.Round((double)role.mStartPos.y, 0); cSelector.rGuys[cSelector.mActivePlayer].transform.position += (Vector3)vMovement / 10f; // hacked conversion. // Again, unfortunately we have to convert from internal position to field position. UpdatePositionText(); // cJobsDisplayer.FDisplayJobs(); }
// We also have to destroy the roles currently in the scene. public void FLoadPlay(DATA_Play play) { PE_Role[] roles = FindObjectsOfType <PE_Role>(); for (int i = 0; i < roles.Length; i++) { Destroy(roles[i].gameObject); } Debug.Log("Play: " + play.mName); for (int i = 0; i < play.mPlayerRoles.Length; i++) { PE_Role role = Instantiate(PF_PlayerRole, transform.position, transform.rotation); role.mTag = play.mPlayerRoles[i].mTag; role.mRole = play.mPlayerRoles[i].mRole; // just a string now. role.mDetails = play.mPlayerRoles[i].mDetail; role.mStartPos.x = play.mPlayerRoles[i].mStart.x; role.mStartPos.y = play.mPlayerRoles[i].mStart.y; // Here I'm making sure that the players always start on whole numbers, even if the play is not saved that way. role.mStartPos.x = (float)System.Math.Round((double)role.mStartPos.x, 0); role.mStartPos.y = (float)System.Math.Round((double)role.mStartPos.y, 0); // okay, now actually make it spawn in the right spot. // update. I guess we need to work in pixels. float fMetersToPixels = 50f / rField.GetComponent <RectTransform>().rect.width; Vector3 vPos = new Vector3(); vPos.x = rField.transform.position.x + role.mStartPos.x * fMetersToPixels; vPos.y = rField.transform.position.y + role.mStartPos.y * fMetersToPixels; // set the y to the 10 yard line, normalized. That is where I decided the play starts from. vPos.y -= 15f * fMetersToPixels; role.transform.position = vPos; } // Since the old ones are garbage now. cSelector.FGetNewReferences(); }