5224 子 【1.3.100】游戏帧数优化(一) / 【1.3.100】【前端】游戏帧数优化(一)
| | |
| | |
|
| | | for (int i = 0; i < vNetData.Players.Length; ++i)
|
| | | {
|
| | | if (BattleEffectPlayRule.Instance.sortPlayerList.Contains(vNetData.Players[i]))
|
| | | {
|
| | | BattleEffectPlayRule.Instance.sortPlayerList.Remove(vNetData.Players[i]);
|
| | | }
|
| | | BattleEffectPlayRule.Instance.RemovePlayer(vNetData.Players[i]);
|
| | |
|
| | | _actor = GAMgr.Instance.GetBySID(vNetData.Players[i]);
|
| | |
|
| | |
| | | // 异常
|
| | | }
|
| | |
|
| | | if (!BattleEffectPlayRule.Instance.sortPlayerList.Contains(vNetData.PlayerID))
|
| | | {
|
| | | BattleEffectPlayRule.Instance.sortPlayerList.Add(vNetData.PlayerID);
|
| | | }
|
| | | BattleEffectPlayRule.Instance.AddPlayer(vNetData.PlayerID);
|
| | |
|
| | | // 离线玩家
|
| | | if (vNetData.State == 1)
|
| | |
| | | |
| | | [XLua.LuaCallCSharp] |
| | | public class BattleEffectPlayRule : Singleton<BattleEffectPlayRule> |
| | | |
| | | { |
| | | public List<uint> sortPlayerList = new List<uint>(); |
| | | public readonly List<uint> sortPlayerList = new List<uint>(); |
| | | |
| | | public void AddPlayer(uint id) |
| | | { |
| | | if (sortPlayerList.Contains(id)) |
| | | { |
| | | return; |
| | | } |
| | | sortPlayerList.Add(id); |
| | | SortList(); |
| | | } |
| | | |
| | | public void RemovePlayer(uint id) |
| | | { |
| | | if (sortPlayerList.Contains(id)) |
| | | { |
| | | sortPlayerList.Remove(id); |
| | | } |
| | | SortList(); |
| | | } |
| | | |
| | | private int limit |
| | | { |
| | |
| | | |
| | | public float timeEscape; |
| | | |
| | | private void SortList() |
| | | { |
| | | GA_Hero _hero = PlayerDatas.Instance.hero; |
| | | if (_hero == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | sortPlayerList.Sort((id1, id2) => |
| | | { |
| | | GActor _actor1 = GAMgr.Instance.GetBySID(id1); |
| | | GActor _actor2 = GAMgr.Instance.GetBySID(id2); |
| | | |
| | | float _dis1 = 0f; |
| | | float _dis2 = 0f; |
| | | |
| | | if (_actor1 != null) |
| | | { |
| | | _dis1 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor1.Pos); |
| | | } |
| | | |
| | | if (_actor2 != null) |
| | | { |
| | | _dis2 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor2.Pos); |
| | | } |
| | | |
| | | return _dis2 > _dis1 ? -1 : 1; |
| | | }); |
| | | } |
| | | |
| | | public void Update() |
| | | { |
| | | if (Time.realtimeSinceStartup - timeEscape > .5f) |
| | | { |
| | | GA_Hero _hero = PlayerDatas.Instance.hero; |
| | | if (_hero == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | sortPlayerList.Sort((id1, id2) => |
| | | { |
| | | GActor _actor1 = GAMgr.Instance.GetBySID(id1); |
| | | GActor _actor2 = GAMgr.Instance.GetBySID(id2); |
| | | |
| | | float _dis1 = 0f; |
| | | float _dis2 = 0f; |
| | | |
| | | if (_actor1 != null) |
| | | { |
| | | _dis1 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor1.Pos); |
| | | } |
| | | |
| | | if (_actor2 != null) |
| | | { |
| | | _dis2 = MathUtility.DistanceSqrtXZ(_hero.Pos, _actor2.Pos); |
| | | } |
| | | |
| | | return _dis2 > _dis1 ? -1 : 1; |
| | | }); |
| | | |
| | | SortList(); |
| | | timeEscape = Time.realtimeSinceStartup; |
| | | } |
| | | } |
| | |
| | |
|
| | | private void OnQualityLevelChange()
|
| | | {
|
| | | List<GActor> _petList = GetTypeList(E_ActorClassType.Pet);
|
| | | List<GActor> _list = GetTypeList(E_ActorClassType.Pet);
|
| | |
|
| | | if (_petList == null || _petList.Count == 0)
|
| | | if (_list == null || _list.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | Debug.LogFormat("共有: {0} 只宠物", _petList.Count);
|
| | | //Debug.LogFormat("共有: {0} 只宠物", _petList.Count);
|
| | | GA_Player _player = null;
|
| | | foreach (var _pet in _petList)
|
| | | foreach (var _pet in _list)
|
| | | {
|
| | | var _parentID = _pet.ActorInfo.ownerSID;
|
| | | if (_parentID == PlayerDatas.Instance.PlayerId)
|
| | |
| | | if (_player == null || !_player.ShowOrHide)
|
| | | {
|
| | | _pet.ShowOrHideModel(false);
|
| | | Debug.LogFormat("宠物: {0} 的拥有者: {1} 不可见, 这里隐藏.", _pet.ServerInstID, _parentID);
|
| | | //Debug.LogFormat("宠物: {0} 的拥有者: {1} 不可见, 这里隐藏.", _pet.ServerInstID, _parentID);
|
| | | continue;
|
| | | }
|
| | |
|
| | | var _index = BattleEffectPlayRule.Instance.GetIndex(_parentID);
|
| | | if (_index != -1 && _index < BattleEffectPlayRule.Instance.petLimit)
|
| | | {
|
| | | _pet.ShowOrHideModel(true);
|
| | | Debug.LogFormat("宠物: {0} 的拥有者: {1} 在列表中且位于: {2}, 小于限制数量: {3}", _pet.ServerInstID, _parentID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | //Debug.LogFormat("宠物: {0} 的拥有者: {1} 在列表中且位于: {2}, 小于限制数量: {3}", _pet.ServerInstID, _parentID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | }
|
| | | else
|
| | | {
|
| | | _pet.ShowOrHideModel(false);
|
| | | Debug.LogFormat("宠物: {0} 的拥有者: {1} 在列表中且位于: {2}, 大于限制数量: {3}", _pet.ServerInstID, _parentID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | //Debug.LogFormat("宠物: {0} 的拥有者: {1} 在列表中且位于: {2}, 大于限制数量: {3}", _pet.ServerInstID, _parentID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | }
|
| | | }
|
| | |
|
| | | _list = GetTypeList(E_ActorClassType.Player);
|
| | |
|
| | | //Debug.LogFormat("共有: {0} 只守护", _list.Count);
|
| | | foreach (var _chkPlayer in _list)
|
| | | {
|
| | | _player = _chkPlayer as GA_Player;
|
| | | if (_chkPlayer == null || !_chkPlayer.ShowOrHide)
|
| | | {
|
| | | _player.SwitchGuard(0);
|
| | | //Debug.LogFormat("_list: {0} 的拥有者: {1} 不可见, 这里隐藏.", _chkPlayer.ServerInstID, _player.ServerInstID);
|
| | | continue;
|
| | | }
|
| | |
|
| | | var _index = BattleEffectPlayRule.Instance.GetIndex(_player.ServerInstID);
|
| | | if (_index != -1 && _index < BattleEffectPlayRule.Instance.petLimit)
|
| | | {
|
| | | _player.SwitchGuard((uint)_player.serverGuardId);
|
| | | //Debug.LogFormat("_list: {0} 的拥有者: {1} 在列表中且位于: {2}, 小于限制数量: {3}", _chkPlayer.ServerInstID, _player.ServerInstID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | }
|
| | | else
|
| | | {
|
| | | _player.SwitchGuard(0);
|
| | | //Debug.LogFormat("_list: {0} 的拥有者: {1} 在列表中且位于: {2}, 大于限制数量: {3}", _chkPlayer.ServerInstID, _player.ServerInstID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (!_showOrHide)
|
| | | {
|
| | | ShowOrHideModel(_showOrHide);
|
| | | Debug.LogFormat("宠物: {0} 的拥有者: {1} 在列表中且位于: {2}, 小于限制数量: {3}", ServerInstID, _parentSID, _index, BattleEffectPlayRule.Instance.petLimit);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | else if (_equipInfo.Place == (int)RoleEquipType.retSpiritAnimal)
|
| | | {
|
| | | SwitchGuard(_equipInfo.ItemID);
|
| | | var _index = BattleEffectPlayRule.Instance.GetIndex(ServerInstID);
|
| | | if (_index != -1 && _index < BattleEffectPlayRule.Instance.petLimit)
|
| | | {
|
| | | SwitchGuard(_equipInfo.ItemID);
|
| | | }
|
| | | serverGuardId = (int)_equipInfo.ItemID;
|
| | | }
|
| | | else if (_equipInfo.Place == (int)RoleEquipType.mount)
|
| | |
| | | public override void ChangeEquip(EquipInfo equipInfo)
|
| | | {
|
| | | // 传入ID为0代表脱下了装备
|
| | | if(equipInfo.itemID == 0 && equipInfo.place != 0)
|
| | | if (equipInfo.itemID == 0 && equipInfo.place != 0)
|
| | | {
|
| | | if(m_EquipDict.ContainsKey(equipInfo.place))
|
| | | if (m_EquipDict.ContainsKey(equipInfo.place))
|
| | | {
|
| | | m_EquipDict.Remove(equipInfo.place);
|
| | | }
|
| | |
| | | if (ShowOrHide)
|
| | | {
|
| | | m_Guard = GAMgr.Instance.RequestNpcNoFight<GA_Guard>(ServerInstID * 100 + 1, (uint)config.npcId, Group, null);
|
| | | m_Guard.ActorInfo.ownerSID = ServerInstID;
|
| | | m_Guard.itemID = (int)guardID;
|
| | | m_Guard.InitBase();
|
| | | m_Guard.IsStateActive = true;
|
| | |
| | | ReleaseShadow();
|
| | | }
|
| | |
|
| | | GA_Pet _pet = GAMgr.Instance.GetBySID(ServerInstID * 10 + 1) as GA_Pet;
|
| | | if (_pet != null)
|
| | | GA_Player _player = this as GA_Player;
|
| | | if (_player != null)
|
| | | {
|
| | | _pet.ShowOrHideModel(showOrHide);
|
| | | }
|
| | |
|
| | | ShowOrHide = showOrHide;
|
| | |
|
| | | if (this is GA_Player)
|
| | | {
|
| | | var _player = this as GA_Player;
|
| | |
|
| | | if (ShowOrHide)
|
| | | GA_Pet _pet = GAMgr.Instance.GetBySID(ServerInstID * 10 + 1) as GA_Pet;
|
| | | var _index = BattleEffectPlayRule.Instance.GetIndex(ServerInstID);
|
| | | if (_index != -1 && _index < BattleEffectPlayRule.Instance.petLimit)
|
| | | {
|
| | | if (_player.serverGuardId != 0)
|
| | | if (_pet != null)
|
| | | {
|
| | | _pet.ShowOrHideModel(true);
|
| | | }
|
| | |
|
| | | if (m_Guard == null)
|
| | | {
|
| | | SwitchGuard((uint)_player.serverGuardId);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (_pet != null)
|
| | | {
|
| | | _pet.ShowOrHideModel(false);
|
| | | }
|
| | |
|
| | | if (m_Guard != null)
|
| | | {
|
| | | SwitchGuard(0);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | ShowOrHide = showOrHide;
|
| | |
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | System.Type type = typeof(BattleEffectPlayRule); |
| | | Utils.BeginObjectRegister(type, L, translator, 0, 2, 2, 2); |
| | | Utils.BeginObjectRegister(type, L, translator, 0, 5, 4, 1); |
| | | |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "AddPlayer", _m_AddPlayer); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "RemovePlayer", _m_RemovePlayer); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "Update", _m_Update); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "GetIndex", _m_GetIndex); |
| | | Utils.RegisterFunc(L, Utils.METHOD_IDX, "CanPlay", _m_CanPlay); |
| | | |
| | | |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "sortPlayerList", _g_get_sortPlayerList); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "petLimit", _g_get_petLimit); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "guardLimit", _g_get_guardLimit); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "sortPlayerList", _g_get_sortPlayerList); |
| | | Utils.RegisterFunc(L, Utils.GETTER_IDX, "timeEscape", _g_get_timeEscape); |
| | | |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "sortPlayerList", _s_set_sortPlayerList); |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "timeEscape", _s_set_timeEscape); |
| | | Utils.RegisterFunc(L, Utils.SETTER_IDX, "timeEscape", _s_set_timeEscape); |
| | | |
| | | |
| | | Utils.EndObjectRegister(type, L, translator, null, null, |
| | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_AddPlayer(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | |
| | | |
| | | |
| | | { |
| | | uint _id = LuaAPI.xlua_touint(L, 2); |
| | | |
| | | gen_to_be_invoked.AddPlayer( _id ); |
| | | |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_RemovePlayer(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | |
| | | |
| | | |
| | | { |
| | | uint _id = LuaAPI.xlua_touint(L, 2); |
| | | |
| | | gen_to_be_invoked.RemovePlayer( _id ); |
| | | |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_Update(RealStatePtr L) |
| | | { |
| | | try { |
| | |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_GetIndex(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | |
| | | |
| | | |
| | | { |
| | | uint _sid = LuaAPI.xlua_touint(L, 2); |
| | | |
| | | int gen_ret = gen_to_be_invoked.GetIndex( _sid ); |
| | | LuaAPI.xlua_pushinteger(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_petLimit(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.petLimit); |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_guardLimit(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.guardLimit); |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_sortPlayerList(RealStatePtr L) |
| | | { |
| | | try { |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _s_set_sortPlayerList(RealStatePtr L) |
| | | { |
| | | try { |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | BattleEffectPlayRule gen_to_be_invoked = (BattleEffectPlayRule)translator.FastGetCSObj(L, 1); |
| | | gen_to_be_invoked.sortPlayerList = (System.Collections.Generic.List<uint>)translator.GetObject(L, 2, typeof(System.Collections.Generic.List<uint>)); |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _s_set_timeEscape(RealStatePtr L) |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 9af4f8cb7bea139439969d8767ea1d39 |
| | | timeCreated: 1543808664 |
| | | timeCreated: 1543992918 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |