public void Aim(Vector3 aimPoint)
 {
     if (equippedGun != null)
     {
         equippedGun.Aim(aimPoint);
     }
 }
Esempio n. 2
0
 public void Aim(Vector3 AimPoint)
 {
     if (EquippedGun != null)
     {
         EquippedGun.Aim(AimPoint);
     }
 }
Esempio n. 3
0
 public void Aim()
 {
     if (m_EquippedGun != null)
     {
         m_EquippedGun.Aim();
     }
 }
Esempio n. 4
0
 public void Aim(Vector3 pos)
 {
     if (_equipedGun != null)
     {
         _equipedGun.Aim(pos);
     }
 }
Esempio n. 5
0
    void FixedUpdate()
    {
        //Movement
        bool  shoot = Input.GetAxis("Fire1") > 0;
        float h     = Input.GetAxis("Horizontal");
        float v     = Input.GetAxis("Vertical");

        Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

        moveInput   = _cam.transform.TransformDirection(moveInput);
        moveInput.y = 0;
        moveInput   = moveInput.normalized;

        //Rotation
        Ray   ray         = _cam.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.up * _gunHeight);
        float rayDistance;

        if (groundPlane.Raycast(ray, out rayDistance))
        {
            lookPoint = ray.GetPoint(rayDistance);

            crosshairs.transform.position = lookPoint;

            if ((new Vector2(lookPoint.x, lookPoint.z) - new Vector2(transform.position.x, transform.position.z)).sqrMagnitude > 1)
            {
                _gun.Aim(lookPoint);
            }
        }

        _player.Move(moveInput, lookPoint);
        _gun.Shooting(shoot);
    }
 public void Aim(Vector3 aimPoint)
 {
     if (currentGun != null)
     {
         currentGun.Aim(aimPoint);
     }
 }
Esempio n. 7
0
 public void Aim(Vector3 target)
 {
     if (equippedGun != null)
     {
         equippedGun.Aim(target);
     }
 }
 public void Aim(Vector3 aimPoint)
 {
     if (equippedGun != null)
     {
         equippedGun.OnTriggerRelease();
         equippedGun.Aim(aimPoint);
     }
 }
Esempio n. 9
0
 public void Aim(Vector3 aimPoint)
 {
     if (_equippedGun != null)
     {
         shotTime = _equippedGun.nextShotTime;
         _equippedGun.Aim(aimPoint);
     }
 }
    void Update()
    {
        if (Input.GetButtonDown("A_" + PlayerNumber))
        {
            Jumping = true;
        }

        float RHorizontal = Input.GetAxis("RHorizontal_" + PlayerNumber);
        float RVertical   = Input.GetAxis("RVertical_" + PlayerNumber);

        gun.Aim(new Vector3(RHorizontal, RVertical, 0));

        if (Input.GetAxis("Triggers_" + PlayerNumber) < 0)
        {
            gun.Fire();
        }
    }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        if (isFirstUpdate)
        {
            isFirstUpdate = false;
            Init();
        }

        gun.Aim();
        if (Input.GetButtonDown("Fire3") && !strategies[nextWeaponIndex].isReloading)
        {
            Swap();
        }
        if (Input.GetButtonDown("Reload"))
        {
            if (!strategies[nextWeaponIndex].isReloading)
            {
                strategies[nextWeaponIndex].currentAmmo = 0;
                ammoText.gameObject.SetActive(false);
                StartCoroutine(strategies[nextWeaponIndex].Reload());
            }
        }

        if (!strategies[nextWeaponIndex].isReloading && !ammoText.gameObject.activeSelf)
        {
            ammoText.gameObject.SetActive(true);
            ammoText.text = "Ammo: " + strategies[nextWeaponIndex].currentAmmo + " / " + strategies[nextWeaponIndex].capacity;
        }

        if ((Input.GetAxis("RightTrigger") <= -0.5 || Input.GetAxisRaw("RightTrigger") >= 0.5) && strategies[nextWeaponIndex].currentAmmo > 0 && !strategies[nextWeaponIndex].isReloading)
        {
            //cooldown time has to be zero to be able to shoot
            if (Time.time > timeToFire)
            {
                //Debug.Log("cooldown: " + cooldown);
                timeToFire = Time.time + cooldown;
                gun.Shoot();
                ammoText.text = "Ammo: " + strategies[nextWeaponIndex].currentAmmo + " / " + strategies[nextWeaponIndex].capacity;
                StartCoroutine(strategies[nextWeaponIndex].ShotEffect());
            }
        }
    }
Esempio n. 12
0
    // Handles input through controller scripts
    void GetInput()
    {
        // Movement
        Vector3 velocity     = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
        Vector3 moveVelocity = velocity.normalized * moveSpeed;

        playerController.Move(moveVelocity);

        // Turning
        Ray   ray         = viewCamera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.up * gunSpot.transform.position.y);
        float rayDistance;

        if (groundPlane.Raycast(ray, out rayDistance))      // Returns true if the ray intersects with the plane and also assigns
                                                            // value to the rayDistance - the out keyword

        {
            Vector3 intersection = ray.GetPoint(rayDistance);   // This is the itercestion point
                                                                //Debug.DrawLine(ray.origin, intersection, Color.red);
            playerController.LookAt(intersection);
            equippedGun.Aim(intersection);
        }

        // Gun pick up
        if (Input.GetKeyDown(KeyCode.F))
        {
            PickUpGun();
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            DropCurrentGun();
        }

        // Shooting
        if (equippedGun != null)
        {
            if (Input.GetMouseButton(0))
            {
                equippedGun.OnTriggerHold();
            }
            else if (Input.GetMouseButtonUp(0))
            {
                equippedGun.OnTriggerRelease();
            }
            //if (equippedGun.name == "C4(Clone)") {
            //    if (Input.GetMouseButtonUp(0)) {
            //        print("Want to detonate");
            //        equippedGun.Detonade();
            //    }
            //}
        }

        // Cam rise up
        if (Input.GetKeyDown(KeyCode.O))
        {
            camHeight += 3f;
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            camHeight -= 3f;
        }

        // Exit game
        if (Input.GetKey(KeyCode.R))
        {
            FindObjectOfType <SceneManager>().ReloadLevel();
            //Application.LoadLevel(Application.loadedLevel);
        }

        // Exit game
        if (Input.GetKey(KeyCode.Escape))
        {
            FindObjectOfType <SceneManager>().LoadLevel("Menu");
        }

        // WTFFFFFFFF DISABLING COLLIDER DOSENT WORKKKK
        if (Input.GetKeyDown(KeyCode.Space))
        {
            equippedGun.GetComponent <SphereCollider>().enabled = !equippedGun.GetComponent <SphereCollider>().enabled;
        }
    }
Esempio n. 13
0
    private void Update()
    {
        if (Input.GetKeyDown(reset))
        {
            Reset();
        }

        if (Game.Playing)
        {
            if (Input.GetKeyDown(aim))
            {
                SetupAim();
            }
            aiming         = Input.GetKey(aim);
            Time.timeScale = Aiming ? aimTimeScale : 1.0f;
            if (Aiming)
            {
                Aim();
            }
            else
            {
                Follow();
                Controll();
            }

            Vector3 direction;

            direction = cameraPosition - camera.position;
            if (direction.magnitude > 1)
            {
                direction.Normalize();
            }

            camera.Translate(direction * speed * Time.fixedDeltaTime);

            //camera.position = cameraPosition;
            camera.LookAt(player.transform.position + Vector3.up * player.height);
            //camera.position = camera.position + (player.Switch ? -camera.right : camera.right);

            if (Aiming)
            {
                camera.Translate(aimOffset);
                camera.Rotate(aimOffsetRotation);
                gun.Aim(camera.forward);
            }

            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                mousePosition = Input.mousePosition;
                if (mousePosition.y > Screen.height / 2)
                {
                    player.Push();
                }
            }
            else if (Input.GetKey(KeyCode.Mouse0))
            {
                player.Rotate((Input.mousePosition.x - mousePosition.x) / Screen.width);
                if (Input.mousePosition.y - mousePosition.y > Screen.height * 0.75f)
                {
                    mousePosition.y = Input.mousePosition.y;
                    Reset();
                }
            }

            /*
             * if (Input.GetKeyDown(fire))
             * {
             *  if (Aiming)
             *  {
             *      gun.Fire();
             *  }
             *  else
             *  {
             *      if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit, missleMaxDistance))
             *      {
             *          missles.Launch(hit.point, missleAccuracy);
             *      }
             *  }
             * }
             */

            //Chunk.Update(player.transform.position.x, player.transform.position.z, 3);
        }
    }
Esempio n. 14
0
 public void Aim(Vector3 aimPoint)
 {
     equippedGun?.Aim(aimPoint);
 }