Exemplo n.º 1
0
 public PlayerSkillVO GetSkillByID(int skillID)
 {
     // 蓄力技能, 在蓄力结束后, 释放的是另外一个技能. 这个技能没有配置在船身上
     // 实际上客户端存储技能实例的信息只是为了保存冷却时间. 这个逻辑检查留给服务器了
     if (!m_SkillIDToSkill.ContainsKey(skillID))
     {
         PlayerSkillVO newSkillVO = PlayerSkillVO.CreateSkillVO(skillID);
         if (newSkillVO != null)
         {
             m_SkillIDToSkill.Add(skillID, newSkillVO);
             return(m_SkillIDToSkill[skillID]);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(m_SkillIDToSkill[skillID]);
     }
 }
Exemplo n.º 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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 创建一个新的技能
    /// </summary>
    /// <param name="skillID"></param>
    /// <returns></returns>
    private SkillBase CreateSkill(int skillID)
    {
        SkillCategory skillType = (SkillCategory)m_CfgSkillProxy.GetSkillGrow(skillID).CastWay;

        SkillBase newSkillInstance = null;

        switch (skillType)
        {
        case SkillCategory.Immediate:
        case SkillCategory.Immediate_Trigger:
            newSkillInstance = new SkillImmediate();
            break;

        case SkillCategory.Immediate_MultiShot:
            newSkillInstance = new SkillImmediateMultiShot();
            break;

        case SkillCategory.Chanting:
        case SkillCategory.Chanting_Trigger:
            newSkillInstance = new SkillChanting();
            break;

        case SkillCategory.Charge:
            newSkillInstance = new SkillCharging();
            break;

        case SkillCategory.AutoChannel:
            newSkillInstance = new SkillChannellingBeam(SkillChannellingBeam.ChannellingType.Auto);
            break;

        case SkillCategory.ManualChannel:
            newSkillInstance = new SkillChannellingBeam(SkillChannellingBeam.ChannellingType.Manual);
            break;

        case SkillCategory.RapidFire:
            newSkillInstance = new SkillRapidFire();
            break;

        case SkillCategory.Immediate_MultiShot_MultiTarget:
            newSkillInstance = new SkillImmediateMultiShot_MultiTarget();
            break;

        case SkillCategory.Immediate_MultiTarget:
            newSkillInstance = new SkillImmediate_MultiTarget();
            break;

        case SkillCategory.SelectSkillByBuff:
            newSkillInstance = new SkillSelectByBuff();
            break;

        case SkillCategory.MiningBeam:
            newSkillInstance = new SkillMiningBeam(SkillMiningBeam.ChannellingType.Manual);
            break;

        default:
            newSkillInstance = new SkillBase();
            break;
        }

        if (newSkillInstance == null)
        {
            return(null);
        }

        // FIXME 技能, 重构这部分代码
        // 消除动态分配, 弄一个池子
        if (m_Property.IsMain())
        {
            if (m_SkillProxy.GetSkillByID(skillID) != null)
            {
                newSkillInstance.Initialize(m_Property, m_SkillProxy.GetSkillByID(skillID), OnSkillStopped);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            PlayerSkillVO skillVO = PlayerSkillVO.CreateSkillVO(skillID);
            if (skillVO != null)
            {
                newSkillInstance.Initialize(m_Property, skillVO, OnSkillStopped);
            }
            else
            {
                return(null);
            }
        }

        return(newSkillInstance);
    }