public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            if (GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain)
            {
                // 场景资源ID和服务器ID分开,暂时使用相同ID [10/24/2011 Sun]
                GCNotifyChangeScene Packet = (GCNotifyChangeScene)pPacket;

                LogManager.Log("RECV GCNotifyChangeScene");
                LogManager.Log("RECV GCNotifyChangeScene: id=" + Packet.TargetSceneID);

                int nSourceID = WorldManager.Instance.GetActiveSceneID();
                if (nSourceID != Packet.CurrentSceneID)
                {
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                fVector2 pos = new fVector2(Packet.Position.m_fX, Packet.Position.m_fZ);
                WorldManager.Instance.ChangeScene(
                    Packet.TargetSceneID,
                    Packet.ResID,
                    ref pos,
                    Packet.TargetDir,
                    Packet.Flag);
            }

            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #2
0
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase packet, ref Peer pPlayer)
        {
            //当前流程是主流程
            if (GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain)
            {
                GCNewPet       pPacket        = (GCNewPet)packet;
                CObjectManager pObjectManager = CObjectManager.Instance;
                //检查位置是否合法
                fVector2 pos = new fVector2(pPacket.getWorldPos().m_fX, pPacket.getWorldPos().m_fZ);
                if (!WorldManager.Instance.ActiveScene.IsValidPosition(ref pos))
                {
                    LogManager.LogError("Valid Position @GCNewPetHandler.Execute");
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_ERROR);
                }
                //创建宠物
                CObject_PlayerNPC pNPC = (CObject_PlayerNPC)pObjectManager.FindServerObject((int)pPacket.getObjID());

                float fFaceDir = pPacket.getDir();
                if (pNPC == null)
                {
                    pNPC = pObjectManager.NewPlayerNPC((int)pPacket.getObjID());

                    SObjectInit initPlayerNPC = new SObjectInit();

                    initPlayerNPC.m_fvPos = new Vector3(pos.x, 0, pos.y);
                    initPlayerNPC.m_fvRot = new Vector3(0.0f, fFaceDir, 0.0f);

                    pNPC.Initial(initPlayerNPC);
                }
                else
                {
                    pNPC.SetMapPosition(pos.x, pos.y);
                    pNPC.SetFaceDir(fFaceDir);
                    pNPC.Enable((uint)ObjectStatusFlags.OSF_VISIABLE);
                    pNPC.Disalbe((uint)ObjectStatusFlags.OSF_OUT_VISUAL_FIELD);
                }

                pNPC.SetNpcType(ENUM_NPC_TYPE.NPC_TYPE_PET);
                pNPC.GetCharacterData().Set_MoveSpeed(pPacket.getMoveSpeed());

                SCommand_Object cmdTemp = new SCommand_Object();
                cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_IDLE;
                cmdTemp.SetValue <float>(0, pos.x);
                cmdTemp.SetValue <float>(1, pos.y);
                cmdTemp.SetValue <bool>(2, false);
                pNPC.PushCommand(cmdTemp);

                //放入Ask队列
                pObjectManager.LoadQueue.TryAddLoadTask(pNPC.ID);


                //同步渲染层
                string szTemp = "GCNewPet(" + pos.x.ToString() + "," + pos.y.ToString() + ")";
                pNPC.PushDebugString(szTemp);
                pNPC.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow());
            }

            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);;
        }
Exemple #3
0
    public override fVector2 GetAs_Vector2(string szName, ref bool bHave)
    {
        fVector2 fv = GetAs_Vector2(szName);

        if (fv.x == FLOAT_INEXISTS)
        {
            bHave = false;
        }
        return(fv);
    }
Exemple #4
0
    ///游戏过程中切换场景
    public void ChangeScene(short idTargetScene, short nSceneResID, ref fVector2 fvPos, int nDirection, byte bFlag)
    {
        if (GameProcedure.GetActiveProcedure() != GameProcedure.s_ProcMain)
        {
            //TDThrow("Must change scene at MAIN procedure");
            return;
        }

        //发送请求消息
        CGAskChangeScene msg = (CGAskChangeScene)NetManager.GetNetManager().CreatePacket((int)PACKET_DEFINE.PACKET_CG_ASKCHANGESCENE);

        msg.SourSceneID = GetActiveSceneID();
        msg.DestSceneID = idTargetScene;

        NetManager.GetNetManager().SendPacket(msg);


        //目标场景名
        //DBC_DEFINEHANDLE(s_pSceneDBC, DBC_SCENE_DEFINE);
        //const _DBC_SCENE_DEFINE* pSceneDef =
        //    (const _DBC_SCENE_DEFINE*)s_pSceneDBC->Search_First_Column_Equ(
        //    _DBC_SCENE_DEFINE::SCENE_SERVER_ID_COLUMN, nSceneResID);

        ////通知UI,关闭相应窗口
        //CGameProcedure::s_pEventSystem->PushEvent(GE_PLAYER_LEAVE_WORLD,
        //    pSceneDef ? pSceneDef->szName : "");

        _DBC_SCENE_DEFINE pSceneDef = m_SceneDBC.Search_Index_EQU(nSceneResID);

        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_PLAYER_LEAVE_WORLD, pSceneDef != null ? pSceneDef.szName : "");

        //---
        //保存状态
        m_idNextScene = idTargetScene;
        m_fvNextPos   = fvPos;
        //	m_fNextDir = (FLOAT)((nDirection%36)*2.0f*TDU_PI/36.0f);
        //  INT idDefaultSkill = CActionSystem::GetMe()->GetDefaultAction() ? CActionSystem::GetMe()->GetDefaultAction()->GetDefineID() : 0;
        //
        //  CGameProcedure::s_pVariableSystem->SetAs_Int("DefaultSkill",idDefaultSkill);
        //	CActionSystem::GetMe()->SaveAction();


        m_Station = bFlag == 1 ? WORLD_STATION.WS_RELIVE : WORLD_STATION.WS_ASK_CHANGE_SCANE;
    }
    //进入指定场景
    public void                             EnterScene()
    {
        //todo load scene
        //LogManager.Log("Enter Scene");

        if (!WorldManager.Instance.EnterScene(m_nSceneID, m_nSceneResID, m_nCityLevel))
        {
            return;
        }
        AssetBundleManager.AssetBundleRequestManager.releaseAssetBundles();//切换场景时释放已下载的www对象
        //转入主循环
        GameProcedure.SetActiveProc(GameProcedure.s_ProcMain);

        //创建玩家自身
        int idMySelfServer           = s_pVariableSystem.GetAs_Int("MySelf_ID");
        CObject_PlayerMySelf pMySelf = s_pObjectManager.getPlayerMySelf();

        if (pMySelf == null)
        {
            pMySelf = s_pObjectManager.NewPlayerMySelf(idMySelfServer);
        }
        s_pObjectManager.SetObjectServerID(pMySelf.ID, idMySelfServer);
        pMySelf.SetServerGUID(s_pVariableSystem.GetAs_Int("User_GUID"));

        fVector2 MySelfPos = s_pVariableSystem.GetAs_Vector2("MySelf_Pos");

        pMySelf.Initial(null);//初始化玩家,创建角色数据
        string posMsg = "玩家位置:";

        posMsg += MySelfPos.x.ToString() + " " + MySelfPos.y.ToString();
        //LogManager.Log(posMsg);
        pMySelf.SetMapPosition(MySelfPos.x, MySelfPos.y);

        //设置摄像机参数
        // TODO

        //////////////////////////////////////////////////////////////////////////
        // 检查是否在自动寻路 [8/9/2011 ivan edit]
        Interface.GameInterface.Instance.AutoMovePlayerReady();

        //产生事件
        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_PLAYER_ENTER_WORLD);
    }
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                GCNewSpecial Packet = (GCNewSpecial)pPacket;
                //LogManager.Log("Receive GCNewSpecial Packet ObjID:" + Packet.ObjID);
                fVector2 pos = new fVector2(Packet.posWorld.m_fX, Packet.posWorld.m_fZ);
                if (!WorldManager.Instance.ActiveScene.IsValidPosition(ref pos))
                {
                    LogManager.LogError("ERROR POSITION @ GCNewSpecialHandler");
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                CObject_Special pSpecial = (CObject_Special)CObjectManager.Instance.FindServerObject(Packet.ObjID);
                if (pSpecial == null)
                {
                    //创建平台生长点
                    pSpecial = (CObject_Special)CObjectManager.Instance.NewSpecialObject(Packet.ObjID);
                }
                else
                {
                    pSpecial.Release();
                }

                SObject_SpecialInit initSpecial = new SObject_SpecialInit();
                initSpecial.m_fvPos.x = Packet.posWorld.m_fX;
                initSpecial.m_fvPos.z = Packet.posWorld.m_fZ;
                initSpecial.m_fvPos.y = 0.0f;
                initSpecial.m_fvRot   = new Vector3(0.0f, Packet.Dir, 0.0f);
                initSpecial.m_nDataID = Packet.DataID;
                pSpecial.Initial(initSpecial);
                pSpecial.SetMapPosition(Packet.posWorld.m_fX, Packet.posWorld.m_fZ);
                pSpecial.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow());
            }
            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #7
0
 //场景位置是否合法
 public bool     IsValidPosition(ref fVector2 fvPos)
 {
     return(true);
 }
Exemple #8
0
    //该物品是否能够在某对象上使用
    public bool     IsValidTarget(CObject pSelectObj, ref fVector2 fvPos, ref int objID, ref PET_GUID_t petID)
    {
        if (m_theBaseDef == null)
        {
            return(false);
        }
        //玩家自己
        CObject_PlayerMySelf pMySlef = CObjectManager.Instance.getPlayerMySelf();

        ENUM_ITEM_TARGET_TYPE targetType = (ENUM_ITEM_TARGET_TYPE)m_theBaseDef.nTargetType;

        //无需目标
        if (ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_NONE == targetType)
        {
            return(true);
        }

        //需要选择一个场景位置
        if (ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_POS == targetType)
        {
            return(WorldManager.Instance.ActiveScene.IsValidPosition(ref fvPos));
        }

        //目前不支持的方式
        if (ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_DIR == targetType ||         //方向
            ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ITEM == targetType)          //物品->物品
        {
            return(false);
        }

        switch (targetType)
        {
        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_SELF:       //自已
        {
            objID = pMySlef.ServerID;
        }
            return(true);

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_SELF_PET:           //自己的宠物
        {
            //petID = pMySlef.GetCharacterData().Get_CurrentPetGUID();
            ////宠物尚未释放
            //if(petID.IsNull())
            //    return false;

            objID = pMySlef.ServerID;
            return(true);
        }
        //break;

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND:     //友好的目标
        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY:      //敌对目标
        {
            //必须需要一个目标
            if (pSelectObj == null)
            {
                return(false);
            }
            //必须是角色
            if (!(pSelectObj is CObject_Character))
            {
                return(false);
            }

            //检查阵营
            ENUM_RELATION eCampType =
                GameProcedure.s_pGameInterface.GetCampType(pMySlef, pSelectObj);

            //必须是友好目标/敌对目标
            if ((targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND &&
                 (pSelectObj == pMySlef || eCampType == ENUM_RELATION.RELATION_FRIEND)) ||
                (targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY &&
                 (eCampType == ENUM_RELATION.RELATION_ENEMY)))
            {
                objID = pSelectObj.ServerID;
                return(true);
            }
        }
            return(false);

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_PLAYER:     // 友好玩家
        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_PLAYER:      //	敌对玩家
        {
            //必须需要一个目标
            if (pSelectObj == null)
            {
                return(false);
            }
            //必须是玩家
            if (!(pSelectObj is CObject_PlayerOther))
            {
                return(false);
            }

            //检查阵营
            ENUM_RELATION eCampType =
                GameProcedure.s_pGameInterface.GetCampType(pMySlef, pSelectObj);

            //必须是友好玩家/敌对玩家
            if ((targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_PLAYER &&
                 (pSelectObj == pMySlef || eCampType == ENUM_RELATION.RELATION_FRIEND)) ||
                (targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_PLAYER &&
                 (eCampType == ENUM_RELATION.RELATION_ENEMY)))
            {
                objID = pSelectObj.ServerID;
                return(true);
            }
        }
            return(false);

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_MONSTER:     //友好怪物
        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_MONSTER:      //敌对怪物
        {
            //必须需要一个目标
            if (pSelectObj == null)
            {
                return(false);
            }
            //必须是角色
            if (!(pSelectObj is CObject_Character))
            {
                return(false);
            }
            //必须是NPC
            if (((CObject_Character)pSelectObj).GetCharacterType() !=
                CHARACTER_TYPE.CT_MONSTER)
            {
                return(false);
            }

            //检查阵营
            ENUM_RELATION eCampType =
                GameProcedure.s_pGameInterface.GetCampType(pMySlef, pSelectObj);

            //必须是友好NPC
            if ((targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_MONSTER &&
                 eCampType == ENUM_RELATION.RELATION_FRIEND) ||
                (targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_MONSTER &&
                 eCampType == ENUM_RELATION.RELATION_ENEMY))
            {
                objID = pSelectObj.ServerID;
                return(true);
            }
        }
            return(false);

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_PET:         //友好宠物
        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_PET:          //敌对宠物
        {
            //必须需要一个目标
            if (pSelectObj == null)
            {
                return(false);
            }
            //必须是角色
            if (!(pSelectObj is CObject_Character))
            {
                return(false);
            }
            //必须是NPC
            if (((CObject_Character)pSelectObj).GetCharacterType() !=
                CHARACTER_TYPE.CT_MONSTER)
            {
                return(false);
            }
            //必须是宠物
            if (((CObject_PlayerNPC)pSelectObj).GetNpcType() !=
                ENUM_NPC_TYPE.NPC_TYPE_PET)
            {
                return(false);
            }

            //检查阵营
            ENUM_RELATION eCampType =
                GameProcedure.s_pGameInterface.GetCampType(pMySlef, pSelectObj);

            //必须是友好宠物
            if ((targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_FRIEND_MONSTER &&
                 eCampType == ENUM_RELATION.RELATION_FRIEND) ||
                (targetType == ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ENEMY_PET &&
                 eCampType == ENUM_RELATION.RELATION_ENEMY))
            {
                objID = pSelectObj.ServerID;
                return(true);
            }
        }
            return(false);

        case ENUM_ITEM_TARGET_TYPE.ITEM_TARGET_TYPE_ALL_CHARACTER:      //所有角色
        {
            //必须需要一个目标
            if (pSelectObj == null)
            {
                return(false);
            }
            //必须是角色
            if (!(pSelectObj is CObject_Character))
            {
                return(false);
            }

            return(true);
        }
        //return false;

        default:
            break;
        }

        return(false);
    }
    public override void Tick()
    {
        base.Tick();


        switch (GetStatus())
        {
        case ENTER_STATUS.ENTERSCENE_CONNECTING:
        {
            //等待服务器的回应
            SetStatus(ENTER_STATUS.ENTERSCENE_READY);
            break;
        }

        //发送进入场景的请求
        case ENTER_STATUS.ENTERSCENE_READY:
        {
            int nSceneID = GameProcedure.s_pVariableSystem.GetAs_Int("Scene_ID");

            //发送进入场景的请求
            CGEnterScene msg = (CGEnterScene)NetManager.GetNetManager().CreatePacket((int)PACKET_DEFINE.PACKET_CG_ENTERSCENE);
            msg.EnterType = (byte)m_dwEnterType;
            msg.SceneID   = (short)nSceneID;
            fVector2 pos = GameProcedure.s_pVariableSystem.GetAs_Vector2("Scene_EnterPos");

            WORLD_POS Pos;
            Pos.m_fX     = pos.x;
            Pos.m_fZ     = pos.y;
            msg.Position = Pos;

            NetManager.GetNetManager().SendPacket(msg);

            //LogManager.Log("Send EnterScene: " + nSceneID);
            //等待服务器的回应
            SetStatus(ENTER_STATUS.ENTERSCENE_REQUESTING);
        }
        break;

        //发送进入场景的请求,等待服务器的回应...
        case ENTER_STATUS.ENTERSCENE_REQUESTING:
            break;

        //服务器允许进入场景
        case ENTER_STATUS.ENTERSCENE_OK:
        {
            // 关闭系统界面
            //CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_CLOSE_SYSTEM_INFO);
            // 关闭帐号输入界面
            //CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_CLOSE_COUNT_INPUT);
            // 关闭人物选择界面
            //CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_CLOSE_SELECT_CHARACTOR);
            //设置场景摄像机
            //CGameProcedure::s_pGfxSystem->Camera_SetCurrent(CRenderSystem::SCENE);

            // 在外层已经调用,这里屏蔽 [6/2/2011 Sun]
            //EnterScene();
        }
        break;

        //服务器不允许进入场景
        case ENTER_STATUS.ENTERSCENE_FAILED:
        {
            //CGameProcedure::s_pEventSystem->PushEvent( GE_GAMELOGIN_SHOW_SYSTEM_INFO_CLOSE_NET, "服务器不允许进入场景");
        }
        break;
        }
    }
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase packet, ref Peer pPlayer)
        {
            GCNewItemBox pPacket = (GCNewItemBox)packet;

            //当前流程是主流程
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                CObjectManager pObjectManager = CObjectManager.Instance;

                //检查位置是否合法
                fVector2 pos = new fVector2(pPacket.Position.m_fX, pPacket.Position.m_fZ);
                if (!WorldManager.Instance.ActiveScene.IsValidPosition(ref pos))
                {
                    LogManager.LogError("Valid Position @GCNewItemBoxHandler.Execute");
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_ERROR);
                }

                if ((int)ITEMBOX_TYPE.ITYPE_DROPBOX == pPacket.ObjectType)
                {
                    bool    bMustCreater = true;
                    CObject pObj         = (CObject)(pObjectManager.FindServerObject((int)pPacket.MonsterID));
                    if (pObj != null && pObj is CObject_Character)
                    {
                        CObject_Character pCharacter = (CObject_Character)pObj;
                        if (!pCharacter.IsDie())
                        {
                            uint      idItemBox = (uint)pPacket.ObjectID;
                            uint      idOwner   = (uint)pPacket.OwnerID;
                            WORLD_POS posCreate = pPacket.Position;
                            pCharacter.AddDropBoxEvent(idItemBox, idOwner, ref posCreate);
                            bMustCreater = false;
                        }
                    }

                    if (bMustCreater)
                    {
                        //创建ItemBox
                        CTripperObject_ItemBox pBox = (CTripperObject_ItemBox)CObjectManager.Instance.NewTripperItemBox((int)pPacket.ObjectID);
                        pBox.Initial(null);
                        //设置位置
                        pBox.SetMapPosition(pPacket.Position.m_fX, pPacket.Position.m_fZ);
                        //设置掉落箱的归属
                        pBox.SetOwnerGUID((uint)pPacket.OwnerID);

                        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_DROP_ITEMBOX);
                    }
                }
                else
                {
                    //创建矿物生长点
                    CTripperObject_Resource pResource = (CTripperObject_Resource)CObjectManager.Instance.NewTripperResource((int)pPacket.ObjectID);
                    if (!(pResource.SetResourceID((int)pPacket.ObjectType)))
                    {
                        //非法的资源ID
                        CObjectManager.Instance.DestroyObject(pResource);
                        return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                    }
                    pResource.Initial(null);
                    //设置位置
                    pResource.SetMapPosition(pPacket.Position.m_fX, pPacket.Position.m_fZ);
                    jhCount++;
                }
            }
            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }