GetCurrentWeapon() public method

public GetCurrentWeapon ( ) : PlayerWeapon,
return PlayerWeapon,
Beispiel #1
0
    private void Update()
    {
        SetHealthAmount(player.GetHealthPct());
        if (!weaponManager.isReloading)
        {
            SetAmmoAmount(weaponManager.GetCurrentWeapon().bullets, weaponManager.GetCurrentWeapon().maxBullets);
        }
        else
        {
            SetAmmoAmount(0, weaponManager.GetCurrentWeapon().maxBullets);
        }
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            scoreboard.SetActive(true);
        }
        else if (Input.GetKeyUp(KeyCode.Tab))
        {
            scoreboard.SetActive(false);
        }

        if (Input.GetKeyDown(KeyCode.R) && !weaponManager.isReloading)
        {
            weaponManager.Reload();
        }
    }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         if (manager)
         {
             manager.GetCurrentWeapon().PressTrigger();
         }
     }
     else if (Input.GetButtonUp("Fire1"))
     {
         if (manager)
         {
             manager.GetCurrentWeapon().ReleaseTrigger();
         }
     }
     else if (Input.GetKeyDown(KeyCode.R))
     {
         if (manager)
         {
             manager.Reload();
         }
     }
     else
     {
         foreach (var pair in keyMap)
         {
             if (Input.GetKeyDown(pair.Key))
             {
                 manager.SetCurrentWeapon(pair.Value);
             }
         }
     }
 }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (PauseMenu.IsOn)
        {
            return;
        }

        currentWeapon = weaponManager.GetCurrentWeapon();
        if (currentWeapon.fireRate <= 0f)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }
    }
Beispiel #4
0
 void Update()
 {
     SetFuelAmount(controller.GetThrusterFuelAmount());
     SetHealthAmount(player.GetHealthPct());
     if (weaponManager != null && weaponManager.GetCurrentWeapon() != null)
     {
         SetAmmoAmount(weaponManager.GetCurrentWeapon().bullets);
     }
 }
    public void Upgrade()
    {
        int upgradeCost = weaponManager.GetCurrentWeapon().GetUpgradeCost();

        if (PlayerStats.Money < upgradeCost)
        {
            Debug.Log("Not enought money to upgrade it");
        }
        else
        {
            weaponManager.GetCurrentWeapon().UpgradeWeapon();
            PlayerStats.Money -= upgradeCost;
            SetTarget(target);      // refresh
        }
    }
Beispiel #6
0
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (currentWeapon.fireRate <= 0f)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                ShootWeapon();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                //Repeatedly call X method, after Y wait time, at Z rate
                InvokeRepeating("ShootWeapon", 0f, (60f / currentWeapon.fireRate));
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                //Cancel calling of X method
                CancelInvoke("ShootWeapon");
            }
        }
    }
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (currentWeapon.fireRate <= 0)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                //j
                InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                //when we let go of fire1
                CancelInvoke("Shoot");
            }
        }
    }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (PauseMenu.IsOn)
        {
            return;
        }
        if (currentWeapon.type == GameConstants.BASE_WEAPON)
        {
            UseBaseWeapon();
        }
        else if (currentWeapon.type == GameConstants.TIME_STOP)
        {
            UseTimeStop();
        }
        else if (currentWeapon.type == GameConstants.PHONE_GRENADE)
        {
            UsePhoneGrenade();
        }
        else
        {
            UseWeapon();
        }
    }
Beispiel #9
0
    private void Update()
    {
        if (player.isLocalPlayer)
        {
            Vector3 newPosition = player.transform.position;
            newPosition.y = player.transform.position.y + 10;
            minimapCamera.transform.position = newPosition;
        }

        SetFuelAmount(controller.GetThrusterFuelAmount());
        SetHealthAmount(player.GetHealthPct());
        SetAmmoAmount(weaponManager.GetCurrentWeapon().bullets);

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            TogglePauseMenu();
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            scoreboard.SetActive(true);
        }
        else if (Input.GetKeyUp(KeyCode.Tab))
        {
            scoreboard.SetActive(false);
        }
    }
Beispiel #10
0
    void Update()
    {
        _currentWeapon = _weaponManager.GetCurrentWeapon();
        if (_currentWeapon == null)
        {
            return;
        }

        if (_currentWeapon.fireRate <= 0)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Attack();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Attack", 0f, 1f / _currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Attack");
            }
        }
    }
Beispiel #11
0
    private void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (currentWeapon.bullets < currentWeapon.maxBullets)
        {
            if (Input.GetButtonDown("Reload"))
            {
                weaponManager.Reload();
                return;
            }
        }

        if (currentWeapon.fireRate <= 0.0f)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0.0f, 1.0f / currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }
    }
Beispiel #12
0
 private void Update()
 {
     currentWeapon = weaponManager.GetCurrentWeapon();
     if (!GetComponent <PlayerController>().actMenu)
     {
         if (currentWeapon.fireRate <= 0f)
         {
             if (Input.GetButtonDown("Fire1"))
             {
                 Shoot();
             }
         }
         else
         {
             if (Input.GetButtonDown("Fire1"))
             {
                 GetComponent <PlayerController>().speed = GetComponent <PlayerController>().shootSpeed;
                 InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
             }
             else if (Input.GetButtonUp("Fire1"))
             {
                 GetComponent <PlayerController>().speed = GetComponent <PlayerController>().normalSpeed;
                 CancelInvoke("Shoot");
             }
         }
     }
     if (GetComponent <PlayerController>().actMenu)
     {
         CancelInvoke("Shoot");
     }
 }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        _currentWeapon = _weaponManager.GetCurrentWeapon();

        if (Input.GetButtonDown("Reload") && _currentWeapon.currentAmmo != _currentWeapon.maxAmmo)
        {
            _weaponManager.Reload();
            return;
        }

        if (_currentWeapon.fireRate <= 0f)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0f, 1f / _currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke(nameof(Shoot));
            }
        }
    }
Beispiel #14
0
    // Update is called once per frame
    private void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        //offset = target.position - transform.position;
        //sqrDistance = offset.sqrMagnitude;

        //if (sqrDistance < sqrDetectionRange)
        //{
        //    agent.SetDestination(target.position);
        //}

        //stateCheckCD -= Time.deltaTime;
        //if(stateCheckCD <= 0)
        //{
        //    CheckState();
        //    stateCheckCD = Random.Range(0.2f,0.7f);
        //}

        //FaceTarget();
        //currentWeapon = weaponManager.GetCurrentWeapon();
        //// stop moving when in range
        //if (target.CompareTag("Player"))
        //    agent.stoppingDistance = currentWeapon.range;
        //else
        //    agent.stoppingDistance = 2;
    }
Beispiel #15
0
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (!PauseMenu.isOn)
        {
            if (currentWeapon.fireRate <= 0f)
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    Shoot();
                }
            }
            else
            {
                if (Input.GetButtonDown("Fire1"))
                {
                    accuracyDiv = 5;
                    firstShot   = true;
                    InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
                }
                else if (Input.GetButtonUp("Fire1"))
                {
                    CancelInvoke("Shoot");
                }
            }
        }
        else if (IsInvoking("Shoot"))
        {
            CancelInvoke("Shoot");
        }
    }
Beispiel #16
0
    public void WeaponChanged()
    {
        if (weaponManager != null)
        {
            Weapon tempWeapon = weaponManager.GetCurrentWeapon();
            //we have no weapons
            if (tempWeapon == null)
            {
                weapon = null;
                return;
            }
            switch (tempWeapon.gameObject.name)
            {
            case ("AK47"):
                weapon = tempWeapon as AK47Script;
                break;

            case ("UMP45"):
                weapon = tempWeapon as UMP45Script;
                break;

            default:
                weapon = tempWeapon as AK47Script;
                break;
            }
            weapon.SetupWeapon();
            currentAmmo = weapon.currentAmmo;
            sprayIndex  = 0;
        }
    }
Beispiel #17
0
    private void Update()
    {
        if (PauseMenu.isOn)
        {
            return;
        }

        currentWeapon = weaponManager.GetCurrentWeapon();
        if (currentWeapon.fireRate <= 0)
        {
            if (Input.GetButtonDown("Fire1"))
            {
                //Debug.Log("Fire button pressed.");
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }
    }
Beispiel #18
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.T))
        {
            CancelInvoke();
            weaponManager.TogglePrimarySecondary();
        }

        currentWeapon = weaponManager.GetCurrentWeapon();

        //Regardless of *current* weapon type,
        //cancel any previously invoked fire() when releasing trigger
        if (Input.GetButtonUp("Fire1"))
        {
            CancelInvoke();
        }
        else if (Input.GetButtonDown("Fire1"))
        {
            if (currentWeapon.CanAutoFire())
            {
                InvokeRepeating("FireWeapon", 0.000001f, currentWeapon.fireDelay);
            }
            else
            {
                FireWeapon();
            }
        }
    }
    void Start()
    {
        time   = 0;
        rb     = GetComponent <Rigidbody>();
        player = GameObject.Find(Character.PLAYER);

        Transform player_object_transform = player.transform.Find("front");

        colliderPos = player_object_transform.position + player_object_transform.forward * 10f + new Vector3(0f, 3.2f, 0f);

        wm     = player.GetComponent <WeaponManager>();
        weapon = wm.GetCurrentWeapon();

        if (weapon is GrenadeLauncher) //grenadelauncher
        {
            rb.velocity = (colliderPos - rb.position).normalized;
            speed       = 2000;
            Destroy(gameObject, 5f);
        }
        else
        {
            rb.velocity = ((colliderPos - rb.position).normalized + AddNoiseOnAngle(-weapon.weapon_spread, weapon.weapon_spread)) * speed;
            //if(Vector3.Distance(gameObject.transform.position, colliderPos) < 1f)
            //{
            //    rb.velocity = player_object_transform.position + player_object_transform.forward * 10f + new Vector3(0f, 3.2f, 0f);
            //}
            rb.velocity = new Vector3(rb.velocity.x, 2.5f, rb.velocity.z);
            Destroy(gameObject, 1f);
        }
        rb.transform.rotation = Quaternion.LookRotation(rb.velocity);
    }
Beispiel #20
0
    /// <summary>
    /// Handles shooting when firing
    /// </summary>
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        currentWeapon = weaponManager.GetCurrentWeapon();

        if (currentWeapon != null)
        {
            if (currentWeapon.fireRate <= 0f && Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
            else
            {
                // Rapid fire
                if (Input.GetButtonDown("Fire1") && !GameMenu.isOn)
                {
                    InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
                    GetComponent <Animator>().SetBool("Fire", true);
                }
                else if (Input.GetButtonUp("Fire1"))
                {
                    CancelInvoke("Shoot");
                    GetComponent <Animator>().SetBool("Fire", false);
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (PauseMenu.isOn)
        {
            return;
        }
        if (currentWeapon == null)
        {
            return;
        }
        if (currentWeapon.fireRate <= 0)
        {
            //Debug.Log("Weapon found");
            if (Input.GetButtonDown("Fire1"))
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButton("Fire1"))
            {
                Debug.Log("ffffffffffffffff");
                InvokeRepeating("Shoot", 0f, currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }
    }
Beispiel #22
0
    private void Update()
    {
        curWeapon = weaponManager.GetCurrentWeapon();

        if (curWeapon.fireRate <= 0f)
        {
            if (Input.GetButtonDown("Fire1"))    //make shoot via left click of the mouse
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1"))
            {
                InvokeRepeating("Shoot", 0f, 1f / curWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            CmdPlayerRayCast();
        }
    }
    // Check shooting.
    void Update()
    {
        // Get the current weapon from the WeaponManager.
        currentWeapon = weaponManager.GetCurrentWeapon();

        // If the weapon is semi-automatic.
        if (currentWeapon.fireRate <= 0f)
        {
            // If the player pressed the Fire button.
            if (Input.GetButtonDown("Fire1"))
            {
                // Call method to the the shooting.
                Shoot();
            }
        }
        else
        {
            // The weapon si full-auto!
            // If the player pressed the Fire button.
            if (Input.GetButtonDown("Fire1"))
            {
                // This will call the Shoot function, with a 0f delay and at (1/fireRate) intervals.
                InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
            }
            else if (Input.GetButtonUp("Fire1"))
            {
                // The player stopped pressing the fire button.
                CancelInvoke("Shoot");
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (!isAllowedToShoot)
        {
            return;
        }

        if (currentWeapon.fireRate <= 0)
        {
            if (Input.GetButtonDown("Fire1") && !weaponManager.isReloading)
            {
                Shoot();
            }
        }
        else
        {
            if (Input.GetButtonDown("Fire1") && !weaponManager.isReloading)
            {
                InvokeRepeating("Shoot", 0f, 1f / currentWeapon.fireRate);
            }
            if (Input.GetButtonUp("Fire1"))
            {
                CancelInvoke("Shoot");
            }
        }

        if (Input.GetMouseButton(1)) // right click held
        {
            Focus();
        }
        else
        {
            Unfocus();
        }

        if (Input.GetKeyDown("r"))
        {
            TryToReload();
        }

        if (currentWeapon.bullets <= 0)
        {
            TryToReload();
        }
    }
Beispiel #25
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        weaponUP        = weaponManager.GetCurrentWeapon().GetWeaponUpgrade();
        damage.text     = weaponUP.damage.ToString();
        fireRate.text   = weaponUP.fireRate.ToString();
        maxBullets.text = weaponUP.maxBullets.ToString();

        ui.SetActive(true);
    }
Beispiel #26
0
    void Awake()
    {
        weaponManager = GetComponent <WeaponManager>();

        if (weaponManager)
        {
            ChangeAnimationState(weaponManager.GetCurrentWeapon().GetAnimationString(), true);
        }
    }
 void Start()
 {
     if (cam == null)
     {
         this.enabled = false;
     }
     weaponManager             = GetComponent <WeaponManager>();
     currentWeapon             = weaponManager.GetCurrentWeapon();
     EventManager.WeaponCheck += setCurrentWeapon;
 }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();

        if (Input.GetButtonDown("Fire1"))
        {
            Attack();
            weaponManager.Attack();
        }
    }
Beispiel #29
0
    // Update is called once per frame
    void Update()
    {
        currentWeapon = weaponManager.GetCurrentWeapon();
        ammo          = currentWeapon.bullets;

        if (canShoot && Input.GetButtonDown("Fire1") && !playerMotor.zoom && !gameOver)
        {
            Shoot();
        }
    }
Beispiel #30
0
    private void Update()
    {
        SetFeulAmount(controller.GetThusterFuelAmount());
        SetHealthAmount(player.GetHealthPct());
        SetAmmoAmount(weaponManager.GetCurrentWeapon().bullets, weaponManager.GetCurrentWeapon().maxBullets);

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            TogglePauseMenu();
        }

        if (Input.GetKeyDown(KeyCode.Tab))
        {
            scoreboard.SetActive(true);
        }
        else if (Input.GetKeyUp(KeyCode.Tab))
        {
            scoreboard.SetActive(false);
        }
    }