From 34c01f30d2e26aa76a0ee0a5a06664a25ef3fe5a Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期一, 10 九月 2018 19:20:01 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
Fight/GameActor/GAMgr.cs | 85 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/Fight/GameActor/GAMgr.cs b/Fight/GameActor/GAMgr.cs
index cfd77c6..1072535 100644
--- a/Fight/GameActor/GAMgr.cs
+++ b/Fight/GameActor/GAMgr.cs
@@ -63,6 +63,8 @@
// 瀹㈡埛绔痠d瀵瑰簲鐩稿簲瑙掕壊
private Dictionary<uint, GActor> m_Cid2GA;
+ private List<uint> m_OffLineList;
+
// 鏈嶅姟绔�氱煡鐨勬浜$洰鏍囧搴旂殑瀹㈡埛绔痠d,
// 杩欓噷涓轰簡澶勭悊鍙兘鍑虹幇鐨勬棤娉曟浜$幇璞�,瀵规瘡涓�鍙洰鏍囪繘琛岃鏃�,寮哄埗鍏舵浜�
private List<uint> serverDeadList = new List<uint>();
@@ -85,10 +87,91 @@
m_AllList = new List<GActor>();
m_Sid2Cid = new Dictionary<uint, uint>();
m_Cid2GA = new Dictionary<uint, GActor>();
+ m_OffLineList = new List<uint>();
m_Inited = true;
SystemSetting.Instance.playerSyncCountChangeEvent += OnPlayerSyncCountChange;
SystemSetting.Instance.OnSettingChanged += OnSettingChanged;
+ }
+ }
+
+ public void AddOffLinePlayer(uint sid)
+ {
+ if (m_OffLineList.Contains(sid))
+ {
+ return;
+ }
+
+ m_OffLineList.Add(sid);
+ }
+
+ public void RemoveOffLinePlayer(uint sid)
+ {
+ if (m_OffLineList.Contains(sid))
+ {
+ m_OffLineList.Remove(sid);
+ }
+ }
+
+ public void ClearOffLinePlayer()
+ {
+ m_OffLineList.Clear();
+ }
+
+ private float m_UpdateOffLineInterval;
+ private List<uint> m_CacheList = new List<uint>();
+ private List<uint> m_ContaintList = new List<uint>();
+
+ private void UpdateOffLinePlayer()
+ {
+ if (m_OffLineList == null || m_OffLineList.Count == 0)
+ {
+ return;
+ }
+
+ if (Time.realtimeSinceStartup - m_UpdateOffLineInterval > 2)
+ {
+ m_CacheList.Clear();
+ m_ContaintList.Clear();
+
+ int _count = Mathf.Min(m_OffLineList.Count, 4);
+
+ //Debug.LogFormat("姝ゆ灏嗕細鏈�: {0} 涓寕鏈鸿�呴噴鏀炬妧鑳�", _count);
+
+ for (int i = 0; i < m_OffLineList.Count; ++i)
+ {
+ m_CacheList.Add(m_OffLineList[i]);
+ }
+
+ int _time = 0;
+
+ while (m_ContaintList.Count < _count)
+ {
+ int _index = UnityEngine.Random.Range(0, m_CacheList.Count);
+ m_ContaintList.Add(m_CacheList[_index]);
+ //Debug.LogFormat("娣诲姞瀵硅薄: {0}, 宸叉坊鍔�: {1} 涓�", m_CacheList[_index], m_ContaintList.Count);
+ m_CacheList.RemoveAt(_index);
+ if (_time > _count)
+ {
+ //Debug.LogFormat("鍏辨坊鍔犱簡: {0} 涓帺瀹�", m_ContaintList.Count);
+ break;
+ }
+ _time++;
+ }
+
+ GA_Player _player = null;
+ for (int i = 0; i < m_ContaintList.Count; ++i)
+ {
+ _player = GAMgr.Instance.GetBySID(m_ContaintList[i]) as GA_Player;
+ if (_player == null)
+ {
+ continue;
+ }
+
+ _player.UpdateOffLineAction();
+ }
+
+ m_UpdateOffLineInterval = Time.realtimeSinceStartup;
}
}
@@ -838,6 +921,8 @@
{
m_AllList[i].Update();
}
+
+ UpdateOffLinePlayer();
}
public void DoLateUpdate()
--
Gitblit v1.8.0