コード例 #1
0
    public void PrepareUseSkill(GameCmd.stPrepareUseSkillSkillUserCmd_S cmd)
    {
        EntityType type      = EntitySystem.EntityHelper.GetEntityEtype(cmd.usertype);
        ISkillPart skillPart = SkillHelper.GetSkillPart(cmd.userid, type);

        if (skillPart == null)
        {
            Engine.Utility.Log.Error("获取技能部件失败!" + cmd.userid + " type is " + Enum.GetName(typeof(EntityType), type));
            return;
        }
        if (cmd.level == 0)
        {
            cmd.level = 1;
        }
        SkillDatabase database = GameTableManager.Instance.GetTableItem <table.SkillDatabase>(cmd.skillid, (int)cmd.level);

        if (database == null)
        {
            Engine.Utility.Log.Error(" skill database is null skillid is " + cmd.skillid.ToString() + " level is " + cmd.level.ToString());
            return;
        }
        skillPart.OnPrepareUseSkill(cmd);


        if (type == EntityType.EntityType_Player)
        {
            uint time = (database.dwReadTime);
            if (time > 0)
            {
                TimerAxis.Instance().SetTimer(m_uReadSliderTimerID, time, this, 1);
            }
        }
        else if (type == EntityType.EntityType_NPC)
        {
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                Engine.Utility.Log.Error("GetEntitySystem failed!");
                return;
            }

            INPC npc = es.FindEntity <INPC>(cmd.userid);
            if (npc != null)
            {
                int masterID = npc.GetProp((int)NPCProp.Masterid);
                if (masterID == MainPlayerHelper.GetPlayerID())
                {
                    SkillDatabase db = GameTableManager.Instance.GetTableItem <SkillDatabase>((uint)cmd.skillid);
                    if (db != null)
                    {
                        if (db.petType == 1 || db.petType == 2)
                        {
                            Client.stSkillCDChange st = new Client.stSkillCDChange();
                            st.skillid = (uint)cmd.skillid;
                            st.cd      = -1;
                            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.SKILLCD_BEGIN, st);
                            TipsManager.Instance.ShowTips(npc.GetName() + CommonData.GetLocalString("使用") + db.strName);
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
        //// 服务器通知
        public void OnPrepareUseSkill(GameCmd.stPrepareUseSkillSkillUserCmd_S cmd)
        {

            if (m_ClientGlobal == null)
            {
                return;
            }
            if (m_Master.GetCurState() != CreatureState.Dead)
            {
                bLive = true;
            }
            //服务器如果第一次发来所有的消息 此处可优化
            SkillDatabase db = GameTableManager.Instance.GetTableItem<SkillDatabase>(cmd.skillid, (int)cmd.level);
            if (db != null)
            {
                if (!CurSkillDic.ContainsKey(cmd.skillid))
                {
                    CurSkillDic.Add(cmd.skillid, db);
                }
                else
                {
                    if (db.wdLevel != cmd.level)
                    {
                        CurSkillDic[cmd.skillid] = db;
                    }
                }

            }
            else
            {
                Log.LogGroup("ZDY", "skilldatabase not contain skillid {0}" , cmd.skillid);
                return;
            }
            SkillTarget = EntitySystem.EntityHelper.GetEntity((SceneEntryType)cmd.defertype, cmd.deferid);
            if (SkillTarget == null&&db.targetType == 0)
            {
                Log.LogGroup("ZDY", "没有找到服务器要攻击的目标");
                return;
            }
            //Log.LogGroup( "ZDY" , "******************** " + stateMachine.GetCurState().GetStateID().ToString() );

            if ((CreatureState)m_Master.GetCurState() == CreatureState.Move)
            {
                IPlayer p = Master as IPlayer;
                if (p != null)
                {
                    if (!p.IsMainPlayer())
                    {
                        Log.LogGroup("ZDY", "other player is move -----------------");
                        CurSkillID = cmd.skillid;
                        m_lastSkillId = cmd.skillid;
                        p.SendMessage(EntityMessage.EntityCommond_IgnoreMoveAction, false);
                        BreakSkill();
                        FreeSkill(cmd.skillid, this, m_uDamageID);
                        //释放技能攻击

                        stateMachine.ChangeState((int)SkillState.Prepare, this);
                    }
                }

                if (cmd.usertype == (int)SceneEntryType.SceneEntry_NPC)
                {//如果是怪物 移动中就 等结束时候在播放
                    npcWillUseSkillCmd = cmd;
                }
            }
            else
            {
                int stateID = stateMachine.GetCurState().GetStateID();
                if (stateMachine.GetCurState().GetStateID() == (int)SkillState.None)
                {
                    CurSkillID = cmd.skillid;
                    m_lastSkillId = cmd.skillid;
                    FreeSkill(cmd.skillid, this, m_uDamageID);
                    //释放技能攻击
                    stateMachine.ChangeState((int)SkillState.Prepare, this);

                }
                else
                {
                    IPlayer p = Master as IPlayer;
                    if (p != null)
                    {
                        if (!p.IsMainPlayer())
                        {
                            CurSkillID = cmd.skillid;
                            m_lastSkillId = cmd.skillid;
                            p.SendMessage(EntityMessage.EntityCommond_IgnoreMoveAction, false);
                            BreakSkill();
                            FreeSkill(cmd.skillid, this, m_uDamageID);
                            //释放技能攻击
                            stateMachine.ChangeState((int)SkillState.Prepare, this);
                        }

                
                    }
                    if (cmd.usertype == (int)SceneEntryType.SceneEntry_NPC)
                    {//如果是怪物 不在移动中直接放
                        CurSkillID = cmd.skillid;
                        m_lastSkillId = cmd.skillid;
                        BreakSkill();
                        FreeSkill(cmd.skillid, this, m_uDamageID);
                        //释放技能攻击
                        stateMachine.ChangeState((int)SkillState.Prepare, this);
                        npcWillUseSkillCmd = null;
                    }
                }
            }

        }