コード例 #1
0
    void Start()
    {
        //m_WeaponsManager = GetComponentInParent<IS_PlayerWeaponsManager>();
        DebugUtility.HandleErrorIfNullFindObject <IS_PlayerWeaponsManager, CrosshairManager>(m_WeaponsManager, this);

        OnWeaponChanged(m_WeaponsManager.GetActiveWeapon());

        m_WeaponsManager.onSwitchedToWeapon += OnWeaponChanged;
    }
コード例 #2
0
    void Update()
    {
        float currenFillRatio = m_Weapon.currentAmmoRatio;

        ammoFillImage.fillAmount = Mathf.Lerp(ammoFillImage.fillAmount, currenFillRatio, Time.deltaTime * ammoFillMovementSharpness);

        bool isActiveWeapon = m_Weapon == m_IS_PlayerWeaponsManager.GetActiveWeapon();

        canvasGroup.alpha    = Mathf.Lerp(canvasGroup.alpha, isActiveWeapon ? 1f : unselectedOpacity, Time.deltaTime * 10);
        transform.localScale = Vector3.Lerp(transform.localScale, isActiveWeapon ? Vector3.one : unselectedScale, Time.deltaTime * 10);
        controlKeysRoot.SetActive(!isActiveWeapon);

        FillBarColorChange.UpdateVisual(currenFillRatio);
    }
コード例 #3
0
    void OnPicked(IS_PlayerCharacterController byPlayer)
    {
        IS_PlayerWeaponsManager IS_PlayerWeaponsManager = byPlayer.GetComponent <IS_PlayerWeaponsManager>();

        if (IS_PlayerWeaponsManager)
        {
            if (IS_PlayerWeaponsManager.AddWeapon(weaponPrefab))
            {
                // Handle auto-switching to weapon if no weapons currently
                if (IS_PlayerWeaponsManager.GetActiveWeapon() == null)
                {
                    IS_PlayerWeaponsManager.SwitchWeapon(true);
                }

                m_Pickup.PlayPickupFeedback();

                Destroy(gameObject);
            }
        }
    }
コード例 #4
0
    void Start()
    {
        if (desiredPlayer != null)
        {
            m_IS_PlayerWeaponsManager = desiredPlayer.GetComponent <IS_PlayerWeaponsManager>();
        }
        // m_IS_PlayerWeaponsManager = FindObjectOfType<IS_PlayerWeaponsManager>();
        DebugUtility.HandleErrorIfNullFindObject <IS_PlayerWeaponsManager, WeaponHUDManager>(m_IS_PlayerWeaponsManager, this);

        WeaponController activeWeapon = m_IS_PlayerWeaponsManager.GetActiveWeapon();

        if (activeWeapon)
        {
            AddWeapon(activeWeapon, m_IS_PlayerWeaponsManager.activeWeaponIndex);
            ChangeWeapon(activeWeapon);
        }

        m_IS_PlayerWeaponsManager.onAddedWeapon      += AddWeapon;
        m_IS_PlayerWeaponsManager.onRemovedWeapon    += RemoveWeapon;
        m_IS_PlayerWeaponsManager.onSwitchedToWeapon += ChangeWeapon;
    }