public void OnSaveData()
        {
            #if DEBUG
            Logger.Info("Try to save mod data");
            #endif

            try {
                if (this.sd != null)
                {
                    byte[] building_data = Buildings.toByteArray();
                    if (building_data != null)
                    {
                        this.sd.SaveData(BUILDINGS_DATA_ID, building_data);
                    }

                    byte[] district_data = Districts.toByteArray();
                    if (district_data != null)
                    {
                        this.sd.SaveData(DISTRICT_DATA_ID, district_data);
                    }

                    #if DEBUG
                    Logger.Info("Saving was successful");
                    #endif
                }
                else
                {
                    Logger.Warning("Serializer is null, saving mod data not possible");
                }
            } catch (Exception e) {
                Logger.Error("Error during save mod data :" + e.Message);
            }
        }
        public void OnLoadData()
        {
            #if DEBUG
            Logger.Info("Try to load mod data");
            #endif

            try {
                if (this.sd != null)
                {
                    byte[] building_data = this.sd.LoadData(BUILDINGS_DATA_ID);
                    Buildings.fromByteArray(building_data);
                    byte[] district_data = this.sd.LoadData(DISTRICT_DATA_ID);
                    Districts.fromByteArray(district_data);

                    #if DEBUG
                    Logger.Info("Loading was successful");
                    Buildings.dump();
                    Districts.dump();
                    #endif
                }
                else
                {
                    Logger.Warning("Serializer is null, loading mod data not possible");
                }
            } catch (Exception e) {
                Logger.Error("Error during load mod data :" + e.Message);
            }
        }
        private Level determineLockLevel(ushort buildingID)
        {
            Level buildingLockLevel = Buildings.getLockLevel(buildingID);

            if (buildingLockLevel != Level.None)
            {
                return(buildingLockLevel);
            }
            else
            {
                Byte districtID   = Buildings.getDistrictID(buildingID);
                int  buildingType = Buildings.getBuildingType(buildingID);

                Level districtLockLevel = Districts.getLockLevels(districtID)[buildingType];

                if (districtLockLevel != Level.None)
                {
                    return(districtLockLevel);
                }
                else
                {
                    return(Level.None);
                }
            }
        }
Example #4
0
        private void updateDistrictView()
        {
            Level[] districtLockLevels = Districts.getLockLevels(this.getSelectedDistrictID());

            int index = 0;

            foreach (UIPanel progressPanel in this.districtProgressPanels)
            {
                this.updateProgressPanel(progressPanel, districtLockLevels[index], true);
                index++;
            }
        }
Example #5
0
        private void updateBuildingView(ushort buildingID, Level buildingLockLevel)
        {
            if (buildingLockLevel != Level.None)
            {
                this.updateProgressPanel(this.panelBuildingProgress, buildingLockLevel, false);
            }
            else
            {
                Byte  districtID        = Buildings.getDistrictID(buildingID);
                int   buildingType      = Buildings.getBuildingType(buildingID);
                Level districtLockLevel = Districts.getLockLevels(districtID)[buildingType];

                if (districtLockLevel != Level.None)
                {
                    this.updateProgressPanel(this.panelBuildingProgress, districtLockLevel, true);
                }
                else
                {
                    this.updateProgressPanel(this.panelBuildingProgress, Level.None, false);
                }
            }
        }
Example #6
0
        private void DistrictProgressBarClick(UIComponent progressBar, UIMouseEventParameter eventParam)
        {
            ushort      districtID    = this.getSelectedDistrictID();
            int         districtType  = this.getProgressBarType(progressBar.parent);
            UIComponent progressPanel = progressBar.parent;

            Level[] districtLockLevels = Districts.getLockLevels(districtID);
            Level   progressBarLevel   = this.getProgressBarLevel(progressBar);

            if (districtLockLevels[districtType] == Level.None)
            {
                Districts.add(districtID, progressBarLevel, districtType);
                this.updateProgressPanel(progressPanel, progressBarLevel, true);
                #if DEBUG
                Logger.Info("district lock level (" + districtType + " | " + districtID + "): " + progressBarLevel);
                #endif
            }
            else
            {
                if (districtLockLevels[districtType] == progressBarLevel)
                {
                    Districts.update(districtID, Level.None, districtType);
                    this.updateProgressPanel(progressPanel, Level.None, true);
                    #if DEBUG
                    Logger.Info("district lock level (" + districtType + " | " + districtID + "): " + Level.None);
                    #endif
                }
                else
                {
                    Districts.update(districtID, progressBarLevel, districtType);
                    this.updateProgressPanel(progressPanel, progressBarLevel, true);
                    #if DEBUG
                    Logger.Info("district lock level (" + districtType + " | " + districtID + "): " + progressBarLevel);
                    #endif
                }
            }
        }