Exemplo n.º 1
0
 void OnConnect(IAsyncResult ar)
 {
     if (m_Tcp.Client == null)
     {
         OnError(MessageRetCode.MRC_DISCONNECT);
         return;
     }
     if (!m_Tcp.Client.Connected)
     {
         OnError(MessageRetCode.MRC_DISCONNECT);
         return;
     }
     m_IsConnect  = true;
     m_AllDone    = new EventWaitHandle(false, EventResetMode.AutoReset);
     m_RecvThread = new Thread(OnReceive);
     m_RecvThread.Start();
     GTAsync.Instance.Run(() =>
     {
         if (OnConnectSuccess != null)
         {
             OnConnectSuccess.Invoke();
         }
         OnConnectSuccess = null;
         GTEventCenter.FireEvent(GTEventID.TYPE_CONNECT_SUCCESS);
     });
 }
Exemplo n.º 2
0
    public void TryCastSkill(ESkillPos pos)
    {
        if (GTWorld.Main == null || GTWorld.Main.CacheTransform == null)
        {
            return;
        }
        ActSkill skill = GTWorld.Main.Skill.GetSkill(pos);

        if (skill == null)
        {
            return;
        }
        if (GTWorld.Main.Target != null && GTWorld.Main.Target.IsDead())
        {
            CharacterHelper.ClearTarget(GTWorld.Main);
        }
        if (GTWorld.Main.Target == null)
        {
            Character target = GTWorld.Main.FindEnemyNearest(GTWorld.Main.Skill.WarnerDist);
            CharacterHelper.SetTarget(GTWorld.Main, target);
        }
        GTWorld.Main.PausedAI(true);
        Resp resp = GTWorld.Main.Command.Get <CommandUseSkill>().Update(skill.ID).Do();

        CharacterHelper.CalcCharacterOperateError(resp);
        if (resp == Resp.TYPE_YES)
        {
            GTWorld.Main.UsePowerByCostType(skill.CostType, skill.CostNum);
            GTEventCenter.FireEvent(GTEventID.TYPE_UPDATE_AVATAR_HP);
            GTEventCenter.FireEvent(GTEventID.TYPE_UPDATE_AVATAR_MP);
        }
        GTWorld.Main.PausedAI(false);
    }
Exemplo n.º 3
0
    public Character AddActorLocalSync(XCharacter data)
    {
        if (data == null)
        {
            return(null);
        }
        GTTransform dTrans = GTTransform.Create(data.PosX, data.PosY, data.PosZ, data.Face);
        Character   cc     = AddActor(data.Id, (EBattleCamp)data.Camp, (EActorType)data.Type, dTrans, data, false);

        cc.Carrer        = data.Carrer;
        cc.IsRemoteActor = true;
        switch (cc.Type)
        {
        case EActorType.MONSTER:
            cc.EnableAI(true);
            cc.OnDeadFinish = () =>
            {
                if (cc != null && cc.CacheTransform != null)
                {
                    cc.CacheTransform.gameObject.SetActive(false);
                    GTEventCenter.FireEvent(GTEventID.TYPE_ACTOR_KILL_MONSTER, cc.GUID, cc.ID);
                    cc.OnDeadFinish = null;
                }
            };
            break;

        case EActorType.NPC:
            cc.EnableAI(true);
            break;
        }
        return(cc);
    }
Exemplo n.º 4
0
    private void OnAck_UseItem(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckUseItem             ack = Serializer.Deserialize <AckUseItem>(ms);

        int pos = ack.Pos;
        int num = ack.Num;
        int id  = ack.ID;

        XItem item   = DataDBSBagItem.GetDataById(pos);
        DItem itemDB = ReadCfgItem.GetDataById(item.Id);

        switch (itemDB.ItemType)
        {
        case EItemType.DRUG:
            GTDataManager.Instance.AddNewItem(itemDB.Data2, itemDB.Data1 * num);
            GTDataManager.Instance.UseItemById(itemDB.Id, num);
            break;

        case EItemType.BOX:
            break;
        }

        GTEventCenter.FireEvent(GTEventID.TYPE_BAG_USE_ITEM, id, num);
    }
Exemplo n.º 5
0
    private void OnAck_ChangePartner(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckChangePartner       ack = Serializer.Deserialize <AckChangePartner>(ms);

        XCharacter role = RoleModule.Instance.GetCurPlayer();

        switch (ack.Pos)
        {
        case 1:
            role.Partner1 = ack.ID;
            break;

        case 2:
            role.Partner2 = ack.ID;
            break;
        }
        DataDBSRole.Update(role.Id, role);
        if (!DataDBSPartner.ContainsKey(ack.ID))
        {
            XPartner xp = new XPartner();
            xp.Id      = ack.ID;
            xp.Level   = 1;
            xp.Star    = 0;
            xp.Wake    = 0;
            xp.Advance = 1;
            xp.Exp     = 0;
            DataDBSPartner.Insert(ack.ID, xp);
        }

        CharacterManager.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_PARTNER, ack.Pos, ack.ID);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 6
0
    private void OnAck_RoleLoginAck(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        RoleLoginAck           ack = Serializer.Deserialize <RoleLoginAck>(ms);

        if (GTItemHelper.ShowNetworkError(ack.RetCode) == false)
        {
            return;
        }
        GTGlobal.CurPlayerCarrerID = ack.Carrer;
        GTGlobal.CurPlayerGUID     = ack.RoleID;
        for (int i = 0; i < ack.Action.Count; i++)
        {
            int num = (int)ack.Action[i];
            int id  = i + 101;
            DataDBSAction.Update(id, new XAction()
            {
                Id = id, Num = num
            });
        }
        GTDataTimer.Instance.Init();
        GTWorld.Instance.EnterGuide();
        GTWorld.Instance.Bie.UseGuide = GTLauncher.Instance.UseGuide;
        GTEventCenter.FireEvent(GTEventID.TYPE_LOGIN_ROLELOGIN);
    }
Exemplo n.º 7
0
    private void OnAck_SelectServer(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        SelectServerAck        ack = Serializer.Deserialize <SelectServerAck>(ms);

        if (GTItemHelper.ShowNetworkError(ack.RetCode) == false)
        {
            return;
        }
        GTEventCenter.FireEvent(GTEventID.TYPE_LOGIN_SELECTSERVER);
        if (GTGlobal.IsAlong)
        {
            GTLauncher.Instance.LoadScene(GTCopyKey.SCENE_Role);
        }
        else
        {
            NetworkManager.Instance.Close();
            NetworkManager.Instance.ConnectGameServer(ack.ServerAddr, ack.ServerPort, () =>
            {
                RoleListReq req = new RoleListReq();
                req.AccountID   = MLLogin.Instance.LastAccountID;
                req.LoginCode   = ack.LoginCode;
                NetworkManager.Instance.Send(MessageID.MSG_ROLE_LIST_REQ, req);
            });
        }
    }
Exemplo n.º 8
0
    public GTWindow OpenWindow(EWindowID windowID)
    {
        if (!m_AllWindows.ContainsKey(windowID))
        {
            return(null);
        }
        GTWindow window = m_AllWindows[windowID];

        DealWindowStack(window, true);
        window.Show();
        Transform trans = window.transform;

        if (trans == null)
        {
            return(null);
        }
        if (window.MaskType != EWindowMaskType.None)
        {
            GTEventCenter.FireEvent(GTEventID.TYPE_FORCE_STOPJOYSTICK);
        }
        if (window.ShowMode == EWindowShowMode.SaveTarget && m_MutexStacks.Count > 0)
        {
            GTWindow w = m_MutexStacks[m_MutexStacks.Count - 1];
            window.TargetID = w.ID;
        }
        GTCameraManager.Instance.AddUI(trans.gameObject);
        if (m_OpenWindows.Contains(window) == false)
        {
            m_OpenWindows.Add(window);
        }
        RefreshDepth(window);
        DealMask();
        return(window);
    }
Exemplo n.º 9
0
    private void OnAck_AccountRegister(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountRegAck          ack = Serializer.Deserialize <AccountRegAck>(ms);

        GTEventCenter.FireEvent(GTEventID.TYPE_REGISTER_CALLBACK);
    }
Exemplo n.º 10
0
    private void OnAck_AdvanceEquip(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckAdvanceEquip        ack = Serializer.Deserialize <AckAdvanceEquip>(ms);

        XEquip       equip     = ack.TarEquip;
        List <XItem> list      = ack.UseItems;
        DEquip       equipDB   = ReadCfgEquip.GetDataById(equip.Id);
        int          advanceID = equipDB.Quality * 1000 + equip.AdvanceLevel + 1;

        DEquipAdvanceCost db = ReadCfgEquipAdvanceCost.GetDataById(advanceID);

        GTDataManager.Instance.UseMoney(db.CostMoneyId, db.CostMoneyNum);
        GTDataManager.Instance.UseItemById(db.CostItemId, db.CostItemNum);
        if (list != null)
        {
            for (int i = 0; i < list.Count; i++)
            {
                GTDataManager.Instance.DelBagEquip(list[i].Pos);
            }
        }
        equip.AdvanceLevel++;
        DataDBSEquip.Update(equip.Instance, equip);

        CharacterManager.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);

        GTEventCenter.FireEvent(GTEventID.TYPE_ADVANCE_EQUIP);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 11
0
 void OnError(MessageRetCode retCode)
 {
     GTAsync.Instance.Run(() =>
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_NETWORK_CONNECT_FAIL, retCode);
     });
     OnClose();
 }
Exemplo n.º 12
0
    private void OnCastSkillClick(GameObject go)
    {
        GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_SKILLCLICK, 0.2f);
        int       pos      = go.name.ToInt32();
        ESkillPos skillPos = (ESkillPos)pos;

        GTEventCenter.FireEvent(GTEventID.TYPE_CAST_SKILL, skillPos);
    }
Exemplo n.º 13
0
    private void OnAck_EnterScene(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        EnterSceneAck          ack = Serializer.Deserialize <EnterSceneAck>(ms);


        GTEventCenter.FireEvent(GTEventID.TYPE_ENTERGAME_CALLBACK);
        GTLauncher.Instance.LoadScene(GTGlobal.LAST_CITY_ID);
    }
Exemplo n.º 14
0
    private void OnAck_GetServerList(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        ClientServerListAck    ack = Serializer.Deserialize <ClientServerListAck>(ms);

        LoginModule.Instance.SetServerList(ack.SvrNode);

        GTEventCenter.FireEvent(GTEventID.TYPE_GETSERVERS_CALLBACK);
    }
Exemplo n.º 15
0
 public static int SetSelectMountID(int value)
 {
     mSelectMountID = value;
     if (value > 0)
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_SELECT_MOUNT);
     }
     return(0);
 }
Exemplo n.º 16
0
 void OnError(MessageRetCode retCode)
 {
     GTAsync.Instance.Run(() =>
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_CONNECT_FAIL, retCode);
     });
     Debug.LogError(retCode.ToString());
     OnClose();
 }
Exemplo n.º 17
0
 public void Connect()
 {
     m_Tcp = new TcpClient();
     m_Tcp.BeginConnect(IPAddress.Parse(m_IP), m_Port, OnConnect, m_Tcp);
     GTAsync.Instance.Run(() =>
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_CONNECT);
     });
 }
Exemplo n.º 18
0
    private void OnAck_SetMount(MessageRecv obj)
    {
        System.IO.MemoryStream ms   = new System.IO.MemoryStream(obj.Data);
        AckSetMount            ack  = Serializer.Deserialize <AckSetMount>(ms);
        XCharacter             role = GTGlobal.Main;

        role.Mount = ack.MountID;
        DataDBSCharacter.Update(role.Carrer, role);
        GTEventCenter.FireEvent(GTEventID.TYPE_MOUNT_DRESSMOUNT);
    }
Exemplo n.º 19
0
    private void OnAck_RoleLoginAck(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        RoleLoginAck           ack = Serializer.Deserialize <RoleLoginAck>(ms);

        GTGlobal.CurPlayerID = (int)ack.RoleType;

        GTEventCenter.FireEvent(GTEventID.TYPE_ENTERGAME_CALLBACK);
        GTLauncher.Instance.LoadScene(GTGlobal.LAST_CITY_ID);
    }
Exemplo n.º 20
0
    private void OnAck_SetMount(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckSetMount            ack = Serializer.Deserialize <AckSetMount>(ms);

        XCharacter role = RoleModule.Instance.GetCurPlayer();

        role.Mount = ack.MountID;
        DataDBSRole.Update(role.Id, role);
        GTEventCenter.FireEvent(GTEventID.TYPE_DRESS_MOUNT);
    }
Exemplo n.º 21
0
    private void OnAck_AccountRegister(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountRegAck          ack = Serializer.Deserialize <AccountRegAck>(ms);

        if (GTItemHelper.ShowNetworkError(ack.RetCode) == false)
        {
            return;
        }
        GTEventCenter.FireEvent(GTEventID.TYPE_LOGIN_ACCOUNT_REGISTER);
    }
Exemplo n.º 22
0
    private void On_MainCopyAck(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        MainCopyAck            ack = Serializer.Deserialize <MainCopyAck>(ms);

        if (ack.RetCode != 0)
        {
            return;
        }
        GTEventCenter.FireEvent(GTEventID.TYPE_ECTYPE_BATTLECHECK);
        GTLauncher.Instance.LoadScene(FTEctypeData.CopyID);
    }
Exemplo n.º 23
0
    private void OnAck_GetServerList(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        ClientServerListAck    ack = Serializer.Deserialize <ClientServerListAck>(ms);

        if (GTItemHelper.ShowNetworkError(ack.RetCode) == false)
        {
            return;
        }
        MLLogin.Instance.SetServerList(ack.SvrNode);
        GTEventCenter.FireEvent(GTEventID.TYPE_LOGIN_GETSERVERLIST);
    }
Exemplo n.º 24
0
    private void OnAck_UnloadRelics(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckUnloadRelics        ack = Serializer.Deserialize <AckUnloadRelics>(ms);

        XCharacter role = RoleModule.Instance.GetCurPlayer();

        role.Relic = 0;
        DataDBSRole.Update(role.Id, role);

        CharacterManager.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);
        GTEventCenter.FireEvent(GTEventID.TYPE_UNLOAD_RELICS, ack.RelicsID);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 25
0
    private void OnAck_BuyStore(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckBuyStore            ack = Serializer.Deserialize <AckBuyStore>(ms);

        DStore db   = ReadCfgStore.GetDataById(ack.StoreID);
        GTItem data = new GTItem(db.ItemID, db.ItemNum * ack.Num);

        GTItemHelper.ShowAwardTip(data);
        GTDataManager.Instance.AddNewItem(db.ItemID, db.ItemNum * ack.Num);
        GTDataManager.Instance.UseMoney(db.CostMoneyID, db.CostMoneyNum * ack.Num);

        GTEventCenter.FireEvent(GTEventID.TYPE_STORE_BUYSUCCESS);
    }
Exemplo n.º 26
0
    private void OnAck_BattlePet(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckBattlePet           ack = Serializer.Deserialize <AckBattlePet>(ms);

        XCharacter role = GTGlobal.Main;

        role.PetID = ack.ID;
        DataDBSCharacter.Update(role.Carrer, role);

        GTWorld.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);
        GTEventCenter.FireEvent(GTEventID.TYPE_PET_BATTLE);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 27
0
    private void OnAck_BattlePet(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckBattlePet           ack = Serializer.Deserialize <AckBattlePet>(ms);

        XCharacter role = RoleModule.Instance.GetCurPlayer();

        role.PetID = ack.ID;
        DataDBSRole.Update(role.Id, role);

        CharacterManager.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);
        GTEventCenter.FireEvent(GTEventID.TYPE_BATTLE_PET);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 28
0
    private void OnAck_UnloadRelics(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AckUnloadRelics        ack = Serializer.Deserialize <AckUnloadRelics>(ms);

        XCharacter role = GTGlobal.Main;

        role.Relic = 0;
        DataDBSCharacter.Update(role.Carrer, role);

        GTWorld.Instance.SyncMainPlayerData(ESyncDataType.TYPE_BASEATTR);
        GTEventCenter.FireEvent(GTEventID.TYPE_RELICS_UNLOAD, ack.RelicsID);
        GTEventCenter.FireEvent(GTEventID.TYPE_CHANGE_FIGHTVALUE);
    }
Exemplo n.º 29
0
    //响应账号登录成功
    private void OnAck_AccountLogin(MessageRecv obj)
    {
        System.IO.MemoryStream ms  = new System.IO.MemoryStream(obj.Data);
        AccountLoginAck        ack = Serializer.Deserialize <AccountLoginAck>(ms);

        ClientServerNode newNode = new ClientServerNode();

        newNode.SvrID   = ack.LastSvrID;
        newNode.SvrName = ack.LastSvrName;
        LoginModule.Instance.SetCurrServer(newNode);
        LoginModule.Instance.LastAccountID = ack.AccountID;

        GTEventCenter.FireEvent(GTEventID.TYPE_ACCLOGIN_CALLBACK);
    }
Exemplo n.º 30
0
 public static void UpdateHP(Character cc)
 {
     if (cc.IsMain)
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_UPDATE_AVATAR_HP);
     }
     if (cc.Type == EActorType.PARTNER && cc.Host == GTWorld.Main)
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_UPDATE_PARTNER_HP);
     }
     if (cc.IsBoss())
     {
         GTEventCenter.FireEvent(GTEventID.TYPE_UPDATE_BOSS_HP);
     }
 }