Esempio n. 1
0
    /// <summary>
    /// 全局UI事件处理器
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="data"></param>
    public void GlobalEventHandler(int eventType, object data)
    {
        switch (eventType)
        {
        case (int)Client.GameEventID.SYSTEM_LOADSCENECOMPELETE:
        {
            Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)data;
            if (loadScene.nMapID == 159)
            {
                DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.CampFightingPanel);
            }
        }
        break;

        case (int)Client.GameEventID.ENTITYSYSTEM_LEVELUP:
        {
            CaculateCampSectionIndex();
        }
        break;

        case (int)Client.GameEventID.ENTITYSYSTEM_CREATEENTITY:
        {
            //             if (isEnterScene == false)
            //             {
            //                 return;
            //             }

            Client.stCreateEntity npcEntity = (Client.stCreateEntity)data;

            Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
            if (es == null)
            {
                return;
            }

            Client.IEntity npc = es.FindEntity(npcEntity.uid);
            if (npc == null)
            {
                return;
            }

            int npcBaseId = npc.GetProp((int)Client.EntityProp.BaseID);
            //采集物
            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcBaseId);
            if (npctable != null && npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT)        //采集物
            {
                GameCmd.eCamp camp = (GameCmd.eCamp)npc.GetProp((int)Client.CreatureProp.Camp);
                if (m_CampCombatResultInfo != null && m_CampCombatResultInfo.m_MyCampCombatInfo.camp != camp)
                {
                    CampNpcOnTrigger callback = new CampNpcOnTrigger();
                    npc.SetCallback(callback);
                }
            }
        }
        break;
        }
    }
Esempio n. 2
0
    public void OnSetCampUser(GameCmd.stSetCampUserCmd_S cmd)
    {
        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
        if (es == null)
        {
            return;
        }
        //0是玩家,1是npc
        Client.IEntity entity = null;
        if (cmd.entry_type == 0)
        {
            entity = es.FindPlayer(cmd.entry_id);
        }
        else if (cmd.entry_type == 1)
        {
            entity = es.FindNPC(cmd.entry_id);
        }

        if (entity != null)
        {
            Client.stPropUpdate prop = new Client.stPropUpdate();
            prop.uid        = entity.GetUID();
            prop.nPropIndex = (int)Client.CreatureProp.Camp;
            prop.oldValue   = entity.GetProp((int)Client.CreatureProp.Camp);
            prop.newValue   = (int)cmd.camp;
            entity.SetProp((int)Client.CreatureProp.Camp, (int)cmd.camp);
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.ENTITYSYSTEM_PROPUPDATE, prop);
        }



        if (Client.ClientGlobal.Instance().IsMainPlayer(cmd.entry_id))
        {
            if (cmd.camp == eCamp.CF_Green || cmd.camp == eCamp.CF_Red)
            {
                DataManager.Manager <CampCombatManager>().OnSetCamp();
            }
            //进去就请求刷行数据
            DataManager.Instance.Sender.RequestCampInfoCamp(0, 0, DataManager.Manager <CampCombatManager>().FightingIndex);
        }
    }