示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (weaponStatus == WEAPONSTATUS.FIRE)
        {
            accumRecharge += Time.deltaTime;
            if (accumRecharge >= currentWeaponInfo.GetRechargeVelocity)
            {
                entityComp.canShoot = true;

                accumRecharge = 0;
                weaponStatus  = WEAPONSTATUS.STAND;
            }
        }
    }
示例#2
0
    //Create Shot and add force to
    public void Shot()
    {
        if (currentWeaponInfo)
        {
            GameObject instance    = currentWeaponInfo.GetBulletPrefabObject;
            GameObject _bullet     = Instantiate(instance) as GameObject;
            Bullet     _bulletComp = _bullet.GetComponent <Bullet>();
            Rigidbody  _bulletRb   = _bullet.GetComponent <Rigidbody>();

            var newPosition = transform.position + (transform.forward * .07f);
            _bullet.transform.position = newPosition;

            _bulletComp.SetDamage(currentWeaponInfo.GetFireForce);
            _bulletComp.SetLife(currentWeaponInfo.GetBulletLife);

            _bulletRb.AddForce(transform.forward * currentWeaponInfo.GetSpeed);

            entityComp.canShoot = false;
            weaponStatus        = WEAPONSTATUS.FIRE;
        }
    }