private List <PlayerDatabase.PlayerData> GetCurrentRoster() { // Get the current drafter. DrafterEnum currentDrafter = timerScript.GetCurrentDrafter(); List <PlayerDatabase.PlayerData> rosterList = new List <PlayerDatabase.PlayerData>(); var allPlayerList = timerScript.playerProfiles[(int)currentDrafter].allPlayerPicks; // Check if there are players in the all players list. if (allPlayerList.Count > 0) { // Loop through the player list and add them all to the roster list. for (int i = allPlayerList.Count - 1; i >= Mathf.Max(0, allPlayerList.Count - 5); --i) { rosterList.Add(allPlayerList[i]); } } else { // Grab all contract players. rosterList.AddRange(timerScript.playerProfiles[(int)currentDrafter].oneYearContracts); rosterList.AddRange(timerScript.playerProfiles[(int)currentDrafter].twoYearContracts); rosterList.Add(timerScript.playerProfiles[(int)currentDrafter].threeYearContract); while (rosterList.Count > 5) { rosterList.RemoveAt(rosterList.Count - 1); } } return(rosterList); }
private void SetupPlayerButtonsFor(DrafterEnum drafter) { int tradePlayerScriptListIndex = 0; // Get all the relevant main draft pick infos. foreach (var pickRound in timerScript.pickInfo) { foreach (var pickInfo in pickRound) { // Pick is owned by this drafter if (pickInfo.drafterID == drafter) { tradePlayerSelectionScriptList[tradePlayerScriptListIndex].SetPickInfo(pickInfo); ++tradePlayerScriptListIndex; } } } // Empty out these buttons while (tradePlayerScriptListIndex < tradePlayerSelectionScriptList.Count) { tradePlayerSelectionScriptList[tradePlayerScriptListIndex].SetPickInfo(null); ++tradePlayerScriptListIndex; } // Show the array. this.parentTradePlayerButtonsObject.transform.DOMove(this.tradePlayerButtonArrayShowPosition, timerScript.quickAnimationTime); this.tradeText.GetComponent <TextMeshPro>().text = string.Format("Choose who {0} is giving up:", timerScript.DrafterNames[(int)drafter]); }
public void SerializeContractData(DrafterEnum drafter) { StringBuilder lineToWrite = new StringBuilder(); lineToWrite.Append(DrafterNames[(int)drafter] + ":"); lineToWrite.Append(playerProfiles[(int)drafter].threeYearContract.playerName); lineToWrite.Append("*3:"); playerProfiles[(int)drafter].allPlayerPicks.Add(playerProfiles[(int)drafter].threeYearContract); // Append two year contracts foreach (PlayerDatabase.PlayerData contract in playerProfiles[(int)drafter].twoYearContracts) { lineToWrite.Append(contract.playerName); lineToWrite.Append("*2:"); playerProfiles[(int)drafter].allPlayerPicks.Add(contract); } // Append one year contracts foreach (PlayerDatabase.PlayerData contract in playerProfiles[(int)drafter].oneYearContracts) { lineToWrite.Append(contract.playerName); lineToWrite.Append("*1:"); playerProfiles[(int)drafter].allPlayerPicks.Add(contract); } contractWriter.WriteLine(lineToWrite); }
// Use this for initialization void Start() { currentYValue = threeYearPickYValue; timerScript = GameObject.Find("DraftTimer").GetComponent <DraftTimerScript>(); contractDrafterIndex = (int)DrafterEnum.TotalDrafters - 1; currentContractDrafter = timerScript.DraftOrder[contractDrafterIndex]; currentLabelText = "Signing Open Contracts: " + timerScript.DrafterNames[(int)currentContractDrafter]; }
// Add a given drafter to the order ticker public void AddNameplateToTicker(DrafterEnum drafterID) { // Create and initialize the nameplate int numNameplates = draftOrderNameplates.Count; draftOrderNameplates.Add(Instantiate(nameplateTemplate, new Vector3(-7.0f + numNameplates * 3.5f + gameObject.transform.position.x, 3.9f, 0), Quaternion.identity)); draftOrderNameplates.LastOrDefault().transform.DOMoveX(-7.0f + (numNameplates - 1) * 3.5f, timerScript.animationTime); draftOrderNameplates.LastOrDefault().GetComponent <UpdateNameplate>().InitializeVariables(drafterID); }
// Update is called once per frame void Update() { switch (currentContractPhase) { case ContractPhaseState.StoppedState: case ContractPhaseState.SignContractsPhase: break; case ContractPhaseState.AnimateToNextDrafter: currentTimer += Time.deltaTime; if (currentTimer >= animationTime) { currentTimer = 0; currentContractPhase = ContractPhaseState.SignContractsPhase; timerScript.UpdateLabels(); } break; case ContractPhaseState.AnimateToBuyOutPhase: currentTimer += Time.deltaTime; if (currentTimer >= animationTime) { currentTimer = 0; currentContractPhase = ContractPhaseState.BuyOutPhase; timerScript.UpdateLabels(); } break; case ContractPhaseState.AnimateOutEverything: currentTimer += Time.deltaTime; if (currentTimer >= animationTime) { --contractDrafterIndex; if (contractDrafterIndex >= 0) { currentTimer = 0; currentContractPhase = ContractPhaseState.AnimateToNextDrafter; currentContractDrafter = timerScript.DraftOrder[contractDrafterIndex]; InitializeContracts(); } else { GameObject.Find("NextContractButton").GetComponent <NextContractButton>().Hide(); //GameObject.Find("TradeButton").GetComponent<TradeButton>().Hide(); timerScript.StartMainDraft(); Destroy(gameObject); } } break; } }
private void ResetTradeStuffs() { // Reset draft button locations. foreach (var buttonScript in this.leftSide.GetComponentsInChildren <TradeNameplateButton>()) { buttonScript.ResetToStartPosition(); } foreach (var buttonScript in this.rightSide.GetComponentsInChildren <TradeNameplateButton>()) { buttonScript.ResetToStartPosition(); } this.firstDrafter = DrafterEnum.TotalDrafters; this.secondDrafter = DrafterEnum.TotalDrafters; }
public void SetDrafter(DrafterEnum drafter) { // First drafter chosen if (this.tradeState == TradeState.ChooseFirstPlayer) { this.firstDrafter = drafter; GameObject.Find("FirstDrafterName").GetComponent <TextMeshPro>().text = timerScript.DrafterNames[(int)this.firstDrafter] + " Trades:"; this.SwitchToTradeState(TradeState.ChooseSecondPlayer); } else if (this.tradeState == TradeState.ChooseSecondPlayer) { this.secondDrafter = drafter; GameObject.Find("SecondDrafterName").GetComponent <TextMeshPro>().text = timerScript.DrafterNames[(int)this.secondDrafter] + " Trades:"; this.SwitchToTradeState(TradeState.ChooseFirstPlayerTrade); } }
public void DelayPicks(DrafterEnum drafterToDelay, int numPicks) { if (numPicks <= 0) { return; } List <PickInfo> delayedPicks = new List <PickInfo>(); // Add picks to delay to the list for (int i = 0; i <= totalRounds; ++i) { for (int j = 0; j < pickInfo[i].Count; ++j) { // Found the pick to delay if (pickInfo[i][j].drafterID == drafterToDelay) { pickInfo[i][j].roundNumber = i; pickInfo[i][j].pickNumber = j; delayedPicks.Add(pickInfo[i][j]); --numPicks; } if (numPicks <= 0) { break; } } if (numPicks <= 0) { break; } } // Reverse the list to move the last pick first delayedPicks.Reverse(); // Go through all the picks and delay them foreach (PickInfo pick in delayedPicks) { DelayPick(pick, pick.roundNumber, pick.pickNumber); } }
public void AddNewsToTicker(DrafterEnum drafter, string playerName, bool isGoodNews) { if (isGoodNews) { this.breakingNewsQueue.Enqueue(string.Format(this.goodBreakingNews[this.goodNewsIndex], timerScript.DrafterNames[(int)drafter], playerName)); if (++this.goodNewsIndex >= this.goodBreakingNews.Count) { this.goodNewsIndex = 0; } } else { this.breakingNewsQueue.Enqueue(string.Format(this.badBreakingNews[this.badNewsIndex], timerScript.DrafterNames[(int)drafter], playerName)); if (++this.badNewsIndex >= this.badBreakingNews.Count) { this.badNewsIndex = 0; } } }
// Initialize this nameplate for the given drafter public void InitializeVariables(DrafterEnum drafter) { timerScript = GameObject.Find("DraftTimer").GetComponent <DraftTimerScript>(); drafterID = drafter; this.GetComponent <SpriteRenderer>().sprite = timerScript.nameplateSprites[(int)drafterID]; }