Example #1
0
    private void LaunchBullet()
    {
        Quaternion rot = this.gameObject.transform.rotation;
        Vector3    pos = this.transform.position + (rot * m_launchPoint);

        int bonusCharm = m_magazine.UseBonusCharmBullet();

        UnityAction <Vector3> act = (vec) =>
        {
            GameObject obj = XFunctions.Instance(m_bullet, pos, rot);
            Rigidbody  rb  = obj.GetComponent <Rigidbody>();
            rb.AddForce(vec * m_shotPower, ForceMode.Impulse);
            BulletCtrl ctrl = obj.GetComponent <BulletCtrl>();
            ctrl.SetUserID(m_parent.GetComponent <UserData>().userID);
            ctrl.AddBonusCharm(bonusCharm);
        };

        act.Invoke(this.transform.forward);
        if (m_magazine.UseBonus3WayBullet())
        {
            act.Invoke(Quaternion.AngleAxis(-m_shot3WayAngle, Vector3.up) * this.transform.forward);
            act.Invoke(Quaternion.AngleAxis(m_shot3WayAngle, Vector3.up) * this.transform.forward);
        }
        else
        {
            m_magazine.SubBullet(m_costBullet);
        }

        m_knockback += m_knockbackTime;
    }
    private void LaunchBullet()
    {
        Quaternion rot = this.gameObject.transform.rotation;
        Vector3    pos = this.transform.position + (rot * m_launchPoint);

        GameObject obj = XFunctions.Instance(m_bullet, pos, rot);
        Rigidbody  rb  = obj.GetComponent <Rigidbody>();

        rb.AddForce(this.transform.forward * m_shotPower, ForceMode.Impulse);
        BulletCtrl ctrl = obj.GetComponent <BulletCtrl>();

        ctrl.SetUserID(m_parent.GetComponent <UserData>().userID);
        ctrl.AddBonusCharm(m_magazine.UseBonusCharmBullet());

        m_magazine.SubBullet(m_costBullet);

        m_knockback += m_knockbackTime;
    }