860 lines
30 KiB
C#
860 lines
30 KiB
C#
//using Axibug;
|
||
//using Axibug.Event;
|
||
//using Axibug.Resources;
|
||
//using Axibug.Runtime;
|
||
//using Game.Config;
|
||
//using System;
|
||
//using System.Collections;
|
||
//using System.Collections.Generic;
|
||
//using System.Linq;
|
||
//using UnityEngine;
|
||
|
||
//namespace Game
|
||
//{
|
||
// public class UserMgrComponent : GameComponent
|
||
// {
|
||
// private Queue<S_ROLE_BASE> temp_RemoveUser = new Queue<S_ROLE_BASE>();//需要移除的玩家列表
|
||
// private Queue<Int32> temp_RemoveRequest = new Queue<Int32>();//请求数据列表
|
||
|
||
// //key:职业+性别 比如:ss_w
|
||
// private Dictionary<string, Queue<GameObject>> userPool = new Dictionary<string, Queue<GameObject>>();
|
||
|
||
// private float temp_CheckTime = 0;
|
||
// private float temp_RequestTime = 0;
|
||
|
||
// private S_ROLE_SELF myrole { get { return UserData.role; } }
|
||
|
||
|
||
// private void Start()
|
||
// {
|
||
// //AppEntry.Event.Subscribe(UserMoveEventArgs.EventId, OnUserMoveEvent);
|
||
// //AppEntry.Event.Subscribe(UserPlayerSkillEventArgs.EventId, OnUserPlayerSkill);
|
||
// //AppEntry.Event.Subscribe(RoleDeadEventArgs.EventId, OnRoleDead);
|
||
// //AppEntry.Event.Subscribe(RoleReviveEventArgs.EventId, OnRoleRevive);
|
||
// //AppEntry.Event.Subscribe(RoleLevelupEventArgs.EventId, OnRoleLevelUp);
|
||
// //AppEntry.Event.Subscribe(AddRoleBufferEvent.EventId, AddBuffer);
|
||
// //AppEntry.Event.Subscribe(RemoveRoleBufferEvent.EventId, RemoveBuffer);
|
||
// }
|
||
|
||
// public GameObject Accquire(string myKey, S_ROLE_BASE role)
|
||
// {
|
||
// if (!userPool.ContainsKey(myKey))
|
||
// return null;
|
||
|
||
// Queue<GameObject> gos = userPool[myKey];
|
||
// if (gos.Count == 0)
|
||
// return null;
|
||
|
||
// GameObject go = gos.Dequeue();
|
||
// go.SetActive(true);
|
||
// //role.userview.go = go;
|
||
// role.userview.rolePrefabGo = go;
|
||
// return go;
|
||
// }
|
||
|
||
// public void Release(S_ROLE_BASE role)
|
||
// {
|
||
// string strJob = Common.GetStrJob((byte)role.innate.job);
|
||
// string strSex = Common.GetStrSex(role.innate.sex);
|
||
// string myKey = $"{strJob}_{strSex}";
|
||
|
||
|
||
// // 清理玩家信息条
|
||
// BattleEntitysInfoCtrl.Instance.DisposeUserInfo(role.mem.userindex);
|
||
|
||
// Queue<GameObject> gos = null;
|
||
// if (userPool.ContainsKey(myKey))
|
||
// gos = userPool[myKey];
|
||
// else
|
||
// {
|
||
// gos = new Queue<GameObject>();
|
||
// userPool.Add(myKey, gos);
|
||
// }
|
||
|
||
// if(role.userview.go != null)
|
||
// {
|
||
// /*
|
||
// gos.Enqueue(role.userview.go);
|
||
// role.userview.go.SetActive(false);
|
||
// role.userview.go = null;
|
||
// */
|
||
|
||
// gos.Enqueue(role.userview.rolePrefabGo);
|
||
// role.userview.go.SetActive(false);
|
||
// }
|
||
|
||
// role.userview.Release();
|
||
// AppEntry.Event.FireNow(null, CharReleaseEventArgs.Create(role.dataSet.GetCharIndex(), E_NODE_TYPE.N_ROLE));
|
||
|
||
|
||
// }
|
||
|
||
// public void CreateMainPlayer(S_ROLE_SELF myrole)
|
||
// {
|
||
// if (myrole == null)
|
||
// return;
|
||
|
||
// //初始化便捷数据类
|
||
// MainPlayerDataSet mainDataSet = new MainPlayerDataSet();
|
||
// mainDataSet.Init(myrole);
|
||
// myrole.dataSet = mainDataSet;
|
||
|
||
// CreateRole((byte)myrole.innate.job, myrole, true);
|
||
// }
|
||
|
||
// public void CreateRole(byte job, S_ROLE_BASE role, bool isMainPlayer=false)
|
||
// {
|
||
// if (!isMainPlayer)
|
||
// {
|
||
// //产生时,标记角色格子占据
|
||
// HotfixEntry.Map.SetRoleCell(role.mem.userindex, (int)role.status.pos.x, (int)role.status.pos.z, E_NODE_TYPE.N_ROLE);
|
||
// }
|
||
|
||
// //RoleTop.transform.localRotation = Quaternion.EulerRotation(60, 0, 0);
|
||
|
||
// string strJob = Common.GetStrJob(job);
|
||
// string strSex = Common.GetStrSex(role.innate.sex);
|
||
|
||
// string myKey = $"{strJob}_{strSex}";
|
||
// //@Test 测试模型用
|
||
// string path = Utility.Path.GetPlayerPath(myKey, myKey+"_Test");
|
||
|
||
// //还没写完, 待测试
|
||
// GameObject go = Accquire(myKey, role);
|
||
// if(go == null)
|
||
// {
|
||
// //ch
|
||
// GameObject RoleTop = new GameObject();
|
||
// if (isMainPlayer)
|
||
// {
|
||
// RoleTop.transform.parent = HotfixEntry.MainPlayer.transform;
|
||
// RoleTop.transform.localPosition = Vector3.zero;
|
||
// }
|
||
// else
|
||
// RoleTop.transform.parent = HotfixEntry.UserMgr.transform;
|
||
|
||
// HotfixEntry.Resources.Clone(path, CreateCallback, RoleTop.transform, role, myKey.ToLower());
|
||
// return;
|
||
// }
|
||
|
||
// role.userview.go = go;
|
||
// role.userview.ResetGameObject(go);
|
||
// }
|
||
|
||
|
||
// protected void CreateCallback(UnityEngine.Object obj, CallbackType err, object userData)
|
||
// {
|
||
// if (err != CallbackType.Success)
|
||
// {
|
||
// Log.Error("创建角色失败");
|
||
// return;
|
||
// }
|
||
|
||
// if (userData == null)
|
||
// return;
|
||
|
||
// S_ROLE_BASE role = (S_ROLE_BASE)userData;
|
||
// if (role as S_ROLE_SELF != null)
|
||
// HotfixEntry.MainPlayer.myView.InitGameObject(obj as GameObject);
|
||
// else
|
||
// {
|
||
// role.userview.InitGameObject(obj as GameObject);
|
||
// }
|
||
// }
|
||
|
||
// /// <summary>
|
||
// /// 主角色换装
|
||
// /// </summary>
|
||
// /// <param name="roleView"></param>
|
||
// /// <param name="job"></param>
|
||
// /// <param name="SubJob">二级职业,如DZ_M_DD刀盾模型中,末尾的"DD"</param>
|
||
// public void MainPlayerChangeEquipment(byte job,string SubJob)
|
||
// {
|
||
// MyView myview = HotfixEntry.MainPlayer.myView;
|
||
// ChangeEquipment(myview, myview.myrole,job,SubJob);
|
||
// }
|
||
|
||
// protected void ChangeEquipmentCallback(UnityEngine.Object obj, CallbackType err, object userData)
|
||
// {
|
||
// if (err != CallbackType.Success)
|
||
// {
|
||
// Log.Error("创建角色失败");
|
||
// return;
|
||
// }
|
||
// if (userData == null)
|
||
// return;
|
||
|
||
// S_ROLE_BASE role = (S_ROLE_BASE)userData;
|
||
|
||
// GameObject Oldobj = role.characterview.rolePrefabGo.gameObject;
|
||
// GameObject Newobj = (obj as GameObject);
|
||
// role.characterview.rolePrefabGo = Newobj;
|
||
|
||
// //重置Movement,而不是创建
|
||
// if (role as S_ROLE_SELF != null)
|
||
// {
|
||
// HotfixEntry.MainPlayer.myView.InitMovement(obj as GameObject);
|
||
// }
|
||
// else
|
||
// role.userview.InitMovement(obj as GameObject);
|
||
|
||
// Newobj.transform.localPosition = Oldobj.transform.localPosition;
|
||
// Newobj.transform.localRotation = Oldobj.transform.localRotation;
|
||
|
||
// //完全替换后再销毁原角色,保证时序靠后
|
||
// Destroy(Oldobj);
|
||
// }
|
||
|
||
// //角色移动
|
||
// private void OnUserMoveEvent(object sender, LogicEventArgs e)
|
||
// {
|
||
// UserMoveEventArgs move = (UserMoveEventArgs)e;
|
||
// if (move == null)
|
||
// throw new GameException("UserMoveEventArgs is null");
|
||
|
||
// var role = UserData.findRoleData(move.userIndex);
|
||
// if(role == null)
|
||
// throw new GameException("the role is null");
|
||
|
||
// role.userview.StartMove(move.speed, role.status.face);
|
||
|
||
// //更新下玩家的大格子
|
||
// HotfixEntry.Map.UpdateUserBC(role);
|
||
// }
|
||
|
||
// //角色播放技能
|
||
// private void OnUserPlayerSkill(object sender, LogicEventArgs e)
|
||
// {
|
||
// UserPlayerSkillEventArgs skill = (UserPlayerSkillEventArgs)e;
|
||
// if (skill == null)
|
||
// throw new GameException("UserPlayerSkillEventArgs is null");
|
||
|
||
// int clientId = ConstClass.GetClientSkillID(skill.skillid, skill.skilllevel);
|
||
// SkillData script = HotfixEntry.Luban.GetSkill(clientId);
|
||
// if (script == null)
|
||
// throw new GameException($"the skillid:[{clientId}] is null");
|
||
|
||
// Transform source = null;
|
||
// Transform target = null;
|
||
// Vector3 targetPos = Vector3.zero;
|
||
|
||
|
||
// CellNode cell = null;
|
||
|
||
// switch (skill.lock_type)
|
||
// {
|
||
// case (byte)Lock_Type.LOCK_PLAYER:
|
||
// {
|
||
// var role = UserData.findRoleData(skill.lockIndex);
|
||
// if (role == null || role.userview == null)
|
||
// throw new GameException($"the lockIndex:{skill.lockIndex} is null");
|
||
|
||
// cell = role.userview.CurCell;
|
||
// target = role.userview.rolePrefabGo.transform;
|
||
// targetPos = role.userview.rolePrefabGo.transform.position;
|
||
// }
|
||
// break;
|
||
// case (byte)Lock_Type.LOCK_MONSTER:
|
||
// {
|
||
// var robot = RobotData.findRobotData(skill.lockIndex);
|
||
// if (robot == null || robot.data == null)
|
||
// throw new GameException($"the lockIndex:{skill.lockIndex} is null");
|
||
|
||
// cell = robot.view.CurCell;
|
||
// target = robot.view.rolePrefabGo.transform;
|
||
// targetPos = robot.view.rolePrefabGo.transform.position;
|
||
// }
|
||
// break;
|
||
// }
|
||
|
||
// if (cell == null)
|
||
// return;
|
||
|
||
// //修改特效发送source和taget的位置
|
||
// if (skill.userIndex == myrole.mem.userindex)
|
||
// {
|
||
// HotfixEntry.MainPlayer.myView.Attack(cell, script.Motion);
|
||
// myrole.move.state = 1;
|
||
// source = HotfixEntry.MainPlayer.myView.rolePrefabGo.transform;
|
||
// }
|
||
// else
|
||
// {
|
||
// S_ROLE_BASE role = UserData.findRoleData(skill.userIndex);
|
||
// if (role == null)
|
||
// throw new GameException("the role is null");
|
||
|
||
// role.userview.Attack(role.userview.CurCell, script.Motion, false);
|
||
// source = role.userview.rolePrefabGo.transform;
|
||
// }
|
||
|
||
|
||
// //播放技能特效
|
||
// string path = string.Empty;
|
||
// //如果有技能动作,则播放
|
||
// if (!string.IsNullOrEmpty(script.BindEffect) && script.BindEffect != "0")
|
||
// {
|
||
// path = Utility.Path.GetPrefabPath("Effects", script.BindEffect);
|
||
// HotfixEntry.EffectMgr.PlayAttackEffect(path, source);
|
||
// }
|
||
|
||
// if (!string.IsNullOrEmpty(script.WorldEffect) && script.WorldEffect != "0")
|
||
// {
|
||
// path = Utility.Path.GetPrefabPath("Effects", script.WorldEffect);
|
||
// HotfixEntry.EffectMgr.PlayWorldEffect(path, targetPos);
|
||
// }
|
||
|
||
// if (!string.IsNullOrEmpty(script.BallisticEffect) && script.BallisticEffect != "0")
|
||
// {
|
||
// path = Utility.Path.GetPrefabPath("Effects", script.BallisticEffect);
|
||
// StartCoroutine(DelayPlayerEffect(script.EffectDelayTime, path, source, target));
|
||
|
||
// }
|
||
|
||
// Log.Debug($"播放技能:ID={clientId}, 动作={script.Motion}, 绑定特效={script.BindEffect}, 世界特效={script.WorldEffect}, 弹道特效={script.BallisticEffect}, 被击特效={script.HitEffect}");
|
||
// }
|
||
|
||
// IEnumerator DelayPlayerEffect(int delay, string path, Transform source, Transform target)
|
||
// {
|
||
// yield return new WaitForSeconds(delay / 1000.0f);
|
||
|
||
// HotfixEntry.EffectMgr.PlayBallisticEffect(path, source, target);
|
||
// }
|
||
|
||
// //角色死亡
|
||
// public void OnRoleDead(object sender, LogicEventArgs e)
|
||
// {
|
||
// RoleDeadEventArgs dead = (RoleDeadEventArgs)e;
|
||
// if (dead == null)
|
||
// throw new GameException("RoleDeadEventArgs is null");
|
||
|
||
// S_ROLE_BASE role = null;
|
||
|
||
// if (dead.roleIndex == myrole.mem.userindex)
|
||
// {
|
||
// role = myrole;
|
||
|
||
// //HotfixEntry.MainPlayer.myView.SetAnimation("Dead", true);
|
||
// myrole.myView.movement.characterAnimator.PlayDead();
|
||
|
||
// HotfixEntry.UI.OpenUI<DeathPanelUI>();
|
||
// }
|
||
// else
|
||
// {
|
||
// role = UserData.findRoleData(dead.roleIndex);
|
||
|
||
// if (role == null)
|
||
// throw new GameException("the role is null");
|
||
|
||
// //role.userview.SetAnimation("Dead", true);
|
||
// role.userview.movement.characterAnimator.PlayDead();
|
||
// HotfixEntry.Map.ClearRoleCellData(dead.roleIndex, E_NODE_TYPE.N_ROLE);
|
||
// }
|
||
|
||
// switch ((Lock_Type)role.tmp.lockData.lock_type)
|
||
// {
|
||
// case Lock_Type.LOCK_PLAYER://玩家
|
||
// {
|
||
// var lockRole = UserData.findRoleData(role.tmp.lockData.lock_index);
|
||
// if (lockRole == null || lockRole.userview == null || lockRole.userview.go == null)
|
||
// return;
|
||
|
||
// lockRole.userview.SetSublightOff();
|
||
// }
|
||
// break;
|
||
// case Lock_Type.LOCK_MONSTER://怪物
|
||
// {
|
||
// var lockRobot = RobotData.findRobotData(role.tmp.lockData.lock_index);
|
||
// if (lockRobot == null || lockRobot.view == null || lockRobot.view.go == null)
|
||
// return;
|
||
|
||
// lockRobot.view.SetSublightOff();
|
||
// }
|
||
// break;
|
||
// }
|
||
|
||
// role.tmp.lockData.lock_state = 0;
|
||
// role.tmp.lockData.lock_index = -1;
|
||
|
||
// }
|
||
|
||
// //角色复活
|
||
// public void OnRoleRevive(object sender, LogicEventArgs e)
|
||
// {
|
||
// RoleReviveEventArgs revive = (RoleReviveEventArgs)e;
|
||
// if (revive == null)
|
||
// throw new GameException("RoleReviveEventArgs is null");
|
||
|
||
// //传送
|
||
// if (revive.userIndex == myrole.mem.userindex)
|
||
// {
|
||
// myrole.myView.movement.characterAnimator.DeadToIdle();
|
||
|
||
// AppEntry.Event.Fire(null, BattleRoleMovingEventArgs.Create(myrole.myDataSet.GetCharIndex(),E_NODE_TYPE.N_MAINPLAYER));
|
||
|
||
// HotfixEntry.MainPlayer.myView.TeleportingToPos(revive.pos);
|
||
// myrole.status.state = (int)CharacterState.Living;
|
||
// return;
|
||
// }
|
||
|
||
// S_ROLE_BASE role = UserData.findRoleData(revive.userIndex);
|
||
|
||
// if (role == null)
|
||
// throw new GameException("the role is null");
|
||
|
||
// role.userview.movement.characterAnimator.DeadToIdle();
|
||
// role.userview.TeleportingToPos(revive.pos);
|
||
// role.status.state = (int)CharacterState.Living;
|
||
// }
|
||
|
||
// //角色升级
|
||
// public void OnRoleLevelUp(object sender, LogicEventArgs e)
|
||
// {
|
||
// RoleLevelupEventArgs msg = (RoleLevelupEventArgs)e;
|
||
// if (msg == null)
|
||
// throw new GameException("RoleLevelupEventArgs is null");
|
||
|
||
// S_ROLE_BASE role = null;
|
||
// if (msg.roleIndex == myrole.mem.userindex)
|
||
// {
|
||
// //如果升级的是自己
|
||
// role = myrole;
|
||
// }
|
||
// else
|
||
// {
|
||
// role = UserData.findRoleData(msg.roleIndex);
|
||
|
||
// if (role == null)
|
||
// throw new GameException("the role is null");
|
||
// }
|
||
|
||
// role.exp.level = msg.currentLevel;
|
||
// Log.Warning($"角色提升到{role.exp.level}级");
|
||
// }
|
||
|
||
// //角色播放buff
|
||
// public void AddBuffer(object sender, LogicEventArgs e)
|
||
// {
|
||
// //播放特效
|
||
// AddRoleBufferEvent msg = (AddRoleBufferEvent)e;
|
||
// if (msg == null)
|
||
// throw new GameException("AddRoleBufferEvent is null");
|
||
|
||
// if (msg.roleIndex != myrole.mem.userindex)
|
||
// return;
|
||
|
||
// AppEntry.Event.Fire(this, AddBufferIconEvent.Create(msg.buffId));
|
||
// }
|
||
|
||
// //角色删除buff
|
||
// public void RemoveBuffer(object sender, LogicEventArgs e)
|
||
// {
|
||
// //删除特效
|
||
// RemoveRoleBufferEvent msg = (RemoveRoleBufferEvent)e;
|
||
// if (msg == null)
|
||
// throw new GameException("AddRoleBufferEvent is null");
|
||
|
||
// if (msg.roleIndex != myrole.mem.userindex)
|
||
// return;
|
||
|
||
// AppEntry.Event.Fire(this, RemoveBufferIconEvent.Create(msg.buffId));
|
||
// }
|
||
|
||
// // Update is called once per frame
|
||
// void Update()
|
||
// {
|
||
// #region
|
||
// if (Input.GetKeyDown(KeyCode.O))
|
||
// {
|
||
// CaoCaoLog.Debug("测试换装到,DD");
|
||
// MainPlayerChangeEquipment((byte)eJob.Warrior, "DD");
|
||
// }
|
||
// if (Input.GetKeyDown(KeyCode.P))
|
||
// {
|
||
// CaoCaoLog.Debug("测试换装到,KD");
|
||
// MainPlayerChangeEquipment((byte)eJob.Warrior, "KD");
|
||
// }
|
||
// if (Input.GetKeyDown(KeyCode.U))
|
||
// {
|
||
// CaoCaoLog.Debug("测试升级");
|
||
// UIMgr.Instance.OpenUI<TipShowLevelUpUI>();
|
||
// }
|
||
// if (Input.GetKeyDown(KeyCode.Y))
|
||
// {
|
||
// HotfixEntry.UI.OpenUI<AttrPointTipsUI>();
|
||
// }
|
||
// if (Input.GetKeyDown(KeyCode.T))
|
||
// {
|
||
// HotfixEntry.UI.OpenUI<TaskMainUI>();
|
||
// }
|
||
// //if (Input.GetKeyDown(KeyCode.M))
|
||
// //{
|
||
// // if (!HotfixEntry.UI.IsOpen<FullMapUI>())
|
||
// // HotfixEntry.UI.OpenUI<FullMapUI>();
|
||
// //}
|
||
// #endregion
|
||
|
||
// if (HotfixEntry.MainPlayer.myView == null)
|
||
// return;
|
||
|
||
// if (!UserData.role.isEntryWorld)
|
||
// return;
|
||
|
||
|
||
// //1、同步自己的移动 三大策略发送移动数据
|
||
// SyncMove();
|
||
// UserBuffManager.renderBuff();
|
||
|
||
// UpdateUserCell();
|
||
|
||
// //2、更新其他玩家显示 200毫秒检查一次
|
||
// float ftime = Time.time - temp_CheckTime;
|
||
// if (ftime > 0.2f)
|
||
// {
|
||
// temp_CheckTime = Time.time;
|
||
// UpdateUserRect();
|
||
// return;
|
||
// }
|
||
|
||
// //3、更新其他玩家信息
|
||
// foreach (var r in UserData.onlines)
|
||
// {
|
||
// var role = r.Value;
|
||
// if (role.userview == null)
|
||
// continue;
|
||
|
||
// if (role.userview.go == null)
|
||
// continue;
|
||
|
||
// if (role.status.state == (int)CharacterState.Dead)
|
||
// continue;
|
||
|
||
// role.userview.Update();
|
||
// }
|
||
|
||
// //4、排队申请其他玩家和怪物数据 节约服务器性能 把峰值平摊在逐帧
|
||
// float ftime2 = Time.time - temp_RequestTime;
|
||
// if (ftime2 > 0.05f)
|
||
// {
|
||
// temp_RequestTime = Time.time;
|
||
// UpdateRequestRoleData();
|
||
// UpdateRequestRobotData();
|
||
// }
|
||
// }
|
||
|
||
|
||
// private void UpdateUserCell()
|
||
// {
|
||
// int[] keys = UserData.onlines.Keys.ToArray();
|
||
|
||
// for (int i = 0; i < keys.Length; i++)
|
||
// {
|
||
// S_ROLE_BASE user = UserData.onlines[keys[i]];
|
||
// if (user.mem.userindex != HotfixEntry.MainPlayer.myDataSet.GetCharIndex() && user.status.state < (byte)CharacterState.Dead && user.life.curHP > 0)
|
||
// {
|
||
// //产生时,标记角色格子占据
|
||
// HotfixEntry.Map.SetRoleCell(keys[i], user.userview.go.transform.position, E_NODE_TYPE.N_ROLE);
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
// //更新请求玩家数据列表或者怪物数据列表
|
||
// private void UpdateRequestRoleData()
|
||
// {
|
||
// if (UserData.requestRoleDatas.Count == 0)
|
||
// return;
|
||
|
||
// Int32 count = 0;
|
||
// foreach (var r in UserData.requestRoleDatas)
|
||
// {
|
||
// int index = r.Value;
|
||
// temp_RemoveRequest.Enqueue(index);
|
||
// ++count;
|
||
// if (count >= UserData.MAX_REQUEST_ROLE_COUNT)
|
||
// break;
|
||
// }
|
||
|
||
// //清理玩家
|
||
// while (temp_RemoveRequest.Count > 0)
|
||
// {
|
||
// Int32 userindex = temp_RemoveRequest.Dequeue();
|
||
// //移除其他玩家
|
||
// UserData.removeRequestRoledata(userindex);
|
||
// //发送请求其他玩家详细数据
|
||
// AppEntryWorld.send_700(userindex);
|
||
// //var entryWorld = HotfixEntry.Resources.m_Assembly.GetType("Game.HotFix.AppEntryWorld");
|
||
// //var start = entryWorld.GetMethod("send_700");
|
||
// //start?.Invoke(null, new object[] { userindex });
|
||
|
||
|
||
// //AppEntryWorld.send_700(userindex);
|
||
// }
|
||
|
||
// temp_RemoveRequest.Clear();
|
||
// }
|
||
|
||
// //更新请求玩家数据列表或者怪物数据列表
|
||
// private void UpdateRequestRobotData()
|
||
// {
|
||
// if (UserData.requestRobotDatas.Count == 0)
|
||
// return;
|
||
|
||
// Int32 count = 0;
|
||
// foreach (var r in UserData.requestRobotDatas)
|
||
// {
|
||
// int index = r.Value;
|
||
// temp_RemoveRequest.Enqueue(index);
|
||
// ++count;
|
||
// if (count >= UserData.MAX_REQUEST_ROBOT_COUNT)
|
||
// break;
|
||
// }
|
||
// //清理玩家
|
||
// while (temp_RemoveRequest.Count > 0)
|
||
// {
|
||
// Int32 robotindex = temp_RemoveRequest.Dequeue();
|
||
// //移除其他玩家
|
||
// UserData.removeRequestRobotdata(robotindex);
|
||
|
||
// //var app = HotfixEntry.Resources.m_Assembly.GetType("Game.HotFix.AppRobot");
|
||
// //var method = app.GetMethod("send_8000");
|
||
// //method?.Invoke(null, new object[] { robotindex });
|
||
|
||
// //发送请求怪物详细数据
|
||
// AppRobot.send_8000(robotindex);
|
||
// }
|
||
|
||
// temp_RemoveRequest.Clear();
|
||
// }
|
||
|
||
// //玩家离开世界
|
||
// public void LeaveWorld(S_ROLE_BASE role)
|
||
// {
|
||
// if (role == null)
|
||
// return;
|
||
|
||
// //释放角色,清楚角色格子占据数据
|
||
// HotfixEntry.Map.ClearRoleCellData(role.mem.userindex, E_NODE_TYPE.N_ROLE);
|
||
|
||
// //0、清理锁定
|
||
// ClearLock(role, null);
|
||
|
||
// //1、释放显示资源
|
||
// if (role.userview != null)
|
||
// {
|
||
// //role.userview.Release();
|
||
// Release(role);
|
||
// UserData.pushUserView(role.userview);
|
||
// role.userview = null;
|
||
|
||
// //清除便捷数据类
|
||
// UserData.pushRoleDataSet(role.dataSet);
|
||
// role.dataSet = null;
|
||
// }
|
||
|
||
// //2、释放数据
|
||
// UserData.removeRoleData(role.mem.userindex);//从玩家数据中移除
|
||
// UserData.pushRoleData(role);//放回对象回收池 重复利用
|
||
|
||
// }
|
||
|
||
// public void ClearLock(S_ROLE_BASE role, S_ROBOT_BASE robot)
|
||
// {
|
||
// bool islock = false;
|
||
// if (role == null && robot == null)
|
||
// {
|
||
// islock = true;
|
||
// }
|
||
// else
|
||
// {
|
||
// switch ((Lock_Type)UserData.role.tmp.lockData.lock_type)
|
||
// {
|
||
// case Lock_Type.LOCK_PLAYER:
|
||
// if (role != null)
|
||
// if (role.mem.userindex == UserData.role.tmp.lockData.lock_index)
|
||
// islock = true;
|
||
// break;
|
||
// case Lock_Type.LOCK_MONSTER:
|
||
// if (robot != null)
|
||
// if (robot.data.robotindex == UserData.role.tmp.lockData.lock_index)
|
||
// islock = true;
|
||
// break;
|
||
// }
|
||
// }
|
||
|
||
// if (!islock)
|
||
// return;
|
||
|
||
// if (UserData.role.tmp.lockData.lock_type > 0)
|
||
// {
|
||
// //FGUIManager.GetFUI(FGUIType.BattlePanel).GetComponent<UIBattleComponent>().HideSelectObjInfo();
|
||
// //GameObject.Destroy(MyUserData.lockeffect);
|
||
// }
|
||
|
||
// UserData.role.tmp.lockData.Init();
|
||
// }
|
||
|
||
// //同步移动 状态同步
|
||
// //三种策略 1、状态发送变化 2、方向发生了变化 3、距离发生了变化
|
||
// public void SyncMove()
|
||
// {
|
||
// float face = HotfixEntry.MainPlayer.myView.movement.CurRotate;
|
||
|
||
// //1、状态发生变化
|
||
// if (myrole.move.state != myrole.move.oldstate)
|
||
// {
|
||
// myrole.move.oldstate = myrole.move.state;
|
||
// SendMove();
|
||
// return;
|
||
// }
|
||
|
||
// if (myrole.move.state == 0)
|
||
// return;
|
||
|
||
// //2、验证距离
|
||
// float ftime = Time.time - myrole.move.syncTime;
|
||
// if (ftime > 0.2f)
|
||
// {
|
||
// //距离格子中心点0.2才算
|
||
// Vector3 centerPos = HotfixEntry.Map.GetPosByCell(HotfixEntry.MainPlayer.myView.movement.CurCell.X, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
|
||
// float centerDis = Vector3.Distance(HotfixEntry.MainPlayer.myView.Pos, centerPos);
|
||
// if (centerDis >= 0.2f)
|
||
// return;
|
||
|
||
|
||
// Vector3 tPos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
|
||
// float distance = Vector3.Distance(myrole.move.pos, tPos);
|
||
// if (distance >= 0.8f)
|
||
// {
|
||
// SendMove();
|
||
// return;
|
||
// }
|
||
// }
|
||
// else if (ftime > 0.1f)
|
||
// {
|
||
// //3、角度发生了变化
|
||
// float angle = Math.Abs(myrole.move.face - face);
|
||
// if (angle >= 5)
|
||
// {
|
||
// SendMove();
|
||
// return;
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
// public void SendMove()
|
||
// {
|
||
// float face = HotfixEntry.MainPlayer.myView.movement.CurRotate;
|
||
|
||
// myrole.move.syncTime = Time.time;
|
||
// myrole.move.face = face;
|
||
|
||
// //发送数据
|
||
// if (myrole.move.state == 0)
|
||
// AppMove.send_1000(face, 0, myrole.status.pos, myrole.status.pos);
|
||
// else
|
||
// {
|
||
// myrole.move.pos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
|
||
// //Log.Debug($"发送路径:起始点:[{myrole.status.pos}], 结束点:[{myrole.move.pos}]");
|
||
// AppMove.send_1000(face, HotfixEntry.MainPlayer.myView.movement.speed, myrole.status.pos, myrole.move.pos);
|
||
// myrole.status.pos = new Vector3(HotfixEntry.MainPlayer.myView.movement.CurCell.X, 0, HotfixEntry.MainPlayer.myView.movement.CurCell.Y);
|
||
|
||
// }
|
||
|
||
// HotfixEntry.Map.UpdateUserBC(myrole);
|
||
|
||
// }
|
||
|
||
|
||
// //更新删除玩家显示
|
||
// //玩家三大策略 1、收到服务器玩家离开信息删除ok 2、不在主控玩家九宫格范围删除 3、心跳包时间超时删除
|
||
// private void UpdateUserRect()
|
||
// {
|
||
// foreach (var r in UserData.onlines)
|
||
// {
|
||
// var role = r.Value;
|
||
// if (role.userview == null)
|
||
// continue;
|
||
|
||
// if (role.userview.go == null)
|
||
// continue;
|
||
|
||
// role.userview.Update();
|
||
|
||
// //1、验证大格子是不是在主控玩家九宫格区域内
|
||
// if (!myrole.bc.edge.IsRect(role.bc.grid_big.row, role.bc.grid_big.col))
|
||
// {
|
||
// //需要删除
|
||
// temp_RemoveUser.Enqueue(role);
|
||
|
||
// Debug.Log("玩家不在九宫格范围..." + role.mem.userId);
|
||
// continue;
|
||
// }
|
||
// //2、心跳时间验证 超过60秒 认为这个玩家是个死链接 删除
|
||
// float ftime = Time.time - role.tmp.heartTime;
|
||
// if (ftime > 60)
|
||
// {
|
||
// //需要删除
|
||
// temp_RemoveUser.Enqueue(role);
|
||
// Debug.Log("玩家hearttime...删除" + role.mem.userId);
|
||
// continue;
|
||
// }
|
||
// }
|
||
|
||
// //清理玩家
|
||
// while (temp_RemoveUser.Count > 0)
|
||
// {
|
||
// var role = temp_RemoveUser.Dequeue();
|
||
// //移除其他玩家
|
||
// if (UserData.onlines.ContainsKey(role.mem.userindex))
|
||
// {
|
||
// UserData.onlines.Remove(role.mem.userindex);
|
||
// }
|
||
// //玩家离开世界
|
||
// LeaveWorld(role);
|
||
// }
|
||
// temp_RemoveUser.Clear();
|
||
// }
|
||
|
||
// public List<S_ROLE_BASE> GetRoleListInRadius(int cellNum, int curRobotIndex = -1)
|
||
// {
|
||
// CellNode cur = HotfixEntry.MainPlayer.myView.CurCell;
|
||
// List<S_ROLE_BASE> roles = new List<S_ROLE_BASE>();
|
||
|
||
// foreach (var r in UserData.onlines)
|
||
// {
|
||
// var role = r.Value;
|
||
// if (role.userview == null)
|
||
// continue;
|
||
|
||
// var roleCell = role.userview.CurCell;
|
||
|
||
// float count = Vector2Int.Distance(new Vector2Int(cur.X, cur.Y), new Vector2Int(roleCell.X, roleCell.Y));
|
||
// //超过距离,过滤
|
||
// if (count > cellNum)
|
||
// continue;
|
||
|
||
|
||
// //当前已选中怪,过滤, 并且取消选中状态
|
||
// if (role.mem.userindex == curRobotIndex)
|
||
// continue;
|
||
|
||
// roles.Add(role);
|
||
// }
|
||
|
||
// return roles;
|
||
// }
|
||
|
||
// public void SetAllSublightOff()
|
||
// {
|
||
// foreach (var r in UserData.onlines)
|
||
// {
|
||
// var role = r.Value;
|
||
// if (role.userview == null)
|
||
// continue;
|
||
|
||
// role.userview.SetSublightOff();
|
||
// }
|
||
// }
|
||
// }
|
||
//}
|
||
|