コード例 #1
0
    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();
    }
コード例 #2
0
    void Start()
    {
        mainObj = GameObject.Find("undestructable");
        gm      = mainObj.GetComponent <globalMatchManager> ();
        string     jsonData = File.ReadAllText(@"Assets/jsonSettings.txt");
        jsonConfig json     = JsonUtility.FromJson <jsonConfig>(jsonData);


        keeperAnim = GameObject.Find("keeper").GetComponent <Animator> ();
        ballAnim   = GameObject.Find("bowler").GetComponent <Animator> ();
        touch      = 0;
        if (GameObject.Find("Main Camera"))
        {
            fs = GameObject.Find("Main Camera").GetComponent <FastBall> ();
        }
        else
        {
            fs = GameObject.Find("ground").GetComponent <FastBall> ();
        }
        updated = 0;
        mainmenu.gameObject.SetActive(false);
        canvasRendered = 0;
        keepercaught   = 0;
        temp           = 0;
    }
コード例 #3
0
 void Start()
 {
     keeperAnim = GameObject.Find("keeper").GetComponent <Animator> ();
     ballAnim   = GameObject.Find("bowler").GetComponent <Animator> ();
     touch      = 0;
     fs         = new FastBall();
     updated    = 0;
     //mainmenu.gameObject.SetActive(false);
     canvasRendered = 0;
 }
コード例 #4
0
 void Start()
 {
     keeperAnim = GameObject.Find("keeper").GetComponent <Animator> ();
     ballAnim   = GameObject.Find("bowler").GetComponent <Animator> ();
     touch      = 0;
     if (GameObject.Find("Main Camera"))
     {
         fs = GameObject.Find("Main Camera").GetComponent <FastBall> ();
     }
     else
     {
         fs = GameObject.Find("Bat1").GetComponent <FastBall> ();
     }
     updated = 0;
     mainmenu.gameObject.SetActive(false);
     canvasRendered = 0;
 }
コード例 #5
0
    void Update()
    {
        if (fs == null)
        {
            fs = GameObject.Find("Bat1").GetComponent <FastBall>();
        }
        if ((GameObject.Find("Sphere") && (canvasRendered == 0)))
        {
            curVel = GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity;
            curPos = GameObject.Find("Sphere").transform.position;
        }
        Keeper_code();
        Infeilder_code("feilder");
        Infeilder_code("feilder1");
        Outfeilder_code("feilder2");
        Outfeilder_code("feilder3");
        Outfeilder_code("feilder4");
        Outfeilder_code("feilder5");
        Infeilder_code("feilder6");
        Outfeilder_code("feilder7");
        Infeilder_code("feilder8");
        if (GameObject.Find("Sphere"))
        {
            if (GameObject.Find("Sphere").transform.position.y < -1.07)
            {
                touch++;
                //				Debug.Log (touch);
            }
        }


        if (gm.isGameOver == true)
        {
            canvasRendered = 2;
            mainmenu.gameObject.SetActive(true);
            ballAnim.SetBool("wait", true);
            ballAnim.Play("wait", 0);
            if (GameObject.Find("Sphere"))
            {
                GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity = new Vector3(0f, 0f, 0f);
                GameObject.Find("Sphere").transform.position = curPos;
            }
            if (SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost)).GetHairTriggerDown())
            {
                Application.LoadLevel("Own_menu");
            }
        }

        if (SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost)).GetHairTriggerDown())
        {
            if (canvasRendered == 0)
            {
                mainmenu.gameObject.SetActive(true);
                canvasRendered = 1;
                ballAnim.SetBool("wait", true);
                ballAnim.Play("wait", 0);
                if (GameObject.Find("Sphere"))
                {
                    GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity = new Vector3(0f, 0f, 0f);
                    GameObject.Find("Sphere").transform.position = curPos;
                }
            }
            else
            {
                mainmenu.gameObject.SetActive(false);
                canvasRendered = 0;
                if (GameObject.Find("bowler").transform.position.z < GameObject.Find("backline").transform.position.z)
                {
                    ballAnim.SetBool("wait", false);
                    ballAnim.Play("wait", 0);
                }
                else
                {
                    ballAnim.SetBool("idel", true);
                    ballAnim.Play("idel", 0);
                }
                if (GameObject.Find("Sphere"))
                {
                    GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity = curVel;
                    GameObject.Find("Sphere").transform.position = curPos;
                }
            }
        }
    }
コード例 #6
0
 void Keeper_code()
 {
     if (canvasRendered == 0)
     {
         if (GameObject.Find("Sphere"))
         {
             Vector3 ball_pos     = new Vector3(GameObject.Find("Sphere").transform.position.x, GameObject.Find("Sphere").transform.position.y, GameObject.Find("Sphere").transform.position.z);
             Vector3 feilder_pos  = new Vector3(GameObject.Find("keeper").transform.position.x, GameObject.Find("keeper").transform.position.y, GameObject.Find("keeper").transform.position.z);
             Vector3 wicket_pos   = new Vector3(GameObject.Find("frontstump_middle").transform.position.x, GameObject.Find("frontstump_middle").transform.position.y, GameObject.Find("frontstump_middle").transform.position.z);
             float   ball_wickets = ((ball_pos.x - wicket_pos.x) * (ball_pos.x - wicket_pos.x)) + ((ball_pos.y - wicket_pos.y) * (ball_pos.y - wicket_pos.y)) + ((ball_pos.z - wicket_pos.z) * (ball_pos.z - wicket_pos.z));
             float   difference   = ((ball_pos.x - feilder_pos.x) * (ball_pos.x - feilder_pos.x)) + ((ball_pos.y - feilder_pos.y) * (ball_pos.y - feilder_pos.y)) + ((ball_pos.z - feilder_pos.z) * (ball_pos.z - feilder_pos.z));
             difference   = Mathf.Sqrt(difference);
             ball_wickets = Mathf.Sqrt(ball_wickets);
             if (difference < 2)
             {
                 GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity = new Vector3(0f, 0f, 0f);
             }
             if (difference < 10)
             {
                 if ((feilder_pos.x - ball_pos.x < 5) && (feilder_pos.x - ball_pos.x > 1))
                 {
                     GameObject.Find("keeper").transform.position = new Vector3(GameObject.Find("keeper").transform.position.x - 0.3f, GameObject.Find("keeper").transform.position.y, GameObject.Find("keeper").transform.position.z);
                 }
                 if ((feilder_pos.x - ball_pos.x > -5) && (feilder_pos.x - ball_pos.x < -1))
                 {
                     GameObject.Find("keeper").transform.position = new Vector3(GameObject.Find("keeper").transform.position.x + 0.3f, GameObject.Find("keeper").transform.position.y, GameObject.Find("keeper").transform.position.z);
                 }
                 if ((feilder_pos.z - ball_pos.z < 2) && (feilder_pos.z - ball_pos.z > 1))
                 {
                     GameObject.Find("keeper").transform.position = new Vector3(GameObject.Find("keeper").transform.position.x, GameObject.Find("keeper").transform.position.y, GameObject.Find("keeper").transform.position.z - .3f);
                 }
                 if ((feilder_pos.z - ball_pos.z > -2) && (feilder_pos.z - ball_pos.z < -1))
                 {
                     GameObject.Find("keeper").transform.position = new Vector3(GameObject.Find("keeper").transform.position.x, GameObject.Find("keeper").transform.position.y, GameObject.Find("keeper").transform.position.z + .3f);
                 }
             }
             if ((GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity.z == 0f) && (difference < 2))
             {
                 keepercaught = 1;
                 GameObject.Find("Sphere").transform.position = new Vector3(GameObject.Find("Sphere").transform.position.x, GameObject.Find("Sphere").transform.position.y + 1.5f, GameObject.Find("Sphere").transform.position.z);
                 var heading = GameObject.Find("frontstump_middle").transform.position - GameObject.Find("Sphere").transform.position;
                 StartCoroutine(DelayThrow());
                 GameObject.Find("Sphere").GetComponent <Rigidbody> ().AddForce(heading * 100);
                 Debug.Log("keeper threw the ball");
                 if ((touch < 3) && (updated == 0))
                 {
                     if (fs.hit == 0)
                     {
                         fs.Runs(0, 0);
                     }
                     else
                     {
                         fs.Runs(0, 1);
                     }
                     updated = 1;
                 }
                 else
                 if (updated == 0)
                 {
                     fs.Runs(0, 0);
                 }
             }
             if (ball_wickets < 1)
             {
                 Debug.Log("ball at stumps");
                 GameObject.Find("Sphere").GetComponent <Rigidbody> ().velocity = new Vector3(0f, 0f, 0f);
                 if ((keepercaught == 0) && (temp == 0))
                 {
                     if (fs == null)
                     {
                         fs = GameObject.Find("Bat1").GetComponent <FastBall>();
                     }
                     fs.Runs(0, 1);
                     temp = 1;
                 }
                 StartCoroutine(Reset());
             }
         }
     }
 }