コード例 #1
0
    /// <summary>
    /// 在武器变化的时候, 更新当前实装的武器的准星信息
    /// </summary>
    private void UpdateBattleWeapons(IComponentEvent entityEvent)
    {
        ItemOperateEvent itemEvent = entityEvent as ItemOperateEvent;

        Dictionary <ulong, BattleWeaponBase> newBattleWeapons = new Dictionary <ulong, BattleWeaponBase>();

        for (int iWeapon = 0; iWeapon < BATTLE_WEAPON_COUNT; iWeapon++)
        {
            IWeapon weapon = m_SkillProxy.GetWeaponByIndex(iWeapon);
            if (weapon == null)
            {
                continue;
            }

            // 获取iWeapon对应武器的UID
            ulong uid = weapon.GetUID();
            // 查看当前是否有这把武器的准星信息
            if (m_Property.HaveBattleWeapon(uid))
            {
                newBattleWeapons.Add(uid, m_Property.GetBattleWeapon(uid));
            }
            else
            {
                BattleWeaponBase.BattleWeaponType weaponType = BattleWeaponBase.GetBattleWeaponTypeByReticle(weapon.GetConfig().Reticle);
                newBattleWeapons.Add(uid, CreateNewBattleWeapon(weaponType, weapon));
            }
        }

        m_Property.ResetBattleWeapons(newBattleWeapons);
    }
コード例 #2
0
    /// <summary>
    /// 在武器变化的时候, 更新当前实装的武器的准星信息
    /// </summary>
    private void UpdateBattleWeapons(IComponentEvent entityEvent)
    {
        PlayerSkillProxy m_SkillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

        for (int iWeapon = 0; iWeapon < BATTLE_WEAPON_COUNT; iWeapon++)
        {
            IWeapon weapon = m_SkillProxy.GetWeaponByIndex(iWeapon);
            if (weapon == null)
            {
                continue;
            }

            ulong uid = weapon.GetUID();

            if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid))
            {
                WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid,
                                                                                             weapon.GetConfig().Id, weapon.GetBaseConfig().SkillId,
                                                                                             (WeaponAndCrossSight.WeaponAndCrossSightTypes)weapon.GetConfig().Reticle);

                //Debug.LogError(string.Format("创建准星 uid = {0}, tid = {1} , type = {2}, null? {3}", uid, weapon.GetConfig().Id, weapon.GetConfig().Reticle , (weaponAndCross== null)));

                if (weaponAndCross == null)
                {
                    continue;
                }
                m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross);
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// 武器切换时
    /// </summary>
    /// <param name="hiddenRoot">是否隐藏根节点</param>
    private void OnWeaponToggleEnd(bool hiddenRoot)
    {
        m_Root.alpha = hiddenRoot ? 0 : 1;

        PlayerSkillProxy skillProxy = Facade.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

        IWeapon currWeapon = skillProxy.GetCurrentWeapon();

        if (currWeapon != null)
        {
            IWeapon mainWeapon      = skillProxy.GetWeaponByIndex(0);
            IWeapon secondaryWeapon = skillProxy.GetWeaponByIndex(1);

            m_MainWeapon.gameObject.SetActive(true);
            m_SecondaryWeapon.gameObject.SetActive(true);

            m_MainWeapon.ResetTrigger("Big");
            m_MainWeapon.ResetTrigger("Small");

            m_SecondaryWeapon.ResetTrigger("Big");
            m_SecondaryWeapon.ResetTrigger("Small");

            m_RootAnimator.ResetTrigger("Show");
            m_RootAnimator.SetTrigger("Show");

            if (skillProxy.UsingReformer())
            {
                if (currWeapon.GetPos() == 0)
                {
                    m_MainWeapon.SetTrigger("Big");
                    m_SecondaryWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.gameObject.SetActive(secondaryWeapon != null);
                }
                else if (currWeapon.GetPos() == 1)
                {
                    m_MainWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.SetTrigger("Big");
                    m_MainWeapon.gameObject.SetActive(mainWeapon != null);
                }
            }
            else
            {
                if (currWeapon.GetPos() == 0)
                {
                    m_MainWeapon.SetTrigger("Big");
                    m_SecondaryWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.gameObject.SetActive(secondaryWeapon != null);
                }
                else if (currWeapon.GetPos() == 1)
                {
                    m_MainWeapon.SetTrigger("Small");
                    m_SecondaryWeapon.SetTrigger("Big");
                    m_MainWeapon.gameObject.SetActive(mainWeapon != null);
                }
            }

            m_MainWeapon.gameObject.SetActive(mainWeapon != null);
            if (mainWeapon != null)
            {
                UIUtil.SetIconImage(m_MainWeaponIcon, mainWeapon.GetBaseConfig().Icon);
            }

            m_SecondaryWeaponIcon.gameObject.SetActive(secondaryWeapon != null);
            if (secondaryWeapon != null)
            {
                UIUtil.SetIconImage(m_SecondaryWeaponIcon, secondaryWeapon.GetBaseConfig().Icon);
            }
        }
        else
        {
            m_MainWeapon.gameObject.SetActive(false);
            m_SecondaryWeapon.gameObject.SetActive(false);
        }
    }