コード例 #1
0
    IEnumerator HitCoroutine()
    {
        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, currentHand.range))
        {
            var individualCube = hitInfo.transform.GetComponent <IndividualCube>();
            var adjacencyGraph = hitInfo.transform.root.GetComponent <CreateAdjacencyGraph>();

            if (hitInfo.transform.tag == "WeakPoint")
            {
                individualCube.DestroyParent();
            }

            if (hitInfo.transform.tag == "Enemy")
            {
                //Have fun~ (  ̄ 3 ̄)y▂ξ

                IndividualCube weakPoint = null;
                weakPoint = adjacencyGraph.GetWeakPoint();

                hitInfo.transform.GetComponent <IndividualCube>().MarkAsHit(2);
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyHit();

                weakPoint.GetComponent <IndividualCube>().CheckDetached();
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyDetached();
            }
        }

        yield return(null);
    }
コード例 #2
0
    void Shooting()
    {
        RaycastHit   hitInfo;
        LineRenderer line = gameObject.AddComponent <LineRenderer>();

        if (line != null)
        {
            line.positionCount = 2;
            line.startWidth    = 0.02f;
            line.endWidth      = 0.02f;
        }

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hitInfo, maxDistance))
        {
            if (hitInfo.transform.CompareTag("WeakPoint"))
            {
                if (line != null)
                {
                    line.SetPositions(new Vector3[2] {
                        cam.transform.position + cam.transform.right * 0.2f, hitInfo.point
                    });
                }
                hitInfo.transform.GetComponent <IndividualCube>().DestroyParent();
            }

            if (hitInfo.transform.CompareTag("Enemy"))
            {
                if (line != null)
                {
                    line.SetPositions(new Vector3[2] {
                        cam.transform.position + cam.transform.right * 0.2f, hitInfo.point
                    });
                }
                //Have fun~ (  ̄ 3 ̄)y▂ξ

                IndividualCube weakPoint = null;
                weakPoint = hitInfo.transform.root.GetComponent <CreateAdjacencyGraph>().GetWeakPoint();

                hitInfo.transform.GetComponent <IndividualCube>().MarkAsHit(2);
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyHit();

                weakPoint.GetComponent <IndividualCube>().CheckDetached();
                weakPoint.transform.root.GetComponent <CreateAdjacencyGraph>().DestroyDetached();
            }
        }
        if (line != null)
        {
            line.SetPositions(new Vector3[2] {
                cam.transform.position + cam.transform.right * 0.2f, cam.transform.forward * maxDistance
            });
        }
        Destroy(line, 0.2f);
    }