Exemplo n.º 1
0
    public void OnLearnSkillFinish()
    {
        m_CurTime = -1F;
        m_Time    = -1F;
        CSMain.Instance.RemoveCounter(m_Counter);
        if (PeGameMgr.IsMulti)
        {
            return;
        }
        //--to do:
        CSPersonnel tn         = m_MgCreator.GetNpc(TraineeNpcId);
        Ablities    cur_skill  = tn.GetNpcAllSkill;
        Ablities    coverSkill = new Ablities();

        foreach (int ls in LearningSkills)
        {
            //--to do getCoverSkill
            List <int> cSkills = NpcAblitycmpt.GetCoverAbilityId(ls);
            foreach (int coverS in cSkills)
            {
                if (cur_skill.Contains(coverS))
                {
                    coverSkill.Add(coverS);
                }
            }
        }
        cur_skill.RemoveAll(it => coverSkill.Contains(it));
        //--to do: remove redundant skill
        int redundantCount = cur_skill.Count + LearningSkills.Count - MAX_SKILL_COUNT;

        if (redundantCount > 0)
        {
            System.Random removeRand = new System.Random();
            for (int i = 0; i < redundantCount; i++)
            {
                cur_skill.RemoveAt(removeRand.Next(cur_skill.Count));
            }
        }

        cur_skill.AddRange(LearningSkills);


        tn.GetNpcAllSkill = cur_skill;
        SetNpcIsTraining(false);
        SetStopBtn(false);
        LockUI(false);
        UpdateUI();
    }
Exemplo n.º 2
0
    static void SetNpcAbility(PeEntity entity, string text)
    {
        if (string.IsNullOrEmpty(text) || text == "0")
        {
            return;
        }

        Ablities abilitys = new Ablities();

        string[] tmp1 = text.Split(',');
        for (int i = 0; i < tmp1.Length; i++)
        {
            abilitys.Add(Convert.ToInt32(tmp1[i]));
        }

        NpcCmpt npccmpt = entity.GetCmpt <NpcCmpt>();

        if (npccmpt != null)
        {
            npccmpt.SetAbilityIDs(abilitys);
        }
    }