Esempio n. 1
0
        /// <summary> 向其他玩家推送在监狱移动</summary>
        public void PusuMovingActivity(Int64 userid, view_scene_user scene)
        {
            if (!Variable.OnlinePlayer.ContainsKey(userid))
            {
                return;
            }
            var otherplays = Core.Common.Scene.ActivityOtherPlayers(userid, (int)ModuleNumber.BUILDING);   //监狱内其他玩家

            foreach (var item in otherplays)
            {
                var tokenTest = new CancellationTokenSource();
                var temp      = new ScenePush()
                {
                    user_id       = userid,
                    scene_key     = item,
                    user_scene    = scene.CloneEntity(),
                    other_user_id = Variable.Activity.ScenePlayer[item].user_id
                };
                Task.Factory.StartNew(m =>
                {
                    var t = m as ScenePush;
                    if (t == null)
                    {
                        return;
                    }
                    var aso = new ASObject(BuildData((int)ResultType.SUCCESS, t.user_id, t.user_scene.X, t.user_scene.Y));
                    SendPv(t.other_user_id, aso, (int)BuildingCommand.PUSH_PLAYER_MOVING, (int)ModuleNumber.BUILDING);
                    tokenTest.Cancel();
                }, temp, tokenTest.Token);
            }
        }
Esempio n. 2
0
        /// <summary> 推送玩家进入场景并向其他人推送 </summary>
        public void PushMyEnterScene(Int64 userid, view_scene_user userscene)
        {
            if (!Variable.OnlinePlayer.ContainsKey(userid))
            {
                return;
            }
            if (userscene == null)
            {
                return;
            }
            userscene.model_number = (int)ModuleNumber.SCENE;
            var key = string.Format("{0}_{1}", (int)ModuleNumber.SCENE, userid);

            if (Variable.SCENCE.ContainsKey(key))
            {
                Variable.SCENCE[key].model_number = (int)ModuleNumber.SCENE;
            }
            var otherplays = Core.Common.Scene.GetOtherPlayers(userid, userscene.scene_id, (int)ModuleNumber.SCENE);//同场景内的其他玩家
            var aso        = new ASObject(BuildData((int)ResultType.SUCCESS, userscene.scene_id, userscene.X, userscene.Y, otherplays));

            SendPv(userid, aso, (int)SceneCommand.PUSH_ENTER_SCENET, (int)ModuleNumber.SCENE);
            foreach (var item in otherplays)
            {
                var temp = new ScenePush()
                {
                    user_id       = userid,
                    other_user_id = item.user_id,
                    user_scene    = userscene.CloneEntity()
                };
                var tokentest = new CancellationTokenSource();
                Task.Factory.StartNew(m =>
                {
                    var t = m as ScenePush;
                    if (t == null)
                    {
                        return;
                    }
                    var aso1 = new ASObject(BuildData((int)ResultType.SUCCESS, t.user_scene));
                    SendPv(t.other_user_id, aso1, (int)SceneCommand.PLAYER_ENTER_SCENE, (int)ModuleNumber.SCENE);// 向其他玩家推送A玩家退出后的场景
                    tokentest.Cancel();
                }, temp, tokentest.Token);
            }
        }
Esempio n. 3
0
        /// <summary> 场景处理</summary>
        private void CheckScene(Int64 userid, view_scene_user scene, int camp)
        {
            if (scene == null)
            {
                return;
            }
            scene.model_number = (int)ModuleNumber.BUILDING;
            var oldkey = string.Format("{0}_{1}", (int)ModuleNumber.BUILDING, scene.user_id);

            if (Variable.SCENCE.ContainsKey(oldkey))
            {
                Variable.SCENCE[oldkey].model_number = (int)ModuleNumber.BUILDING;
            }
            Common.GetInstance().PushMyLeaveScene(userid, scene); //活动外场景推送离开
            var activityscene = scene.CloneEntity();

            activityscene.model_number = (int)ModuleNumber.BUILDING;
            Common.GetInstance().GetActivityPoint(activityscene, camp); //初始坐标
            var key = string.Format("{0}_{1}", (int)ModuleNumber.BUILDING, userid);

            Variable.Activity.ScenePlayer.AddOrUpdate(key, activityscene, (m, n) => n); //加入到内存中
            Common.GetInstance().PushEnterActivity(userid, activityscene);              //向活动内玩家推送进入
        }