コード例 #1
0
ファイル: CSTraining.cs プロジェクト: shrubba/planetexplorers
    public void StartCounter(float curTime, float finalTime, ETrainingType ttype)
    {
        if (finalTime < 0F)
        {
            return;
        }

        LockUI(true);
        if (m_Counter == null)
        {
            m_Counter = CSMain.Instance.CreateCounter("Train", curTime, finalTime);
        }
        else
        {
            m_Counter.Init(curTime, finalTime);
        }
        if (!GameConfig.IsMultiMode)
        {
            if (ttype == ETrainingType.Skill)
            {
                m_Counter.OnTimeUp = OnLearnSkillFinish;
            }
            else if (ttype == ETrainingType.Attribute)
            {
                m_Counter.OnTimeUp = OnTrainAttributeFinish;
            }
        }
    }
コード例 #2
0
ファイル: CSTraining.cs プロジェクト: shrubba/planetexplorers
    void OnStartTraining(ETrainingType ttype, List <int> skillIds, CSPersonnel instructorNpc, CSPersonnel traineeNpc)
    {
        if (!IsRunning)
        {
            return;
        }
        if (instructorNpc == null || traineeNpc == null)
        {
            return;
        }
        if (m_Counter != null)
        {
            return;
        }
        //1.check
        if (!CheckInstructorAndTraineeId(instructorNpc.ID, traineeNpc.ID))
        {
            return;
        }

        if (!CheckNpcState(instructorNpc, traineeNpc))
        {
            return;
        }

        if (ttype == ETrainingType.Skill &&
            (skillIds == null || skillIds.Count == 0))
        {
            return;
        }

        //check trainning times
        if (ttype == ETrainingType.Attribute)
        {
            if (!traineeNpc.CanUpgradeAttribute())
            {
                return;
            }
        }


        if (PeGameMgr.IsMulti)
        {
            switch (ttype)
            {
            case ETrainingType.Skill:
                _Net.RPCServer(EPacketType.PT_CL_TRN_StartSkillTraining, skillIds.ToArray(), instructorNpc.ID, traineeNpc.ID);
                break;

            case ETrainingType.Attribute:
                _Net.RPCServer(EPacketType.PT_CL_TRN_StartAttributeTraining, instructorNpc.ID, traineeNpc.ID);
                break;
            }
        }
        else
        {
            switch (ttype)
            {
            case ETrainingType.Skill:
                StartSkillCounter(skillIds);
                break;

            case ETrainingType.Attribute:
                StartAttributeCounter();
                break;
            }

            instructorNpc.trainingType = ttype;
            traineeNpc.trainingType    = ttype;
            trainingType             = ttype;
            InstructorNpcId          = instructorNpc.ID;
            TraineeNpcId             = traineeNpc.ID;
            instructorNpc.IsTraining = true;
            traineeNpc.IsTraining    = true;
            SetStopBtn(true);
        }
        if (m_MgCreator.GetNpc(InstructorNpcId) != null && m_MgCreator.GetNpc(TraineeNpcId) != null)
        {
            CSUI_MainWndCtrl.ShowStatusBar(
                CSUtils.GetNoFormatString(PELocalization.GetString(CSTrainMsgID.START_TRAINING)
                                          , m_MgCreator.GetNpc(InstructorNpcId).FullName
                                          , m_MgCreator.GetNpc(TraineeNpcId).FullName));
        }
    }