registerIn() public static méthode

public static registerIn ( string eventname, object obj, string funcname ) : bool
eventname string
obj object
funcname string
Résultat bool
        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);
        }
Exemple #2
0
 public void installEvents()
 {
     Event.registerIn(AvatarEvent_In.EventName.enterStartGame, this, "enterStartGame");
     Event.registerIn(AvatarEvent_In.EventName.statisticalResult, this, "statisticalResult");
     Event.registerIn(AvatarEvent_In.EventName.endOfStatistics, this, "endOfStatistics");
     Event.registerIn(AvatarEvent_In.EventName.weaponChanged, this, "weaponChanged");
 }
        public void connectTo(string ip, int port, ConnectCallback callback, object userData)
        {
            if (valid())
            {
                throw new InvalidOperationException("Have already connected!");
            }

            if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip))
            {
                IPHostEntry ipHost = Dns.GetHostEntry(ip);
                ip = ipHost.AddressList[0].ToString();
            }

            _socket = createSocket();

            ConnectState state = new ConnectState();

            state.connectIP        = ip;
            state.connectPort      = port;
            state.connectCB        = callback;
            state.userData         = userData;
            state.socket           = _socket;
            state.networkInterface = this;

            Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ...");
            connected = false;

            // 先注册一个事件回调,该事件在当前线程触发
            Event.registerIn("_onConnectionState", this, "_onConnectionState");

            var v = new AsyncConnectMethod(this._asyncConnect);

            v.BeginInvoke(state, new AsyncCallback(this._asyncConnectCB), state);
        }
        public override void __init__()
        {
            Event.registerIn("relive", this, "relive");
            Event.registerIn("updatePlayer", this, "updatePlayer");

            // 触发登陆成功事件
            Event.fireOut("onLoginSuccessfully", new object[] { KBEngineApp.app.entity_uuid, id, this });
        }
Exemple #5
0
        public override void __init__()
        {
            Event.fireOut("onLoginSuccess", new object[] { KBEngineApp.app.entity_uuid, id, this });

            Event.registerIn("reqRoleList", this, "reqRoleList");
            Event.registerIn("reqCreateRole", this, "reqCreateRole");
            Event.registerIn("reqRemoveRole", this, "reqRemoveRole");
        }
Exemple #6
0
 // 由于任何玩家被同步到该客户端都会使用这个模块创建,因此客户端可能存在很多这样的实体
 // 但只有一个是自己的玩家实体,所以需要判断一下
 public override void __init__()
 {
     if (isPlayer())
     {
         Event.registerIn("relive", this, "relive");
         Event.registerIn("updatePlayer", this, "updatePlayer");
         Event.registerIn("sendChatMessage", this, "sendChatMessage");
     }
 }
 public override void __init__()
 {
     if (isPlayer())
     {
         GameData.Instance.localPlayer = this;
         Event.registerIn("reqFrameChange", this, "reqFrameChange");
         Event.fireOut("AvatarReady", new object[] { this });
     }
 }
Exemple #8
0
 public override void __init__()
 {
     Debug.Log("场景分配器初始化!!");
     Event.fireOut("onSceneAlloc", new object[] { KBEngineApp.app.entity_uuid, id, this });
     if (isPlayer())
     {
         Event.registerIn("reqMoveObjSync", this, "reqMoveObjSync");
         Event.registerIn("reqMoveObjsSync", this, "reqMoveObjsSync");
     }
 }
Exemple #9
0
        public override void __init__()
        {
            //注册事件
            Event.registerIn("reqAvatarList", this, "reqAvatarList");
            Event.registerIn("reqRemoveAvatar", this, "reqRemoveAvatar");
            Event.registerIn("selectAvatarGame", this, "selectAvatarGame");

            Event.fireOut("onLoginSuccessfully", new object[] { KBEngineApp.app.entity_uuid, id, this });

//            baseEntityCall.reqAvatarList();
        }
Exemple #10
0
        public override void __init__()
        {
            combat = new Combat(this);

            if (isPlayer())
            {
                Event.registerIn("relive", this, "relive");
                Event.registerIn("useTargetSkill", this, "useTargetSkill");
                Event.registerIn("jump", this, "jump");
            }
        }
 public override void __init__()
 {
     // 由于任何玩家被同步到该客户端都会使用这个模块创建,因此客户端可能存在很多这样的实体
     // 但只有一个是自己的玩家实体,所以需要判断一下
     if (isPlayer())
     {
         Event.registerIn("relive", this, "relive");
         Event.registerIn("useTargetSkill", this, "useTargetSkill");
         Event.registerIn("jump", this, "jump");
         Event.registerIn("updatePlayer", this, "updatePlayer");
     }
 }
Exemple #12
0
 public override void onAttached()
 {
     if (this.owner.isPlayer())
     {
         Event.registerIn("reqRoomList", this, "reqRoomList");
         Event.registerIn("reqEnterRoom", this, "reqEnterRoom");
         Event.registerIn("reqGameBegin", this, "reqGameBegin");
         Event.registerIn("reqLeaveRoom", this, "reqLeaveRoom");
         Event.registerIn("reqCreateRoom", this, "reqCreateRoom");
         Event.registerIn("reqTrueSyncData", this, "reqTrueSyncData");
     }
 }
Exemple #13
0
        public override void __init__()
        {
            // 注册事件
            Event.registerIn("reqCreateAvatar", this, "reqCreateAvatar");
            Event.registerIn("reqRemoveAvatar", this, "reqRemoveAvatar");
            Event.registerIn("selectAvatarGame", this, "selectAvatarGame");

            // 触发登陆成功事件
            Event.fireOut("onLoginSuccessfully", new object[] { KBEngineApp.app.entity_uuid, id, this });

            // 向服务端请求获得角色列表
            baseCall("reqAvatarList");
        }
Exemple #14
0
        public void connectTo(string ip, int port, ConnectCallback callback, object userData)
        {
            if (valid())
            {
                throw new InvalidOperationException("Have already connected!");
            }

            if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip))
            {
                IPHostEntry ipHost = Dns.GetHostEntry(ip);
                ip = ipHost.AddressList[0].ToString();
            }

            // Security.PrefetchSocketPolicy(ip, 843);
            IPAddress[]   hostAddresses = Dns.GetHostAddresses(ip);
            IPAddress[]   outIPs        = hostAddresses;
            AddressFamily addressFamily = AddressFamily.InterNetwork;

            if (Socket.OSSupportsIPv6 && this.IsHaveIpV6Address(hostAddresses, ref outIPs))
            {
                addressFamily = AddressFamily.InterNetworkV6;
            }
            _socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, NetworkInterface.RECV_BUFFER_MAX * 2);

            ConnectState state = new ConnectState();

            state.connectIP        = ip;
            state.connectPort      = port;
            state.connectCB        = callback;
            state.userData         = userData;
            state.socket           = _socket;
            state.networkInterface = this;

            Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ...");

            // 先注册一个事件回调,该事件在当前线程触发
            Event.registerIn("_onConnectStatus", this, "_onConnectStatus");

            try
            {
                _socket.BeginConnect(new IPEndPoint(IPAddress.Parse(ip), port), new AsyncCallback(connectCB), state);
            }
            catch (Exception e)
            {
                state.error = e.ToString();
                Event.fireIn("_onConnectStatus", new object[] { state });
            }
        }
Exemple #15
0
        public override void __init__()
        {
            combat = new Combat(this);

            if (isPlayer())
            {
                Event.registerIn("relive", this, "relive");
                Event.registerIn("useTargetSkill", this, "useTargetSkill");
                Event.registerIn("jump", this, "jump");
                Event.registerIn("updatePlayer", this, "updatePlayer");
                Event.registerIn("onSpellTarget", this, "onSpellTarget");

                Event.registerIn("sendChatMessage", this, "sendChatMessage");
            }
        }
Exemple #16
0
        public override void __init__()
        {
            // 由于任何玩家被同步到该客户端都会使用这个模块创建,因此客户端可能存在很多这样的实体
            // 但只有一个是自己的玩家实体,所以需要判断一下
            if (isPlayer())
            {
                Event.registerIn("relive", this, "relive");
                Event.registerIn("jump", this, "jump");
                Event.registerIn("updatePlayer", this, "updatePlayer");
                Event.registerIn("useWeapon", this, "useWeapon");
                Event.registerIn("transAvatar", this, "transAvatar");
                Event.registerIn("updateCruiseSpeed", this, "updateCruiseSpeed");

                Debug.Log("Avatar::__init__,position:" + position + ",direction:" + direction);
            }
        }
        public void connectTo(string ip, int port, ConnectCallback callback, object userData)
        {
            if (valid())
            {
                throw new InvalidOperationException("Have already connected!");
            }

            if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip))
            {
                IPHostEntry ipHost = Dns.GetHostEntry(ip);
                ip = ipHost.AddressList[0].ToString();
            }

            // Security.PrefetchSocketPolicy(ip, 843);
            IPAddress[]   hostAddresses = Dns.GetHostAddresses(ip);
            IPAddress[]   outIPs        = hostAddresses;
            AddressFamily addressFamily = AddressFamily.InterNetwork;

            if (Socket.OSSupportsIPv6 && this.IsHaveIpV6Address(hostAddresses, ref outIPs))
            {
                addressFamily = AddressFamily.InterNetworkV6;
            }
            _socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp);
            _socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, NetworkInterface.TCP_PACKET_MAX * 2);
            _socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.SendBuffer, NetworkInterface.TCP_PACKET_MAX * 2);
            _socket.NoDelay = true;
            //_socket.Blocking = false;

            ConnectState state = new ConnectState();

            state.connectIP        = ip;
            state.connectPort      = port;
            state.connectCB        = callback;
            state.userData         = userData;
            state.socket           = _socket;
            state.networkInterface = this;

            Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ...");
            connected = false;

            // 先注册一个事件回调,该事件在当前线程触发
            Event.registerIn("_onConnectionState", this, "_onConnectionState");

            var v = new AsyncConnectMethod(this._asyncConnect);

            v.BeginInvoke(state, new AsyncCallback(this._asyncConnectCB), state);
        }
Exemple #18
0
        public void connectTo(string ip, int port, ConnectCallback callback, object userData)
        {
            if (valid())
            {
                throw new InvalidOperationException("Have already connected!");
            }

            if (!(new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))")).IsMatch(ip))
            {
                IPHostEntry ipHost = Dns.GetHostEntry(ip);
                ip = ipHost.AddressList[0].ToString();
            }

            // Security.PrefetchSocketPolicy(ip, 843);
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, KBEngineApp.app.getInitArgs().getRecvBufferSize() * 2);
            _socket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.Socket, SocketOptionName.SendBuffer, KBEngineApp.app.getInitArgs().getSendBufferSize() * 2);
            _socket.NoDelay = true;

            ConnectState state = new ConnectState();

            state.connectIP        = ip;
            state.connectPort      = port;
            state.connectCB        = callback;
            state.userData         = userData;
            state.socket           = _socket;
            state.networkInterface = this;

            Dbg.DEBUG_MSG("connect to " + ip + ":" + port + " ...");

            // 先注册一个事件回调,该事件在当前线程触发
            Event.registerIn("_onConnectStatus", this, "_onConnectStatus");

            try
            {
                _socket.BeginConnect(new IPEndPoint(IPAddress.Parse(ip), port), new AsyncCallback(connectCB), state);
            }
            catch (Exception e)
            {
                state.error = e.ToString();
                Event.fireIn("_onConnectStatus", new object[] { state });
            }
        }
Exemple #19
0
 public void installEvents()
 {
     Event.registerIn("reqRangeFire", this, "reqRangeFire");
 }
Exemple #20
0
 public void installEvents()
 {
     Event.registerIn("reqShot", this, "reqShot");
 }
 public void installEvents()
 {
     Event.registerIn(AccountEvent_In.EventName.reqAvatarList, this, "reqAvatarList");
     Event.registerIn(AccountEvent_In.EventName.reqCreateAvatar, this, "reqCreateAvatar");
     Event.registerIn(AccountEvent_In.EventName.enterGameRoom, this, "enterGameRoom");
 }
Exemple #22
0
 public void installEvents()
 {
     Event.registerIn("reqDestroySelf", this, "reqDestroySelf");
 }
 public virtual void installEvents()
 {
     Event.registerIn("onImportClientSDK", this, "onImportClientSDK");
 }
Exemple #24
0
 public void installEvents()
 {
     Event.registerIn("reqMoveObjSync", this, "reqMoveObjSync");
     Event.registerIn("reqMoveObjsSync", this, "reqMoveObjsSync");
 }