예제 #1
0
 // On Attack down
 private void ActivateAttack()
 {
     if (allowAttack)
     {
         Weapon.Activate(ShootPoint.transform.position, ShootPoint.transform.forward);
     }
 }
예제 #2
0
 public void ActivateWeapon()
 {
     if (lastWeaponUsed)
     {
         lastWeaponUsed.Activate();
     }
 }
예제 #3
0
    IEnumerator Shoot()
    {
        _wpn.Activate();
        yield return(new WaitForSeconds(1f));

        _wpn.Shoot();
        yield return(new WaitForSeconds(6f));

        SceneManager.LoadScene(0);
    }
예제 #4
0
 public void EquipWeapon(Weapon weapon)
 {
     if (weapon != equippedWeapon && equippedWeapon != null)
     {
         equippedWeapon.Deactivate();
     }
     equippedWeapon = weaponPool.GetObject(weapon);
     equippedWeapon.Activate();
     equippedWeapon.PlayerOwner = this;
     OnPlayerDataUpdated.Invoke(this);
 }
예제 #5
0
 public void ActivateWeapon()
 {
     if (UseClaw())
     {
         myClaw.Activate();
     }
     else
     {
         myWeapon.Activate();
     }
 }
예제 #6
0
 public void ActivateAllWeapons(Weapon weapon)
 {
     if (inventory.Weapons.Contains(weapon))
     {
         activeWeapon = weapon;
         activeWeapon.Activate(bulletColor);
     }
     else
     {
         Log.log(gameObject.name + " doesn't own this weapon");
     }
 }
예제 #7
0
 private void HandleShooting()
 {
     if (Input.GetMouseButton(0))
     {
         if (!isPlacing && currentWeapon.CanActivate())
         {
             currentWeapon.recoil += 0.001f;
             currentWeapon.Activate();
         }
     }
     if (Input.GetKey(KeyCode.R))
     {
         currentWeapon.StartReloading();
     }
     currentWeapon.Recoil();
 }
예제 #8
0
    private void Shoot()
    {
        if (towerAim.getTarget() != null && equipment != null)
        {
            Debug.Log("activating weapon");
            equipment.Activate();
        }

        /*
         *      this.GetComponentInChildren<LineRenderer> ().enabled = true; //this might not be the best way to do this...
         *      yield return new WaitForSeconds (0.2f);
         *      Component targetComponent =  this.GetComponent<TowerAim> ().getTarget ().GetComponent<ReactiveTarget> ();
         *      if (targetComponent != null)
         *              this.GetComponent<TowerAim> ().getTarget ().GetComponent<ReactiveTarget> ().reactToHit ();
         *      this.GetComponentInChildren<LineRenderer> ().enabled = false;
         */
    }
예제 #9
0
    // Update is called once per frame
    void Update()
    {
        if (!(Inventory.isInventoryVisible || Inventory.isCharacterVisible))
        {
            if (Input.GetButton("Fire1") && weapon.CanFire())
            {
                weapon.PlayAttackAnimation();
                Debug.Log(transform.name + " attacked with " + weapon.GetName());
                Attack();
            }

            // TODO: Create WeaponSwitchDelay function instead of CanFire
            if (Input.GetButton("Fire2") && weapon.CanFire())
            {
                if (weapon.isActive)
                {
                    weapon.Deactivate();
                }
                else
                {
                    weapon.Activate();
                }
            }


            if (Input.GetButton("E"))
            {
                RaycastHit hit;

                if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, 3))
                {
                    Interactable interactable = hit.collider.GetComponent <Interactable>();
                    if (interactable != null)
                    {
                        PickupItem();
                    }
                }
            }
        }

        if (playerStats.currentHealth <= 0)
        {
            Die();
        }
    }
예제 #10
0
 // Update is called once per frame
 void Update()
 {
     checkPhase();
     if (!paused)
     {
         if (lastFired.isFinished)
         {
             timer -= Time.deltaTime;
             if (timer <= 0)
             {
                 Weapon nextWeapon = phases[currentPhase].weapons[(int)Mathf.Floor(UnityEngine.Random.Range(0, phases[currentPhase].weapons.Length))];
                 nextWeapon.Activate();
                 lastFired = nextWeapon;
                 timer     = lastFired.coolDown;
             }
         }
     }
 }
예제 #11
0
    public void PickUpNearestWeapon()
    {
        var nearest = TakeNearest();

        if (nearest)
        {
            Destroy(weapon);
            weapon             = nearest;
            weapScr            = nearest.GetComponent <Weapon>();
            weapScr.isFriendly = this.isFriendly;
            weapScr.Activate();
            weapon.transform.SetParent(weaponCenter);
            weapScr.targetPosition         = viewObject;
            weapon.transform.localPosition = new Vector2(0, 0);

            Utils.Throw(weapScr.weaponName, weaponCenter.position, weapScr.type);
        }
    }
    IEnumerator ActivateSecondaryWeapon()
    {
        while (true)
        {
            secondaryWpn.Activate();

            if (secondaryWpn.GetWeaponType() == WeaponType.Auto)
            {
                yield return(new WaitForSeconds(secondaryWpn.GetShotCooldown().GetCalcValue()));
            }
            else if (secondaryWpn.GetWeaponType() == WeaponType.Charged)
            {
                yield return(0);
            }

            yield return(0);
        }
    }
예제 #13
0
 public void ActivateWeapon(Weapon weapon)
 {
     if (inventory.Weapons.Contains(weapon))
     {
         if (activeWeapon != null)
         {
             activeWeapon.Deactivate();
         }
         activeWeapon = weapon;
         activeWeapon.Activate(bulletColor);
         if (OnWeaponChange != null)
         {
             OnWeaponChange(activeWeapon);
         }
     }
     else
     {
         Log.log(gameObject.name + " doesn't own this weapon");
     }
 }
예제 #14
0
    public void EquipWeapon(Weapon weapon)
    {
        if (Weapon != null)
        {
            PreviousWeapon = this.Weapon;
            Weapon.UnequipWeapon();
        }
        Weapon = weapon;
        Weapon.EquipWeapon();
        if (WeaponModel != null)
        {
            Destroy(WeaponModel);
        }
        if (weaponParticles.Root != null)
        {
            Destroy(weaponParticles.Root);
        }

        ShootPoint.transform.localPosition = ShootPointDefaultPosition;
        if (weapon.weaponData.particleEffects != null)                                                                      //attach the particle effects prefab to shootpoint if it exists
        {
            weaponParticles.UpdateRoot(Instantiate(weapon.weaponData.particleEffects, ShootPoint.transform), player.Color); //instantiate a particles prefab and make it the root of the weapon particles script
            weaponParticles.Root.name = "WeaponParticles";
            //if (weapon.weaponData.ShootPointPosition != null)
            //    weaponParticles.Root.transform.localPosition = weapon.weaponData.ShootPointPosition;
        }
        if (weapon.weaponData.weaponModel != null)
        {
            WeaponModel      = Instantiate(weapon.weaponData.weaponModel, ShootPoint.transform);
            WeaponModel.name = "Weapon";
            if (weapon.weaponData.WeaponPosition != null)
            {
                WeaponModel.transform.localPosition = weapon.weaponData.WeaponPosition;
            }
        }

        if (input.controllers[player.inputControllerNumber].attack.Pressed && allowAttack) // If the attack button was held down at the time of equipting new weapon activate the new weapon
        {
            Weapon.Activate(ShootPoint.transform.position, ShootPoint.transform.forward);
        }
    }
예제 #15
0
    public void SetWeapon(PartialWeapon weapon)
    {
        if (ActiveWeapon?.Data.Name == weapon.Name)
        {
            return;
        }

        ActiveWeapon?.Deactivate();

        var newWeapon = Weapons.SingleOrDefault(w => w.Data.Name == weapon.Name);

        if (newWeapon == null)
        {
            ActiveWeapon?.Activate();
            return;
        }

        ActiveWeapon = newWeapon;

        ActiveWeapon.Activate();
    }
예제 #16
0
 private void ChangeWeapon()
 {
     activeWeapon = weapons.Where(weapon => weapon.GetIndex() == currentWeaponSlot).First();
     activeWeapon.Activate();
     lastWeaponSlot = currentWeaponSlot;
 }
예제 #17
0
 void EndTimer()
 {
     weapon.Activate();
 }
예제 #18
0
 // What happens when trigger is activated
 private void OnActivate(Vector3 start, Vector3 direction, PlayerController targetController = null)
 {
     weapon.Activate(start, direction, targetController);
     weapon.Release();
 }