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();
    }
Esempio n. 2
0
    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);
    }