public LongDrive() { conditional = (p, s, t, g) => { HoleData hole = g.GetHoleBag().GetCurrentHoleData(); bool longDrive = s == 1 && g.GetBall().DistanceFromTee() > 320f; if (hole.GetFir() && longDrive) { return(new Tuple <string, int>("Long Drive", 2)); } else { return(null); } }; }
public Fir() { conditional = (p, s, t, g) => { HoleData hole = g.GetHoleBag().GetCurrentHoleData(); bool fir = s == 1 && t == MaterialType.FAIRWAY; if (!hole.GetFir() && fir) { hole.SetFir(); return(new Tuple <string, int>("FIR", 5)); } else { return(null); } }; }
void Start() { gcObject = GameObject.Find(GameController.NAME); Game game = gcObject.GetComponent <Game>(); List <HoleData> holesPlayed = game.GetHoleBag().GetHolesPlayed(); for (int i = 0; i < 18; i++) { Hole[i].text = (i + 1).ToString(); if (i < holesPlayed.Count) { HoleData h = holesPlayed[i]; Back[i].text = MathUtil.ToYardsRounded(h.GetLengthBack()).ToString(); Front[i].text = MathUtil.ToYardsRounded(h.GetLengthFront()).ToString(); if (h.GetTee() == Tee.BACK) { Back[i].fontStyle = FontStyle.Bold; } else { Front[i].fontStyle = FontStyle.Bold; } Hcp[i].text = h.GetPar().ToString(); Hcp[i].fontStyle = FontStyle.Bold; Par[i].text = h.GetHandicap().ToString("F1"); Strokes[i].text = h.GetStrokes().ToString(); Putts[i].text = h.GetPutts().ToString(); Fir[i].text = h.GetFir() ? "X" : ""; Gir[i].text = h.GetGir() ? "X" : ""; } else { Back[i].text = ""; Front[i].text = ""; Hcp[i].text = ""; Par[i].text = ""; Strokes[i].text = ""; Putts[i].text = ""; Fir[i].text = ""; Gir[i].text = ""; } moneyText.text = game.GetScore().GetEarnings().ToString(); } foreach (Text t in tot) { t.fontStyle = FontStyle.Bold; } List <HoleData> front = holesPlayed.Take(9).ToList(); tot[0].text = "OUT"; tot[1].text = (front.Sum(h => MathUtil.ToYardsRounded(h.GetLengthBack()))).ToString(); tot[2].text = (front.Sum(h => MathUtil.ToYardsRounded(h.GetLengthFront()))).ToString(); tot[3].text = front.Count > 0 ? (front.Average(h => h.GetHandicap())).ToString("F1") : ""; tot[4].text = (front.Sum(h => h.GetPar())).ToString(); tot[5].text = (front.Sum(h => h.GetStrokes())).ToString(); tot[6].text = (front.Sum(h => h.GetPutts())).ToString(); tot[7].text = (front.Sum(h => h.GetFir() ? 1 : 0)).ToString(); tot[8].text = (front.Sum(h => h.GetGir() ? 1 : 0)).ToString(); List <HoleData> back = holesPlayed.Skip(9).Take(9).ToList(); tot[9].text = "IN"; tot[10].text = (back.Sum(h => MathUtil.ToYardsRounded(h.GetLengthBack()))).ToString(); tot[11].text = (back.Sum(h => MathUtil.ToYardsRounded(h.GetLengthFront()))).ToString(); tot[12].text = back.Count > 0 ? (back.Average(h => h.GetHandicap())).ToString("F1") : ""; tot[13].text = (back.Sum(h => h.GetPar())).ToString(); tot[14].text = (back.Sum(h => h.GetStrokes())).ToString(); tot[15].text = (back.Sum(h => h.GetPutts())).ToString(); tot[16].text = (back.Sum(h => h.GetFir() ? 1 : 0)).ToString(); tot[17].text = (back.Sum(h => h.GetGir() ? 1 : 0)).ToString(); foreach (Text t in grndTot) { t.fontStyle = FontStyle.Bold; } grndTot[0].text = "TOT"; grndTot[1].text = (holesPlayed.Sum(h => MathUtil.ToYardsRounded(h.GetLengthBack()))).ToString(); grndTot[2].text = (holesPlayed.Sum(h => MathUtil.ToYardsRounded(h.GetLengthFront()))).ToString(); grndTot[3].text = holesPlayed.Count > 0 ? (holesPlayed.Average(h => h.GetHandicap())).ToString("F1") : ""; grndTot[4].text = (holesPlayed.Sum(h => h.GetPar())).ToString(); grndTot[5].text = (holesPlayed.Sum(h => h.GetStrokes())).ToString(); grndTot[6].text = (holesPlayed.Sum(h => h.GetPutts())).ToString(); grndTot[7].text = (holesPlayed.Sum(h => h.GetFir() ? 1 : 0)).ToString(); grndTot[8].text = (holesPlayed.Sum(h => h.GetGir() ? 1 : 0)).ToString(); }