Пример #1
0
        //弓を打つところ
        //-------------------------------------------------
        private void FireArrow()
        {
            GameObject special = comboChecker.GetSpecialSkill();

            if (special != null)
            {
                GameObject obj = Instantiate(special, null);
                obj.transform.forward  = currentArrow.transform.forward;
                obj.transform.position = currentArrow.transform.position;
                Destroy(obj, 5);
            }
            else
            {
                currentArrow.transform.parent = null;

                Arrow arrow = currentArrow.GetComponent <Arrow>();
                arrow.shaftRB.isKinematic = false;
                arrow.shaftRB.useGravity  = true;
                arrow.shaftRB.transform.GetComponent <BoxCollider>().enabled = true;

                arrow.arrowHeadRB.isKinematic = false;
                arrow.arrowHeadRB.useGravity  = true;
                arrow.arrowHeadRB.transform.GetComponent <BoxCollider>().enabled = true;

                //弓の生成
                int bouNum = bow.GetArrowNum();
                int damage;
                if (bouNum == 0)
                {
                    damage = 3;
                }
                else if (bouNum == 1)
                {
                    damage = 2;
                }
                else
                {
                    damage = 1;
                }

                GameObject       arrowDeleteObject = Instantiate(arrowDeleteCount, null);
                ArrowDeleteCount arrowDelete       = arrowDeleteObject.GetComponent <ArrowDeleteCount>();
                arrowDelete.SetArrowNum(bouNum * 2 + 1);

                for (int i = -bouNum; i <= bouNum; i++)
                {
                    GameObject arrowCopy = Instantiate(currentArrow, bow.transform, false);
                    arrowCopy.transform.parent              = null;
                    arrowCopy.transform.forward             = currentArrow.transform.forward;
                    arrowCopy.transform.rotation            = currentArrow.transform.rotation;
                    arrowCopy.transform.localRotation       = currentArrow.transform.localRotation;
                    arrowCopy.gameObject.transform.position = currentArrow.transform.position;
                    arrowCopy.gameObject.transform.Rotate(0.0f, 5.0f * i, 0.0f, Space.Self);

                    Arrow arrowCopy1 = arrowCopy.GetComponent <Arrow>();

                    arrowCopy1.SetArrowDeleteArea(arrowDeleteObject);
                    arrowCopy1.arrowHeadRB.AddForce(arrowCopy.transform.forward * bow.GetArrowVelocity(), ForceMode.VelocityChange);
                    arrowCopy1.arrowHeadRB.AddTorque(arrowCopy.transform.forward * 10);
                    arrowCopy1.ArrowReleased(100.0f);
                    arrowCopy1.damage = damage;
                }
            }
            nocked         = false;
            nockedWithType = GrabTypes.None;

            currentArrow.GetComponent <Arrow>().ArrowReleased(bow.GetArrowVelocity());
            bow.ArrowReleased();

            Destroy(currentArrow);

            allowArrowSpawn = false;
            Invoke("EnableArrowSpawn", 0.5f);
            StartCoroutine(ArrowReleaseHaptics());

            currentArrow = null;
            allowTeleport.teleportAllowed = true;
        }