コード例 #1
0
    // Update is called once per frame

    void FixedUpdate()

    {
        if (diskComp == 10)
        {
            NextRound();
        }

        if (Input.GetMouseButtonDown(0))
        {
            Camera ca = cam.GetComponent <Camera>();

            Ray ray = ca.ScreenPointToRay(Input.mousePosition);

            RaycastHit rayHit;

            if (Physics.Raycast(ray, out rayHit))
            {
                if (rayHit.collider.gameObject.tag.Contains("Disk") && isPaused == false)
                {
                    this.recordScore();
                    rayHit.collider.gameObject.GetComponent <Rigidbody>().isKinematic = true;
                    DiskData disk = rayHit.collider.gameObject.GetComponent <DiskData>();


                    factory.Free(disk.UsedIndex);

                    disk.currentSSAction.enable  = false;
                    disk.currentSSAction.destroy = true;
                }
            }
        }
    }
コード例 #2
0
    // Update is called once per frame
    void OnGUI()
    {
        if (Input.GetKeyDown("space"))
        {
            isSpacce = true;
        }
        if (isSpacce)
        {
            if (query.getTrial() == false)
            {
                //倒计时
                thistime += Time.deltaTime;
                if (thistime < 1f)
                {
                    TimeText.text = "3";
                }
                else if (thistime > 1f && thistime < 2f)
                {
                    TimeText.text = "2";
                }
                else if (thistime > 2f && thistime < 3f)
                {
                    TimeText.text = "1";
                }
                else if (thistime > 3f)
                {
                    TimeText.text = "";
                    judge.RoundStart();
                }
            }
            else
            {
                uInt.emitDisk();
                judge.RoundEnd();
                isSpacce = false;
                thistime = 0;
            }
        }
        else
        {
            if (Input.GetMouseButton(0))
            {
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                bullet.GetComponent <Rigidbody>().velocity = Vector3.zero;//初速度
                bullet.transform.position = Camera.main.transform.position;
                bullet.GetComponent <Rigidbody>().AddForce(ray.direction * 500f, ForceMode.Impulse);

                RaycastHit hit;
                if (Physics.Raycast(ray, out hit) && hit.collider.gameObject.tag == "Disk")
                {
                    myFactory.Free(hit.collider.gameObject.GetComponent <MoveToAction>().getId());
                    judge.addScoreEvent();
                }
            }
        }
        RoundText.text = "Round: " + query.getRound();
        ScoreText.text = "Score: " + query.getScore();
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (diskComp == 5)
        {
            NextRound();
        }
        if (Input.GetButtonDown("Fire1"))
        {
            Debug.Log("Fire1 Pressed");
            Vector3 mouse = Input.mousePosition;
            Camera  camer = cam.GetComponent <Camera> ();
            Ray     ray   = camer.ScreenPointToRay(Input.mousePosition);

            RaycastHit hits;
            if (Physics.Raycast(ray, out hits))
            {
                if (hits.collider.gameObject.tag.Contains("Disk") && isPaused == false)
                {
                    this.addScoreByRound();

                    hit.collider.gameObject.GetComponent <Rigidbody> ().isKinematic = false;
                    float      radius       = 3f;
                    Vector3    explosionPos = hit.collider.gameObject.transform.position;
                    Collider[] colliders    = Physics.OverlapSphere(explosionPos, radius);
                    foreach (Collider chit in colliders)
                    {
                        Rigidbody Rig = chit.gameObject.GetComponent <Rigidbody> ();
                        if (Rig != null)
                        {
                            Rig.AddExplosionForce(600, explosionPos, radius);
                        }
                    }

                    DiskData tmp = hit.collider.GetComponent <DiskData> ();

                    currentDiskFactory.Free(tmpDiskData.indexInUsed);
                    tmp.currentSSAction.enable  = false;
                    tmp.currentSSAction.destory = true;
                }
            }
        }
    }