public void ShowShip()
    {
        ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        IShip     ship      = shipProxy.GetAppointWarShip();

        if (ship != null)
        {
            CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
            Model            model            = cfgEternityProxy.GetItemModelByKey(ship.GetTID());
            GameObject       container        = GameObject.Find(model.ExhibitionPoint);
            if (container)
            {
                m_Show = true;
                TransformUtil.FindUIObject <Transform>(container.transform, "Ship_Light").gameObject.SetActive(true);
                AssetUtil.InstanceAssetAsync(model.AssetName,
                                             (pathOrAddress, returnObject, userData) =>
                {
                    if (returnObject != null)
                    {
                        GameObject gameobj = (GameObject)returnObject;
                        gameobj.transform.SetParent(container.transform, false);
                        m_ShipGameObject = gameobj;
                        if (!m_Show)
                        {
                            HideShip();
                        }
                    }
                    else
                    {
                        Debug.LogError(string.Format("资源加载成功,但返回null,  pathOrAddress = {0}", pathOrAddress));
                    }
                });
            }
        }
    }
 /// <summary>
 /// 设置船内容显示
 /// </summary>
 /// <param name="ship"></param>
 public void SetData(IShip ship, bool isList)
 {
     Initialize();
     m_Ship = ship;
     if (isList)
     {
         UIUtil.SetIconImage(m_IconImage, TableUtil.GetItemIconBundle(ship.GetTID()), TableUtil.GetItemIconImage(ship.GetTID()));
     }
     else
     {
         UIUtil.SetIconImage(m_IconImage, TableUtil.GetItemIconBundle(ship.GetTID()), TableUtil.GetItemSquareIconImage(ship.GetTID()));
     }
     m_OverlyingIcon.sprite = m_IconImage.sprite;
     m_NameLabel.text       = TableUtil.GetItemName((int)ship.GetTID());
     m_LvLabel.text         = TableUtil.ShowLevel(ship.GetLv());
     m_Appoint.gameObject.SetActive(ship.GetUID() == m_ShipProxy.GetAppointWarShip().GetUID());
     m_New.gameObject.SetActive(!m_ShipProxy.MarkNew(ship));
 }
    /// <summary>
    /// 获取技能表
    /// </summary>
    /// <returns>玩家技能数据列表</returns>
    public PlayerSkillVO[] GetSkills()
    {
        if (m_ShipIDToSkillList == null || m_ShipIDToSkillList.Count == 0)
        {
            m_ShipIDToSkillList = new Dictionary <uint, List <PlayerSkillVO> >();
            RebuildSkillList();
        }

        ShipProxy shipProxy   = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        IShip     currentShip = shipProxy.GetAppointWarShip();

        if (currentShip != null)
        {
            if (m_ShipIDToSkillList.ContainsKey(currentShip.GetTID()))
            {
                return(m_ShipIDToSkillList[currentShip.GetTID()].ToArray());
            }
        }

        return(new PlayerSkillVO[] { });
    }
Exemple #4
0
    public override void OnShow(object msg)
    {
        base.OnShow(msg);

        LoadViewPart(ASSET_ADDRESS, OwnerView.ListBox);
        OwnerView.PageBox.gameObject.SetActive(false);
        m_WarshipDialogPanel             = OwnerView as WarshipDialogPanel;
        m_BeforeToggle                   = m_WarshipDialogPanel.BeforeToggle;
        m_CfgEternityProxy               = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        m_ShipProxy                      = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;
        m_PackageProxy                   = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        m_ServerListProxy                = GameFacade.Instance.RetrieveProxy(ProxyName.ServerListProxy) as ServerListProxy;
        m_SceneShipProxy                 = GameFacade.Instance.RetrieveProxy(ProxyName.SceneShipProxy) as SceneShipProxy;
        m_WarshipDialogPanel.AppointShip = m_ShipProxy.GetAppointWarShip();

        if (m_WarshipDialogPanel.LastShip != null)
        {
            if (m_ShipProxy.GetAppointWarShip().GetTID() != m_WarshipDialogPanel.LastShip.GetTID())
            {
                m_SceneShipProxy.HideShip();
                m_SceneShipProxy.ShowShip();
            }
        }
        m_WarshipDialogPanel.LastShip = m_ShipProxy.GetAppointWarShip();
        if (msg != null)
        {
            m_CurrentShip = msg as IShip;
        }
        else
        {
            m_CurrentShip = m_ShipProxy.GetAppointWarShip();
        }
        m_ShowAppiontIcon = true;
        if (m_WarshipDialogPanel.AppointShip.GetTID() != m_CurrentShip.GetTID())
        {
            m_ShowAppiontIcon = false;
        }
        if (m_CurrentShip == null)
        {
            return;
        }
        if (m_CurrentShip == null)
        {
            Debug.Log("没有战船");
            return;
        }

        m_Weapons = new IWeapon[m_CurrentShip.GetWeaponContainer().GetCurrentSizeMax()];
        IWeapon[] tempWeapons = m_CurrentShip.GetWeaponContainer().GetWeapons();
        if (tempWeapons != null)
        {
            for (int i = 0; i < tempWeapons.Length; i++)
            {
                m_Weapons[tempWeapons[i].GetPos()] = tempWeapons[i];
            }
            tempWeapons = null;
        }

        m_Equipment = new IEquipment[m_CurrentShip.GetEquipmentContainer().GetCurrentSizeMax()];
        IEquipment[] tempEquips = m_CurrentShip.GetEquipmentContainer().GetEquipments();
        if (tempEquips != null)
        {
            for (int i = 0; i < tempEquips.Length; i++)
            {
                m_Equipment[tempEquips[i].GetPos()] = tempEquips[i];
            }
            tempEquips = null;
        }

        m_Reformer = m_CurrentShip.GetReformerContainer().GetReformer();
    }
    /// <summary>
    /// 重建技能列表
    /// </summary>
    public void RebuildSkillList()
    {
        RefreshShipSkills();

        ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy;

        IShip currentShip = shipProxy.GetAppointWarShip();

        if (currentShip != null)
        {
            if (m_ShipIDToSkillList == null)
            {
                m_ShipIDToSkillList = new Dictionary <uint, List <PlayerSkillVO> >();
            }

            // 缓存飞船自带技能
            if (!m_ShipIDToSkillList.ContainsKey(currentShip.GetTID()))
            {
                ISkill[]             shipSkills  = currentShip.GetSkillContainer().GetSkills();
                List <PlayerSkillVO> listToCache = new List <PlayerSkillVO>();
                for (int iSkill = 0; iSkill < shipSkills.Length; iSkill++)
                {
                    int           skillID  = (int)shipSkills[iSkill].GetTID();
                    PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID);
                    if (newSkill != null)
                    {
                        listToCache.Add(newSkill);
                        if (!m_SkillIDToSkill.ContainsKey(skillID))
                        {
                            m_SkillIDToSkill.Add(skillID, newSkill);
                        }
                    }
                }

                m_ShipIDToSkillList.Add(currentShip.GetTID(), listToCache);
            }

            // 缓存武器技能
            IWeaponContainer container = currentShip.GetWeaponContainer();
            if (container != null)
            {
                IWeapon[] weapons = container.GetWeapons();
                if (weapons != null)
                {
                    for (int iWeapon = 0; iWeapon < weapons.Length; iWeapon++)
                    {
                        if (weapons[iWeapon] != null)
                        {
                            int           skillID  = (int)weapons[iWeapon].GetBaseConfig().SkillId;
                            PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID);
                            if (newSkill != null)
                            {
                                if (!m_SkillIDToSkill.ContainsKey(skillID))
                                {
                                    m_SkillIDToSkill.Add(skillID, newSkill);
                                }

                                if (!m_ShipIDToSkillList[currentShip.GetTID()].Contains(newSkill))
                                {
                                    m_ShipIDToSkillList[currentShip.GetTID()].Add(newSkill);
                                }
                            }
                        }
                    }
                }
            }
        }
    }