コード例 #1
0
    void OnTriggerEnter(Collider other)
    {
        GameObject hitObject = other.gameObject;

        if (hitObject.tag == "Player" && renderer.enabled)
        {
            weaponController = hitObject.GetComponent <PlayerWeapons>();

            if (!weaponController.HasWeaponCheck("SniperRifle"))
            {
                weaponController.AddWeapon("SniperRifle");
                weaponController.SetCurrentWeapon("SniperRifle");
                renderer.enabled = false;
                StartCoroutine(PickupReturn());
            }
            else if (!weaponController.IsFullCheck("SniperRifle"))
            {
                curAmmo = weaponController.GetSniperCurrentAmmo();
                weaponController.SetCurrentWeapon("SniperRifle");
                weaponController.SetWeaponCurrentAmmo(curAmmo + plusAmmo);
                renderer.enabled = false;
                StartCoroutine(PickupReturn());
            }
        }
    }
コード例 #2
0
    public void Buy(GameObject player)
    {
        PlayerWeapons playerWeapons = player.GetComponent <PlayerWeapons>();
        PlayerMoney   playerMoney   = player.GetComponent <PlayerMoney>();

        if (playerWeapons && playerMoney && playerMoney.currentMoney >= weaponPrice)
        {
            playerWeapons.AddWeapon(weapon);
            playerMoney.LooseMoney(weaponPrice);
        }
    }
コード例 #3
0
    public void PickUp(GameObject player)
    {
        PlayerWeapons playerWeapons = player.GetComponentInParent <PlayerWeapons>();

        if (playerWeapons)
        {
            Debug.Log("Pick Up" + gameObject.name);
            playerWeapons.AddWeapon(weapon);
            player.GetComponentInChildren <PlayerInteraction>().RemoveFocus();
            Destroy(gameObject);
        }
    }
コード例 #4
0
    public void UpdateWeaponList(IState state, string propertyPath, ArrayIndices arrayIndices)
    {
        int          index = arrayIndices[0];
        IPlayerState s     = (IPlayerState)state;

        if (s.Weapons[index].ID == -1)
        {
            _playerWeapons.RemoveWeapon(index);
        }
        else
        {
            _playerWeapons.AddWeapon((WeaponID)s.Weapons[index].ID);
        }
    }
コード例 #5
0
    void OnTriggerEnter(Collider other)
    {
        GameObject hitObject = other.gameObject;
        if( hitObject.tag == "Player" && renderer.enabled ) {
            weaponController = hitObject.GetComponent<PlayerWeapons>();

            if( ! weaponController.HasWeaponCheck("SniperRifle") ) {
                weaponController.AddWeapon("SniperRifle");
                weaponController.SetCurrentWeapon("SniperRifle");
                renderer.enabled = false;
                StartCoroutine( PickupReturn() );
            } else if ( ! weaponController.IsFullCheck("SniperRifle") ) {
                curAmmo = weaponController.GetSniperCurrentAmmo();
                weaponController.SetCurrentWeapon("SniperRifle");
                weaponController.SetWeaponCurrentAmmo( curAmmo + plusAmmo );
                renderer.enabled = false;
                StartCoroutine( PickupReturn() );
            }
        }
    }