public void Shoot()
 {
     if (cannon != null)
     {
         cannon.Shoot();
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        animator.SetFloat("Speed", rigidbody.velocity.magnitude);

        Vector3 dir;

        dir.x = Input.GetAxis("Horizontal");
        dir.y = 0;
        dir.z = Input.GetAxis("Vertical");

        rigidbody.velocity = dir * 5f;

        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, float.MaxValue))
        {
            Vector3 dirToCursor = hit.point - transform.position;
            dirToCursor.y     = 0;
            transform.forward = dirToCursor;

            if (Input.GetButtonDown("Fire1"))
            {
                dirToCursor.y = transform.position.y;
                shootComponent.Shoot(transform.position, dirToCursor);
                particleSystem.Play();
            }
        }
    }
Example #3
0
    private void Shoot()
    {
        ShootComponent shootComponent = (ShootComponent)weaponInventory.weapons[index].components.Find(BaseComponent => BaseComponent.GetType() == typeof(ShootComponent));

        if (shootComponent != null)
        {
            Vector3 barrelPosition     = weaponInventory.weapons[index].barrelPosition;
            Vector3 projectilePosition = weaponHolder.TransformPoint(barrelPosition);
            shootComponent.Shoot(projectilePosition, weaponTransform.rotation);
        }
    }
Example #4
0
    public void Shoot(float angleOffset = 0)
    {
        Vector3 diff = targetTransform.position - transform.position;

        if (diff.magnitude > shootRange)
        {
            return;
        }
        Vector3 direction = diff.normalized;

        shootComponent.Shoot(direction, angleOffset);
    }
Example #5
0
 void InputCntrl_Space()
 {
     ShootComp.Shoot();
 }
Example #6
0
 public void Shoot()
 {
     _shootComp.Shoot();
 }