예제 #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;
        }
        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);
        }
        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());
        }
        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);
            }
        }
 public virtual void Launch(ShootInfo info)
 {
     shootInfo = info;
     launched  = true;
 }