/// <summary> /// 切换装备回调 /// </summary> /// <param name="itemID">装备id</param> /// <param name="suc">结果: 0-成功, 1-未拥有</param> public override void onChangeEquip(int itemID, byte suc) { KBEDebug.LogFormat("onChangeEquip {0}, result is {1}", itemID, suc); KBEDebug.LogFormat("current equip, head: {0}, clothes: {1}, hand: {2}, shoe: {3}, bag: {4}", currentItemDict.head, currentItemDict.clothes, currentItemDict.hand, currentItemDict.shoe, currentItemDict.bag); Event.fireOut("onChangeEquip", itemID, (int)suc); }
public override void __init__() { if (isPlayer()) { #region register //匹配 Event.registerIn("StartMatching", this, "StartMatching"); Event.registerIn("updateProgress", this, "updateProgress"); //比赛 Event.registerIn("updatePlayer", this, "updatePlayer"); Event.registerIn("regGetProps", this, "regGetProps"); Event.registerIn("regUseProp", this, "regUseProp"); Event.registerIn("regPropResult", this, "regPropResult"); Event.registerIn("reachDestination", this, "reachDestination"); Event.registerIn("regGetGold", this, "regGetGold"); Event.registerIn("regBuyEquip", this, "regBuyEquip"); Event.registerIn("regChangeEquip", this, "regChangeEquip"); #endregion register // 触发登陆成功事件 Event.fireOut("onLoginSuccessfully", KBEngineApp.app.entity_uuid, id, this); } KBEDebug.LogFormat("gold: {0}", gold); KBEDebug.LogFormat("current equip, head: {0}, clothes: {1}, hand: {2}, shoe: {3}, bag: {4}", currentItemDict.head, currentItemDict.clothes, currentItemDict.hand, currentItemDict.shoe, currentItemDict.bag); }
/// <summary> /// 设置玩家的地图和模式编号 /// </summary> /// <param name="mapNum">地图</param> /// <param name="modeNum">模式</param> public override void onMapModeChanged(int mapNum, int modeNum) { if (isPlayer()) { KBEDebug.LogFormat("Account::设置玩家的地图为: {0}, 模式为: {1}", mapNum, modeNum); Event.fireOut("onMapModeChanged", mapNum, modeNum); } }
public override void onMatchingFinish(int arg1) { KBEDebug.Log("onMatchingFinish, id is: " + id); if (isPlayer()) { Event.fireOut("onMatchingFinish", arg1); } }
public void updateProgress(int tprogerss) { if (progress < tprogerss) { KBEDebug.LogFormat("Account::Player:{0} now progress {1}, update to rogress:{2}", name, progress, tprogerss); progress = tprogerss; cellEntityCall.regProgress(progress); } }
// public void onReloginBaseappTimer() // { // if (ui_state == 0) // { // KBEDebug.LogError("disconnect! (你已掉线!)"); // return; // } // KBEngineApp.app.reloginBaseapp(); // if (startRelogin) // Invoke("onReloginBaseappTimer", 3.0f); // } public void onLoginFailed(UInt16 failedcode) { if (failedcode == 20) { KBEDebug.LogError("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode) + ", " + System.Text.Encoding.ASCII.GetString(KBEngineApp.app.serverdatas())); } else { KBEDebug.LogError("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode)); } }
/// <summary> /// 字符串转Unicode码 /// </summary> /// <returns>The to unicode.</returns> /// <param name="value">Value.</param> public static string StringToUnicode(string value) { byte[] bytes = Encoding.Unicode.GetBytes(value); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < bytes.Length; i += 2) { // 取两个字符,每个字符都是右对齐。 stringBuilder.AppendFormat("u{0}{1}", bytes[i + 1].ToString("x").PadLeft(2, '0'), bytes[i].ToString("x").PadLeft(2, '0')); } KBEDebug.Log("player reg name is " + stringBuilder.ToString()); return(stringBuilder.ToString()); }
public void onConnectionState(bool success) { if (!success) { KBEDebug.LogError("connect(" + KBEngineApp.app.getInitArgs().ip + ":" + KBEngineApp.app.getInitArgs().port + ") is error! (连接错误)"); } else { KBEDebug.Log("connect successfully, please wait...(连接成功,请等候...)"); } ServerEvents.Instance.onConnectionState(success); }
public override void onEnterWorld() { base.onEnterWorld(); KBEDebug.LogFormat("Room::onEnterWorld, room: {0}", id); // Event.fireOut("onEntityEnterWorld", KBEngineApp.app.entity_uuid, roomNo, this); }
public void onLoginSuccessfully(UInt64 rndUUID, Int32 eid, KBEngine.Account account) { KBEDebug.Log("login is successfully!(登陆成功!)"); KBEngine.Avatar m_Avatar = new KBEngine.Avatar(account); ServerEvents.Instance.onLoginSuccessfully(eid, m_Avatar); }
// public override void onProgressChanged(int oldValue) // { // KBEDebug.LogFormat("Player:{0} onProgressChanged:{1}", name, progress); // } #endregion Matching Send #region Matching Callback public override void onEnterWorld() { base.onEnterWorld(); KBEDebug.LogFormat("Account::onEnterWorld, id: {0}, name: {1}, roomNo: {2}", id, name, roomNo); Event.fireOut("onEntityEnterWorld", KBEngineApp.app.entity_uuid, roomNo, this); }
/// <summary> /// 玩家登陆时在服务器中的状态 /// </summary> /// <param name="arg1">0-未登录或未匹配; 1-匹配但未比赛; 2-比赛中</param> public override void onLoginState(int arg1) { KBEDebug.LogFormat("Account::onLoginState : {0}", arg1); Event.fireOut("onLoginState", arg1); }
// 玩家发送匹配请求 public void StartMatching(int map, int mode, int matchCode) { progress = 0; KBEDebug.Log("Account::Player Start Matching, id:" + id); baseEntityCall.regStartMatching(map, mode, matchCode); }
public void onExitRoom(int suc) { KBEDebug.Log("onExitRoom"); ServerEvents.Instance.onExitRoom(suc); }
public void reachDestination() { KBEDebug.Log("send reachDestination info"); cellEntityCall.regReachDestination(); }
// public void onConnectionState(bool success) // { // if (!success) // { // KBEDebug.LogError("connect(" + KBEngineApp.app.getInitArgs().ip + ":" + KBEngineApp.app.getInitArgs().port + ") is error! (连接错误)"); // GameNetwork.Instance.IfConnectToServer = false; // Debug.LogError("玩家断开连接"); // } // else // { // KBEDebug.Log("connect successfully, please wait...(连接成功,请等候...)"); // GameNetwork.Instance.IfConnectToServer = true; // Debug.LogError("玩家已连接"); // } // } public void onDisconnected() { KBEDebug.LogError("disconnect! will try to reconnect...(你已掉线,尝试重连中!)"); // startRelogin = true; // Invoke("onReloginBaseappTimer", 1.0f); }
/// <summary> /// 得到金币回调 /// </summary> /// <param name="tGold"></param> public override void onGetGold(int tGold) { KBEDebug.LogFormat("onGetGold {0}", tGold); Event.fireOut("onGetGold", tGold); }
public override void onTimerChanged(int sec) { KBEDebug.LogFormat("Room::onTimerChanged:{0}, name:{1}", sec); Event.fireOut("onTimerChanged", sec); }
/// <summary> /// 恢复相应道具 /// </summary> /// <param name="propList">需要恢复的道具列表</param> public override void onResetProps(PROP_LIST propList) { KBEDebug.LogFormat("Room::onResetProps"); Event.fireOut("onResetProps", propList); }
/// <summary> /// 有玩家施放技能 /// </summary> /// <param name="arg1">使用者ID</param> /// <param name="arg2">技能目标ID</param> /// <param name="arg3">prop_type</param> /// <param name="arg4">使用技能时坐标</param> public override void onUseProp(int arg1, int arg2, int arg3, Vector3 arg4) { KBEDebug.LogFormat("Account::{0} use prop {1} to {2}, pos is {3}", arg1, arg2, arg3, arg4); Event.fireOut("onUseProp", arg1, arg2, arg3, arg4); }
/// <summary> /// 玩家获得道具, 不一定是当前player /// </summary> /// <param name="arg1">id</param> /// <param name="arg2">prop_key</param> /// <param name="arg3">prop_type</param> public override void onGetPropsClient(int arg1, string arg2, int arg3) { KBEDebug.LogFormat("Account::onGetPropsClient, self id: {3}, owner id:{0}, key:{1}, type:{2}", arg1, arg2, arg3, id); Event.fireOut("onGetProps", arg1, arg2, arg3); }
public void regGetProps(string propKey, int type) { KBEDebug.Log("send get orops info, type: " + type); cellEntityCall.regGetProps(propKey, type); }
/// <summary> /// 技能施放结果回调 /// </summary> /// <param name="userID">使用者ID</param> /// <param name="targetID">技能目标ID</param> /// <param name="type">prop_type</param> /// <param name="suc">结算结果:0-命中, 1-未命中</param> public override void onPropResult(int userID, int targetID, int type, byte suc) { KBEDebug.LogFormat("Room::onPropResult {0} use prop hit {1} : {2}", userID, targetID, suc == 0 ? true : false); Event.fireOut("onPropResult", userID, targetID, type, (int)suc); }
/// <summary> /// 得到金币 /// </summary> /// <param name="tGold"></param> public void regGetGold(int tGold) { KBEDebug.LogFormat("Account::regGetGold: {0}", tGold); baseEntityCall.regGetGold(tGold); }
public override void __init__() { KBEDebug.LogFormat("Room::Init"); }
/// <summary> /// 切换装备 /// </summary> /// <param name="itemID">装备id</param> public void regChangeEquip(int itemID) { KBEDebug.LogFormat("regChangeEquip: {0}", itemID); baseEntityCall.regChangeEquip(itemID); }