Beispiel #1
0
        //when we throw the object we first want to center it in the players view
        public virtual void Throw(Transform location)
        {
            //if we can't throw this weapon just return
            if (!this._isThrowable)
            {
                return;
            }
            this._isBeingHeld = false;

            // instantiate the throwable
            GameObject prefab = (GameObject)Instantiate(
                this._throwPrefab,
                transform.parent.position + (transform.parent.forward * 2),
                transform.parent.rotation
                );

            prefab.transform.localPosition = Camera.main.transform.position + (Camera.main.transform.forward * 3);
            prefab.transform.localRotation = Camera.main.transform.rotation * this._throwPrefab.transform.rotation;
            prefab.transform.localScale    = this._throwPrefab.transform.localScale;

            ProjectileWeapon projectile = prefab.GetComponent <ProjectileWeapon> ();

            projectile.Project(location.forward);
            GameObject.Destroy(this.gameObject);
        }
Beispiel #2
0
        protected virtual void Shoot()
        {
            if (ammo == 0)
            {
                GlobalUtilities.ShowInteractMessage("Needs reload");
                return;
            }
            else if (this._lastShootTime < fireRate)
            {
                this._lastShootTime += Time.deltaTime;
                return;
            }

            this._lastShootTime = 0;
            ammo -= 1;


            // instantiate the projectile weapon
            GameObject child = (GameObject)Instantiate(
                this.projectile,
                transform.parent.position + (transform.parent.forward * 2),
                transform.parent.rotation
                );

            child.transform.localPosition = Camera.main.transform.position + (Camera.main.transform.forward * 3);
            child.transform.localRotation = Camera.main.transform.rotation * this.projectile.transform.rotation;
            child.transform.localScale    = this.projectile.transform.localScale;


            ProjectileWeapon projectile = child.GetComponent <ProjectileWeapon> ();

            projectile.speed *= _projectileSpeedMod;
            projectile.Damage = projectile.Damage * _projectileDamageMod;
            projectile.Project(Camera.main.transform.forward);
        }