예제 #1
0
    public void RefreshShipSkills()
    {
        skillVOs = null;

        List <PlayerShipSkillVO> skills = new List <PlayerShipSkillVO>();
        IShip currentShip = m_ShipProxy.GetAppointWarShip();

        if (currentShip != null)
        {
            ISkill[]      shipSkills = currentShip.GetSkillContainer().GetSkills();
            List <ISkill> tempList   = new List <ISkill>(shipSkills);
            tempList.Sort((skill1, skill2) =>
            {
                int pos1 = m_PackageProxy.GetItem <ItemSkillVO>(skill1.GetUID()).Position;
                int pos2 = m_PackageProxy.GetItem <ItemSkillVO>(skill2.GetUID()).Position;
                return(pos1.CompareTo(pos2));
            });

            foreach (var skill in tempList)
            {
                int skillID = (int)skill.GetTID();
                if (m_CfgEternityProxy.IsSkillExist(skillID))
                {
                    PlayerShipSkillVO skillVO = new PlayerShipSkillVO((int)skill.GetTID());
                    skills.Add(skillVO);
                }
            }
        }

        if (skills.Count > 0)
        {
            skillVOs = skills.ToArray();
        }

        SendNotification(NotificationName.MSG_SHIP_SKILL_CHANGED);
    }
예제 #2
0
    /// <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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }