Ejemplo n.º 1
0
    public void ChangeWeapon(Raven_Weapon weaponID)
    {
        Weapon weapon = gameObject.GetComponent <Weapon>();

        weapon.ChooseWeapon(weaponID);

        ProjectileSpeed = weapon.ProjectileSpeed;

        currentBulletNum = bulletNumInBag[(int)weaponID];
        currentWeapon    = weaponID;
    }
Ejemplo n.º 2
0
 public void ChooseWeapon(Raven_Weapon weaponID)
 {
     if (weaponID == Raven_Weapon.Blaster)
     {
         ProjectileSpeed = 10;
         Bullet          = (GameObject)Resources.Load("Prefabs/BlasterBullet", typeof(GameObject));
         currentWeapon   = Raven_Weapon.Blaster;
     }
     if (weaponID == Raven_Weapon.ShotGun)
     {
         ProjectileSpeed = 30;
         Bullet          = (GameObject)Resources.Load("Prefabs/ShotGunBullet", typeof(GameObject));
         currentWeapon   = Raven_Weapon.ShotGun;
     }
     if (weaponID == Raven_Weapon.RocketLuncher)
     {
         ProjectileSpeed = 45;
         Bullet          = (GameObject)Resources.Load("Prefabs/RocketLuncherBullet", typeof(GameObject));
         currentWeapon   = Raven_Weapon.RocketLuncher;
     }
 }
Ejemplo n.º 3
0
    public void Shoot(Raven_Weapon weapon)
    {
        if (weapon == Raven_Weapon.Blaster)
        {
            GameObject newBullet      = Instantiate(Bullet, ShootPoint.position, ShootPoint.rotation) as GameObject;
            Vector3    shootDirection = ShootPoint.forward;
            newBullet.GetComponent <Rigidbody>().AddForce(shootDirection * ShootForce, ForceMode.Impulse);
            return;
        }

        if (weapon == Raven_Weapon.ShotGun)
        {
            Instantiate(Bullet, ShootPoint.position, ShootPoint.rotation);
            Collider[] cols = Physics.OverlapSphere(ShootPoint.position, Radius, 1 << 8);
            if (cols.Length != 0)
            {
                foreach (var item in cols)
                {
                    Rigidbody r = item.GetComponent <Rigidbody>();
                    if (r != null)
                    {
                        r.AddForce(r.transform.forward * ShootForce, ForceMode.Impulse);
                    }
                }
            }
            return;
        }

        if (weapon == Raven_Weapon.RocketLuncher)
        {
            GameObject newBullet      = Instantiate(Bullet, ShootPoint.position, ShootPoint.rotation) as GameObject;
            Vector3    shootDirection = ShootPoint.forward;
            newBullet.GetComponent <Rigidbody>().AddForce(shootDirection * 50, ForceMode.Impulse);
            return;
        }
    }