예제 #1
0
    /// <summary>
    /// 主武器改变时
    /// </summary>
    private void OnMainWeaponChanged()
    {
        m_lastFireFail = false;

        m_CurrentTargetList.Clear();

        m_Crosshair = null;
        m_Point = null;
        m_Frame = null;
        m_FrameBox = null;
        m_TargetBox = null;

        for (int i = 0; i < m_Root.childCount; i++)
        {
            m_Root.GetChild(i).gameObject.SetActive(false);
        }

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

        IWeapon currentWeapon = skillProxy.GetCurrentWeapon();

        m_WeaponStyle = (int)WeaponAndCrossSight.WeaponAndCrossSightTypes.Null;
        m_AutoLockEnabled = currentWeapon != null && currentWeapon.GetConfig().AssistKey != 0;

        SpacecraftEntity main = GetMainEntity();
        if (main && IsBattling())
        {
            IReformer reformer = skillProxy.UsingReformer() ? skillProxy.GetReformer() : null;

            if (reformer != null)
                m_WeaponStyle = (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.GetConfig().Reticle;
            else if (currentWeapon != null)
                m_WeaponStyle = (WeaponAndCrossSight.WeaponAndCrossSightTypes)currentWeapon.GetConfig().Reticle;
        }

        m_Crosshair = m_Root.GetChild((int)m_WeaponStyle).GetComponent<RectTransform>();
       // m_Crosshair.gameObject.SetActive(true);
        m_Point = m_Crosshair.Find("point") != null ? m_Crosshair.Find("point").GetComponent<RectTransform>() : null;
        m_Frame = m_Crosshair.Find("frame") != null ? m_Crosshair.Find("frame").GetComponent<RectTransform>() : null;
        m_FrameBox = m_Crosshair.Find("FrameBox") != null ? m_Crosshair.Find("FrameBox").GetComponent<RectTransform>() : null;
        m_TargetBox = m_Crosshair.Find("Targets") != null ? m_Crosshair.Find("Targets").GetComponent<RectTransform>() : null;
	}
    /// <summary>
    /// 转化炉切换
    /// </summary>
    /// <param name="entityEvent"></param>
    private void ReformerWeapons(IComponentEvent entityEvent)
    {
        if (m_IPerceptronTarget.GetCurrentState().IsHasSubState(EnumSubState.Peerless))
        {
            //转化炉模式
            if (!m_SkillProxy.UsingReformer())
            {
                return;
            }

            IReformer reformer = m_SkillProxy.GetReformer();
            if (reformer == null)
            {
                return;
            }
            ulong uid = reformer.GetUID();
            if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid))
            {
                WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid,
                                                                                             reformer.GetConfig().Id, reformer.GetBaseConfig().SkillId,
                                                                                             (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.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)
                {
                    return;
                }
                m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross);
            }
        }
        else
        {
            //非转化炉模式
            m_IPerceptronTarget.DeleReformerWeaponAndCrossSight();
        }
    }