示例#1
0
 public void ReqSceneObjInfoChange()
 {
     // Debug.Log("GameVariable.IsNeedSynchSceneInfo : "+GameVariable.IsNeedSynchSceneInfo.ToString());
     if (GameVariable.IsNeedSynchSceneInfo)
     {
         SprotoType.scene_get_objs_info_change.request req = new SprotoType.scene_get_objs_info_change.request();
         NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_get_objs_info_change>(req, OnAckSceneObjInfoChange);
     }
     else
     {
         Timer.Register(0.5f, () => ReqSceneObjInfoChange());
     }
 }
示例#2
0
 public void ReqNewFightEvens()
 {
     // Debug.Log("GameVariable.IsNeedSynchSceneInfo : "+GameVariable.IsNeedSynchSceneInfo.ToString());
     if (GameVariable.IsNeedSynchSceneInfo)
     {
         SprotoType.scene_listen_fight_event.request req = new SprotoType.scene_listen_fight_event.request();
         NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_listen_fight_event>(req, OnAckFightEvents);
     }
     else
     {
         Timer.Register(0.5f, () => ReqNewFightEvens());
     }
 }
示例#3
0
        public void OnAckSceneObjInfoChange(SprotoTypeBase result)
        {
            // Debug.Log("synch from net received OnAckSceneObjInfoChange:"+(result!=null).ToString());
            SprotoType.scene_get_objs_info_change.request req = new SprotoType.scene_get_objs_info_change.request();
            NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_get_objs_info_change>(req, OnAckSceneObjInfoChange);
            SprotoType.scene_get_objs_info_change.response ack = result as SprotoType.scene_get_objs_info_change.response;
            if (ack == null)
            {
                return;
            }
            int len = ack.obj_infos.Count;

            for (int i = 0; i < len; i++)
            {
                long   uid              = ack.obj_infos[i].scene_obj_uid;
                Entity scene_obj        = SceneMgr.Instance.GetSceneObject(uid);
                var    change_info_list = ack.obj_infos[i].info_list;
                int    info_len         = change_info_list.Count;
                // Debug.Log("uid : "+uid.ToString()+ " info_len:"+info_len.ToString());
                for (int info_index = 0; info_index < info_len; info_index++)
                {
                    var cur_change_info = change_info_list[info_index];
                    // Debug.Log("cur_change_info.key : "+cur_change_info.key.ToString()+" scene_obj:"+(scene_obj!=Entity.Null).ToString()+ " ContainsKey:"+changeFuncDic.ContainsKey((SceneInfoKey)cur_change_info.key).ToString()+" uid"+uid.ToString()+" value:"+cur_change_info.value.ToString());
                    if (cur_change_info.key == (int)SceneInfoKey.EnterScene)
                    {
                        if (scene_obj == Entity.Null)
                        {
                            SceneObjectType sceneObjType = (SceneObjectType)Enum.Parse(typeof(SceneObjectType), cur_change_info.value);
                            scene_obj = SceneMgr.Instance.AddSceneObject(uid, sceneObjType);
                        }
                    }
                    else if (cur_change_info.key == (int)SceneInfoKey.LeaveScene)
                    {
                        if (scene_obj != Entity.Null)
                        {
                            SceneMgr.Instance.RemoveSceneObject(uid);
                            scene_obj = Entity.Null;
                        }
                    }
                    else if (scene_obj != Entity.Null && changeFuncDic.ContainsKey((SceneInfoKey)cur_change_info.key))
                    {
                        changeFuncDic[(SceneInfoKey)cur_change_info.key](scene_obj, cur_change_info);
                    }
                }
            }
        }
示例#4
0
 private void Update()
 {
     if (Input.GetKeyUp(UnityEngine.KeyCode.U))
     {
         Debug.Log("key U up");
         account_select_role_enter_game.request req = new account_select_role_enter_game.request();
         req.role_id = 123654;
         NetMsgDispatcher.GetInstance().SendMessage <Protocol.account_select_role_enter_game>(req, (_) =>
         {
             account_select_role_enter_game.response rsp = _ as account_select_role_enter_game.response;
             Debug.Log("rsp.result : " + rsp.result.ToString());
             if (rsp.result == 0)
             {
             }
         });
     }
 }
示例#5
0
        public void OnAckFightEvents(SprotoTypeBase result)
        {
            SprotoType.scene_listen_fight_event.request req = new SprotoType.scene_listen_fight_event.request();
            NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_listen_fight_event>(req, OnAckFightEvents);
            SprotoType.scene_listen_fight_event.response ack = result as SprotoType.scene_listen_fight_event.response;
            Debug.Log("ack : " + (ack != null).ToString() + " fightevents:" + (ack.fight_events != null).ToString());
            if (ack == null || ack.fight_events == null)
            {
                return;
            }
            var len = ack.fight_events.Count;

            Debug.Log("lisend fight event : " + len);
            for (int i = 0; i < len; i++)
            {
                HandleCastSkill(ack.fight_events[i]);
            }
        }
示例#6
0
        public void OnAckHurtEvents(SprotoTypeBase result)
        {
            SprotoType.scene_listen_hurt_event.request req = new SprotoType.scene_listen_hurt_event.request();
            NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_listen_hurt_event>(req, OnAckHurtEvents);
            SprotoType.scene_listen_hurt_event.response ack = result as SprotoType.scene_listen_hurt_event.response;
            // Debug.Log("ack : "+(ack!=null).ToString()+" fightevents:"+(ack.events!=null).ToString());
            if (ack == null || ack.events == null)
            {
                return;
            }
            var len = ack.events.Count;

            // Debug.Log("lisend hurt event : "+len);
            // ack.events.Sort((SprotoType.scene_hurt_event_info a, SprotoType.scene_hurt_event_info b)=>DisallowRefReturnCrossingThisAttribute a.time)
            for (int i = 0; i < len; i++)
            {
                HandleHurtEvent(ack.events[i]);
            }
        }
示例#7
0
        // protected override void OnCreateManager(int capacity)
        // {
        //     Debug.Log("synch system OnCreateManager");
        //     base.OnCreateManager(capacity);

        // }

        protected override void OnUpdate()
        {
            //upload per second
            // Debug.Log("synch system"+Time.time.ToString()+" lasttime:"+lastSynchTime.ToString());
            if (Time.time - lastSynchTime < 0.1 || !GameVariable.IsNeedSynchSceneInfo)
            {
                return;
            }
            lastSynchTime = Time.time;
            long synchTime = System.DateTime.Now.Millisecond;

            for (int index = 0; index < m_Data.Length; ++index)
            {
                // Debug.Log("synch system");
                scene_walk.request walk    = new scene_walk.request();
                float3             cur_pos = m_Data.Position[index].Value;
                walk.pos_x = (int)(cur_pos.x * GameConst.RealToLogic);
                walk.pos_y = (int)(cur_pos.y * GameConst.RealToLogic);
                walk.pos_z = (int)(cur_pos.z * GameConst.RealToLogic);
                walk.time  = synchTime;
                NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_walk>(walk);
            }
        }
示例#8
0
 protected override void OnUpdate()
 {
     //upload per second
     // Debug.Log("synch system"+Time.time.ToString()+" lasttime:"+lastSynchTime.ToString());
     if (Time.time - lastSynchTime < 4)
     {
         return;
     }
     lastSynchTime = Time.time + 500;
     for (int index = 0; index < m_Data.Length; ++index)
     {
         Debug.Log("synch system");
         scene_walk.request walk    = new scene_walk.request();
         float3             cur_pos = m_Data.Position[index].Value;
         walk.pos_x = (int)(cur_pos.x * GameConst.RealToLogic);
         walk.pos_y = (int)(cur_pos.y * GameConst.RealToLogic);
         walk.pos_z = (int)(cur_pos.z * GameConst.RealToLogic);
         walk.dir_x = 3;
         walk.dir_y = 4;
         walk.dir_z = 5;
         walk.time  = 6;
         NetMsgDispatcher.GetInstance().SendMessage <Protocol.scene_walk>(walk);
     }
 }