/** * Update death message with the given player as killer. * Message fades away via TweenColor */ public void Activate(PhotonPlayer player) { // find the RocketFightPlayer instance for the given player to get its color Match match = GameObject.Find("PhotonNetman").GetComponent <Match>(); List <RocketFightPlayer> playerList = match.GetPlayerList(); RocketFightPlayer rfplayer = null; foreach (RocketFightPlayer rfp in playerList) { if (rfp.photonPlayer == player) { rfplayer = rfp; break; } } // activate label if it is inactive if (!label.gameObject.activeSelf) { label.gameObject.SetActive(true); } // update text label.text = "[" + ColorX.RGBToHex(rfplayer.color) + "] " + rfplayer.photonPlayer.name + " [ffffff]has killed you!"; // init fade via TweenColor label.color = Color.white; TweenColor.Begin(label.gameObject, 1.5f, new Color(1, 1, 1, 0)); }
/** * Select the last element as pivot element and sort it that way, * that all elemts on the left of pivot are smaller and all * elements on the right are bigger then pivot. * Return position of the pivot element */ private int QuickSortDivideScore(ref List <RocketFightPlayer> list, int left, int right) { int i = left; // start with j left beside pivot element int j = right - 1; int pivot = list[right].score; do { // search element greater then pivot starting from left while (list[i].score >= pivot && i < right) { i++; } // seach element smaller then pivot starting from right while (list[j].score <= pivot && j > left) { j--; } if (i < j) { // swap list[i] and list[j] RocketFightPlayer z = list[i]; list[i] = list[j]; list[j] = z; } } while (i < j); // as long as i < j // swap pivot element (list[right]) with new final positoin (list[i]) if (list[i].score < pivot) { RocketFightPlayer z = list[i]; list[i] = list[right]; list[right] = z; } return(i); // return position of pivot element }