コード例 #1
0
    private void SwapCurrentWeapon(Weapon_SO weaponSo)
    {
        if (_currentWeaponGameObject != null)
        {
            if (_currentWeapon == null)
            {
                Debug.LogError("Something wrong with the weapon SO here");
            }
            //TODO change if want to drop current weapon on the floor
            Destroy(_currentWeaponGameObject);
            _currentWeaponGameObject = null;
            _currentWeapon           = null;
        }

        if (_currentWeapon == null && _currentWeaponGameObject == null)
        {
            if (weaponSo.weaponPrefab != null)
            {
                _currentWeaponGameObject =
                    Instantiate(original: weaponSo.weaponPrefab, position: weaponSlotGameObject.position,
                                Quaternion.identity, parent: weaponSlotGameObject);
                _currentWeaponGameObject.transform.localRotation = Quaternion.Euler(0, 0, 0);
                _currentWeapon = weaponSo;
                _currentWeaponGameObject.transform.parent = weaponSlotGameObject;
            }
        }
    }
コード例 #2
0
 public void SetWeaponType(Weapon_SO weapon)
 {
     rend.material.color      = weapon.projectileColor;
     rendTrail.material.color = weapon.projectileColor;
     lifeTimeMax = weapon.projectileLifeTime;
     type        = weapon.weaponType;
     damagePower = weapon.damageOnHit;
 }
コード例 #3
0
    /// <summary>
    /// Apply weapon type for weapon. If weapon type is none, deactivates weapon gameonject
    /// </summary>
    /// <param name="type"></param>
    public void SetType(WeaponType type)
    {
        weaponType = type;
        if (type == WeaponType.none)
        {
            weaponDefinition = null;
            this.gameObject.SetActive(false);
            return;
        }
        else
        {
            this.gameObject.SetActive(true);
        }

        weaponDefinition          = WeaponManager.Instance.GetWeaponDefinition(type);
        collarRend.material.color = weaponDefinition.color;
/*        lastShotTime = 0;*/
    }
コード例 #4
0
 /// <summary>
 /// Call this method to add Weapon (for item call AddItemToPlayer)
 /// for swapping weapon call swap
 /// </summary>
 /// <param name="weapon"></param>
 /// <returns></returns>
 public bool AddWeaponToPlayer(Weapon_SO weapon)
 {
     // TODO ask the player if he wants to switch
     if (weapon != null)
     {
         Debug.Log("Switching weapon from " + _currentWeapon + " to " + weapon);
         SwapCurrentWeapon(weapon);
         if (_currentWeaponGameObject.GetComponent <PlayerWeapon>())
         {
             var playerWeapon = _currentWeaponGameObject.GetComponent <PlayerWeapon>();
             playerWeapon.fireClips             = weapon.fireSounds;
             _passiveStatsManager._playerWeapon = playerWeapon;
             _playerController.Weapon           = playerWeapon;
         }
         else
         {
             Debug.LogError("Something wrong here with PlayerWeapon");
         }
         Debug.Log("Current weapon now is " + _currentWeapon);
         return(true);
     }
     return(false);
 }
コード例 #5
0
    public void AbsorbePowerUp(ShipController ship)
    {
        ShipStats shipStats = ship.stats;

        switch (item.type)
        {
        case ItemType.shield:
            ShieldController shield = ship.gameObject.GetComponentInChildren <ShieldController>();
            shield.PowerUpShield();
            break;

        case ItemType.weapon:
            Weapon_SO newWeapon = (Weapon_SO)item;
            if (shipStats.GetActiveWeapon() != newWeapon.weaponType)
            {
                ship.ClearWeapons();
            }
            ship.ActivateFirstInactiveWeapon(newWeapon.weaponType);
            break;
        }

        Destroy(gameObject);
    }
コード例 #6
0
 private void SetWeaponHandler(WeaponHandler weaponHandler)
 {
     _weapon = weaponHandler.Weapon_SO;
 }
コード例 #7
0
 /// <summary>
 /// Call this method to remove the current equipped weapon
 /// Basically set the currentWeapon to null
 /// </summary>
 public void RemoveWeapon()
 {
     _currentWeapon = null;
 }