//Player requesting a new ID private void OnNeedID(MessageCmdData data) { Debug.Log("NEED ID!"); int ID = PlayerIDManager.NewPlayer(this); myInfo = PlayerIDManager.playerInfos[PlayerIDManager.playerInfos.Count - 1]; Debug.Log(m_color); myInfo.color = m_color; myInfo.id = PlayerIDManager.SessionID.ToString() + "|" + ID.ToString(); //myInfo.copterSlot = getFreeCopterSlot(); m_netPlayer.SendCmd("assignID", new MessageAssignID(myInfo.id)); //m_netPlayer.SendCmd("restoreColor", new MessageRestoreColor(myInfo.color)); //m_netPlayer.SendCmd("score", new MessageScored(0)); }
void Start() { myInfo = null; //m_position = gameObject.transform.localPosition; m_color = new Color(0.0f, 1.0f, 0.0f); if (AllCopters == null) { Transform copterContainer = GameObject.Find("_ALL_COPTERS").transform; AllCopters = new GameObject[copterContainer.childCount]; for (int i = 0; i < AllCopters.Length; i++) { AllCopters[i] = copterContainer.GetChild(i).gameObject; } idToCopterSlotMap = new Dictionary<string, int>(); } }
//Player checking an existing ID (from a cookie) private void OnCheckID(MessageCheckID data) { Debug.Log("CHECK ID " + data.id); if (PlayerIDManager.checkID(data.id))// if their ID was already good, we can assume(?) they have a copter assignment { //the phone had the correct ID, we're cool. //Get the appropriate player info Debug.Log("ID is valid"); string[] sSplit = data.id.Split('|'); int pID = int.Parse(sSplit[1]); myInfo = PlayerIDManager.playerInfos[pID]; myInfo.id = data.id; //m_netPlayer.SendCmd("score", new MessageScored(myInfo.score)); //remind of character, and player number m_netPlayer.SendCmd(new MessageCharacter(Copter.getFruitNameByIndex(this.myCopter.copterNumber), this.isHorizontalController)); m_netPlayer.SendCmd("assignID", new MessageAssignID(myInfo.id)); } else { Debug.Log("ID is invalid, sending a new one..."); OnNeedID(null); } }