예제 #1
0
    public void OnTaskBtnClick(int fbid)
    {
        audioSvc.PlayUIAudio(Constant.UICommonClick);

        //检查体力是否足够TODO
        int costStamina = resSvc.GetMapCfg(fbid).costStamina;

        if (playerData.stamina < costStamina)
        {
            GameRoot.AddTipsToQueue("体力不足");
        }
        else
        {
            //向服务器发送数据,请求进入战斗场景
            GameMsg msg = new GameMsg
            {
                cmd        = (int)CMD.ReqFBFight,
                reqFBFight = new ReqFBFight
                {
                    fbid = fbid,
                }
            };
            netSvc.SendMsg(msg);
        }

        SetWindowState(false);
    }
예제 #2
0
    /// <summary>
    /// 进入游戏按钮点击事件
    /// </summary>
    public void  OnEnterButtonClick()
    {
        //播放按钮点击音效
        audioSvc.PlayUIAudio(Constant.UILoginEnter);

        string acct   = idInput.text;
        string passwd = pwInput.text;

        if (acct != "" && passwd != "")
        {
            PlayerPrefs.SetString("Acct", acct);
            PlayerPrefs.SetString("PW", passwd);

            //发送网络消息 请求登录
            GameMsg msg = new GameMsg {
                cmd      = (int)CMD.ReqLogin,
                reqLogin = new ReqLogin
                {
                    acct = acct,
                    pwd  = passwd
                }
            };
            netSvc.SendMsg(msg);
            //LoginSys.Instance.RspLogin();
        }
        else
        {
            GameRoot.AddTipsToQueue("账号或 密码为空");
        }
    }
예제 #3
0
    public void RspFBFight(GameMsg msg)
    {
        GameRoot.AddTipsToQueue("正在进入战斗场景");

        GameRoot.Instance.SetPlayerDataByRspFBFight(msg.rspFBFight);

        MainCitySys.Instance.mainCityWindow.SetWindowState(false);
        //进入战斗场景
        BattleSys.Instance.StartBattle(msg.rspFBFight.fbid);
    }
예제 #4
0
 public void OpenChatWindow()
 {
     if (!chatWindow.gameObject.activeInHierarchy)
     {
         chatWindow.SetWindowState(true);
     }
     else
     {
         GameRoot.AddTipsToQueue("聊天界面已打开");
     }
 }
예제 #5
0
    public void RspTask(GameMsg msg)
    {
        PlayerData playerData = GameRoot.Instance.PlayerData;
        RspTask    taskData   = msg.rspTask;

        GameRoot.AddTipsToQueue("任务奖励 金币+" + curAutoGuideCfg.coin + " 经验+" + curAutoGuideCfg.exp, Constant.ColorRed);

        switch (curAutoGuideCfg.actID)
        {
        case 0:
            //与智者对话
            break;

        case 1:
            //进入副本
            EnterFuBen();
            break;

        case 2:
            //进入强化
            OpenStrongWindow();
            break;

        case 3:
            //进入体力购买
            OpenPurchaseWindow(0);
            break;

        case 4:
            //进入金币制造
            OpenPurchaseWindow(1);
            break;

        case 5:
            //进入世界聊天
            OpenChatWindow();
            break;
        }
        //更新信息
        GameRoot.Instance.SetPlayerDataByRspTask(taskData);
        //更新UI
        mainCityWindow.RefreshUI();
        roleInfoWindow.RefreshUI();

        if (msg.pshTaskProgs != null)
        {
            GameRoot.Instance.SetPlayerDataByPshTaskProgs(msg.pshTaskProgs);
            if (taskWindow.gameObject.activeInHierarchy)
            {
                taskWindow.RefreshUI();
            }
        }
    }
예제 #6
0
파일: NetSvc.cs 프로젝트: hoppyNaut/DarkGod
 public void SendMsg(GameMsg msg)
 {
     if (client.session != null)
     {
         client.session.SendMsg(msg);
     }
     else
     {
         GameRoot.AddTipsToQueue("服务器未连接");
         InitSvc();
     }
 }
예제 #7
0
    public void RspRename(GameMsg msg)
    {
        if (msg.rspRename.name != null)
        {
            GameRoot.AddTipsToQueue("改名成功,正在进入游戏");

            GameRoot.Instance.SetPlayerDataName(msg.rspRename.name);

            //进入主城
            //关闭创建角色界面
            createWindow.SetWindowState(false);
            MainCitySys.Instance.EnterMainCity();
        }
    }
예제 #8
0
    public void OnTakeBtnClick()
    {
        AudioSvc.Instance.PlayUIAudio(Constant.UICommonClick);
        GameMsg msg = new GameMsg
        {
            cmd = (int)CMD.ReqTakeTaskReward,
            reqTakeTaskReward = new ReqTakeTaskReward
            {
                rid = rewardID,
            }
        };

        NetSvc.Instance.SendMsg(msg);

        TaskRewardCfg trc  = ResSvc.Instance.GetTaskRewardCfg(rewardID);
        int           coin = trc.coin;
        int           exp  = trc.exp;

        GameRoot.AddTipsToQueue("获得奖励:" + "金币 " + coin + " 经验 " + exp, Constant.ColorRed);
    }
예제 #9
0
    public void OnSendBtnClick()
    {
        if (!canSend)
        {
            GameRoot.AddTipsToQueue("聊天消息每5秒才能发送一条");
            return;
        }
        audioSvc.PlayUIAudio(Constant.UICommonClick);
        //string chatMsg = Constant.GetColoredString(GameRoot.Instance.PlayerData.name, Constant.ColorBlue) + ":" +inputTxt.text;
        if (inputTxt.text != "")
        {
            if (inputTxt.text.Length > 12)
            {
                GameRoot.AddTipsToQueue("输入信息不能超过12个字");
            }
            else
            {
                //发送消息到服务器
                GameMsg msg = new GameMsg
                {
                    cmd     = (int)CMD.SndChat,
                    sndChat = new SndChat
                    {
                        msg = inputTxt.text
                    }
                };
                inputTxt.text = "";
                netSvc.SendMsg(msg);
                canSend = false;

                timeSvc.AddTimeTask((int timeID) =>
                {
                    canSend = true;
                }, 5, PETimeUnit.Second, 0);
            }
        }
        else
        {
            GameRoot.AddTipsToQueue("发送内容不能为空");
        }
    }
예제 #10
0
    public void RspLogin(GameMsg msg)
    {
        //显示登录成功的tips
        GameRoot.AddTipsToQueue("登陆成功");

        //存储PlayerData
        GameRoot.Instance.SetPlayerData(msg.rspLogin.playerData);
        if (msg.rspLogin.playerData.name == "")
        {
            //打开角色创建界面
            createWindow.SetWindowState(true);
        }
        else
        {
            //进入主城
            MainCitySys.Instance.EnterMainCity();
        }

        //关闭登录界面
        loginWindow.SetWindowState(false);
    }
예제 #11
0
    public void OnEnterButtonClick()
    {
        audioSvc.PlayUIAudio(Constant.UICommonClick);

        if (nameInput != null)
        {
            //发送名字数据到服务器
            GameMsg msg = new GameMsg
            {
                cmd       = (int)CMD.ReqRename,
                reqRename = new ReqRename
                {
                    name = nameInput.text
                }
            };
            netSvc.SendMsg(msg);
        }
        else
        {
            GameRoot.AddTipsToQueue("你输入的名字不合法 ");
        }
    }
예제 #12
0
    public void RspStrong(GameMsg msg)
    {
        //提升战力
        int preFight = PECommon.GetFightByProps(GameRoot.Instance.PlayerData);

        GameRoot.Instance.SetPlayerDataByRspStrong(msg.rspStrong);
        int nowFight = PECommon.GetFightByProps(GameRoot.Instance.PlayerData);

        GameRoot.AddTipsToQueue("战力提升:" + preFight + " --> " + nowFight, Constant.ColorRed);
        //更新UI
        strongWindow.RefreshItemUI();
        mainCityWindow.RefreshUI();

        if (msg.pshTaskProgs != null)
        {
            GameRoot.Instance.SetPlayerDataByPshTaskProgs(msg.pshTaskProgs);
            if (taskWindow.gameObject.activeInHierarchy)
            {
                taskWindow.RefreshUI();
            }
        }
    }
예제 #13
0
 /// <summary>
 /// 强化按钮点击事件
 /// </summary>
 public void OnStrongBtnClick()
 {
     audioSvc.PlayUIAudio(Constant.UICommonClick);
     if (playerData.strongArr[currentIndex] != 10)
     {
         if (playerData.lv < nextStrongCfg.minlv)
         {
             GameRoot.AddTipsToQueue("等级不足", Constant.ColorRed);
             return;
         }
         if (playerData.coin < nextStrongCfg.coin)
         {
             GameRoot.AddTipsToQueue("金钱不足", Constant.ColorRed);
             return;
         }
         if (playerData.crystal < nextStrongCfg.crystal)
         {
             GameRoot.AddTipsToQueue("水晶不足", Constant.ColorRed);
             return;
         }
         //向服务器发送强化请求
         GameMsg msg = new GameMsg
         {
             cmd       = (int)CMD.ReqStrong,
             reqStrong = new ReqStrong
             {
                 pos    = currentIndex,
                 starlv = playerData.strongArr[currentIndex]
             }
         };
         netSvc.SendMsg(msg);
     }
     else
     {
         GameRoot.AddTipsToQueue("星级已升满", Constant.ColorRed);
     }
 }
예제 #14
0
    public void  RspPurchase(GameMsg msg)
    {
        GameRoot.Instance.SetPlayerDataByRspPurchase(msg.rspPurchase);
        switch (msg.rspPurchase.buyType)
        {
        case 0:
            GameRoot.AddTipsToQueue("体力购买成功");
            break;

        case 1:
            GameRoot.AddTipsToQueue("金币铸造成功");
            break;
        }
        mainCityWindow.RefreshUI();

        if (msg.pshTaskProgs != null)
        {
            GameRoot.Instance.SetPlayerDataByPshTaskProgs(msg.pshTaskProgs);
            if (taskWindow.gameObject.activeInHierarchy)
            {
                taskWindow.RefreshUI();
            }
        }
    }
예제 #15
0
파일: NetSvc.cs 프로젝트: hoppyNaut/DarkGod
    public void HandOutMsg(GameMsg msg)
    {
        //有错误
        if (msg.err != (int)ErrorCode.None)
        {
            switch ((ErrorCode)msg.err)
            {
            case ErrorCode.ServerDataError:
                GameRoot.AddTipsToQueue("服务器数据错误,请重新登录");
                break;

            case ErrorCode.AcctIsOnLine:
                GameRoot.AddTipsToQueue("账号已上线");
                break;

            case ErrorCode.WrongPwd:
                GameRoot.AddTipsToQueue("密码错误,请输入正确的密码");
                break;

            case ErrorCode.UpdateDBError:
                PECommon.Log("数据库更新异常", LogType.Error);
                GameRoot.AddTipsToQueue("网络不稳定");
                break;

            case ErrorCode.NameIsExist:
                GameRoot.AddTipsToQueue("该角色名已存在");
                break;

            case ErrorCode.ClientDataError:
                PECommon.Log("客户端数据异常", LogType.Error);
                GameRoot.AddTipsToQueue("网络不稳定");
                break;
            }
            return;
        }

        switch ((CMD)msg.cmd)
        {
        case CMD.RspLogin:
            LoginSys.Instance.RspLogin(msg);
            break;

        case CMD.RspRename:
            LoginSys.Instance.RspRename(msg);
            break;

        case CMD.RspTask:
            MainCitySys.Instance.RspTask(msg);
            break;

        case CMD.RspStrong:
            MainCitySys.Instance.RspStrong(msg);
            break;

        case CMD.PshChat:
            MainCitySys.Instance.PshChat(msg);
            break;

        case CMD.RspPurchase:
            MainCitySys.Instance.RspPurchase(msg);
            break;

        case CMD.PshStamina:
            MainCitySys.Instance.PshStamina(msg);
            break;

        case CMD.RspTakeTaskReward:
            MainCitySys.Instance.RspTakeTaskReward(msg);
            break;

        case CMD.PshTaskProgs:
            MainCitySys.Instance.PshTaskProgs(msg);
            break;

        case CMD.RspFBFight:
            FuBenSys.Instance.RspFBFight(msg);
            break;

        case CMD.RspFBFFightEnd:
            BattleSys.Instance.RspFBFightEnd(msg);
            break;
        }
    }
예제 #16
0
 protected override void OnDisConnected()
 {
     GameRoot.AddTipsToQueue("服务器断开连接");
     PECommon.Log("Client DisConnected To Server");
 }
예제 #17
0
 protected override void OnConnected()
 {
     GameRoot.AddTipsToQueue("连接服务器成功");
     PECommon.Log("Client Connected To Server Succ");
 }
예제 #18
0
 public void OnNoticButtonClick()
 {
     GameRoot.AddTipsToQueue("公告按钮正在开发中......");
     //按钮点击音效
     audioSvc.PlayUIAudio(Constant.UICommonClick);
 }