コード例 #1
0
 public override void Launch(ShootInfo info)
 {
     ApplyPlayerVelocity();
     StartCoroutine(SetInvisibleForTwoFrames());
     base.Launch(info);
     MoveForward(info);
 }
コード例 #2
0
        private void MoveForward(ShootInfo info)
        {
            float originalSpeed = info.speed;

            info.speed = 0.15f;

            Update();
            info.speed = originalSpeed;
        }
コード例 #3
0
        private ShootInfo CreateShootInfo()
        {
            ShootInfo data = new ShootInfo();

            data.dir            = shootPoint.forward;
            data.dmg            = dmg;
            data.range          = range;
            data.speed          = bulletSpeed;
            data.maxBounceCount = maxBulletBounceCount;
            data.hitForce       = Random.Range(minHitForce, maxHitForce);
            data.hitLayer       = hitLayer;
            data.hitEffect      = hitEffect;
            data.sender         = grabbable.GrabController.transform.root.gameObject;

            return(data);
        }
コード例 #4
0
        public object Clone()
        {
            ShootInfo clone = new ShootInfo();

            clone.dir         = dir;
            clone.dmg         = dmg;
            clone.speed       = speed;
            clone.range       = range;
            clone.hitForce    = hitForce;
            clone.gravity     = gravity;
            clone.hitLayer    = hitLayer;
            clone.hitCallback = hitCallback;
            clone.hitEffect   = hitEffect;
            clone.sender      = sender;

            return(clone);
        }
コード例 #5
0
        private void Shoot()
        {
            ShootInfo info = new ShootInfo();
            float     d    = Vector3.Distance(bowStringController.Middle.position, bowStringController.MiddleStart.position);

            info.speed    = Mathf.Min((currentArrow.Size / (d < 1.0f ? 1.0f : d)) * speedFactor, arrowMaxSpeed);
            info.dir      = lastArrowDirection;
            info.hitForce = hitForce * (info.speed / arrowMaxSpeed);
            info.dmg      = dmg * (info.speed / arrowMaxSpeed);
            info.hitLayer = hitLayerMask;
            info.sender   = thisGrabbable.GrabController.transform.root.gameObject;

            currentArrow.Launch(info);
            currentArrow = null;

            SetControlPositionMode(arrowController, MotionControlMode.Engine);
        }
コード例 #6
0
        public override void Launch(ShootInfo info)
        {
            base.Launch(info);

            lastArrowHeadPosition = arrowHead.position;

            thisCollider.enabled = false;
            transform.parent     = null;
            thisRB.isKinematic   = false;
            transform.forward    = info.dir;
            shootDir             = info.dir;
            frameFix             = true;
            thisRB.AddForce(info.dir * info.speed, ForceMode.VelocityChange);

            hitSomething  = false;
            grabProcessed = false;

            StartCoroutine(DisableForOneFrame());
        }
コード例 #7
0
        private void Shoot()
        {
            ShootInfo data = CreateShootInfo();

            if (useSpread)
            {
                int spreadCount = Random.Range(minSpreadCount, maxSpreadCount);

                data.dmg      = data.dmg / spreadCount;
                data.hitForce = data.hitForce / spreadCount;

                for (int n = 0; n < spreadCount; n++)
                {
                    ShootInfo clone = (ShootInfo)data.Clone();
                    Vector3   dir   = GetRandomSpreadDirection(clone.dir);
                    clone.dir = dir;

                    Bullet bullet = Instantiate(bulletPrefab, shootPoint.position, Quaternion.LookRotation(dir));
                    bullet.Launch(clone);
                }
            }
            else
            {
                Bullet bullet = null;

                if (reloadMode == ReloadMode.Launcher)
                {
                    GameObject go = Instantiate(insertedBullet.gameObject, shootPoint.position, shootPoint.rotation);
                    data.dir = shootPoint.forward;
                    go.transform.localScale = insertedBullet.transform.lossyScale;
                    bullet = go.GetComponent <Bullet>();
                    Destroy(insertedBullet.gameObject);
                }
                else
                {
                    bullet = Instantiate(bulletPrefab, shootPoint.position, shootPoint.rotation);
                }


                bullet.Launch(data);
            }
        }
コード例 #8
0
 public virtual void Launch(ShootInfo info)
 {
     shootInfo = info;
     launched  = true;
 }