Ejemplo n.º 1
0
        public void Execute(Point startClick, Point endClick)
        {
            var pt = new System.Drawing.Point((int) startClick.X, (int) startClick.Y);

            if (askForColor)
            {
                colorDlg.ShowDialog();
                fillColor = colorDlg.Color;
            }

            Animation animation = Animation.getInstance();
            if (animation.PointInCell(startClick))
            {
                //Already Exisiting Cell
                Cell c = animation.findCell(startClick);
                int frame = _viewModel.currentFrame;
                c.color[frame] = fillColor;

                //Trigers and update on the View
                _viewModel.Cells.Remove(c);
                _viewModel.Cells.Add(c);
            }
            else
            {

                var finder = new RegionFinder(_viewModel.Image, pt, _viewModel.Tolerance);
                finder.LineFound +=
                    line => _viewModel.Cells.Add(new Cell(line.Select(p => new Point(p.X, p.Y)).ToArray(), animation.numFrames(), _viewModel.currentFrame, fillColor));
                finder.Process();

                //Add to the Model
                animation.addCell(_viewModel.Cells.Last());

            }
        }
Ejemplo n.º 2
0
    // Reads in all information of a facade
    public List <Rectangle> initializeNewFacade(InputFacade facade)
    {
        allCurrentFacadeRectangles = RegionFinder.findRectangles(facade.facadeLayoutName, facade.inputFacade.width, facade.inputFacade.height);
        float maxY = 0; float maxX = 0;

        foreach (Color c in allCurrentFacadeRectangles.Keys)
        {
            foreach (Rectangle r in allCurrentFacadeRectangles[c])
            {
                maxX = Mathf.Max(maxX, r.toX);
                maxY = Mathf.Max(maxY, r.toY);
            }
        }

        buildingNameText.text = facade.gameObject.name;
        widthText.text        = facade.getBuildingWidth().ToString();
        heightText.text       = facade.getBuildingHeight().ToString();
        Vector3 previewScale = facadePreview.rectTransform.localScale;

        facadePreview.rectTransform.localScale = new Vector3(previewScale.y * facade.getBuildingWidth() / facade.getBuildingHeight(), previewScale.y, 1);
        layoutPreview.rectTransform.localScale = facadePreview.rectTransform.localScale;
        foreach (Color c in allCurrentFacadeRectangles.Keys)
        {
            Rectangle newRect = new Rectangle();
            newRect.symbol = c;
            currentFacadeRectangles.Enqueue(newRect);
        }
        return(null);
    }
Ejemplo n.º 3
0
    private void splitFacade(List <Region> repeatedRegions, List <Rectangle> terminalRegions, InputFacade inputF)
    {
        string buildingName = inputF.gameObject.name;
        string startShape   = buildingName + "Start";

        // Create the initial decomposition rule to create 4 walls from a cube
        writeInitialRules(buildingName);
        Queue <Region> regionsToSplit = new Queue <Region>();

        Region start = new Region(terminalRegions);

        regionNames.Add(start, startShape);
        regionsToSplit.Enqueue(start);

        while (regionsToSplit.Count > 0)
        {
            Region toSplit = regionsToSplit.Dequeue();
            // If the current region is a terminal region then we should not split further
            if (toSplit.terminals.Count == 1 || hasRules.Contains(getRegionName(toSplit, buildingName)))
            {
                continue;
            }

            // Gets the list of areas that the region can be split into on x and y axes respectively
            List <Region> xSplits = RegionFinder.createSplitHorizontal(toSplit);
            List <Region> ySplits = RegionFinder.createSplitVertical(toSplit);

            List <Region> toEnqueue = new List <Region>();

            // Choose the one with most contained elements
            if (xSplits == null && ySplits == null)
            {
                // No splits were able to be performed
                Debug.Assert(toSplit.terminals.Count == 1, "Unable to split non-terminal region. Terminating rule generation.");
                toSplit.debugPrintRegion();
                return;
            }
            else if (xSplits != null && (ySplits == null || xSplits.Count >= ySplits.Count))
            {
                // If the X-split is preferred
                createSplitRule(xSplits, repeatedRegions, "X", getRegionName(toSplit, buildingName), inputF);
                toEnqueue = xSplits;
            }
            else
            {
                // If the Y-split is preferred
                toEnqueue = createSplitRule(ySplits, repeatedRegions, "Y", getRegionName(toSplit, buildingName), inputF);
                toEnqueue = ySplits;
            }
            foreach (Region newRegion in toEnqueue)
            {
                regionsToSplit.Enqueue(newRegion);
            }
            fileDS.Flush();
        }
    }
Ejemplo n.º 4
0
    public Map InitializeNewMap()
    {
        map          = new Map(MapWidth, MapHeight);
        regionFinder = new RegionFinder(map);
        boardHolder  = new GameObject("Board").transform;
        GenerateMap();

        //LayoutObjectAtRandomSpace(Items, 20, 50);

        return(map);
    }
    public List <bool[]> GetRegions(LayerType _layerTypeCheck, bool _tileType)
    {
        bool[] tmpRelevantLayerRegionData = new bool[mapSize.x * mapSize.y];
        int    index = 0;

        for (int y = 0; y < mapSize.y; y++)
        {
            for (int x = 0; x < mapSize.x; x++)
            {
                index = Andre.Utils.ArrayUtils.ArrayIndex2DTo1D(x, y, mapSize.x);
                foreach (var layer in previousLayerData)
                {
                    if (layer.layerTypeID == _layerTypeCheck)
                    {
                        if (layer.layerData[index])
                        {
                            tmpRelevantLayerRegionData[index] = true;
                        }
                    }
                }
            }
        }

        List <List <Vector2Int> > regions    = RegionFinder.DetectRegions(mapSize, tmpRelevantLayerRegionData, _tileType);
        List <bool[]>             tmpRegions = new List <bool[]>();

        foreach (var region in regions)
        {
            bool[] tmpLayerData = new bool[mapSize.x * mapSize.y];
            foreach (var tile in region)
            {
                index = Andre.Utils.ArrayUtils.ArrayIndex2DTo1D(tile.x, tile.y, mapSize.x);
                tmpLayerData[index] = true;
            }
            tmpRegions.Add(tmpLayerData);
        }
        return(tmpRegions);
    }
Ejemplo n.º 6
0
 public void GetAuthority(string expectedAuthority, string url)
 {
     Assert.AreEqual(expectedAuthority, RegionFinder.GetAuthority(url));
 }
Ejemplo n.º 7
0
    public override void Initialize()
    {
        regionList = RegionFinder.Generate().ToArray();

        //Tabs
        this.Tabs    = new OpTab[1];
        this.Tabs[0] = new OpTab("Weather");

        //Weather Type
        this.logo             = new OpImage(new Vector2(270f, 540f), "logo");
        this.logo2            = new OpImage(new Vector2(270f, 540f), "logo2");
        this.weatherType      = new OpRadioButtonGroup("Type", 0);
        this.weatherTypeLabel = new OpLabel(new Vector2(30f, 570f), new Vector2(400f, 40f), "Weather Type", FLabelAlignment.Left, true);
        this.rainWeather      = new OpRadioButton(new Vector2(0f, 800f));
        this.rainButton       = new OpSimpleButton(new Vector2(30f, 540f), new Vector2(70f, 25f), "rainButton", "Rain");
        this.snowWeather      = new OpRadioButton(new Vector2(0f, 800f));
        this.snowButton       = new OpSimpleButton(new Vector2(130f, 540f), new Vector2(70f, 25f), "snowButton", "Snow");
        this.weatherType.SetButtons(new OpRadioButton[] { rainWeather, snowWeather });
        //this.weatherType.valueInt = 1;
        this.versionNumber     = new OpLabel(new Vector2(10f, -5f), new Vector2(0f, 0f), "Version: " + Downpour.mod.Version, FLabelAlignment.Left, false);
        this.snowWarning       = new OpLabel(305f, 525f, "Snow is experimental, use at your own risk!", false);
        this.snowWarning.color = new Color(0.85f, 0f, 0f);
        this.Tabs[0].AddItems(rainButton, rainWeather, snowWeather, snowButton, weatherType, weatherTypeLabel, versionNumber, snowWarning);

        //Weather Sliders
        this.rainIntensity                = new OpLabel(new Vector2(topAnchor.x, topAnchor.y), new Vector2(400f, 40f), "Rain Settings", FLabelAlignment.Left, true);
        this.intensitySliderLabel         = new OpLabel(new Vector2(topAnchor.x + 40f, topAnchor.y - 83f), new Vector2(400f, 40f), "Weather Progression", FLabelAlignment.Left, false);
        this.weatherIntensity             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 60f), "weatherIntensity", new IntVector2(0, 3), 50f, false, 0);
        this.rainSettingsDescription      = new OpLabel(new Vector2(topAnchor.x, topAnchor.y - 20f), new Vector2(400f, 40f), "Enable or disable rain specific settings:", FLabelAlignment.Left, false);
        this.directionSliderLabel         = new OpLabel(new Vector2(topAnchor.x + 47f, topAnchor.y - 143f), new Vector2(400f, 40f), "Weather Direction", FLabelAlignment.Left, false);
        this.weatherDirection             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 120f), "weatherDirection", new IntVector2(0, 3), 50f, false, 0);
        this.rainChanceLabel              = new OpLabel(new Vector2(topAnchor.x + 47f, topAnchor.y - 203f), new Vector2(400f, 40f), "Weather Chance", FLabelAlignment.Left, false);
        this.rainChanceSlider             = new OpSlider(new Vector2(topAnchor.x + 25, topAnchor.y - 180f), "weatherChance", new IntVector2(0, 100), 1.5f, false, 100);
        this.weatherIntensity.description = "Configure whether the intensity of the chosen weather increases as the cycle progresses or fix it to a certain intensity.";
        this.weatherDirection.description = "Configure whether rain should fall towards a random or chosen direction.";
        this.rainChanceSlider.description = "Configure whether the chosen weather will occur during a cycle.";
        this.topRect = new OpRect(new Vector2(15f, 250f), new Vector2(570f, 270f), 0.1f);
        this.Tabs[0].AddItems(rainIntensity, weatherIntensity, intensitySliderLabel, directionSliderLabel, weatherDirection, topRect, logo, logo2, rainChanceSlider, rainChanceLabel);

        //Checkboxes
        this.lightningCheck             = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y - 30f), "Lightning", false);
        this.lightningLabel             = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Lightning", FLabelAlignment.Left, false);
        this.paletteCheck               = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y + 10), "Palette", true);
        this.paletteLabel               = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Palette changes", FLabelAlignment.Left, false);
        this.muteCheck                  = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y + 10), "Mute", false);
        this.muteLabel                  = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Mute interiors", FLabelAlignment.Left, false);
        this.waterCheck                 = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 30f), "Water", false);
        this.waterLabel                 = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Water ripples", FLabelAlignment.Left, false);
        this.strikeCheck                = new OpCheckBox(new Vector2(checkAnchor.x, checkAnchor.y - 70f), "Strike", true);
        this.strikeLabel                = new OpLabel(new Vector2(checkAnchor.x + 30f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Lightning Strikes", FLabelAlignment.Left, false);
        this.strikeDamage               = new OpSliderSubtle(new Vector2(checkAnchor.x + 10f, checkAnchor.y - 105f), "Damage", new IntVector2(0, 2), 110, false, 1);
        this.damageLabel                = new OpLabel(new Vector2(checkAnchor.x + 10f, checkAnchor.y - 123f), new Vector2(), "Damage Type: ", FLabelAlignment.Left, false);
        this.bgOn                       = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 70f), "Background", true);
        this.bgLabel                    = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Background", FLabelAlignment.Left, false);
        this.decalCheck                 = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 30f), "Decals", true);
        this.decalLabel                 = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 36f), new Vector2(400f, 40f), "Surface decals", FLabelAlignment.Left, false);
        this.dustCheck                  = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 70f), "Dust", true);
        this.dustLabel                  = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 76f), new Vector2(400f, 40f), "Snow dust", FLabelAlignment.Left, false);
        this.blizzardCheck              = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y - 110f), "Blizzard", true);
        this.blizzardLabel              = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y - 116f), new Vector2(400f, 40f), "Blizzard", FLabelAlignment.Left, false);
        this.effectCheck                = new OpCheckBox(new Vector2(checkAnchor.x + 150f, checkAnchor.y + 10), "Effect", true);
        this.effectLabel                = new OpLabel(new Vector2(checkAnchor.x + 180f, checkAnchor.y + 4f), new Vector2(400f, 40f), "Effect Colors", FLabelAlignment.Left, false);
        this.dustCheck.description      = "Puffs of snow appear when landing on the ground.";
        this.decalCheck.description     = "Adds snowy decals to surfaces.";
        this.lightningCheck.description = "Lightning will appear at higher weather intensities.";
        this.paletteCheck.description   = "The region will become darker with higher rain intensity.";
        this.muteCheck.description      = "Mute the sound effect added to interiors when its raining outside.";
        this.waterCheck.description     = "Rain drops can interact with water surfaces and cause ripples, may impact performance.";
        this.bgOn.description           = "Enable or disable collision with background elements, may impact performance.";
        this.strikeDamage.description   = "Adjust the damage type of Lightning Strikes";
        this.strikeCheck.description    = "When weather intensity is high enough, lightning strikes can occur.";
        this.effectCheck.description    = "Whitens things like plants and signs so they better match the snowy palette, can ruin some custom props";
        this.blizzardCheck.description  = "Replaces the end-of-cycle rain with a roaring blizzard and affects normal gameplay";
        this.Tabs[0].AddItems(lightningLabel, lightningCheck, strikeCheck, strikeLabel, strikeDamage, damageLabel, rainSettingsDescription, paletteCheck, muteCheck, waterCheck, bgOn, paletteLabel, muteLabel, waterLabel, bgLabel, dustCheck, dustLabel, decalCheck, decalLabel, effectCheck, effectLabel, blizzardCheck, blizzardLabel);

        //Particle Limit
        this.rainOption = new OpLabel(new Vector2(topAnchor.x + 366f, topAnchor.y - 223f), new Vector2(400f, 40f), "Particle Limit", FLabelAlignment.Left, false);
        this.rainSlider = new OpSlider(new Vector2(topAnchor.x + 275f, topAnchor.y - 200f), "rainAmount", new IntVector2(10, 80), 3.3f, false, 50);
        this.Tabs[0].AddItems(rainSlider, rainOption);

        //Regions
        if (regionList != null)
        {
            this.regionLabelList   = new OpLabel[regionList.Length];
            this.regionChecks      = new OpCheckBox[regionList.Length];
            this.regionLabel       = new OpLabel(new Vector2(30f, 200f), new Vector2(400f, 40f), "Region Settings", FLabelAlignment.Left, true);
            this.regionDescription = new OpLabel(new Vector2(30f, 175f), new Vector2(400f, 40f), "Enable and Disable weather on a per-region basis.", FLabelAlignment.Left, false);
            this.Tabs[0].AddItems(regionLabel, regionDescription);
            for (int i = 0; i < regionList.Length; i++)
            {
                if (i < 10)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(30f + (55f * i), 150f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(60f + (55f * i), 142f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 10 && i < 20)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-520f + (55f * i), 105f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-490f + (55f * i), 97f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 20 && i < 30)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-1070f + (55f * i), 60f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-1040f + (55f * i), 52f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                else if (i >= 30)
                {
                    regionChecks[i]    = new OpCheckBox(new Vector2(-1650f + (55f * i), 15f), regionList[i], true);
                    regionLabelList[i] = new OpLabel(new Vector2(-1620f + (55f * i), 7f), new Vector2(400f, 40f), regionList[i], FLabelAlignment.Left, false);
                }
                this.Tabs[0].AddItems(regionLabelList[i], regionChecks[i]);
                if (regionList[i] == "SS")
                {
                    regionChecks[i].valueBool = false;
                }
            }
        }
        Downpour.configLoaded = true;
    }
Ejemplo n.º 8
0
    // Deducts and write a split rule given a split on an axis
    private List <Region> createSplitRule(List <Region> splits, List <Region> repeats, string axis, string regionName, InputFacade inputF)
    {
        List <Region> splitRepeats = new List <Region>();
        List <Region> nonRepeats   = new List <Region>();

        // If this area already has a rule defined
        if (hasRules.Contains(regionName))
        {
            return(splits);
        }

        repeats = RegionFinder.findRealRepeats(splits, axis);

        // Bad datastructure and complexity, should use other
        foreach (Region current in splits)
        {
            // Find the largest repeat-region that contains our current split region
            Region containedIn = null;
            if (repeats != null)
            {
                foreach (Region other in repeats)
                {
                    // If the repeated region contains the split region and is greater than our current one
                    if (other.containsRegion(current) && (containedIn == null || (other.terminals.Count > containedIn.terminals.Count)))
                    {
                        containedIn = other;
                        other.subregions.Add(current);
                    }
                }
            }
            if (containedIn == null)
            {
                nonRepeats.Add(current);
            }
            else if (!splitRepeats.Contains(containedIn))
            {
                // If there was a repeated area that contains our split region and it was not already added
                splitRepeats.Add(containedIn);
            }
        }

        splits = new List <Region>(splitRepeats);
        splits.AddRange(nonRepeats);

        splits = RegionManager.sortRegions(splits, axis);

        foreach (Region region in splits)
        {
            setRegionName(region, inputF.gameObject.name);
        }

        foreach (Region repeatR in splitRepeats)
        {
            relativeRegions.Add(getRegionName(repeatR, inputF.gameObject.name));
        }

        // Add case for just repeat later
        if (splits.Count > splitRepeats.Count)
        {
            string rule = regionName + " -> split(" + axis + ")";
            rule += createShapeSplitString(splits, axis, inputF);
            writeToRuleFile(rule);
            hasRules.Add(regionName);
        }
        // Now we need to write the repeat rules, which regions are contained in the large repeat areas
        foreach (Region r in splitRepeats)
        {
            writeRepeatRule(r, axis, inputF);
        }
        return(splits);
    }