void Start() { mainObj = GameObject.Find("undestructable"); gm = mainObj.GetComponent <globalMatchManager> (); string jsonData = File.ReadAllText(@"Assets/jsonSettings.txt"); jsonConfig json = JsonUtility.FromJson <jsonConfig>(jsonData); sb = new scoreBoardManager(); string matchText = json.myTeam + " vs " + json.opponentTeam; sb.setMatchText(matchText); hit = 0; if (json.Overs == "2") { gm.totalBalls = 12; } else if (json.Overs == "1") { gm.totalBalls = 6; } else { gm.totalBalls = 30; } gm.init(); sb.SetTargetText(gm.target.ToString()); setMaterial(json.myTeam); k = 0; userAnim = GameObject.Find("bowler").GetComponent <Animator> (); fw = new feilder_working(); fs = new FastBall(); }
public int setTarget(string yourTeam, string oppTeam) { teams = JsonUtility.FromJson <TeamList>(jsonData); json = JsonUtility.FromJson <jsonConfig>(jsonData1); if (json.Overs == "2") { minScore = 15; maxScore = 25; } else if (json.Overs == "1") { minScore = 10; maxScore = 15; } int totTeams = teams.Teams.Count; List <TeamInfo> teamsInfo = teams.Teams; int yourTeamRating = 0, oppTeamRating = 0; int minRate = 100000, maxRate = 0; for (int i = 0; i < totTeams; i++) { int teamRating = int.Parse(teamsInfo [i].team_rating); if (maxRate < teamRating) { maxRate = teamRating; } if (minRate > teamRating) { minRate = teamRating; } if (teamsInfo [i].team == yourTeam) { yourTeamRating = teamRating; } else if (teamsInfo [i].team == oppTeam) { oppTeamRating = teamRating; } } int genScore = computeScoreByRatings(yourTeamRating, oppTeamRating, minRate, maxRate); int lowerBound = genScore - 5; int higherBoundBound = genScore + 5; int finalTarget = Random.Range(lowerBound, higherBoundBound); //populateAutoPlayScore (finalTarget); sbm = new scoreBoardManager(); sbm.SetTargetText(finalTarget.ToString()); mainObj = GameObject.Find("undestructable"); gm = mainObj.GetComponent <globalMatchManager> (); gm.target = finalTarget; return(finalTarget); }
public void updateCurrentBatsmentMeta() { sbm = new scoreBoardManager(); YourPlayer player; for (int i = 0; i < yourTeamPlayers.Count; i++) { if (yourTeamPlayers [i].playerName == currentbatsmen) { int diff = score - prevScore; prevScore = score; yourTeamPlayers [i].score = yourTeamPlayers [i].score + diff; //TODO: Original Score yourTeamPlayers [i].balls++; yourTeamPlayers [i].stRate = ((float)yourTeamPlayers [i].score / (float)yourTeamPlayers [i].balls) * (float)100; sbm.currentScoreUpdate(yourTeamPlayers [i].playerName, diff.ToString(), globalOutStatus); if (diff % 2 == 1) { if (currentbatsmen == player1Name) { currentbatsmen = player2Name; } else { currentbatsmen = player1Name; } } //TODO:Update 4's,6's, and st rate if (globalOutStatus) //TODO: if out or not { yourTeamPlayers[i].isOut = true; yourTeamPlayers [i].fow = ++fallOfWickets; if (fallOfWickets < 10) { if (yourTeamPlayers [i].playerName == player1Name) { player1Name = yourTeamPlayers [fallOfWickets + 1].playerName; } else { player2Name = yourTeamPlayers [fallOfWickets + 1].playerName; } currentbatsmen = yourTeamPlayers [fallOfWickets + 1].playerName; } globalOutStatus = false; } break; } } }
void Start() { mainObj = GameObject.Find("dummyxyz"); gm = mainObj.GetComponent <globalMatchManager> (); string jsonData = File.ReadAllText(@"Assets/jsonSettings.txt"); jsonConfig json = JsonUtility.FromJson <jsonConfig>(jsonData); sb = new scoreBoardManager(); string matchText = json.myTeam + " vs " + json.opponentTeam; sb.setMatchText(matchText); k = 0; }
void Start() { mainObj = GameObject.Find("undestructable"); matchMngr = mainObj.GetComponent <globalMatchManager> (); score = 0; ballCount = 0; bouncerCount = 0; player1Score = 0; player2Score = 0; target = 0; fallOfWickets = 0; prevBallNum = 0; //matchMngr = mainObj.GetComponent<globalMatchManager>(); sbm = new scoreBoardManager(); }
public void handleEndGame() { if (isGameOver) { sbm = new scoreBoardManager(); Debug.Log("GAME FINISHED!!!!"); YourPlayer manOfTheMatch = computeManOfTheMatch(); string message; if (didWon) { message = yourTeam + " has Won the Match by" + "\n" + (10 - fallOfWickets).ToString() + " wickets"; } else { message = oppTeam + " has Won the Match by " + (target - score).ToString() + " runs"; } sbm.updateMatchOverCanvas(message, "Player of the match:" + "\n" + manOfTheMatch.playerName); } }
// Update is called once per frame /* * void Start () { * matchMngr = mainObj.GetComponent<globalMatchManager>(); * sbm = mainObj.GetComponent<scoreBoardManager> (); * * } */ public void updateScoreCanvas() { sbm = new scoreBoardManager(); YourPlayer player; //sbm.setBowlerText ("bret lee"); //TODO: Original bowler string noOfOvers = (ballCount / 6).ToString() + "." + (ballCount % 6).ToString(); if (ballCount == 0) { sbm.setNRRText("0"); } else { sbm.setNRRText((score * 6 / ballCount).ToString()); } bowlerName = opponentTeamPlayers [10 - ballCount / 6].playerName; sbm.setBowlerText(bowlerName); player = getPlayerDetails(player1Name); player1Score = player.score; player = getPlayerDetails(player2Name); player2Score = player.score; if (currentbatsmen == player1Name) { sbm.setPlayer1Text(player1Name + "*"); sbm.setPlayer2Text(player2Name); } else { sbm.setPlayer1Text(player1Name); sbm.setPlayer2Text(player2Name + "*"); } sbm.setScoreText(score.ToString()); sbm.setOversText(noOfOvers.ToString()); sbm.setUpdateText(); }