public void AddColors(GameObject asset, Color[] c)
        {
            CustomColors cc = asset.AddComponent <CustomColors>();

            cc.setColors(c);

            foreach (Material material in AssetManager.Instance.objectMaterials)
            {
                if (material.name == "CustomColorsDiffuse")
                {
                    asset.GetComponentInChildren <Renderer>().sharedMaterial = material;

                    // Go through all child objects and recolor
                    Renderer[] renderCollection;
                    renderCollection = asset.GetComponentsInChildren <Renderer>();

                    foreach (Renderer render in renderCollection)
                    {
                        render.sharedMaterial = material;
                    }

                    break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Paints the bar.
        /// </summary>
        /// <param name="e">The <see cref="PaintEventArgs" /> instance containing the event data.</param>
        protected virtual void PaintBar(PaintEventArgs e)
        {
            if (BarBounds.Height <= 0 || BarBounds.Width <= 0)
            {
                return;
            }

            var blend = new ColorBlend();

            if (CustomColors != null && CustomColors.Count > 0)
            {
                blend.Colors    = CustomColors.ToArray();
                blend.Positions =
                    Enumerable.Range(0, CustomColors.Count).Select(
                        i => i == 0 ? 0 : i == CustomColors.Count - 1 ? 1 : (float)(1.0D / CustomColors.Count) * i).ToArray();
            }

            const int angle = 0;

            // HACK: Inflating the brush rectangle by 1 seems to get rid of a odd issue where the last color is drawn on the first pixel
            using (var brush = new LinearGradientBrush(Rectangle.Inflate(BarBounds, 1, 1), Color.Empty, Color.Empty, angle, false)) {
                brush.InterpolationColors = blend;
                e.Graphics.FillRectangle(brush, BarBounds);
            }
        }
        public override void BindToParkitect(GameObject hider, AssetBundle bundle)
        {
            base.BindToParkitect(hider, bundle);

            BaseDecorator        baseDecorator     = DecoratorByInstance <BaseDecorator>();
            CategoryDecorator    categoryDecorator = DecoratorByInstance <CategoryDecorator>();
            ColorDecorator       colorDecorator    = DecoratorByInstance <ColorDecorator>();
            BoundingBoxDecorator boxDecorator      = DecoratorByInstance <BoundingBoxDecorator>();

            GameObject go = Instantiate(bundle.LoadAsset <GameObject>(Key));

            Wall wall = go.AddComponent <Wall>();

            wall.name        = Key;
            wall.categoryTag = categoryDecorator.Category;
            wall.price       = baseDecorator.Price;
            wall.setDisplayName(baseDecorator.InGameName);
            wall.dontSerialize = true;
            wall.isPreview     = true;

            if (colorDecorator.IsRecolorable)
            {
                CustomColors colors = go.AddComponent <CustomColors>();
                colors.setColors(colorDecorator.Colors.ToArray());
            }

            foreach (var box in boxDecorator.BoundingBoxes)
            {
                var b = go.AddComponent <BoundingBox>();
                b.setBounds(box.Bounds);
            }
        }
        public void Decorate(GameObject go, ParkitectObject PO)
        {
            string ShaderName;

            if (go.GetComponent <BuildableObject>() != null && PO.recolorable)
            {
                CustomColors cc = go.AddComponent <CustomColors>();

                List <Color> colors = new List <Color>();
                if (PO.color1 != new Color(0.95f, 0, 0))
                {
                    colors.Add(PO.color1);
                }
                if (PO.color2 != new Color(0.32f, 1, 0))
                {
                    colors.Add(PO.color2);
                }
                if (PO.color3 != new Color(0.95f, 0, 0))
                {
                    colors.Add(PO.color3);
                }
                if (PO.color4 != new Color(1, 0, 1))
                {
                    colors.Add(PO.color4);
                }


                cc.setColors(colors.ToArray());
                ShaderName = "CustomColors" + PO.XMLNode["shader"].InnerText;
            }
            else
            {
                ShaderName = PO.XMLNode["shader"].InnerText;
            }
            foreach (Material material in AssetManager.Instance.objectMaterials)
            {
                if (material.name == ShaderName)
                {
                    SetMaterial(go, material);

                    // edge case for fences
                    Fence fence = go.GetComponent <Fence>();

                    if (fence != null)
                    {
                        if (fence.flatGO != null)
                        {
                            SetMaterial(fence.flatGO, material);
                        }

                        if (fence.postGO != null)
                        {
                            SetMaterial(fence.postGO, material);
                        }
                    }

                    break;
                }
            }
        }
        //GameDataPacket
        private static void HandlePacket(GameDataPacket packet)
        {
            foreach (var pkt in packet.GameObjects)
            {
                HandlePacket((dynamic)pkt);
            }

            CustomColors.Load(packet.ColorsJson);
            Globals.HasGameData = true;
        }
Beispiel #6
0
        private static bool PreContextSetup(params string[] args)
        {
            if (RunningOnWindows())
            {
                SetConsoleCtrlHandler(ConsoleCtrlHandler, true);
            }

            if (!Strings.Load())
            {
                Console.WriteLine(Strings.Errors.ErrorLoadingStrings);
                Console.ReadKey();

                return(false);
            }

            if (!Options.LoadFromDisk())
            {
                Console.WriteLine(Strings.Errors.errorloadingconfig);
                Console.ReadKey();

                return(false);
            }

            if (!Directory.Exists(Path.Combine("resources", "notifications")))
            {
                Directory.CreateDirectory(Path.Combine("resources", "notifications"));
            }

            if (!File.Exists(Path.Combine("resources", "notifications", "PasswordReset.html")))
            {
                ReflectionUtils.ExtractResource(
                    "Intersect.Server.Resources.notifications.PasswordReset.html",
                    Path.Combine("resources", "notifications", "PasswordReset.html")
                    );
            }

            DbInterface.InitializeDbLoggers();
            DbInterface.CheckDirectories();

            PrintIntroduction();

            ExportDependencies(args);

            Formulas.LoadFormulas();

            CustomColors.Load();

            if (Options.Instance.Metrics.Enable)
            {
                MetricsRoot.Init();
            }

            return(true);
        }
        protected override void BeforeDialogShow(CommonDialog dialog)
        {
            var colorDialog = (ColorDialog)dialog;

            colorDialog.AllowFullOpen  = AllowFullOpen;
            colorDialog.AnyColor       = AnyColor;
            colorDialog.Color          = Color;
            colorDialog.CustomColors   = CustomColors?.Select(x => x.ToArgb()).ToArray();
            colorDialog.FullOpen       = FullOpen;
            colorDialog.SolidColorOnly = SolidColorOnly;
        }
Beispiel #8
0
 public override void Decorate(GameObject go, GameObject hider, ParkitectObj parkitectObj, AssetBundle bundle)
 {
     if (IsRecolorable)
     {
         CustomColors customColors = go.AddComponent <CustomColors>();
         List <Color> final        = new List <Color>();
         for (int x = 0; x < ColorCount; x++)
         {
             final.Add(Colors[x]);
         }
         customColors.setColors(final.ToArray());
     }
 }
 public TSelf CustomColor(Color[] colors)
 {
     AddStep("CUSTOM_COLOR", (payload) =>
     {
         CustomColors customColors = payload.Go.GetComponent <CustomColors>();
         if (customColors == null)
         {
             customColors = payload.Go.AddComponent <CustomColors>();
         }
         customColors.setColors(colors);
     });
     return(this as TSelf);
 }
 public void Decorate(GameObject assetGO, Asset asset, AssetBundle assetBundle)
 {
     if (asset.HasCustomColors)
     {
         CustomColors customColors = assetGO.AddComponent <CustomColors>();
         List <Color> list         = new List <Color>();
         for (int i = 0; i < asset.ColorCount; i++)
         {
             CustomColor customColor = asset.CustomColors[i];
             list.Add(new Color(customColor.Red, customColor.Green, customColor.Blue, customColor.Alpha));
         }
         customColors.setColors(list.ToArray());
     }
 }
Beispiel #11
0
        public void AddColor(ColorDialog colorDialog)
        {
            if (colorDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            CustomColors.Add(new Color
            {
                R   = colorDialog.Color.R,
                G   = colorDialog.Color.G,
                B   = colorDialog.Color.B,
                ScA = 1
            });
        }
Beispiel #12
0
 /// <summary>
 /// Set color to the specified one
 /// </summary>
 /// <param name="color"></param>
 private void SetColor(Color color)
 {
     _currentHotTrack = -1;
     _currentSelected = -1;
     // Search the color on the known color list
     for (int colorIndex = 0; colorIndex < CustomColors.SelectableColors.Length; colorIndex++)
     {
         if (CustomColors.ColorEquals(CustomColors.SelectableColors[colorIndex], color))
         {
             _currentSelected = colorIndex;
             _currentHotTrack = -1;
         }
     }
     this.Refresh();
 }
        void MakeRecolorble(GameObject GO, string shader, Color[] colors)
        {
            CustomColors cc = GO.AddComponent <CustomColors>();

            cc.setColors(colors);

            foreach (Material material in AssetManager.Instance.objectMaterials)
            {
                if (material.name == shader)
                {
                    SetMaterial(GO, material);
                    break;
                }
            }
        }
Beispiel #14
0
    public virtual void Decorate()
    {
        Debug.Log("Decorating: " + Name);
        BuildableObject BO = Object.GetComponent <BuildableObject>();

        BO.price = Price;
        BO.setDisplayName(Name);
        BO.dontSerialize = true;
        BO.isPreview     = true;
        string shader;

        if (Recolorable)
        {
            Debug.Log("Recolorable! : " + Shader);
            CustomColors cc = Object.AddComponent <CustomColors>();
            cc.setColors(Colors);
            shader = "CustomColors" + Shader;
        }
        else
        {
            shader = Shader;
        }
        foreach (Material material in AssetManager.Instance.objectMaterials)
        {
            if (material.name == shader)
            {
                SetMaterial(Object, material);

                // edge case for fences
                Fence fence = Object.GetComponent <Fence>();

                if (fence != null)
                {
                    if (fence.flatGO != null)
                    {
                        SetMaterial(fence.flatGO, material);
                    }

                    if (fence.postGO != null)
                    {
                        SetMaterial(fence.postGO, material);
                    }
                }

                break;
            }
        }
    }
Beispiel #15
0
    // Use this for initialization
    void Start()
    {
        Vector3 center = new Vector3(0F, 0F, 0F);

        transform.localPosition             = center;
        blockFolder                         = new GameObject();
        blockFolder.name                    = "Blocks";
        blockFolder.transform.parent        = transform;
        blockFolder.transform.localPosition = new Vector3(0, 0, 0);
        floatingBlocks                      = new List <FloatingBlock>();
        for (int i = 0; i < Camera.main.orthographicSize * 4; i++)
        {
            Vector3 screen = Camera.main.ScreenToWorldPoint(new Vector3(Random.Range(-Screen.width, Screen.width), Random.Range(-Screen.height, Screen.height), 0));
            addBlock(screen.x, screen.y, CustomColors.randomColor());
        }
    }
Beispiel #16
0
        public void Decorate(GameObject go, Dictionary <string, object> options, AssetBundle assetBundle)
        {
            if (go.GetComponent <BuildableObject>() != null && _recolorable)
            {
                CustomColors cc = go.AddComponent <CustomColors>();

                List <Color> colors = new List <Color>();

                if (options.ContainsKey("recolorableOptions"))
                {
                    Dictionary <string, object> clrs = (Dictionary <string, object>)options["recolorableOptions"];

                    foreach (KeyValuePair <string, object> clr in clrs)
                    {
                        colors.Add(FromHex((string)clr.Value));
                    }
                }

                cc.setColors(colors.ToArray());

                foreach (Material material in AssetManager.Instance.objectMaterials)
                {
                    if (material.name == "CustomColorsDiffuse")
                    {
                        SetMaterial(go, material);

                        // edge case for fences
                        Fence fence = go.GetComponent <Fence>();

                        if (fence != null)
                        {
                            if (fence.flatGO != null)
                            {
                                SetMaterial(fence.flatGO, material);
                            }

                            if (fence.postGO != null)
                            {
                                SetMaterial(fence.postGO, material);
                            }
                        }

                        break;
                    }
                }
            }
        }
Beispiel #17
0
    public void toggle()
    {
        Color c = board.getBackgroundColor();

        if (isToggled)
        {
            board.startBGTransition(CustomColors.subColor(c, leverColor));
            //turn off
            audioSource.PlayOneShot(toggleOffSound, .2f);
            colorModel.onSwitch(CustomColors.subColor(c, leverColor));
        }
        else
        {
            board.startBGTransition(CustomColors.addColor(c, leverColor));
            audioSource.PlayOneShot(toggleOnSound, .2f);
            colorModel.onSwitch(CustomColors.addColor(c, leverColor));
        }
    }
Beispiel #18
0
        public void Confirm()
        {
            if (Name != null && selectedColor != null)
            {
                Group newGroup = new Group()
                {
                    Name      = Name,
                    RGBAColor = CustomColors.ColorToString(selectedColor.ColorPreset.Color),
                    AgendaId  = AgendaRepo.Instance.GetAll().Where(x => x.UserId == SessionManager.CurrentUser.UserId).FirstOrDefault().AgendaId
                };
                newGroup.GroupID = GroupRepo.Instance.Insert(newGroup);

                RefreshRepo?.Invoke(this, EventArgs.Empty);

                AgendaViewModelCollection.Instance.LoadEvent(this, EventArgs.Empty);

                CloseWindow();
            }
        }
        private void panelBackColor_Click(object sender, EventArgs e)
        {
            using (var dialogColor = new ColorDialog())
            {
                dialogColor.Color    = PickedColor;
                dialogColor.FullOpen = true;

                if (CustomColors != null && CustomColors.Length > 0)
                {
                    // Converts the custom colors to there int representations, so a color dialog can use them
                    dialogColor.CustomColors = CustomColors.Select(color => color.ToRgb()).ToArray();
                }

                if (dialogColor.ShowDialog() == DialogResult.OK && PickedColor != dialogColor.Color)
                {
                    PickedColor = dialogColor.Color;
                    ColorPicked(this, EventArgs.Empty);
                }
            }
        }
    // assign in the editor

    public void init(string levelPackName)
    {
        data       = GameObject.Find("GameData").GetComponent <GameData>();
        packName   = levelPackName;
        levelPanel = gameObject;
        buttons    = new List <Button>();
        int        i         = 0;
        GameObject currPanel = Instantiate(Resources.Load <GameObject>("Prefabs/LevelPanel"));

        currPanel.transform.SetParent(levelPanel.transform, false);
        if (Resources.Load <TextAsset>("Levels/" + levelPackName + "/level0") == null)
        {
            i = 1;
        }
        while (Resources.Load <TextAsset>("Levels/" + levelPackName + "/level" + i) != null)
        {
            if (i % 25 == 0 && i > 0)
            {
                currPanel = Instantiate(Resources.Load <GameObject>("Prefabs/LevelPanel"));
                currPanel.transform.SetParent(levelPanel.transform, false);
            }
            GameObject buttonObj = Instantiate(Resources.Load <GameObject>("Prefabs/Button"));
            outline = buttonObj.GetComponent <Outline>();
            if (data.getLevelStatus(packName, i) == 1)
            {
                outline.effectColor = CustomColors.HexToColor("003366");
            }
            else
            if (data.getLevelStatus(packName, i) == 2)
            {
                outline.effectColor = CustomColors.HexToColor("ffbf00");
            }
            buttonObj.transform.SetParent(currPanel.transform, false);
            Button button = buttonObj.GetComponent <Button>();
            buttons.Add(button);
            button.gameObject.GetComponentInChildren <Text>().text = i.ToString();
            int d = i;
            button.onClick.AddListener(() => OnSelect(d));
            i++;
        }
    }
Beispiel #21
0
 public override void onBackgroundChange(Color bgColor)
 {
     isToggled = CustomColors.contains(bgColor, leverColor);
     blockModel.setActive(isToggled);
 }
        /// <summary>
        /// This method sets the values of different color properties
        /// for controls of IGradientButtonColor Type
        /// </summary>
        /// <param name="aCtrl">a control.</param>
        /// <param name="customColors">The custom colors.</param>
        internal void SetColorScheme(IGradientButtonColor aCtrl, CustomColors customColors)
        {
            switch (oClrScheme)
            {
            case EnmColorScheme.Green:
                //=========================================================
                //Setting color properties of button control for
                //Green color scheme
                //---------------------------------------------------------
                aCtrl.BackgroundBottomColor = Color.FromArgb(193, 201, 140);
                aCtrl.BackgroundBottomColor = Color.FromArgb(193, 201, 140);
                aCtrl.BackgroundTopColor    = Color.FromArgb(230, 233, 208);
                aCtrl.BorderBottomColor     = Color.FromArgb(230, 233, 208);
                aCtrl.BorderTopColor        = Color.FromArgb(193, 201, 140);
                aCtrl.DefaultBorderColor    = Color.FromArgb(167, 168, 127);
                aCtrl.DisabledFontColor     = Color.FromArgb(156, 147, 113);
                aCtrl.DisbaledBottomColor   = Color.FromArgb(209, 215, 170);
                aCtrl.DisabledTopColor      = Color.FromArgb(240, 242, 227);
                aCtrl.FontColor             = Color.FromArgb(105, 110, 26);
                aCtrl.PressedFontColor      = Color.Black;

                break;

            //---------------------------------------------------------
            case EnmColorScheme.Purple:
                //=========================================================
                //Setting color properties of button control for
                //Purple color scheme
                //---------------------------------------------------------
                aCtrl.BackgroundBottomColor = Color.FromArgb(183, 157, 206);
                aCtrl.BackgroundTopColor    = Color.FromArgb(231, 222, 239);
                aCtrl.BorderBottomColor     = Color.FromArgb(224, 215, 233);
                aCtrl.BorderTopColor        = Color.FromArgb(193, 157, 206);
                aCtrl.DefaultBorderColor    = Color.FromArgb(132, 100, 161);
                aCtrl.DisabledFontColor     = Color.FromArgb(143, 116, 156);
                aCtrl.DisbaledBottomColor   = Color.FromArgb(209, 192, 210);
                aCtrl.DisabledTopColor      = Color.FromArgb(237, 231, 230);
                aCtrl.FontColor             = Color.FromArgb(74, 30, 115);
                aCtrl.PressedFontColor      = Color.Black;
                break;

            //---------------------------------------------------------
            case EnmColorScheme.Yellow:
                //=========================================================
                //Setting color properties of button control for
                //Yellow color scheme
                //---------------------------------------------------------
                aCtrl.BackgroundBottomColor = Color.FromArgb(194, 168, 120);
                aCtrl.BackgroundTopColor    = Color.FromArgb(248, 245, 224);
                aCtrl.BorderBottomColor     = Color.FromArgb(229, 219, 196);
                aCtrl.BorderTopColor        = Color.FromArgb(194, 168, 120);
                aCtrl.DefaultBorderColor    = Color.FromArgb(189, 153, 74);
                aCtrl.DisabledFontColor     = Color.FromArgb(156, 147, 113);
                aCtrl.DisbaledBottomColor   = Color.FromArgb(201, 177, 135);
                aCtrl.DisabledTopColor      = Color.FromArgb(241, 236, 212);
                aCtrl.FontColor             = Color.FromArgb(96, 83, 43);
                aCtrl.PressedFontColor      = Color.Black;
                break;
            //---------------------------------------------------------

            case EnmColorScheme.Custom:
                //=========================================================
                //Setting color properties of button control for
                //Yellow color scheme
                //---------------------------------------------------------
                aCtrl.BackgroundBottomColor = customColors.BackgroundBottomColor;
                aCtrl.BackgroundTopColor    = customColors.BackgroundTopColor;
                aCtrl.BorderBottomColor     = customColors.BorderBottomColor;
                aCtrl.BorderTopColor        = customColors.BorderTopColor;
                aCtrl.DefaultBorderColor    = customColors.DefaultBorderColor;
                aCtrl.DisabledFontColor     = customColors.DisabledFontColor;
                aCtrl.DisbaledBottomColor   = customColors.DisbaledBottomColor;
                aCtrl.DisabledTopColor      = customColors.DisabledTopColor;
                //aCtrl.FontColor = Color.FromArgb(96, 83, 43);
                aCtrl.PressedFontColor = customColors.PressedFontColor;
                break;
            }
        }
    List <IntPoint> reconstructPath(Dictionary <DistanceDictKey, int>[,] distanceGrid)
    {
        List <IntPoint> path = new List <IntPoint>();
        int             minRemainingDistance = 100000;
        int             x = exit.x;
        int             y = exit.y;
//		int numColors = distanceGrid.GetLength(2);
        DistanceDictKey currKey = null;

        path.Add(new IntPoint(x, y));
        foreach (DistanceDictKey key in distanceGrid[x, y].Keys)
        {
            int value = distanceGrid[x, y][key];
            if (value < minRemainingDistance)
            {
                minRemainingDistance = value;
                currKey = key;
            }
        }
//		for (int color = 0; color < numColors; color++) {
//			if (distanceGrid[x, y, color] < minRemainingDistance && distanceGrid[x, y, color] > -1) {
//				bgColor = color;
//				minRemainingDistance = distanceGrid[x, y].;
//			}
//		}
        while (minRemainingDistance > 0)
        {
            bool foundNextStep = false;
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if ((i == 0 || j == 0) && !(i == 0 && j == 0) && board.onBoard(x + i, y + j))
                    {
                        Dictionary <DistanceDictKey, List <DistanceDictKey> > translateDict = new Dictionary <DistanceDictKey, List <DistanceDictKey> >();
                        foreach (DistanceDictKey key in distanceGrid[x + i, y + j].Keys)
                        {
                            List <ToyEnemy> enemies = copyEnemyList(key.enemies);
                            if (minRemainingDistance > 1)
                            {
                                for (int k = enemies.Count - 1; k >= 0; k--)
                                {
                                    ToyEnemy e = enemies[k];
                                    if (!e.canPassThrough(board, e.x, e.y, key.color))
                                    {
                                        enemies.RemoveAt(k);
                                    }
                                    else
                                    {
                                        e.move(board, key.color);
                                    }
                                }
                            }
                            DistanceDictKey newKey = new DistanceDictKey(key.color, enemies);
                            if (!translateDict.ContainsKey(newKey))
                            {
                                translateDict.Add(newKey, new List <DistanceDictKey>());
                            }
                            translateDict[newKey].Add(key);
                        }
                        int newBGColor = currKey.color;
                        if (minRemainingDistance > 1)
                        {
                            if (board.getBlock(x + i, y + j).name == "Lever")
                            {
                                LeverBlock lever      = (LeverBlock)board.getBlock(x + i, y + j);
                                int        leverColor = CustomColors.indexOf(lever.leverColor);
                                if ((currKey.color & leverColor) == leverColor)
                                {
                                    newBGColor = currKey.color & ~leverColor;
                                }
                                else
                                {
                                    newBGColor = currKey.color | leverColor;
                                }
                            }
                        }
                        DistanceDictKey trialKey = new DistanceDictKey(newBGColor, currKey.enemies);
                        if (translateDict.ContainsKey(trialKey))
                        {
                            foreach (DistanceDictKey translation in translateDict[trialKey])
                            {
                                if (distanceGrid[x + i, y + j][translation] == minRemainingDistance - 1)
                                {
                                    currKey = translation;
                                    x       = x + i;
                                    y       = y + j;
                                    minRemainingDistance--;
                                    path.Add(new IntPoint(x, y));
                                    foundNextStep = true;
                                    break;
                                }
                            }
                            if (foundNextStep)
                            {
                                break;
                            }
                        }
                    }
                }
                if (foundNextStep)
                {
                    break;
                }
            }
            if (!foundNextStep)
            {
                break;
            }
        }
        path.Reverse();
//		print("Before");
//		printList<IntPoint>(path);
        if (path[0] != board.getPlayer().getPos())
        {
            path.Insert(0, board.getPlayer().getPos());
        }
//		print("After");
//		printList<IntPoint>(path);
        return(path);
    }
Beispiel #24
0
        internal override void RegenerateRanges()
        {
            if (UseCustomColors)
            {
                foreach (CustomColor customColor9 in CustomColors)
                {
                    customColor9.AffectedElements.Clear();
                }
            }
            MapCore mapCore = GetMapCore();

            if (mapCore == null || mapCore.Paths.Count == 0 || (UseCustomColors && CustomColors.Count == 0))
            {
                return;
            }
            if (!UseCustomColors)
            {
                CustomColors.Clear();
            }
            if (base.PathField == "(Name)")
            {
                if (UseCustomColors)
                {
                    int num = 0;
                    foreach (Path path4 in mapCore.Paths)
                    {
                        if (num == CustomColors.Count)
                        {
                            break;
                        }
                        CustomColor customColor = CustomColors[num++];
                        customColor.FromValueInt = path4.Name;
                        customColor.ToValueInt   = path4.Name;
                    }
                }
                else
                {
                    Color[] colors = GetColors(ColoringMode, ColorPalette, FromColor, MiddleColor, ToColor, mapCore.Paths.Count);
                    int     num2   = 0;
                    foreach (Path path5 in mapCore.Paths)
                    {
                        if (path5.Category == Category)
                        {
                            CustomColor customColor2 = CustomColors.Add(string.Empty);
                            customColor2.Color          = colors[num2++];
                            customColor2.SecondaryColor = SecondaryColor;
                            customColor2.BorderColor    = BorderColor;
                            customColor2.GradientType   = GradientType;
                            customColor2.HatchStyle     = HatchStyle;
                            customColor2.FromValueInt   = path5.Name;
                            customColor2.ToValueInt     = path5.Name;
                            customColor2.Text           = base.Text;
                            customColor2.ToolTip        = base.ToolTip;
                        }
                    }
                }
                UpdateColorSwatchAndLegend();
                return;
            }
            Field field = GetField();

            if (field == null)
            {
                return;
            }
            if (field.IsNumeric())
            {
                int    intervalCount = (!UseCustomColors) ? ColorCount : CustomColors.Count;
                object obj           = null;
                object obj2          = null;
                if (FromValue != string.Empty)
                {
                    obj = field.Parse(FromValue);
                }
                if (ToValue != string.Empty)
                {
                    obj2 = field.Parse(ToValue);
                }
                if (obj == null || obj2 == null)
                {
                    GetRangeFromPaths(field, intervalCount, ref obj, ref obj2);
                }
                object[] fromValues = null;
                object[] toValues   = null;
                if (DataGrouping == DataGrouping.EqualInterval)
                {
                    GetEqualIntervals(field, obj, obj2, intervalCount, ref fromValues, ref toValues);
                }
                else if (DataGrouping == DataGrouping.EqualDistribution)
                {
                    ArrayList sortedValues = GetSortedValues(field, obj, obj2);
                    GetEqualDistributionIntervals(field, sortedValues, obj, obj2, intervalCount, ref fromValues, ref toValues);
                }
                else if (DataGrouping == DataGrouping.Optimal)
                {
                    ArrayList sortedValues2 = GetSortedValues(field, obj, obj2);
                    GetOptimalIntervals(field, sortedValues2, obj, obj2, intervalCount, ref fromValues, ref toValues);
                }
                if (UseCustomColors)
                {
                    int num3 = 0;
                    foreach (CustomColor customColor10 in CustomColors)
                    {
                        if (num3 < fromValues.Length)
                        {
                            customColor10.FromValueInt = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(fromValues[num3]);
                            customColor10.ToValueInt   = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(toValues[num3]);
                            customColor10.VisibleInt   = true;
                        }
                        else
                        {
                            customColor10.FromValueInt = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(toValues[toValues.Length - 1]);
                            customColor10.ToValueInt   = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(toValues[toValues.Length - 1]);
                            customColor10.VisibleInt   = false;
                        }
                        num3++;
                    }
                }
                else
                {
                    Color[] colors2 = GetColors(ColoringMode, ColorPalette, FromColor, MiddleColor, ToColor, fromValues.Length);
                    for (int i = 0; i < fromValues.Length; i++)
                    {
                        CustomColor customColor4 = CustomColors.Add(string.Empty);
                        customColor4.Color          = colors2[i];
                        customColor4.SecondaryColor = SecondaryColor;
                        customColor4.BorderColor    = BorderColor;
                        customColor4.GradientType   = GradientType;
                        customColor4.HatchStyle     = HatchStyle;
                        customColor4.FromValueInt   = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(fromValues[i]);
                        customColor4.ToValueInt     = Microsoft.Reporting.Map.WebForms.Field.ToStringInvariant(toValues[i]);
                        customColor4.Text           = base.Text;
                        customColor4.ToolTip        = base.ToolTip;
                    }
                }
            }
            else if (field.Type == typeof(string))
            {
                Hashtable hashtable = new Hashtable();
                foreach (Path path6 in GetMapCore().Paths)
                {
                    if (path6.Category == Category)
                    {
                        string text = (string)path6[field.Name];
                        if (text != null)
                        {
                            hashtable[text] = 0;
                        }
                    }
                }
                if (UseCustomColors)
                {
                    ArrayList arrayList = new ArrayList();
                    arrayList.AddRange(hashtable.Keys);
                    arrayList.Sort();
                    int num4 = 0;
                    foreach (object item in arrayList)
                    {
                        if (num4 == CustomColors.Count)
                        {
                            break;
                        }
                        CustomColor customColor5 = CustomColors[num4++];
                        customColor5.FromValueInt = (string)item;
                        customColor5.ToValueInt   = (string)item;
                    }
                }
                else
                {
                    Color[] colors3 = GetColors(ColoringMode, ColorPalette, FromColor, MiddleColor, ToColor, hashtable.Keys.Count);
                    int     num5    = 0;
                    foreach (object key in hashtable.Keys)
                    {
                        CustomColor customColor6 = CustomColors.Add(string.Empty);
                        customColor6.Color          = colors3[num5++];
                        customColor6.SecondaryColor = SecondaryColor;
                        customColor6.BorderColor    = BorderColor;
                        customColor6.GradientType   = GradientType;
                        customColor6.HatchStyle     = HatchStyle;
                        customColor6.FromValueInt   = (string)key;
                        customColor6.ToValueInt     = (string)key;
                        customColor6.Text           = base.Text;
                        customColor6.ToolTip        = base.ToolTip;
                    }
                }
            }
            else if (UseCustomColors)
            {
                CustomColors[0].FromValueInt = "False";
                CustomColors[0].ToValueInt   = "False";
                if (CustomColors.Count > 1)
                {
                    CustomColors[1].FromValueInt = "True";
                    CustomColors[1].ToValueInt   = "True";
                }
            }
            else
            {
                CustomColor customColor7 = CustomColors.Add(string.Empty);
                customColor7.Color          = FromColor;
                customColor7.SecondaryColor = SecondaryColor;
                customColor7.BorderColor    = BorderColor;
                customColor7.GradientType   = GradientType;
                customColor7.HatchStyle     = HatchStyle;
                customColor7.FromValueInt   = "False";
                customColor7.ToValueInt     = "False";
                customColor7.Text           = base.Text;
                customColor7.ToolTip        = base.ToolTip;
                CustomColor customColor8 = CustomColors.Add(string.Empty);
                customColor8.Color          = ToColor;
                customColor8.SecondaryColor = SecondaryColor;
                customColor8.BorderColor    = BorderColor;
                customColor8.GradientType   = GradientType;
                customColor8.HatchStyle     = HatchStyle;
                customColor8.FromValueInt   = "True";
                customColor8.ToValueInt     = "True";
                customColor8.Text           = base.Text;
                customColor8.ToolTip        = base.ToolTip;
            }
            UpdateColorSwatchAndLegend();
        }
    public List <IntPoint> solveLevel()
    {
        enemyList = new List <ToyEnemy>();
        Dictionary <DistanceDictKey, int>[,] distanceGrid = new Dictionary <DistanceDictKey, int> [width, height];
        foreach (Enemy e in board.getEnemyList())
        {
            IntPoint pos = e.getPos();
            IntPoint dir = e.getDirection();
            enemyList.Add(new ToyEnemy(pos.x, pos.y, dir.x, dir.y));
        }
        bool foundPath = false;
        int  targetX   = exit.x;
        int  targetY   = exit.y;

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int c = 0; c < CustomColors.colors.Length; c++)
                {
                    distanceGrid[x, y] = new Dictionary <DistanceDictKey, int>();
                }
            }
        }
        List <QueueEntry> queue     = new List <QueueEntry>();
        IntPoint          playerPos = player.getPos();
//		GameManager.print("Player is at (" + playerPos.x + ", " + playerPos.y + ")");
        int bgColor = CustomColors.indexOf(board.getNextBGColor());

//		GameManager.print("Current background color is: " + bgColor);
//		foreach (ToyEnemy e in enemyList) {
//			GameManager.print("Enemy at (" + e.x + ", " + e.y + ") facing (" + e.dx + ", " + e.dy + ")");
//		}
        queue.Add(new QueueEntry(0, playerPos.x, playerPos.y, bgColor, copyEnemyList(enemyList)));
        if (!board.getBlock(playerPos.x, playerPos.y).name.Equals("Lever"))
        {
            distanceGrid[playerPos.x, playerPos.y].Add(new DistanceDictKey(bgColor, copyEnemyList(enemyList)), 0);
        }
        while (queue.Count > 0)
        {
            QueueEntry firstEntry = queue[0];
            queue.RemoveAt(0);
            int             x          = firstEntry.x;
            int             y          = firstEntry.y;
            bool            playerDead = false;
            List <ToyEnemy> enemies    = firstEntry.enemies;
            if (!board.onBoard(x, y))
            {
                continue;
            }
            if (x == targetX && y == targetY)
            {
                foundPath = true;
                break;
            }

            DistanceDictKey key = new DistanceDictKey(firstEntry.color, copyEnemyList(firstEntry.enemies));

            Block currBlock = board.getBlock(x, y);
            if (firstEntry.distance > 0)
            {
                if (board.getBlock(x, y).name == "Lever")
                {
                    LeverBlock lever      = (LeverBlock)currBlock;
                    int        leverColor = CustomColors.indexOf(lever.leverColor);
                    if ((firstEntry.color & leverColor) == leverColor)
                    {
                        firstEntry.color = firstEntry.color & ~leverColor;
                    }
                    else
                    {
                        firstEntry.color = firstEntry.color | leverColor;
                    }
                }
                for (int i = enemies.Count - 1; i >= 0; i--)
                {
                    ToyEnemy e = enemies[i];
                    if (!e.canPassThrough(board, e.x, e.y, firstEntry.color))
                    {
                        enemies.RemoveAt(i);
                    }
                    else
                    {
                        e.move(board, firstEntry.color);
                        if (e.x == firstEntry.x && e.y == firstEntry.y)
                        {
                            playerDead = true;
                            distanceGrid[firstEntry.x, firstEntry.y].Remove(key);
                            break;
                        }
                    }
                }
                if (playerDead)
                {
                    continue;
                }
            }
            int             newBGColor = firstEntry.color;
            DistanceDictKey newKey     = new DistanceDictKey(newBGColor, copyEnemyList(firstEntry.enemies));
            for (int i = -1; i <= 1; i++)
            {
                for (int j = -1; j <= 1; j++)
                {
                    if ((i == 0 || j == 0) && !(i == 0 && j == 0) && board.onBoard(x + i, y + j))
                    {
                        if (distanceGrid[x + i, y + j].ContainsKey(newKey))
                        {
                            continue;
                        }
                        else
                        {
                            playerDead = false;
                            foreach (ToyEnemy e in firstEntry.enemies)
                            {
                                if (e.x == firstEntry.x && e.y == firstEntry.y)
                                {
                                    playerDead = true;
                                    break;
                                }
                            }
                            if (playerDead)
                            {
                                continue;
                            }
                            Block neighbor = board.getBlock(x + i, y + j);
                            switch (neighbor.name)
                            {
                            case "Block":
                                if (newBGColor == CustomColors.indexOf(neighbor.getBaseColor()))
                                {
                                    queue.Add(new QueueEntry(firstEntry.distance + 1,
                                                             x + i, y + j, newBGColor, copyEnemyList(firstEntry.enemies)));
                                    distanceGrid[x + i, y + j].Add(newKey, firstEntry.distance + 1);
                                }
                                break;

                            case "Lever":
                                queue.Add(new QueueEntry(firstEntry.distance + 1,
                                                         x + i, y + j, newBGColor, copyEnemyList(firstEntry.enemies)));
                                distanceGrid[x + i, y + j].Add(newKey, firstEntry.distance + 1);
                                break;

                            case "Empty Block":
                                queue.Add(new QueueEntry(firstEntry.distance + 1,
                                                         x + i, y + j, newBGColor, copyEnemyList(firstEntry.enemies)));
                                distanceGrid[x + i, y + j].Add(newKey, firstEntry.distance + 1);
                                if (x + i == targetX && y + j == targetY)
                                {
                                    foundPath = true;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (foundPath)
        {
            return(reconstructPath(distanceGrid));
        }
        else
        {
            return(new List <IntPoint>());
        }
    }
Beispiel #26
0
 private void OnAddToCustomColors(object sender, RoutedEventArgs e)
 {
     CustomColors.Add(css.Color);
 }
Beispiel #27
0
 public void RemoveColor(Color color) => CustomColors.Remove(color);