Exemple #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;
        }
    }
Exemple #2
0
    void DoGameEvent(int eventID, object param)
    {
        if (eventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
        {
            Client.stLoadSceneComplete pa = (Client.stLoadSceneComplete)param;
            int homeID = GameTableManager.Instance.GetGlobalConfig <int>("HomeSceneID");
            if (pa.nMapID == homeID)
            {
                IPlayer player = ClientGlobal.Instance().MainPlayer;
                if (player != null)
                {
                    //stRequestAllHomeUserCmd_C cmd = new stRequestAllHomeUserCmd_C();
                    //cmd.char_id = player.GetID();
                    //NetService.Instance.Send(cmd);
                    ReqAllUserHomeData(player.GetID());

                    ReqHomeTradePrice();
                }
            }
        }
        else if (eventID == (int)GameEventID.PLAYER_LOGIN_SUCCESS)
        {
        }
        else if (eventID == (int)GameEventID.HOMELAND_CLICKENTITY)
        {
            stClickEntity ce = (stClickEntity)param;
            IEntitySystem es = ClientGlobal.Instance().GetEntitySystem();
            if (es != null)
            {
                IEntity et = es.FindEntity(ce.uid);
                if (et != null)
                {
                    if (IsMyHome()) //只有自己家园才可以点击实体
                    {
                        if (et.GetEntityType() == EntityType.EntityType_Plant || et.GetEntityType() == EntityType.EntityType_Soil)
                        {//农场点击响应
                            OnClickPlantEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Animal)
                        {
                            OnClickAnimalEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Tree)
                        {
                            OnClickTreeEntity(et);
                        }
                        else if (et.GetEntityType() == EntityType.EntityType_Minerals)
                        {
                            OnClickMineEntity(et);
                        }
                    }
                }
            }
        }
    }
Exemple #3
0
    //自己
    private void OnSceneLoadCompelete(int nEventId, object param)
    {
        Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)param;
        uint nMapID = (uint)loadScene.nMapID;

        m_nCurMapID = nMapID;
        table.MapDataBase mapDB = GameTableManager.Instance.GetTableItem <table.MapDataBase>(nMapID);
        if (mapDB == null)
        {
            return;
        }

        if (mapDB.dwMaterial == 0)
        {
            // 使用默认材质
            Client.IPlayer pPlayer = Client.ClientGlobal.Instance().MainPlayer;
            if (pPlayer != null)
            {
                // 时装id
                uint uSuit = 0;

                List <GameCmd.SuitData> lstSuit = null;
                pPlayer.GetSuit(out lstSuit);

                if (lstSuit.Count > 0)
                {
                    uSuit = lstSuit[0].baseid;
                    ApplyMaterial(pPlayer, uSuit);
                }
            }
        }
        else
        {
            table.ResourceDataBase res = GameTableManager.Instance.GetTableItem <table.ResourceDataBase>(mapDB.dwMaterial);
            if (res == null)
            {
                return;
            }

            if (res.strPath == "")
            {
                return;
            }

            Engine.IRenderObj renderObj = Client.ClientGlobal.Instance().MainPlayer.renderObj;
            if (renderObj != null)
            {
                renderObj.ApplyMaterial(res.strPath);
            }
        }
    }
Exemple #4
0
        // 加载完成
        public void OnComplete()
        {
            // 加载完成处理
            Client.stLoadSceneComplete loadScene = new Client.stLoadSceneComplete();
            loadScene.nMapID          = (int)mapID;
            loadScene.bFirstLoadScene = m_bFirstLoad; // 第一次加载场景
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.SYSTEM_LOADSCENECOMPELETE, loadScene);

            // 播放背景音乐
            PlayBGMusic();

            Engine.Utility.Log.Info("EnterMapStart PreLoadRes");
            // 预加载资源
            //PreLoadResource();   //移到了 登录成功,就会预加载
            Engine.Utility.Log.Info("EnterMapStart PreLoadRes end");
        }
Exemple #5
0
        void OnEvent(int eventID, object param)
        {
            if (eventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
            {
                Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)param;

                uint mapID = (uint)loadScene.nMapID;
                //PreLoadEntity(mapID);
            }
            else if (eventID == (int)GameEventID.ENTITYSYSTEM_LEAVEMAP)
            {
                ClearPreLoadEntity();
            }
            else if (eventID == (int)GameEventID.ENTITYSYSTEM_ENTERMAP)
            {
                uint mapID = (uint)param;
                PreLoadEntity(mapID);
            }
        }
Exemple #6
0
    void DoGameEvent(int eventID, object param)
    {
        if (eventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
        {
            Client.stLoadSceneComplete pa = (Client.stLoadSceneComplete)param;
            if (pa.nMapID == 15)
            {
                IPlayer player = ClientGlobal.Instance().MainPlayer;
                if (player != null)
                {
                    CreatePlayer();
                    CameraFollow.Instance.Update(0f);


                    //LoadNpc();
                }
            }
        }
    }
Exemple #7
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    void OnSceneEvent(int id, object p)
    {
        if (id == (int)Client.GameEventID.SYSTEM_LOADSCENECOMPELETE)
        {
            Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)p;

            DataManager.Manager <UIPanelManager>().SendMsg(PanelID.LoadingPanel, UIMsgID.eLoadingTips, "马上进入场景");

            if (Client.ClientGlobal.Instance().MainPlayer == null)
            {
                return;
            }

            DataManager.Manager <UIPanelManager>().HidePanel(PanelID.LoadingPanel);

            if (Client.ClientGlobal.Instance().MainPlayer.IsDead())
            {
                DataManager.Manager <UIPanelManager>().HideMain();
                DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ReLivePanel);
            }
            else
            {
                DataManager.Manager <UIPanelManager>().ShowMain(loadScene.bFirstLoadScene);
            }


            if (loadScene.bFirstLoadScene)
            {
                m_uStepFlag |= (uint)Step.SCENE_READY;
                Engine.Utility.Log.Info("Step:{0}", Client.GameEventID.SYSTEM_LOADSCENECOMPELETE.ToString());
                OnGameReady();
            }

            Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.UIEVENTADDDISPLAYEFFECT, loadScene.nMapID);
        }
        else if (id == (int)Client.GameEventID.ENTITYSYSTEM_LEAVEMAP)
        {
            DataManager.Manager <UIPanelManager>().ShowLoading();

            Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem();
            if (cs != null)
            {
                Client.ICombatRobot robot = cs.GetCombatRobot();
                if (robot != null && robot.Status != Client.CombatRobotStatus.STOP)
                {
                    robot.Stop();
                }
            }
        }
        else if (id == (int)Client.GameEventID.SYSTEM_LOADUICOMPELETE)
        {
            m_uStepFlag |= (uint)Step.UI_READY;
            Engine.Utility.Log.Info("Step:{0}", Client.GameEventID.SYSTEM_LOADUICOMPELETE.ToString());
            OnGameReady();
        }
        else if (id == (int)Client.GameEventID.LOGINSUCESSANDRECEIVEALLINFO)
        {
            m_uStepFlag |= (uint)Step.DATA_READY;
            Engine.Utility.Log.Info("Step:{0}", Client.GameEventID.LOGINSUCESSANDRECEIVEALLINFO.ToString());
            OnGameReady();
            //ShowUINotfy();
        }
        else if (id == (int)Client.GameEventID.RECONNECT_SUCESS)
        {
            m_uStepFlag |= (uint)Step.SCENE_READY;
            Engine.Utility.Log.Info("Step:{0}", Client.GameEventID.SYSTEM_LOADSCENECOMPELETE.ToString());
            OnGameReady();
        }
    }
Exemple #8
0
    private void OnEvent(int nEventID, object param)
    {
        if (nEventID == (int)GameEventID.ENTITYSYSTEM_CHANGEAREA || nEventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
        {
            //地图区域判断
            if (nEventID == (int)GameEventID.ENTITYSYSTEM_CHANGEAREA)
            {
                stEntityChangeArea changeArea = (stEntityChangeArea)param;

                bool isMainPlayer = Client.ClientGlobal.Instance().IsMainPlayer(changeArea.uid);

                if (isMainPlayer)
                {
                    //初始化
                    InitFishing();

                    //if (changeArea.eType == MapAreaType.Fish)
                    //{
                    //    //  Engine.Utility.Log.Error("到达钓鱼区域了!!!");

                    //    m_bIsInFinshingArea = true;
                    //}
                    //else
                    //{
                    //    //Engine.Utility.Log.Error("离开钓鱼区域了!!!");

                    //    m_bIsInFinshingArea = false;
                    //}
                }
            }

            else if (nEventID == (int)GameEventID.SYSTEM_LOADSCENECOMPELETE)
            {
                Client.stLoadSceneComplete loadScene = (Client.stLoadSceneComplete)param;

                uint mapID = (uint)loadScene.nMapID;

                if (mapID == m_fishingMapId)
                {
                    //初始化
                    InitFishing();
                }
                //IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem();
                //if (ms == null)
                //{
                //    return;
                //}

                //IPlayer mainPlayer = Client.ClientGlobal.Instance().MainPlayer;
                //if (mainPlayer == null)
                //{
                //    return;
                //}

                //if (ms.GetAreaTypeByPos(mainPlayer.GetPos()) == MapAreaType.Fish)
                //{
                //    Engine.Utility.Log.Error("到达钓鱼区域了!!!");
                //    m_bIsInFinshingArea = true;
                //}
                //else
                //{
                //    m_bIsInFinshingArea = false;
                //}
                //}
                //else    //不在钓鱼地图
                //{
                //    m_bIsInFinshingArea = false;
            }
        }
    }