private void UpdateCampCreate(int camp, GameObject copy) { AWBuildingBarrack buildingBarrack = AWCore.Instance.GetGame().GetScene <AWSceneHome>().GetAWBuilding <AWBuildingBarrack>(m_building); IBuildingConfItem buildingConfItem = AW.GetSingleton <IDataAdapter>().GetBuildingConfItem(m_building); List <int> produceUnitLists = AW.GetSingleton <IDataAdapter>().GetProduceUnitList(m_building.GetBuildingType()); Dictionary <int, Camp> produceTroops = barrack.GetProduceTroopDic(); copy.transform.SetParent(campAnchor, false); copy.GetComponent <UISetAnchor>().SetAnchor(buildingBarrack.GetModelAnchor(camp), UIAnchorType.World3DToUI2D); UICampItem campItem = copy.GetComponent <UICampItem>(); campItem.InitCamp(produceTroops, camp, buildingConfItem); campItem.SetUnitName(); campItem.SetSelect(false); itemList.Add(campItem); Button button = copy.GetComponent <Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(CloseUnitList); button.onClick.AddListener(ResetCampItem); button.onClick.AddListener(new OnClickCampEvent(construction, troopsInfoAnchor, produceTroops[camp], replaceUnitList, produceUnitLists, m_building, replaceUnitListAnchor, campItem).OnClickCreateTroopsInfo); m_buildingProcess = copy.ExtGetMissingComponent <AWBuildingProcess>(); m_buildingProcess.InitProcess(produceTroops[camp], copy.transform, new Vector3(-20, 80, 0), UIAnchorType.UI2DToUI2D); m_buildingProcess.SetShow(true); }
//! 获取科技树分列 public List <int> GetUnitTreeColumn(int unitTreeId) { List <int> column = new List <int>(); for (int i = GetUnitTreeStartLv(unitTreeId); i <= AW.GetSingleton <IDataAdapter>().GetCurCommandConfItem().GetMaxLevel(); i++) { column.Add(i); } return(column); }
public void InitProduce() { construction.onClick.RemoveAllListeners(); construction.onClick.AddListener(OnClickConstruction); if (AW.GetSingleton <IDataAdapter>().GetIdleCamp(barrack)) { construction.gameObject.SetActive(true); } else { construction.gameObject.SetActive(false); } }
private int GetUnitTreeStartLv(int unitTreeId) { if (!m_startLvIndex.ContainsKey(unitTreeId)) { int startlv = int.MaxValue; foreach (int unitId in GetUnitTreeLine(unitTreeId)) { IUnit2ConfItem confItem = AW.GetSingleton <IDataAdapter>().GetUnit2ConfItem(unitId, 1); startlv = Mathf.Min(startlv, confItem.GetUnlockCommandLevel()); } m_startLvIndex.Add(unitTreeId, startlv); } return(m_startLvIndex[unitTreeId]); }
public void InitOrUpdateUnitList() { InitProduce(); Barrack barrack = m_building as Barrack; Dictionary <int, Camp> produceTroops = barrack.GetProduceTroopDic(); //AW.GetSingleton<IDataAdapter>().GetBuildingConfItem(barrack).GetCampVolume(); List <int> produceUnitLists = AW.GetSingleton <IDataAdapter>().GetProduceUnitList(m_building.GetBuildingType()); unitList.InitOrUpdateUnitList(produceUnitLists, m_building, unitListItemAnchor); if (campLists != null) { campLists.Clear(); } campLists.AddRange(produceTroops.Keys); campLists.Sort(); itemList.Clear(); m_campCopy.UpdateCopy(campLists.Count, UpdateCampCopy); }
public void OnClickCreateTroopsInfo() { m_campItem.SetSelect(true); UIWindowTroopsInfo info = UIWindowWrapper.GetWindowAddMask <UIWindowTroopsInfo>(); info.transform.SetParent(m_troopsAnchor, false); info.Open(m_camp); IUnitConfItem unitConfItem = AW.GetSingleton <IDataAdapter>().GetOwnedUnitConfItem(m_camp.ProduceItem); IBuildingConfItem buildingConfItem = AW.GetSingleton <IDataAdapter>().GetBuildingConfItem(m_building); m_count = buildingConfItem.GetTroopCostVolume() / unitConfItem.GetCapacityCost(); Building barrck = (Building)m_camp; if (barrck.GetState() == AWEnum.BuildingStateType.Produce) { info.replace.gameObject.SetActive(false); info.SetCompleteButtonStyle(OnClickComplete); info.SetCancelButtonStle(OnClickCancel); if (m_camp.GetProducedCount() < m_count) { info.SetSupplementButtonStyle(OnClickSupplement); } else { info.supplement.gameObject.SetActive(false); } } else { info.complete.gameObject.SetActive(false); info.cancel.gameObject.SetActive(false); if (m_camp.GetProducedCount() < m_count) { info.SetSupplementButtonStyle(OnClickSupplement); info.SetReplaceButtonStyle(OnClickReplace); } else { info.supplement.gameObject.SetActive(false); info.SetReplaceButtonStyle(OnClickReplace); } } info.SetRename(OnClickRename); }
public Dictionary <int, List <IUnit2ConfItem> > GetUnitTreeNode(int unitTreeId) { if (!m_unitTreeNodeIndex.ContainsKey(unitTreeId)) { List <int> lines = GetUnitTreeLine(unitTreeId); Dictionary <int, List <IUnit2ConfItem> > unitTreeLineIndex = new Dictionary <int, List <IUnit2ConfItem> >(); foreach (int unitId in lines) { List <IUnit2ConfItem> items = new List <IUnit2ConfItem>(); IUnit2ConfItem item = AW.GetSingleton <IDataAdapter>().GetUnit2ConfItem(unitId, 1); do { items.Add(item); item = item.GetUpLevelItem(); }while (item != null); unitTreeLineIndex.Add(unitId, items); } m_unitTreeNodeIndex.Add(unitTreeId, unitTreeLineIndex); } return(m_unitTreeNodeIndex[unitTreeId]); }
private void OnClickCancel() { Debug.Log("OnClickCancel"); AWCore.Instance.GetControl().PostEvent(new CancelUnitEvent(m_camp, AW.GetSingleton <IDataAdapter>().GetServerTime(), CallBack)); }