public void ReadFromReference(proto.UnitReference srcReference) { ShipProperty_.ClearAll(); Reference = srcReference; Position = Vector3.zero; }
public static proto.UnitReference GetUnitReference(int id) { proto.UnitReference unit = null; UnitReferenceList.TryGetValue(id, out unit); return(unit); }
/// <summary> /// 生成玩家可布阵舰船的视图列表 /// </summary> private void GeneratePlayerShipListView() { List <ClientShip> dataList = PlayerSys.GetPlayerShipList(); //哈希结构,键--舰船ID,值--拥有该ID的舰船集合 Dictionary <int, List <int> > hash = new Dictionary <int, List <int> >(); for (int index = 0; index < dataList.Count; index++) { int key = dataList[index].Reference.id; if (!hash.ContainsKey(key)) { hash.Add(key, new List <int>()); } hash[key].Add(index); } foreach (var id in hash) { string log = ""; foreach (var item in id.Value) { log += string.Format("{0}, ", item); } //Debug.Log( string.Format( "<color=yellow>[ID{0}] : {1}</color>", id.Key, log) ); } UnitUIElementList_ = new List <DeployUnitUIElement>(); foreach (var item in hash) { GameObject scrollItem = Global.CreateUI("deployitem", ScrollViewRoot.gameObject); scrollItem.name = item.Key.ToString(); DeployUnitUIElement view = scrollItem.AddComponent <DeployUnitUIElement>(); view.SyncEnergy += SyncEnergy; proto.UnitReference unit = GlobalConfig.GetUnitReference(item.Key); view.ShipName = unit.name; view.WrapPointCount = unit.warp_cost; view.IconName = unit.iconfile; view.Level = 10;//舰船成长,暂时没得 foreach (var v in item.Value) { view.ReadyDeployIndexQueue.Enqueue(v); } view.UnitCount = item.Value.Count; UnitUIElementList_.Add(view); } foreach (var item in UnitUIElementList_) { bool cannotDeployThisType = item.WrapPointCount > CurrRemainEnergy_; if (cannotDeployThisType) { item.SetDragAbility(false); } else { if (item.ReadyDeployIndexQueue.Count == 0) { continue; } item.SetDragAbility(true); } } }
public static void AnalyzeBin(byte[] bytes) { var tempManager = new proto.ReferenceManager(); tempManager.Parse(bytes, 0, bytes.Length); for (int i = 0; i < tempManager.units_res_size(); i++) { proto.UnitReference unit = tempManager.units_res(i); UnitReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.defensive_units_res_size(); i++) { proto.DefensiveUnitsReference unit = tempManager.defensive_units_res(i); DefensiveUnitsReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.buff_res_size(); i++) { proto.BuffReference unit = tempManager.buff_res(i); BuffReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.parts_replace_team_res_size(); i++) { proto.PartsReplaceTeamReference unit = tempManager.parts_replace_team_res(i); PartsReplaceTeamReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.shuttle_res_size(); i++) { proto.ShuttleReference unit = tempManager.shuttle_res(i); ShuttleReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.shuttle_team_res_size(); i++) { proto.ShuttleTeamReference unit = tempManager.shuttle_team_res(i); ShuttleTeamReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.skill_res_size(); i++) { proto.SkillReference unit = tempManager.skill_res(i); SkillReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.parts_res_size(); i++) { proto.PartReference unit = tempManager.parts_res(i); PartReferenceList.Add(unit.id, unit); } for (int i = 0; i < tempManager.battlefield_res_size(); i++) { proto.BattlefieldReference battle = tempManager.battlefield_res(i); BattlefieldReferenceList.Add(battle.id, battle); } List <proto.LevelDeployUnitReference> levelDelpoyUnitList = null; for (int i = 0; i < tempManager.leveldeployunit_res_size(); i++) { proto.LevelDeployUnitReference levelDeployUnit = tempManager.leveldeployunit_res(i); if (LevelDeployReferenceDic.ContainsKey(levelDeployUnit.battlefield_id)) { levelDelpoyUnitList = LevelDeployReferenceDic[levelDeployUnit.battlefield_id]; } else { levelDelpoyUnitList = new List <proto.LevelDeployUnitReference>(); LevelDeployReferenceDic.Add(levelDeployUnit.battlefield_id, levelDelpoyUnitList); } levelDelpoyUnitList.Add(levelDeployUnit); } }