Пример #1
0
        private void updateBuildingEditShortcutButton(UIPanel parent)
        {
            if (parent != null)
            {
                UIButton buildingEditShortcut = parent.Find <UIButton>("VMCBuildingShortcut");
                if (!buildingEditShortcut)
                {
                    buildingEditShortcut = initBuildingEditOnWorldInfoPanel(parent);
                }
                FieldInfo prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic
                                                                 | System.Reflection.BindingFlags.Instance);
                ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building;
                IEnumerable <ServiceSystemDefinition> ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info);

                byte count = 0;
                foreach (ServiceSystemDefinition ssd in ssds)
                {
                    int maxCount = VMCBuildingUtils.GetMaxVehiclesBuilding(ref BuildingManager.instance.m_buildings.m_buffer[buildingId], ssd.vehicleType, ssd.level);
                    if (maxCount > 0)
                    {
                        count++;
                        break;
                    }
                }
                buildingEditShortcut.isVisible = count > 0;
            }
        }
Пример #2
0
        public void RefreshLines()
        {
            if (Singleton <BuildingManager> .exists)
            {
                int count = 0;
                ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

                System.Collections.Generic.List <ushort> buildingList = VMCBuildingUtils.getAllBuildingsFromCity(ref ssd);

                LogUtils.DoLog("{0} buildingList = [{1}] (s={2})", GetType(), string.Join(",", buildingList.Select(x => x.ToString()).ToArray()), buildingList.Count);
                foreach (ushort buildingID in buildingList)
                {
                    ref Building b          = ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID];
                    int          maxVehicle = Mathf.CeilToInt(VMCBuildingUtils.GetMaxVehiclesBuilding(ref b, ssd.vehicleType, ssd.level) * VMCBuildingUtils.GetProductionRate(ref b) / 100f);
                    if (maxVehicle > 0)
                    {
                        AddToList(buildingID, ref count);
                    }
                }
                RemoveExtraLines(count);
                LogUtils.DoLog("{0} final count = {1}", GetType(), count);

                m_LinesUpdated = true;
            }