Example #1
0
        /// <summary>
        /// Fires the one shot.
        /// </summary>
        /// <param name="_target">Target.</param>
        public void FireOneShot(Transform _target)
        {
            if (Ammunition.Enabled)
            {
                Ammunition.Fire(_target);
            }

            if (Recoil.Enabled)
            {
                Recoil.Start();
            }

            if (LaunchSound.Enabled)
            {
                LaunchSound.Play();
            }

            if (MuzzleFlash.Enabled)
            {
                MuzzleFlash.Start();
            }

            if (Shell.Enabled)
            {
                Shell.Start();
            }

            if (Effect.Enabled)
            {
                Effect.Start(OwnerComponent);
            }
        }
    public void fireWeapon(GameObject aimSpot)
    {
        if (shot == null)
        {
            Debug.Log(name + " is shooting blanks");

            return;
        }

        //will always return at least the center of this object
        hardpoints = getPoints();

        foreach (Transform gunPoint in hardpoints)
        {
            if (turret && turretAim)
            {
                gunPoint.LookAt(aimSpot.transform.position);
            }
            else
            {
                gunPoint.LookAt(transform.forward);
            }
        }



        //alternating fire

        if (Time.time > nextFire && PlayerControllerAlpha.charge > shotCost)
        {
            Transform gun = nextGun();

            if (gun == null)
            {
                return;
            }

            nextFire = nextFire + fireRate;
            //Instantiate(shot, altFire1.position, altFire1.rotation);
            Ammunition.Fire(shot, gun);

            ShotCost(shotCost);
        }
    }
Example #3
0
        public void Execute()
        {
            var direction = Input.mousePosition - _camera.WorldToScreenPoint(_transform.position);

            _ship.Rotation(direction);

            _ship.Move(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), Time.deltaTime);

            if (Input.GetKeyDown(KeyCode.LeftShift))
            {
                _ship.AddAcceleration();
            }

            if (Input.GetKeyUp(KeyCode.LeftShift))
            {
                _ship.RemoveAcceleration();
            }

            if (Input.GetButtonDown("Fire1"))
            {
                _ammunition.Fire();
            }
        }
Example #4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="target"></param>
    public void Fire(GameObject target)
    {
        Interactable interactable = target.GetComponent <Interactable>();

        if (interactable)
        {
            if (interactable.IsShootableAnytime()) // menu interactables
            {
                interactable.OnInteract();         // shoot but don't decrease ammo
            }
            else if (UmpireControl.isGameStarted)  // game interactables
            {
                if (m_ammunition.CanFire())        // does the player have ammo?
                {
                    interactable.OnInteract();     // shoot
                    m_ammunition.Fire();           // and decrease ammo
                }
            }
            else
            {
                return;
            }
        }
    }