Esempio n. 1
0
 public GeoDemFile(string filePath, IGeoLayerBoundProperty iLayerBound, int dimOffset, DimType type, GridType gridType)
 {
     this.m_RowsCount = 0;
     this.m_ColumnsCount = 0;
     this.m_Resolution = 10.0;
     this.m_DimOffset = 0;
     this.m_IsExceptional = false;
     this.m_DimOffset = dimOffset;
     this.m_DimType = type;
     this.m_GridType = gridType;
     this.m_FilePath = filePath;
     this.m_Resolution = iLayerBound.Resolution;
     this.m_BottomOfBound = iLayerBound.BottomBound;
     this.m_LeftOfBound = iLayerBound.LeftBound;
     this.m_TopOfBound = iLayerBound.TopBound;
     this.m_RightOfBound = iLayerBound.RightBound;
     this.m_BenchmarkHeight = iLayerBound.BenchmarkHeight;
     this.m_HeightStep = iLayerBound.HeightStep;
     try
     {
         this.CalcRowsColums();
     }
     catch
     {
         this.m_IsExceptional = true;
     }
 }
 public DefaultServerGridLayoutOptions(
     ContextualizedHelpers helpers,
     IList<RowType> rows,
     IList<KeyValuePair<string, string>> toolbars,
     Template<LayoutTemplateOptions> layoutTemplate,
     IEnumerable<Template<LayoutTemplateOptions>> subTemplates, 
     IHtmlContent mainContent,
     GridType type,
     string id,
     string prefix,
     GridErrorMessages messages,
     string cssClass,
     string caption,
     Type localizerType
     ) : base(rows, toolbars, layoutTemplate, subTemplates, mainContent)
 {
     this.helpers = helpers;
     Type = type;
     Messages = messages;
     Id = id;
     Prefix = prefix;
     CssClass = cssClass;
     Caption = caption;
     var first = rows.FirstOrDefault();
     MustAddButtonColumn = first.MustAddButtonColumn(helpers, Type== GridType.Batch);
     VisibleColumns = first.VisibleColumns(helpers, Type == GridType.Batch);
     LocalizerType = localizerType;
     Localizer = LocalizerType != null ? helpers.LocalizerFactory.Create(LocalizerType) : null;
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the cell template.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="converterInfo">The converter information.</param>
        /// <param name="gridType">Type of the grid.</param>
        /// <returns>DataTemplate.</returns>
        public static DataTemplate GetCellTemplate(IColumnItem column, ConverterInfo converterInfo, GridType gridType)
        {
            if (column == null)
                return null;

            var highlightBehavior = GetHightlightBehavior(column.ColumnName, gridType);

            var prop = column.Property;
            var stringFormat = GetStringFormat(prop);
            var backcolorBinding = GetBackgroundColor(prop);

            var converter = converterInfo != null ? converterInfo.ConverterString : string.Empty;

            var binding =
                string.Format(CultureInfo.InvariantCulture, GetPropertyBinding(gridType),
                              column.FullName,
                              string.IsNullOrWhiteSpace(column.Prefix) ? string.Empty : string.Format(CultureInfo.InvariantCulture, "{0}.", column.Prefix),
                              string.IsNullOrWhiteSpace(converter) ? string.Empty : string.Format(CultureInfo.InvariantCulture, ", {0}", converter),
                              string.IsNullOrWhiteSpace(stringFormat) ? string.Empty : string.Format(CultureInfo.InvariantCulture, ", {0}", stringFormat));

            var behavior = string.Format(CultureInfo.InvariantCulture, highlightBehavior, binding);

            var templateText = BuildDataTemplate(gridType, behavior, backcolorBinding);
            
            var itemTemplate = XamlReader.Load(templateText);
            return (DataTemplate)itemTemplate;
        }
        public static Bitmap CreateEmbroidery(Bitmap image, int resolutionCoefficient, int cellsCount, Color[] palette, char[] symbols, Color symbolColor, GridType type)
        {
            IKernel kernel = new StandardKernel(new PropertiesModel());

            var patternMapGenerator = kernel.Get<IPatternMapGenerator>();
            var canvasConverter = kernel.Get<ICanvasConverter>();

            var patternCreator = new EmbroideryCreator()
            {
                PatternMapGenerator = patternMapGenerator,
                CanvasConverter = canvasConverter,
            };

            Settings settings = new Settings()
            {
                CellsCount = cellsCount,
                Coefficient = resolutionCoefficient,
                Palette = new Palette(palette),
                Symbols = symbols,
                SymbolColor = symbolColor,
                GridType = type,
                DecoratorsComposition = new DecoratorsComposition()
            };

            if (settings.Palette != null)
                settings.DecoratorsComposition.AddDecorator(new CellsDecorator());
            if (settings.Symbols != null)
                settings.DecoratorsComposition.AddDecorator(new SymbolsDecorator());
            if (settings.GridType != Core.GridType.None)
                settings.DecoratorsComposition.AddDecorator(new GridDecorator());

            Bitmap result = patternCreator.GetEmbroidery(image, settings);

            return result;
        }
 public GridOptions(IList<RowType> rows, IList<KeyValuePair<string, string>> toolbars, GridType type, string id, string fullName): base(rows)
 {
     Toolbars = toolbars;
     Type = type;
     Id = id;
     FullName = fullName;
 }
Esempio n. 6
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public Grid()
 {
     minorGridColor = Colors.LightGray;
     majorGridColor = Colors.LightGray;
     horizontalGridType = GridType.Coarse;
     verticalGridType = GridType.Coarse;
 }
        public static IIndexedPathfindingMap BuildMap(GridType type, Vector2i nodeSize, Vector2u bounds,
            Dictionary<CellState, Color> colorMap)
        {
            switch (type)
            {
                case GridType.SquareEuclidean:
                    var gridEuc = new Vector2i((int)(bounds.X / nodeSize.X), (int)(bounds.Y / nodeSize.Y));
                    return new SquareGrid(nodeSize, gridEuc, colorMap)
                    {
                        UseManhattanMetric = false
                    };
                case GridType.SquareManhattan:
                    var gridMan = new Vector2i((int)(bounds.X / nodeSize.X), (int)(bounds.Y / nodeSize.Y));
                    return new SquareGrid(nodeSize, gridMan, colorMap)
                    {
                        UseManhattanMetric = true
                    };
                case GridType.Hex:
                    var floatHexSize = new Vector2f(nodeSize.X, nodeSize.Y);
                    var testHex = new HexShape(new Layout(Orientation.Flat, floatHexSize, new Vector2f(0, 0)));
                    var size = new Vector2f(testHex.GetLocalBounds().Width, testHex.GetLocalBounds().Height);
                    //We subtract one to handle the center hex
                    var vertRadius = bounds.Y / (2f * size.Y) - 1;
                    var horizRadius = bounds.X / (2f * size.X) - 1;

                    return new HexGrid((int)Math.Min(vertRadius, horizRadius), Orientation.Flat, floatHexSize, colorMap)
                    { Position = new Vector2f(bounds.X / 2f, bounds.Y / 2f) };
            }

            throw new ArgumentException("Cannot build a grid of type " + type);
        }
        public PlanePropertiesForm(Color2 horizontalGridColor, Color2 verticalGridColor, GridType horizontalGrid,
			GridType verticalGrid, int horizontalGridWidth, int verticalGridWidth, Color2 borderColor, Color2 backgroundColor,
			Color2 axisColor, int majorTickLength, float majorTickLineWidth, int minorTickLength, float minorTickLineWidth,
			bool topAxisVisible, bool rightAxisVisible, float axisLineWidth, int numbersFontSize, bool numbersFontBold,
			int titleFontSize, bool titleFontBold, Color2 horizontalZeroColor, Color2 verticalZeroColor, int horizontalZeroWidth,
			int verticalZeroWidth, bool horizontalZeroVisible, bool verticalZeroVisible)
        {
            InitializeComponent();
            numbersFontSizeNumericUpDown.Value = numbersFontSize;
            numbersFontBoldCheckBox.Checked = numbersFontBold;
            titlesFontSizeNumericUpDown.Value = titleFontSize;
            titlesFontBoldCheckBox.Checked = titleFontBold;
            horizontalGridColorButton.BackColor = GraphUtils.ToColor(horizontalGridColor);
            verticalGridColorButton.BackColor = GraphUtils.ToColor(verticalGridColor);
            lineWidthNumericUpDown.Value = (decimal) axisLineWidth;
            switch (horizontalGrid){
                case GridType.None:
                    horizontalGridComboBox.SelectedIndex = 0;
                    break;
                case GridType.Major:
                    horizontalGridComboBox.SelectedIndex = 1;
                    break;
                case GridType.All:
                    horizontalGridComboBox.SelectedIndex = 2;
                    break;
            }
            switch (verticalGrid){
                case GridType.None:
                    verticalGridComboBox.SelectedIndex = 0;
                    break;
                case GridType.Major:
                    verticalGridComboBox.SelectedIndex = 1;
                    break;
                case GridType.All:
                    verticalGridComboBox.SelectedIndex = 2;
                    break;
            }
            showTopAxisCheckBox.Checked = topAxisVisible;
            showRightAxisCheckBox.Checked = rightAxisVisible;
            horizontalGridNumericUpDown.Value = horizontalGridWidth;
            verticalGridNumericUpDown.Value = verticalGridWidth;
            fillColorButton.BackColor = GraphUtils.ToColor(borderColor);
            backgroundColorButton.BackColor = GraphUtils.ToColor(backgroundColor);
            lineColorButton.BackColor = GraphUtils.ToColor(axisColor);
            majorTicLengthNumericUpDown.Value = majorTickLength;
            minorTicLengthNumericUpDown.Value = minorTickLength;
            majorTicLineWidthNumericUpDown.Value = (decimal) majorTickLineWidth;
            minorTicLineWidthNumericUpDown.Value = (decimal) minorTickLineWidth;
            horizontalZeroColorButton.BackColor = GraphUtils.ToColor(horizontalZeroColor);
            verticalZeroColorButton.BackColor = GraphUtils.ToColor(verticalZeroColor);
            horizontalZeroNumericUpDown.Value = horizontalZeroWidth;
            verticalZeroNumericUpDown.Value = verticalZeroWidth;
            horizontalZeroCheckBox.Checked = horizontalZeroVisible;
            verticalZeroCheckBox.Checked = verticalZeroVisible;
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the hightlight behavior.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="gridType">Type of the grid.</param>
        /// <returns>System.String.</returns>
        private static string GetHightlightBehavior(string columnName, GridType gridType)
        {
            string accessDenied = null;
            string condition = null;

            if (gridType == GridType.Spreadsheet)
            {
                accessDenied = string.Format(
                    CultureInfo.InvariantCulture,
                    @"AccessDeniedPropertyList=""{{{{Binding Path={0}, Converter={{{{StaticResource StringToHashSetConverter}}}}}}}}""",
                    Constants.AccessDeniedPropertiesName);

                condition = @"UseCondition=""True"" Condition=""False""";
            }

            if (gridType == GridType.SearchGrid)
            {
                accessDenied = string.Format(
                    CultureInfo.InvariantCulture,
                    @"AccessDeniedPropertyList=""{{{{Binding Path={0}, Converter={{{{StaticResource StringToHashSetConverter}}}}}}}}""",
                    Constants.AccessDeniedPropertiesName);

                condition = string.Empty; //@"UseCondition=""True"" Condition=""{{Binding RelativeSource={{RelativeSource AncestorType=UserControl}}, Path=DataContext.IsItemsLoaded}}""";
            }

            if (gridType == GridType.SingleCrGrid)
                accessDenied = string.Format(
                    CultureInfo.InvariantCulture,
                    @"SingleCrAccessDeniedList=""{{{{Binding Path={0}, Converter={{{{StaticResource StringToHashSetConverter}}}}}}}}""",
                    Constants.AccessDeniedPropertiesName);

            if (gridType == GridType.MultipleCrGrid)
                accessDenied = string.Format(
                    CultureInfo.InvariantCulture,
                    @"MultiCrAccessDeniedList=""{{{{Binding Path={0}, Converter={{{{StaticResource StringToHashSetConverter}}}}}}}}""",
                    Constants.AccessDeniedPropertiesName);

            var highlightBehavior = 
                string.Format(CultureInfo.InvariantCulture, @"
    <i:Interaction.Behaviors>
        <behaviors:HighlightBehavior HighlightBrush=""Red""
                                      HighlightFontWeight=""Bold""
                                      Foreground=""{{{{StaticResource CalmFrontBrush}}}}""
                                      HightlightText=""{{{{Binding RelativeSource={{{{RelativeSource AncestorType=UserControl}}}}, Path=DataContext.FilterString}}}}""
                                      {3}
                                      {0}
                                      ColumnName=""{1}""
                                      Text=""{{0}}"" />
        <behaviors:{2} Text=""{{0}}"" />
    </i:Interaction.Behaviors>"
                , accessDenied, columnName, typeof(HighlightRichTextBehavior).Name, condition);

            return highlightBehavior;
        }
Esempio n. 10
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Grid()
        {
            minorGridPen_ = new Pen( Color.LightGray );
            minorGridPen_.DashStyle = DashStyle.Dash;

            majorGridPen_ = new Pen( Color.LightGray );

            horizontalGridType_ = GridType.Coarse;

            verticalGridType_ = GridType.Coarse;
        }
Esempio n. 11
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Grid()
        {
            minorGridPen_ = new Pen( Color.LightGray );
            float[] pattern = {1.0f, 2.0f};
            minorGridPen_.DashPattern = pattern;

            majorGridPen_ = new Pen( Color.LightGray );

            horizontalGridType_ = GridType.Coarse;

            verticalGridType_ = GridType.Coarse;
        }
Esempio n. 12
0
        public MainWindow()
        {
            this.InitializeComponent();
            FileViewerGrid.Visibility = Visibility.Hidden;
            MainMenuGrid.Visibility = Visibility.Visible;
            CommitHistoryGrid.Visibility = Visibility.Hidden;
            RepositoryCreationGrid.Visibility = Visibility.Hidden;
            RepositorySelectGrid.Visibility = Visibility.Hidden;
            CommitGrid.Visibility = Visibility.Hidden;
            LoginGrid.Visibility = Visibility.Hidden;
            PullGrid.Visibility = Visibility.Hidden;
            RepositoryMainGrid.Visibility = Visibility.Hidden;
            OpenRepoGrid.Visibility = Visibility.Hidden;
            DeleteRepoBoxGrid.Visibility = Visibility.Hidden;
            SettingsMenuGrid.Visibility = Visibility.Hidden;
            HelpGrid.Visibility = Visibility.Hidden;
            BuildbotGrid_green.Visibility = Visibility.Hidden;
            BuildbotGrid_red.Visibility = Visibility.Hidden;
            autoIt.AutoItSetOption("WinTitleMatchMode", 2);
            buildbot.ExecuteCommandAsync(WorkingDirectoryPath);
            lastGrid = GridType.MainMenu;
            HistoryListEntry1.Visibility = Visibility.Visible;
            HistoryListEntry2.Visibility = Visibility.Visible;
            HistoryListEntry3.Visibility = Visibility.Visible;
            HistoryListEntry4.Visibility = Visibility.Visible;
            HistoryListEntry5.Visibility = Visibility.Visible;
            HistoryListEntry6.Visibility = Visibility.Visible;
            HistoryListEntry7.Visibility = Visibility.Visible;
            HistoryListEntry8.Visibility = Visibility.Visible;
            HistoryListEntry9.Visibility = Visibility.Visible;
            HistoryListEntry10.Visibility = Visibility.Visible;
            HistoryListEntry11.Visibility = Visibility.Visible;
            HistoryListEntry12.Visibility = Visibility.Visible;

            HistoryListEntry13.Visibility = Visibility.Visible;
            HistoryListEntry14.Visibility = Visibility.Visible;
            HistoryListEntry15.Visibility = Visibility.Visible;
            HistoryListEntry16.Visibility = Visibility.Visible;

            HistoryListEntry17.Visibility = Visibility.Visible;
            HistoryListEntry18.Visibility = Visibility.Visible;
            HistoryListEntry19.Visibility = Visibility.Visible;
            HistoryListEntry20.Visibility = Visibility.Visible;
            HistoryListEntry21.Visibility = Visibility.Visible;
            HistoryListEntry22.Visibility = Visibility.Visible;
            HistoryListEntry23.Visibility = Visibility.Visible;
            HistoryListEntry24.Visibility = Visibility.Visible;
            HistoryListEntry25.Visibility = Visibility.Visible;
            HistoryListEntry26.Visibility = Visibility.Visible;
            HistoryListEntry27.Visibility = Visibility.Visible;
            HistoryListEntry28.Visibility = Visibility.Visible;
        }
Esempio n. 13
0
        public Simulation(RenderWindow window, AlgorithmType algoType, GridType gridType, Vector2i nodeSize)
        {
            m_Window = window;
            m_Window.MouseButtonPressed += MousePressedEvent;
            m_Window.MouseMoved += MouseMovedEvent;

            SimulationAction = SimulationAction.None;

            m_NodeSize = nodeSize;
            m_AlgorithmType = algoType;
            m_GridType = gridType;
            RebuildGraph();
        }
Esempio n. 14
0
    private void Connect(GameObject cur, GameObject other, bool isLeft, GridType type, GridType otherType, int layer, int x, int y)
    {
        bool connect = true;
        bool springConnection = false;
        bool isDurp = false; // because of x flip wrong pivot point

        #region Wheels

        if (type == GridType.Wheel)
        {
            // Set to right gameobject
            Wheel wb = cur.GetComponent<Wheel>();

            if (isLeft && otherType == GridType.Wheel)
            {
                Wheel otherWb = other.GetComponent<Wheel>();

                if (otherWb.Section == global::Wheel.BlockSection.Right)
                {
                    otherWb = otherWb.SetPiece(global::Wheel.BlockSection.Mid);
                    other = otherWb.gameObject;;
                    BotObjects[layer, x - 1, y] = other;
                    ConnectSpring(other, BotObjects[layer, x - 2, y], isLeft);
                }

                wb = wb.SetPiece(global::Wheel.BlockSection.Right);

                cur = wb.gameObject;
                BotObjects[layer, x, y] = cur;
                isDurp = true;
                connect = true;
            }

            // Group it up
        }
        #endregion

        if (connect)
        {
            if (springConnection)
            {

            }
            else
            {
                ConnectSpring(cur, other, isLeft,isDurp);
            }
        }
    }
Esempio n. 15
0
    public void Init()
    {
        UIWidget widget = gameObject.AddComponent<UIWidget>();//是普通物体显示在NGUI层上
        widget.depth = 20;
        widget.width = 65;
        widget.height = 80;
        BoxCollider box = gameObject.AddComponent<BoxCollider>();
        box.size = new Vector3(65, 80, 0);
       

        if(DataMgr.instance.ContainsdDisable(int.Parse(gameObject.name)))
        {
            gridType = GridType.disable;
        }
    }
Esempio n. 16
0
 public void SetGrid(Position pos,GridType gt)
 {
     if (pos.X < size && pos.Y < size)
         grid[pos.X, pos.Y] = gt;
 }
Esempio n. 17
0
 // Use this for initialization
 void Start()
 {
     width.value = Manager.MyMap.width;
     height.value = Manager.MyMap.height;
     width.GetComponentInChildren<Text> ().text = "宽度" + width.value;
     height .GetComponentInChildren<Text> ().text = "高度" + height.value;
     Close.onClick.AddListener (() => this.gameObject.SetActive (false));
     width.onValueChanged.AddListener (x => Manager.MyMap.width = (int)x);
     width.onValueChanged.AddListener (x => width.GetComponentInChildren<Text>().text="宽度"+x);
     width.onValueChanged.AddListener (x =>Level.LevelNow.ClearBlock  ());
     width.onValueChanged.AddListener (x =>Level.LevelNow.EditorFlash ());
     height.onValueChanged.AddListener (x => Manager.MyMap.height  = (int)x);
     height.onValueChanged.AddListener (x =>height .GetComponentInChildren<Text>().text="高度"+x);
     height.onValueChanged.AddListener (x =>Level.LevelNow.ClearBlock  ());
     height.onValueChanged.AddListener (x =>Level.LevelNow.EditorFlash ());
     BlockChange.onClick.AddListener (() => Manager.ChangeBlock = !Manager.ChangeBlock);
     BlockChange.onClick.AddListener (()=>Level.LevelNow.EditBlock (Manager.ChangeBlock));
     BlockChange.onClick.AddListener (()=>BlockChange.GetComponentInChildren<Text>().text=(Manager.ChangeBlock?"取消":"")+"调整挡板");
     Dictionary<int,string> AllType = new Dictionary<int, string> ();
     AllType.Add (0, "起点");
     AllType.Add (1, "终点");
     AllType.Add (3, "镜子");
     AllType.Add (4, "分光器");
     AllType.Add (5, "变色器");
     //		Dictionary<int,string> AllColor = new Dictionary<int, string> ();
     //		AllColor.Add (0, "普通");
     //		AllColor.Add (1, "红色");
     //		AllColor.Add (2, "蓝色");
     LType.Init (0, AllType);
     LType.OnValueChange.AddListener (()=>GType=(GridType)LType.GetValue ());
     LType.OnValueChange.AddListener (()=>ShowGrid ());
     ShowGrid ();
     //		LColor.Init (0, AllColor);
     //		LColor.OnValueChange.AddListener (()=>GColor=(GridColor)LColor.GetValue ());
     //		LColor.OnValueChange.AddListener (()=>ShowGrid());
     gameObject.SetActive (false);
 }
Esempio n. 18
0
 public void SetGridMode(GridType mode) => GridMode.SelectedIndex = (int)mode;
Esempio n. 19
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        LevelEditor manager = (LevelEditor)target;

        GridType[] types = new GridType[] { GridType.Radial, GridType.Square };

        if (Application.isPlaying)
        {
            if (CanSave(manager))
            {
                gridSaving = EditorGUILayout.BeginFoldoutHeaderGroup(gridSaving, "Grid Saving");
                if (gridSaving)
                {
                    manager.savefileName = EditorGUILayout.TextField("Save File Name", manager.savefileName);
                    if (GUILayout.Button("Save"))
                    {
                        manager.SaveGrid();
                    }
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }
            else if (manager.LoadableFiles != null && manager.LoadableFiles.Count > 0)
            {
                gridLoading = EditorGUILayout.BeginFoldoutHeaderGroup(gridLoading, "Grid Loading");
                if (gridLoading)
                {
                    int index = manager.LoadableFiles.IndexOf(manager.loadFileName);
                    manager.SetLoadFile(EditorGUILayout.Popup(index, manager.LoadableFiles.ToArray()));
                    if (GUILayout.Button("Load"))
                    {
                        manager.LoadGrid();
                    }
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            circuitCreator = EditorGUILayout.BeginFoldoutHeaderGroup(circuitCreator, "Circuit Creator");
            if (circuitCreator)
            {
                circuitName       = EditorGUILayout.TextField("Circuit Name", circuitName);
                circuitDifficulty = (Difficulty)EditorGUILayout.EnumPopup("Difficulty", circuitDifficulty);
                circuitTier       = (CircuitTier)EditorGUILayout.EnumPopup("Circuit Teir", circuitTier);
                finalCircuit      = EditorGUILayout.Toggle("Final Circuit", finalCircuit);

                for (int i = circuitLevels.Count - 1; i > -1; i--)
                {
                    if (GUILayout.Button("Remove " + circuitLevels[i]))
                    {
                        circuitLevels.RemoveAt(i);
                    }
                }

                GUILayout.Space(20);
                if (manager.currentGridFile != null && circuitLevels.Count < 7 && !circuitLevels.Contains(manager.currentGridFile))
                {
                    if (GUILayout.Button("Add Current Grid"))
                    {
                        circuitLevels.Add(manager.currentGridFile);
                    }
                }
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            newspaperInfo = EditorGUILayout.BeginFoldoutHeaderGroup(newspaperInfo, "NewspaperInfo");
            if (newspaperInfo)
            {
                date         = EditorGUILayout.TextField("Date", date);
                headline     = EditorGUILayout.TextField("Headline", headline);
                articleTitle = EditorGUILayout.TextField("Article Title", articleTitle);
                EditorGUILayout.LabelField("Article Description");
                articleDescription = EditorGUILayout.TextArea(articleDescription, GUILayout.Height(60));
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            postCircuitStory = EditorGUILayout.BeginFoldoutHeaderGroup(postCircuitStory, "Post Circuit Story");
            if (postCircuitStory)
            {
                hasStoryScene = GUILayout.Toggle(hasStoryScene, "Has Story");
                storyHeader   = EditorGUILayout.TextField("Story Header", storyHeader);
                GUILayout.Label("Story Scene Description");
                storyDescription = EditorGUILayout.TextArea(storyDescription, GUILayout.Height(60));
            }
            EditorGUILayout.EndFoldoutHeaderGroup();

            if (loadableCircuits.Count > 0)
            {
                circuitLoading = EditorGUILayout.BeginFoldoutHeaderGroup(circuitLoading, "Circuit Loading");
                if (circuitLoading)
                {
                    circuitIndex = EditorGUILayout.Popup(circuitIndex, loadableCircuits.ToArray());
                    if (GUILayout.Button("Load"))
                    {
                        Circuit circuit = JsonSaveLoad.LoadFile <Circuit>(FolderPath.Circuits, loadableCircuits[circuitIndex]);
                        InfoList <NewspaperInfo> newsList = JsonSaveLoad.LoadResource <InfoList <NewspaperInfo> >("Newspaper");

                        circuitFileName   = loadableCircuits[circuitIndex];
                        circuitName       = circuit.name;
                        circuitDifficulty = circuit.difficulty;
                        circuitTier       = circuit.circuitTier;
                        finalCircuit      = circuit.IsFinalCircuit();
                        circuitLevels.Clear();
                        circuitLevels.AddRange(circuit.grids);

                        bool missingNewspaper = true;
                        if (newsList != default(InfoList <NewspaperInfo>))
                        {
                            NewspaperInfo newsInfo = NewspaperInfo.BinarySearch(newsList.info, circuitName);
                            if (newsInfo != null)
                            {
                                missingNewspaper   = false;
                                date               = newsInfo.date;
                                headline           = newsInfo.headline;
                                articleTitle       = newsInfo.title;
                                articleDescription = newsInfo.description;
                            }
                        }

                        if (missingNewspaper)
                        {
                            date         = "August 8th, 2008";
                            headline     = "Fresh Meat Enters the Circuit Breaker Sport!";
                            articleTitle = "An Actual Challenge";
                            if (circuit.description != null)
                            {
                                articleDescription = circuit.description;
                            }
                            else
                            {
                                articleDescription = "The new challenger will actually have to try in order to overcome this challenge."
                                                     + " I hope they survive... or at least show us a spectacular death!";
                            }
                        }

                        if (circuit.postStoryScene != null && circuit.postStoryScene.Length >= 2)
                        {
                            hasStoryScene    = true;
                            storyHeader      = circuit.postStoryScene[0];
                            storyDescription = circuit.postStoryScene[1];
                        }
                        else
                        {
                            hasStoryScene    = false;
                            storyHeader      = "";
                            storyDescription = "";
                        }
                    }
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }

            if (circuitLevels.Count > 0)
            {
                circuitSaving = EditorGUILayout.BeginFoldoutHeaderGroup(circuitSaving, "Circuit Saving");
                if (circuitSaving)
                {
                    circuitFileName = EditorGUILayout.TextField("Circuit File Name", circuitFileName);
                    if (GUILayout.Button("Save Circuit"))
                    {
                        string[] story = null;
                        if (hasStoryScene)
                        {
                            story    = new string[2];
                            story[0] = storyHeader;
                            story[1] = storyDescription;
                        }

                        Circuit circuit   = new Circuit(circuitName, articleDescription, circuitDifficulty, circuitTier, finalCircuit, circuitLevels.ToArray(), story);
                        string  savedName = JsonSaveLoad.SaveFile(FolderPath.Circuits, circuit, circuitFileName, false, true);

                        //Get Newspaper Info and convert it into a list
                        NewspaperInfo            info     = new NewspaperInfo(circuitName, date, headline, articleTitle, articleDescription);
                        InfoList <NewspaperInfo> newsInfo = JsonSaveLoad.LoadResource <InfoList <NewspaperInfo> >("Newspaper");

                        //Add new newspaper info into the list
                        newsInfo.info = NewspaperInfo.BinaryInsert(newsInfo.info, info);

                        //Overwrite previous newspaper list with new data
                        JsonSaveLoad.SaveResource <InfoList <NewspaperInfo> >(newsInfo, "Newspaper");

                        Debug.Log("Saved Circuit as [" + savedName + "]");
                        loadableCircuits = JsonSaveLoad.FindAllFiles(FolderPath.Circuits);
                    }
                }
                EditorGUILayout.EndFoldoutHeaderGroup();
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(manager);
        }
    }
 public void ChangeGridType(int x, int y, GridType type)
 {
     board[x, y] = type;
 }
Esempio n. 21
0
        /// <summary>
        /// Builds the data template.
        /// </summary>
        /// <param name="gridType">Type of the grid.</param>
        /// <param name="behavior">The behavior.</param>
        /// <param name="backcolorBinding">The backcolor binding.</param>
        /// <returns>System.String.</returns>
        private static string BuildDataTemplate(GridType gridType, string behavior, string backcolorBinding)
        {
            var templateText = string.Empty;            

            if (gridType == GridType.Spreadsheet)
            {
                templateText = string.Format(CultureInfo.InvariantCulture, @"
<DataTemplate
    xmlns=""http://schemas.microsoft.com/client/2007""
    xmlns:i=""http://schemas.microsoft.com/expression/2010/interactivity""
    xmlns:behaviors=""clr-namespace:Cebos.Common.Behaviors;assembly=Cebos.Veyron.Common.SL""
    xmlns:converters=""clr-namespace:Cebos.Common.Converters;assembly=Cebos.Veyron.Common.SL"">
        <TextBlock             
            FontFamily=""Verdana"" FontSize=""12""
            MinHeight=""20"" TextWrapping=""Wrap""
            Margin=""5,1,5,0"">
            {0}
        </TextBlock>
</DataTemplate>", behavior);
            }
            else
            {
                templateText = string.Format(CultureInfo.InvariantCulture, @"
<DataTemplate
    xmlns=""http://schemas.microsoft.com/client/2007""
    xmlns:i=""http://schemas.microsoft.com/expression/2010/interactivity""
    xmlns:behaviors=""clr-namespace:Cebos.Common.Behaviors;assembly=Cebos.Veyron.Common.SL""
    xmlns:converters=""clr-namespace:Cebos.Common.Converters;assembly=Cebos.Veyron.Common.SL"">
    <Border {1}>
        <TextBlock MinHeight=""25"" TextWrapping=""Wrap"">
        {0}
        </TextBlock>
    </Border>
</DataTemplate>", behavior, backcolorBinding);    
            }

            return templateText;
        }
Esempio n. 22
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List <FloorBorder> floorBorders, Dictionary <int, List <int> > borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed    = seed;
            this.entry   = entry;
            FloorBorders = floorBorders;
            BorderLinks  = borderLinks;

            BorderPoints = new Loc2D[floorBorders.Count];

            rand = new Random(seed);

            MapArray  = new Tile[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];
            GridArray = new GridType[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];

            Rooms     = new DungeonArrayRoom[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"]];     //array of all rooms
            VHalls    = new DungeonArrayHall[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"] - 1]; //vertical halls
            HHalls    = new DungeonArrayHall[entry.FloorSettings["CellX"] - 1, entry.FloorSettings["CellY"]]; //horizontal halls
            StartRoom = new Loc2D(-1, -1);                                                                    //marks spawn point

            bool isDone;                                                                                      // bool used for various purposes


            //initialize map array to empty
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    GridArray[x, y] = GridType.Blocked;
                }
            }

            //initialize all rooms+halls to closed by default
            for (int x = 0; x < entry.FloorSettings["CellX"]; x++)
            {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++)
                {
                    Rooms[x, y] = new DungeonArrayRoom();
                }
            }



            for (int x = 0; x < entry.FloorSettings["CellX"]; x++)
            {
                for (int y = 0; y < entry.FloorSettings["CellY"] - 1; y++)
                {
                    VHalls[x, y] = new DungeonArrayHall();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"] - 1; x++)
            {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++)
                {
                    HHalls[x, y] = new DungeonArrayHall();
                }
            }

            // path generation algorithm
            StartRoom = new Loc2D(rand.Next(0, entry.FloorSettings["CellX"]), rand.Next(0, entry.FloorSettings["CellY"])); // randomly determine start room
            Loc2D wanderer = StartRoom;

            int        pathsMade   = 0;
            int        pathsNeeded = rand.Next(0, 6) + 5; // magic numbers, determine what the dungeon looks like (in general, paths)
            Direction4 prevDir     = Direction4.None;     // direction of movement

            do
            {
                if (rand.Next(0, (2 + pathsMade)) == 0) //will end the current path and start a new one from the start
                {
                    if (rand.Next(0, 2) == 0)           //determine if the room should be open or a hall
                    {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    }
                    else
                    {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                    pathsMade++;
                    wanderer = StartRoom;
                    prevDir  = Direction4.None;
                }
                else
                {
                    bool working = true;
                    do
                    {
                        Loc2D      sample  = wanderer;
                        Direction4 nextDir = (Direction4)rand.Next(0, 4);
                        if (nextDir != prevDir)  //makes sure there is no backtracking
                        {
                            Operations.MoveInDirection4(ref sample, nextDir, 1);
                            prevDir = Operations.ReverseDir(nextDir);
                            if (sample.X >= 0 && sample.X < entry.FloorSettings["CellX"] && sample.Y >= 0 && sample.Y < entry.FloorSettings["CellY"])  // a is the room to be checked after making a move between rooms
                            {
                                openHallBetween(wanderer, sample);
                                wanderer = sample;
                                working  = false;
                            }
                        }
                        else
                        {
                            prevDir = Direction4.None;
                        }
                    } while (working);

                    if (rand.Next(0, 2) == 0)  //determine if the room should be open or a hall
                    {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    }
                    else
                    {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                }
            } while (pathsMade < pathsNeeded);

            Rooms[StartRoom.X, StartRoom.Y].Opened = DungeonArrayRoom.RoomState.Open;

            //Determine key rooms
            isDone = false;
            do   //determine ending room randomly
            {
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open)
                {
                    EndRoom = new Loc2D(x, y);
                    isDone  = true;
                }
            } while (!isDone);

            StartRoom = new Loc2D(-1, -1);

            isDone = false;
            do   //determine starting room randomly
            {
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open)
                {
                    StartRoom = new Loc2D(x, y);
                    isDone    = true;
                }
            } while (!isDone);



            // begin part 2, creating ASCII map
            //create rooms

            for (int i = 0; i < Rooms.GetLength(0); i++)
            {
                for (int j = 0; j < Rooms.GetLength(1); j++)
                {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed)
                    {
                        createRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++)
            {
                for (int j = 0; j < Rooms.GetLength(1); j++)
                {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed)
                    {
                        drawRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++)
            {
                for (int j = 0; j < Rooms.GetLength(1); j++)
                {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed)
                    {
                        padSingleRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++)
            {
                for (int j = 0; j < VHalls.GetLength(1); j++)
                {
                    if (VHalls[i, j].Open)
                    {
                        createVHall(i, j);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++)
            {
                for (int j = 0; j < HHalls.GetLength(1); j++)
                {
                    if (HHalls[i, j].Open)
                    {
                        createHHall(i, j);
                    }
                }
            }


            for (int i = 0; i < VHalls.GetLength(0); i++)
            {
                for (int j = 0; j < VHalls.GetLength(1); j++)
                {
                    if (VHalls[i, j].Open)
                    {
                        DrawHalls(VHalls[i, j]);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++)
            {
                for (int j = 0; j < HHalls.GetLength(1); j++)
                {
                    if (HHalls[i, j].Open)
                    {
                        DrawHalls(HHalls[i, j]);
                    }
                }
            }

            addSEpos(StartRoom, true);
            addSEpos(EndRoom, false);

            //texturing
            MapLayer ground = new MapLayer(Width, Height);

            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    if (GridArray[x, y] == GridType.End)
                    {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.ChangeFloor, 1, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                    else if (GridArray[x, y] == GridType.Blocked)
                    {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Blocked, 0, 0, 0);

                        bool[] blockedDirs = new bool[8];
                        for (int n = 0; n < 8; n++)
                        {
                            blockedDirs[n] = IsBlocked(x, y, (Direction8)n);
                        }
                        if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 0;
                            if (!blockedDirs[(int)Direction8.DownLeft])
                            {
                                layer += 8 * 2;
                            }

                            if (!blockedDirs[(int)Direction8.UpLeft])
                            {
                                layer += 1;
                            }

                            if (!blockedDirs[(int)Direction8.UpRight])
                            {
                                layer += 8;
                            }

                            if (!blockedDirs[(int)Direction8.DownRight])
                            {
                                layer += 2;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 6;
                            if (blockedDirs[(int)Direction8.UpRight])
                            {
                                layer += 1 * 8;
                            }

                            if (blockedDirs[(int)Direction8.UpLeft])
                            {
                                layer += 2 * 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 7;
                            if (blockedDirs[(int)Direction8.DownRight])
                            {
                                layer += 1 * 8;
                            }

                            if (blockedDirs[(int)Direction8.UpRight])
                            {
                                layer += 2 * 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 4;
                            if (blockedDirs[(int)Direction8.DownLeft])
                            {
                                layer += 1 * 8;
                            }

                            if (blockedDirs[(int)Direction8.DownRight])
                            {
                                layer += 2 * 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 5;
                            if (blockedDirs[(int)Direction8.UpLeft])
                            {
                                layer += 1 * 8;
                            }

                            if (blockedDirs[(int)Direction8.DownLeft])
                            {
                                layer += 2 * 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 34;
                            if (blockedDirs[(int)Direction8.UpRight])
                            {
                                layer += 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 35;
                            if (blockedDirs[(int)Direction8.DownRight])
                            {
                                layer += 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 32;
                            if (blockedDirs[(int)Direction8.DownLeft])
                            {
                                layer += 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 33;
                            if (blockedDirs[(int)Direction8.UpLeft])
                            {
                                layer += 8;
                            }

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(36, 0), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(37, 0), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(38, 0), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(39, 0), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(44, 0), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(45, 0), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(46, 0), 0);
                        }
                    }
                    else
                    {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                }
            }

            GenItems();
            SpawnNpcs();
        }
Esempio n. 23
0
        public static void ChangeStorageObjects(string location, PipeGroup group, GridType type, float hours)
        {
            var netPower = group.powerVector.X + group.powerVector.Y;

            if (group.storageVector.X + netPower < 0) // not enough stored power
            {
                return;
            }

            GameLocation gl = Game1.getLocationFromName(location, false);

            if (gl == null)
            {
                gl = Game1.getLocationFromName(location, true);
                if (gl == null)
                {
                    SMonitor.Log($"Invalid game location {location}", StardewModdingAPI.LogLevel.Error);
                    return;
                }
            }
            var chargeKey     = type == GridType.water ? "aedenthorn.UtilityGrid/waterCharge" : "aedenthorn.UtilityGrid/electricCharge";
            var changeObjects = new Dictionary <Vector2, float>();

            foreach (var v in utilitySystemDict[location][type].objects.Keys.ToArray())
            {
                if (!group.pipes.Contains(v))
                {
                    continue;
                }
                var obj      = utilitySystemDict[location][type].objects[v];
                var objW     = obj.WorldObject;
                var objT     = obj.Template;
                var capacity = type == GridType.water ? objT.waterChargeCapacity : objT.electricChargeCapacity;
                if (capacity == 0)
                {
                    continue;
                }
                float charge = 0;
                if (obj.WorldObject.modData.TryGetValue(chargeKey, out string chargeString))
                {
                    float.TryParse(chargeString, NumberStyles.Float, CultureInfo.InvariantCulture, out charge);
                }
                if (type == GridType.water && hours > 0 && objT.fillWaterFromRain && gl.IsOutdoors && Game1.netWorldState.Value.GetWeatherForLocation(gl.GetLocationContext()).isRaining.Value)
                {
                    charge = Math.Min(charge + objT.waterChargeRate * hours, objT.waterChargeCapacity);
                    objW.modData[chargeKey] = charge + "";
                }
                if (netPower != 0)
                {
                    if (netPower > 0)
                    {
                        changeObjects.Add(v, Math.Min(capacity - charge, type == GridType.water ? objT.waterChargeRate : objT.electricChargeRate));
                    }
                    else
                    {
                        changeObjects.Add(v, Math.Min(charge, type == GridType.water ? objT.waterDischargeRate : objT.electricDischargeRate));
                    }
                }
            }

            // change charges

            while (changeObjects != null && changeObjects.Count > 0 && netPower != 0)
            {
                var eachPower = netPower / changeObjects.Count;
                foreach (var v in changeObjects.Keys.ToArray())
                {
                    var   obj           = utilitySystemDict[location][type].objects[v].WorldObject;
                    var   objT          = utilitySystemDict[location][type].objects[v].Template;
                    float currentCharge = 0;
                    float diff          = changeObjects[v];
                    if (obj.modData.TryGetValue(chargeKey, out string chargeString))
                    {
                        float.TryParse(chargeString, NumberStyles.Float, CultureInfo.InvariantCulture, out currentCharge);
                    }
                    if (eachPower > 0)
                    {
                        var capacity = type == GridType.water ? objT.waterChargeCapacity : objT.electricChargeCapacity;
                        var add      = Math.Min(capacity - currentCharge, Math.Min(diff, eachPower));
                        if (hours > 0)
                        {
                            SMonitor.Log($"adding {add * hours} {type} energy to {obj.Name} at {v}");
                            obj.modData[chargeKey] = Math.Min(capacity, currentCharge + add * hours) + "";
                        }
                        changeObjects[v] -= add;
                        if (add != eachPower)
                        {
                            changeObjects.Remove(v);
                        }
                    }
                    else
                    {
                        float subtract = Math.Min(currentCharge, Math.Min(diff, -eachPower));
                        if (hours > 0)
                        {
                            SMonitor.Log($"subtracting {subtract * hours} {type} energy from {obj.Name} at {v}");
                            obj.modData[chargeKey] = Math.Max(0, currentCharge - subtract * hours) + "";
                        }
                        changeObjects[v] -= subtract;
                        if (subtract != -eachPower)
                        {
                            changeObjects.Remove(v);
                        }
                    }
                }
            }
        }
Esempio n. 24
0
        public static bool PipesAreJoined(string location, Vector2 tile, Vector2 tile2, GridType gridType)
        {
            if (!utilitySystemDict.ContainsKey(location))
            {
                SMonitor.Log($"{location} has no utility grid");
                return(false);
            }

            Dictionary <Vector2, GridPipe> pipeDict = utilitySystemDict[location][gridType].pipes;

            if (!pipeDict.ContainsKey(tile2))
            {
                return(false);
            }
            if (tile2.X == tile.X)
            {
                if (tile.Y == tile2.Y + 1)
                {
                    return(HasIntake(pipeDict[tile], 0) && HasIntake(pipeDict[tile2], 2));
                }
                else if (tile.Y == tile2.Y - 1)
                {
                    return(HasIntake(pipeDict[tile], 2) && HasIntake(pipeDict[tile2], 0));
                }
            }
            else if (tile2.Y == tile.Y)
            {
                if (tile.X == tile2.X + 1)
                {
                    return(HasIntake(pipeDict[tile], 3) && HasIntake(pipeDict[tile2], 1));
                }
                else if (tile.X == tile2.X - 1)
                {
                    return(HasIntake(pipeDict[tile], 1) && HasIntake(pipeDict[tile2], 3));
                }
            }
            return(false);
        }
Esempio n. 25
0
    public void UpdatePanel()
    {
        // Set all tile buttons to not interactable to be safe.
        // Also hide all the enemy piece sprites.
        for (int i = 0; i < mTileButtons.Length; i++)
        {
            mTileButtons[i].interactable = false;
            mTileButtonImages[i].color   = Color.white;
            mTilePieceImages[i].enabled  = false;
        }



        // Settle tile and piece sprites.
        int PlayerPosX = GameManager.Instance.Player.PosX;
        int PlayerPosY = GameManager.Instance.Player.PosY;

        for (int i = 0; i < mTileButtonImages.Length; i++)
        {
            int x = PlayerPosX + ((i % 5) - 2);
            int y = PlayerPosY + ((i / 5) - 2);

            // Check if Exit Tile.
            if (x == DungeonManager.Instance.ExitPosX && y == DungeonManager.Instance.ExitPosY)
            {
                mTileButtonImages[i].sprite = DungeonManager.Instance.exitSprite;

                if (DungeonManager.Instance.IsEnemyPos(x, y))
                {
                    // Check and display the enemy piece
                    mTilePieceImages[i].enabled = true;
                    mTilePieceImages[i].sprite  = DungeonManager.Instance.DungeonBlocks[x, y].Enemy.mSpriteRen.sprite;
                }

                continue;
            }


            // If it's empty, check if white or black tile.
            if (DungeonManager.Instance.IsCellEmpty(x, y))
            {
                if (DungeonManager.Instance.IsWhiteTile(x, y))
                {
                    mTileButtonImages[i].sprite = DungeonManager.Instance.whiteTileSprite;
                }
                else
                {
                    mTileButtonImages[i].sprite = DungeonManager.Instance.blackTileSprite;
                }

                continue;
            }

            // Otherwise, check if it's an enemy piece or a wall.
            if (DungeonManager.Instance.IsEnemyPos(x, y))
            {
                if (DungeonManager.Instance.IsWhiteTile(x, y))
                {
                    mTileButtonImages[i].sprite = DungeonManager.Instance.whiteTileSprite;
                }
                else
                {
                    mTileButtonImages[i].sprite = DungeonManager.Instance.blackTileSprite;
                }

                // Check and display the enemy piece
                mTilePieceImages[i].enabled = true;
                mTilePieceImages[i].sprite  = DungeonManager.Instance.DungeonBlocks[x, y].Enemy.mSpriteRen.sprite;
            }
            // Else check if it is out of bounds.
            else
            {
                mTileButtonImages[i].sprite = DungeonManager.Instance.wallTileSprite;
                if (DungeonManager.Instance.IsValidCell(x, y) == false)
                {
                    mTileButtonImages[i].color = Color.gray;
                }
            }
        }
        // Player sprite.
        mTilePieceImages[12].enabled = true;
        mTilePieceImages[12].sprite  = GameManager.Instance.Player.mSpriteRen.sprite;



        // Set clickable tiles.
        GridType movementType = GameManager.Instance.Player.MovementType;

        switch (movementType)
        {
        case GridType.Pawn:
            // Check top
            if (DungeonManager.Instance.IsCellEmpty(PlayerPosX, PlayerPosY + 1))
            {
                int tileID = (PlayerPosY + 1 - PlayerPosY + 2) * 5 + (PlayerPosX - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }
            else if (DungeonManager.Instance.IsExitCell(PlayerPosX, PlayerPosY + 1))
            {
                int tileID = (PlayerPosY + 1 - PlayerPosY + 2) * 5 + (PlayerPosX - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.exitSelectableSprite;
            }

            // Check bottom
            if (DungeonManager.Instance.IsCellEmpty(PlayerPosX, PlayerPosY - 1))
            {
                int tileID = (PlayerPosY - 1 - PlayerPosY + 2) * 5 + (PlayerPosX - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }
            else if (DungeonManager.Instance.IsExitCell(PlayerPosX, PlayerPosY - 1))
            {
                int tileID = (PlayerPosY - 1 - PlayerPosY + 2) * 5 + (PlayerPosX - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.exitSelectableSprite;
            }

            // Check corner for enemies. (Pawn only can attack if there's an enemy.
            // Top left
            if (DungeonManager.Instance.IsEnemyPos(PlayerPosX - 1, PlayerPosY + 1))
            {
                int tileID = (PlayerPosY + 1 - PlayerPosY + 2) * 5 + (PlayerPosX - 1 - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }

            // Top Right
            if (DungeonManager.Instance.IsEnemyPos(PlayerPosX + 1, PlayerPosY + 1))
            {
                int tileID = (PlayerPosY + 1 - PlayerPosY + 2) * 5 + (PlayerPosX + 1 - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }

            // Bottom Left
            if (DungeonManager.Instance.IsEnemyPos(PlayerPosX - 1, PlayerPosY - 1))
            {
                int tileID = (PlayerPosY - 1 - PlayerPosY + 2) * 5 + (PlayerPosX - 1 - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }

            // Bottom Right
            if (DungeonManager.Instance.IsEnemyPos(PlayerPosX + 1, PlayerPosY - 1))
            {
                int tileID = (PlayerPosY - 1 - PlayerPosY + 2) * 5 + (PlayerPosX + 1 - PlayerPosX + 2);
                mTileButtons[tileID].interactable = true;
                mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
            }
            break;

        default:
            LinkedList <Node> neighbours = DungeonManager.Instance.Grids[(int)movementType].nodes[PlayerPosX, PlayerPosY].neighbours;
            for (LinkedListNode <Node> curLinkedNode = neighbours.First; curLinkedNode != null; curLinkedNode = curLinkedNode.Next)
            {
                Node curNode = curLinkedNode.Value;
                // Check if it's empty cell.
                // Otherwise if it's enemy, still movable tile.
                // If still not, then could be exit tile.
                if (DungeonManager.Instance.IsCellEmpty(curNode.PosX, curNode.PosY) ||
                    DungeonManager.Instance.IsEnemyPos(curNode.PosX, curNode.PosY))
                {
                    int tileID = (curNode.PosY - PlayerPosY + 2) * 5 + (curNode.PosX - PlayerPosX + 2);
                    mTileButtons[tileID].interactable = true;
                    mTileButtonImages[tileID].sprite  = DungeonManager.Instance.selectableSprite;
                }
                else if (DungeonManager.Instance.IsExitCell(curNode.PosX, curNode.PosY))
                {
                    int tileID = (curNode.PosY - PlayerPosY + 2) * 5 + (curNode.PosX - PlayerPosX + 2);
                    mTileButtons[tileID].interactable = true;
                    mTileButtonImages[tileID].sprite  = DungeonManager.Instance.exitSelectableSprite;
                }
            }
            break;
        }
    }
Esempio n. 26
0
 public static DrawAction <GenSpace> MergeIn <T>(ProbabilityPool <T> elements, System.Random random, Theme theme, GridType type = GridType.Doodad, bool typeOnlyDefault = false, bool themeOnlyDefault = false)
     where T : ThemeElement
 {
     return((arr, x, y) =>
     {
         MergeIn(arr, x, y, new GenDeploy(elements.Get(random)), theme, type, typeOnlyDefault, themeOnlyDefault);
         return true;
     });
 }
Esempio n. 27
0
 private GameObject GetGameObject(GridType block)
 {
     switch (block)
     {
         case GridType.Block:
             return Block;
         case GridType.Wheel:
             return Wheel;
         case GridType.Rotator:
             return Rotator;
         case GridType.Spring:
             return Spring;
         default:
             return null;
     }
 }
Esempio n. 28
0
		public void SelectGrid(GridType gridType)
		{
			switch (gridType)
			{
				case GridType.DetailedGrid:
					_selectedOutput = DetailedGrid;
					HelpButtonItem = Controller.Instance.DetailedGridHelp;
					break;
				case GridType.MultiGrid:
					_selectedOutput = MultiGrid;
					HelpButtonItem = Controller.Instance.MultiGridHelp;
					break;
				default:
					_selectedOutput = null;
					break;
			}

			if (_selectedOutput != null)
			{
				UpdateButtonsStateAccordingSelectedOutput();

				if (!pnMain.Controls.Contains(_selectedOutput as Control))
				{
					Application.DoEvents();
					pnEmpty.BringToFront();
					Application.DoEvents();
					pnMain.Controls.Add(_selectedOutput as Control);
					Application.DoEvents();
					pnMain.BringToFront();
					Application.DoEvents();
				}
				(_selectedOutput as Control).BringToFront();

				if (!xtraTabPagePrint.Controls.Contains(_selectedOutput.ColumnsColumns))
				{
					Application.DoEvents();
					xtraTabPagePrint.Controls.Add(_selectedOutput.ColumnsColumns);
				}
				_selectedOutput.ColumnsColumns.BringToFront();

				if (!xtraTabPageAdNotes.Controls.Contains(_selectedOutput.AdNotes))
				{
					Application.DoEvents();
					xtraTabPageAdNotes.Controls.Add(_selectedOutput.AdNotes);
				}
				_selectedOutput.AdNotes.BringToFront();

				if (!xtraTabPageSlideHeaders.Controls.Contains(_selectedOutput.SlideHeader))
				{
					Application.DoEvents();
					xtraTabPageSlideHeaders.Controls.Add(_selectedOutput.SlideHeader);
				}
				_selectedOutput.SlideHeader.BringToFront();

				if (!xtraTabPageSlideBullets.Controls.Contains(_selectedOutput.SlideBullets))
				{
					Application.DoEvents();
					xtraTabPageSlideBullets.Controls.Add(_selectedOutput.SlideBullets);
				}
				_selectedOutput.SlideBullets.BringToFront();

				Controller.Instance.Supertip.SetSuperTooltip(HelpButtonItem, _selectedOutput.HelpToolTip);
			}
			else
			{
				pnEmpty.BringToFront();
				Controller.Instance.Supertip.SetSuperTooltip(HelpButtonItem, null);
			}
		}
Esempio n. 29
0
        /// <summary>
        /// Gets the property binding.
        /// </summary>
        /// <param name="gridType">Type of the grid.</param>
        /// <returns>System.String.</returns>
        private static string GetPropertyBinding(GridType gridType)
        {
            string binding = string.Empty;

            switch (gridType)
            {
                case GridType.SearchGrid:
                    binding = "{{Binding {1}{0}{2}{3}}}"; break;

                default:
                    binding = "{{Binding {1}{0}{2}{3}}}"; break;
            }

            return binding;
        }
Esempio n. 30
0
 public BombGridCell(Point location, GridType type, int level)
 {
     Location = location;
     Type     = type;
     Level    = level;
 }
Esempio n. 31
0
 public static DrawAction <GenSpace> MergeIn(ThemeElement element, Theme theme, GridType type = GridType.Floor, bool typeOnlyDefault = true, bool themeOnlyDefault = false)
 {
     return(MergeIn(new GenDeploy(element), theme, type, typeOnlyDefault, themeOnlyDefault));
 }
Esempio n. 32
0
        /// <summary>
        /// Get the handles of Grid Axes.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="sameDirectionAxes">The grid axes in the same direction of one level.</param>
        /// <param name="representations">The representation of grid axis.</param>
        /// <returns>The list of handles of grid axes.</returns>
        private static List <IFCAnyHandle> CreateIFCGridAxisAndRepresentations(ExporterIFC exporterIFC, ProductWrapper productWrapper, IList <Grid> sameDirectionAxes,
                                                                               IList <IFCAnyHandle> representations, GridRepresentationData gridRepresentationData)
        {
            if (sameDirectionAxes.Count == 0)
            {
                return(null);
            }

            IDictionary <ElementId, List <IFCAnyHandle> > gridAxisMap = new Dictionary <ElementId, List <IFCAnyHandle> >();
            IDictionary <ElementId, List <IFCAnyHandle> > gridRepMap  = new Dictionary <ElementId, List <IFCAnyHandle> >();

            IFCFile ifcFile  = exporterIFC.GetFile();
            Grid    baseGrid = sameDirectionAxes[0];

            Plane plane = new Plane(XYZ.BasisX, XYZ.BasisY, XYZ.Zero);

            List <IFCAnyHandle> ifcGridAxes = new List <IFCAnyHandle>();

            foreach (Grid grid in sameDirectionAxes)
            {
                // Because the IfcGrid is a collection of Revit Grids, any one of them can override the IFC CAD Layer.
                // We will take the first name, and not do too much checking.
                if (string.IsNullOrWhiteSpace(gridRepresentationData.m_IFCCADLayer))
                {
                    ParameterUtil.GetStringValueFromElementOrSymbol(grid, "IFCCadLayer", out gridRepresentationData.m_IFCCADLayer);
                }

                // Get the handle of curve.
                XYZ             projectionDirection = plane.Normal;
                IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, plane, projectionDirection, false);
                ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, grid.Curve, XYZ.Zero, false);
                IList <IFCAnyHandle> curves = info.GetCurves();
                if (curves.Count != 1)
                {
                    throw new Exception("IFC: expected 1 curve when export curve element.");
                }

                IFCAnyHandle axisCurve = curves[0];

                bool sameSense = true;
                if (baseGrid.Curve is Line)
                {
                    Line baseLine = baseGrid.Curve as Line;
                    Line axisLine = grid.Curve as Line;
                    sameSense = (axisLine.Direction.IsAlmostEqualTo(baseLine.Direction));
                }

                IFCAnyHandle ifcGridAxis = IFCInstanceExporter.CreateGridAxis(ifcFile, grid.Name, axisCurve, sameSense);
                ifcGridAxes.Add(ifcGridAxis);

                HashSet <IFCAnyHandle> AxisCurves = new HashSet <IFCAnyHandle>();
                AxisCurves.Add(axisCurve);

                IFCAnyHandle repItemHnd = IFCInstanceExporter.CreateGeometricCurveSet(ifcFile, AxisCurves);

                // get the weight and color from the GridType to create the curve style.
                GridType gridType = grid.Document.GetElement(grid.GetTypeId()) as GridType;

                IFCData curveWidth = null;
                if (ExporterCacheManager.ExportOptionsCache.ExportAnnotations)
                {
                    int    outWidth;
                    double width =
                        (ParameterUtil.GetIntValueFromElement(gridType, BuiltInParameter.GRID_END_SEGMENT_WEIGHT, out outWidth) != null) ? outWidth : 1;
                    curveWidth = IFCDataUtil.CreateAsPositiveLengthMeasure(width);
                }

                int outColor;
                int color =
                    (ParameterUtil.GetIntValueFromElement(gridType, BuiltInParameter.GRID_END_SEGMENT_COLOR, out outColor) != null) ? outColor : 0;
                double blueVal  = 0.0;
                double greenVal = 0.0;
                double redVal   = 0.0;
                GeometryUtil.GetRGBFromIntValue(color, out blueVal, out greenVal, out redVal);
                IFCAnyHandle colorHnd = IFCInstanceExporter.CreateColourRgb(ifcFile, null, redVal, greenVal, blueVal);

                BodyExporter.CreateCurveStyleForRepItem(exporterIFC, repItemHnd, curveWidth, colorHnd);

                HashSet <IFCAnyHandle> curveSet = new HashSet <IFCAnyHandle>();
                curveSet.Add(repItemHnd);

                gridRepresentationData.m_Grids.Add(grid);
                gridRepresentationData.m_curveSets.Add(curveSet);
            }

            return(ifcGridAxes);
        }
Esempio n. 33
0
    public static void MergeIn(this Container2D <GenSpace> arr, int x, int y, GenDeploy deploy, Theme theme, GridType type = GridType.Floor, bool typeOnlyDefault = true, bool themeOnlyDefault = false)
    {
        GenSpace space;

        if (!arr.TryGetValue(x, y, out space))
        {
            space     = new GenSpace(type, theme, x, y);
            arr[x, y] = space;
        }
        else
        {
            if (!themeOnlyDefault)
            {
                space.Theme = theme;
            }
            if (!typeOnlyDefault)
            {
                space.Type = type;
            }
        }
        space.AddDeploy(deploy, x, y);
    }
Esempio n. 34
0
 private void Go_To_RepositorySelectGrid(object sender, System.Windows.RoutedEventArgs e)
 {
     FileViewerGrid.Visibility = Visibility.Hidden;
     MainMenuGrid.Visibility = Visibility.Hidden;
     CommitHistoryGrid.Visibility = Visibility.Hidden;
     RepositoryCreationGrid.Visibility = Visibility.Hidden;
     RepositorySelectGrid.Visibility = Visibility.Visible;
     CommitGrid.Visibility = Visibility.Hidden;
     LoginGrid.Visibility = Visibility.Hidden;
     PullGrid.Visibility = Visibility.Hidden;
     RepositoryMainGrid.Visibility = Visibility.Hidden;
     OpenRepoGrid.Visibility = Visibility.Hidden;
     SettingsMenuGrid.Visibility = Visibility.Hidden;
     HelpGrid.Visibility = Visibility.Hidden;
     lastGrid = GridType.RepositorySelect;
 }
Esempio n. 35
0
 public Grid(Point location, GridType type, int level)
 {
     Location = location;
     Type     = type;
     Level    = level;
 }
Esempio n. 36
0
 public void GridTypeClick()
 {
     this.currentType = (GridType)this.GridSlider.value;
     this.GridTypeText.text = this.currentType.ToString ().Replace('_','-');
 }
Esempio n. 37
0
        public static void AddTilesToGroup(string location, Vector2 tile, ref PipeGroup group, Dictionary <Vector2, GridPipe> pipeDict, GridType gridType)
        {
            Vector2[] adjecents = new Vector2[] { tile + new Vector2(0, 1), tile + new Vector2(1, 0), tile + new Vector2(-1, 0), tile + new Vector2(0, -1) };

            foreach (var a in adjecents)
            {
                if (group.pipes.Contains(a) || !pipeDict.ContainsKey(a))
                {
                    continue;
                }
                if (PipesAreJoined(location, tile, a, gridType))
                {
                    group.pipes.Add(a);
                    pipeDict.Remove(a);
                    //SMonitor.Log($"Adding pipe to group; {group.pipes.Count} pipes in group; total power: {group.input}");
                    AddTilesToGroup(location, a, ref group, pipeDict, gridType);
                }
            }
        }
Esempio n. 38
0
 public override void ExecuteCard(CardTier _tier, GridType _moveType)
 {
     GameManager.Instance.Player.SetMovementType(_moveType);
 }
Esempio n. 39
0
        private static bool IsObjectNeeded(GameLocation location, UtilityObjectInstance obj, GridType checkType)
        {
            var type = checkType == GridType.water ? GridType.electric : GridType.water;

            foreach (var group in utilitySystemDict[location.NameOrUniqueName][type].groups)
            {
                if (group.pipes.Contains(obj.WorldObject.TileLocation))
                {
                    return(group.powerVector.Y < 0 || group.storageVector.Y < 0);
                }
            }
            return(false);
        }
Esempio n. 40
0
 public GridItem(int row, int col, GridType gridType)
 {
     this.gridX    = row;
     this.gridY    = col;
     this.gridType = gridType;
 }
Esempio n. 41
0
        static dynamic Decode(BinaryReader reader, int version, Type ensure = null, bool root = false)
        {
            Type t = DecodeID(reader);

            if (ensure != null && ensure != t)
            {
                throw new InvalidDataException();
            }

            if (t == typeof(Preferences) && root)
            {
                Preferences.AlwaysOnTop         = reader.ReadBoolean();
                Preferences.CenterTrackContents = reader.ReadBoolean();

                if (version >= 24)
                {
                    Preferences.ChainSignalIndicators  = reader.ReadBoolean();
                    Preferences.DeviceSignalIndicators = reader.ReadBoolean();
                }
                else if (version >= 23)
                {
                    Preferences.ChainSignalIndicators = Preferences.DeviceSignalIndicators = reader.ReadBoolean();
                }

                if (version >= 9)
                {
                    Preferences.LaunchpadStyle = (LaunchpadStyles)reader.ReadInt32();
                }

                if (version >= 14)
                {
                    Preferences.LaunchpadGridRotation = reader.ReadInt32() > 0;
                }

                if (version >= 24)
                {
                    Preferences.LaunchpadModel = (LaunchpadModels)reader.ReadInt32();
                }

                Preferences.AutoCreateKeyFilter   = reader.ReadBoolean();
                Preferences.AutoCreateMacroFilter = reader.ReadBoolean();

                if (version >= 11)
                {
                    Preferences.AutoCreatePattern = reader.ReadBoolean();
                }

                Preferences.FadeSmoothness    = reader.ReadDouble();
                Preferences.CopyPreviousFrame = reader.ReadBoolean();

                if (version >= 7)
                {
                    Preferences.CaptureLaunchpad = reader.ReadBoolean();
                }

                Preferences.EnableGestures = reader.ReadBoolean();

                if (version >= 7)
                {
                    Preferences.PaletteName   = reader.ReadString();
                    Preferences.CustomPalette = new Palette((from i in Enumerable.Range(0, 128) select(Color) Decode(reader, version)).ToArray());
                    Preferences.ImportPalette = (Palettes)reader.ReadInt32();

                    Preferences.Theme = (ThemeType)reader.ReadInt32();
                }

                if (version >= 10)
                {
                    Preferences.Backup   = reader.ReadBoolean();
                    Preferences.Autosave = reader.ReadBoolean();
                }

                if (version >= 12)
                {
                    Preferences.UndoLimit = reader.ReadBoolean();
                }

                if (version <= 0)
                {
                    Preferences.DiscordPresence = true;
                    reader.ReadBoolean();
                }
                else
                {
                    Preferences.DiscordPresence = reader.ReadBoolean();
                }

                Preferences.DiscordFilename = reader.ReadBoolean();

                ColorHistory.Set(
                    (from i in Enumerable.Range(0, reader.ReadInt32()) select(Color) Decode(reader, version)).ToList()
                    );

                if (version >= 2)
                {
                    MIDI.Devices = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Launchpad) Decode(reader, version)).ToList();
                }

                if (version >= 15)
                {
                    Preferences.Recents = (from i in Enumerable.Range(0, reader.ReadInt32()) select reader.ReadString()).ToList();
                }

                if (version >= 25)
                {
                    Preferences.VirtualLaunchpads = (from i in Enumerable.Range(0, reader.ReadInt32()) select reader.ReadInt32()).ToList();
                }

                if (15 <= version && version <= 22)
                {
                    reader.ReadString();
                    reader.ReadString();
                }

                if (version >= 23)
                {
                    Preferences.Crashed   = reader.ReadBoolean();
                    Preferences.CrashPath = reader.ReadString();
                }

                if (version >= 16)
                {
                    Preferences.CheckForUpdates = reader.ReadBoolean();
                }

                if (version >= 17)
                {
                    Preferences.BaseTime = reader.ReadInt64();
                }

                return(null);
            }
            else if (t == typeof(Copyable))
            {
                return(new Copyable()
                {
                    Contents = (from i in Enumerable.Range(0, reader.ReadInt32()) select(ISelect) Decode(reader, version)).ToList()
                });
            }
            else if (t == typeof(Project))
            {
                int   bpm    = reader.ReadInt32();
                int[] macros = (version >= 25)? (from i in Enumerable.Range(0, 4) select reader.ReadInt32()).ToArray() : new int[4] {
                    reader.ReadInt32(), 1, 1, 1
                };
                List <Track> tracks = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Track) Decode(reader, version)).ToList();

                string author  = "";
                long   time    = 0;
                long   started = 0;

                if (version >= 17)
                {
                    author  = reader.ReadString();
                    time    = reader.ReadInt64();
                    started = reader.ReadInt64();
                }

                return(new Project(bpm, macros, tracks, author, time, started));
            }
            else if (t == typeof(Track))
            {
                Chain     chain = (Chain)Decode(reader, version);
                Launchpad lp    = (Launchpad)Decode(reader, version);
                string    name  = reader.ReadString();

                bool enabled = true;
                if (version >= 8)
                {
                    enabled = reader.ReadBoolean();
                }

                return(new Track(chain, lp, name)
                {
                    Enabled = enabled
                });
            }
            else if (t == typeof(Chain))
            {
                List <Device> devices = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Device) Decode(reader, version)).ToList();
                string        name    = reader.ReadString();

                bool enabled = true;
                if (version >= 6)
                {
                    enabled = reader.ReadBoolean();
                }

                return(new Chain(devices, name)
                {
                    Enabled = enabled
                });
            }
            else if (t == typeof(Device))
            {
                bool collapsed = false;
                if (version >= 5)
                {
                    collapsed = reader.ReadBoolean();
                }

                bool enabled = true;
                if (version >= 5)
                {
                    enabled = reader.ReadBoolean();
                }

                Device ret = (Device)Decode(reader, version);
                ret.Collapsed = collapsed;
                ret.Enabled   = enabled;

                return(ret);
            }
            else if (t == typeof(Launchpad))
            {
                string name = reader.ReadString();
                if (name == "")
                {
                    return(MIDI.NoOutput);
                }

                InputType format = InputType.DrumRack;
                if (version >= 2)
                {
                    format = (InputType)reader.ReadInt32();
                }

                RotationType rotation = RotationType.D0;
                if (version >= 9)
                {
                    rotation = (RotationType)reader.ReadInt32();
                }

                foreach (Launchpad lp in MIDI.Devices)
                {
                    if (lp.Name == name)
                    {
                        if (lp.GetType() == typeof(Launchpad))
                        {
                            lp.InputFormat = format;
                            lp.Rotation    = rotation;
                        }
                        return(lp);
                    }
                }

                Launchpad ret;
                if (name.Contains("Virtual Launchpad "))
                {
                    ret = new VirtualLaunchpad(name, Convert.ToInt32(name.Substring(18)));
                }
                else if (name.Contains("Ableton Connector "))
                {
                    ret = new AbletonLaunchpad(name);
                }
                else
                {
                    ret = new Launchpad(name, format, rotation);
                }

                MIDI.Devices.Add(ret);

                return(ret);
            }
            else if (t == typeof(Group))
            {
                return(new Group(
                           (from i in Enumerable.Range(0, reader.ReadInt32()) select(Chain) Decode(reader, version)).ToList(),
                           reader.ReadBoolean()? (int?)reader.ReadInt32() : null
                           ));
            }

            else if (t == typeof(Choke))
            {
                return(new Choke(
                           reader.ReadInt32(),
                           (Chain)Decode(reader, version)
                           ));
            }

            else if (t == typeof(Clear))
            {
                return(new Clear(
                           (ClearType)reader.ReadInt32()
                           ));
            }

            else if (t == typeof(ColorFilter))
            {
                return(new ColorFilter(
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble()
                           ));
            }

            else if (t == typeof(Copy))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                CopyType copyType = (CopyType)reader.ReadInt32();
                GridType gridType = (GridType)reader.ReadInt32();
                bool     wrap     = reader.ReadBoolean();

                int           count;
                List <Offset> offsets = (from i in Enumerable.Range(0, count = reader.ReadInt32()) select(Offset) Decode(reader, version)).ToList();
                List <int>    angles  = (from i in Enumerable.Range(0, count) select(version >= 25)? reader.ReadInt32() : 0).ToList();

                return(new Copy(time, gate, copyType, gridType, wrap, offsets, angles));
            }
            else if (t == typeof(Delay))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                return(new Delay(time, gate));
            }
            else if (t == typeof(Fade))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                FadePlaybackType playmode = (FadePlaybackType)reader.ReadInt32();

                int             count;
                List <Color>    colors    = (from i in Enumerable.Range(0, count = reader.ReadInt32()) select(Color) Decode(reader, version)).ToList();
                List <double>   positions = (from i in Enumerable.Range(0, count) select(version <= 13)? (double)reader.ReadDecimal() : reader.ReadDouble()).ToList();
                List <FadeType> types     = (from i in Enumerable.Range(0, count - 1) select(version <= 24) ? FadeType.Linear : (FadeType)reader.ReadInt32()).ToList();

                int?expanded = null;
                if (version >= 23)
                {
                    expanded = reader.ReadBoolean()? (int?)reader.ReadInt32() : null;
                }

                return(new Fade(time, gate, playmode, colors, positions, types, expanded));
            }
            else if (t == typeof(Flip))
            {
                return(new Flip(
                           (FlipType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Hold))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                return(new Hold(
                           time,
                           gate,
                           reader.ReadBoolean(),
                           reader.ReadBoolean()
                           ));
            }
            else if (t == typeof(KeyFilter))
            {
                bool[] filter;
                if (version <= 18)
                {
                    List <bool> oldFilter = (from i in Enumerable.Range(0, 100) select reader.ReadBoolean()).ToList();
                    oldFilter.Insert(99, false);
                    filter = oldFilter.ToArray();
                }
                else
                {
                    filter = (from i in Enumerable.Range(0, 101) select reader.ReadBoolean()).ToArray();
                }

                return(new KeyFilter(filter));
            }
            else if (t == typeof(Layer))
            {
                int target = reader.ReadInt32();

                BlendingType blending = BlendingType.Normal;
                if (version >= 5)
                {
                    if (version == 5)
                    {
                        blending = (BlendingType)reader.ReadInt32();
                        if ((int)blending == 2)
                        {
                            blending = BlendingType.Mask;
                        }
                    }
                    else
                    {
                        blending = (BlendingType)reader.ReadInt32();
                    }
                }

                int range = 200;
                if (version >= 21)
                {
                    range = reader.ReadInt32();
                }

                return(new Layer(target, blending, range));
            }
            else if (t == typeof(LayerFilter))
            {
                return(new LayerFilter(
                           reader.ReadInt32(),
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Move))
            {
                return(new Move(
                           Decode(reader, version),
                           (GridType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Multi))
            {
                return(new Multi(
                           Decode(reader, version),
                           (from i in Enumerable.Range(0, reader.ReadInt32()) select(Chain) Decode(reader, version)).ToList(),
                           reader.ReadBoolean()? (int?)reader.ReadInt32() : null,
                           (MultiType)reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Output))
            {
                return(new Output(
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(MacroFilter))
            {
                return(new MacroFilter(
                           (version >= 25)? reader.ReadInt32() : 1, (from i in Enumerable.Range(0, 100) select reader.ReadBoolean()).ToArray()
                           ));
            }

            else if (t == typeof(Paint))
            {
                return(new Paint(
                           Decode(reader, version)
                           ));
            }

            else if (t == typeof(Pattern))
            {
                int repeats = 1;
                if (version >= 11)
                {
                    repeats = reader.ReadInt32();
                }

                double gate;
                if (version <= 13)
                {
                    gate = (double)reader.ReadDecimal();
                }
                else
                {
                    gate = reader.ReadDouble();
                }

                double pinch = 0;
                if (version >= 24)
                {
                    pinch = reader.ReadDouble();
                }

                List <Frame> frames = (from i in Enumerable.Range(0, reader.ReadInt32()) select(Frame) Decode(reader, version)).ToList();
                PlaybackType mode   = (PlaybackType)reader.ReadInt32();

                bool chokeenabled = false;
                int  choke        = 8;

                if (version <= 10)
                {
                    chokeenabled = reader.ReadBoolean();

                    if (version <= 0)
                    {
                        if (chokeenabled)
                        {
                            choke = reader.ReadInt32();
                        }
                    }
                    else
                    {
                        choke = reader.ReadInt32();
                    }
                }

                bool infinite = false;
                if (version >= 4)
                {
                    infinite = reader.ReadBoolean();
                }

                int?rootkey = null;
                if (version >= 12)
                {
                    rootkey = reader.ReadBoolean()? (int?)reader.ReadInt32() : null;
                }

                bool wrap = false;
                if (version >= 13)
                {
                    wrap = reader.ReadBoolean();
                }

                int expanded = reader.ReadInt32();

                Pattern ret = new Pattern(repeats, gate, pinch, frames, mode, infinite, rootkey, wrap, expanded);

                if (chokeenabled)
                {
                    return(new Choke(choke, new Chain(new List <Device>()
                    {
                        ret
                    })));
                }

                return(ret);
            }
            else if (t == typeof(Preview))
            {
                return(new Preview());
            }

            else if (t == typeof(Rotate))
            {
                return(new Rotate(
                           (RotateType)reader.ReadInt32(),
                           reader.ReadBoolean()
                           ));
            }

            else if (t == typeof(Switch))
            {
                int target = (version >= 25)? reader.ReadInt32() : 1;
                int value  = reader.ReadInt32();

                if (18 <= version && version <= 21 && reader.ReadBoolean())
                {
                    return(new Group(new List <Chain>()
                    {
                        new Chain(new List <Device>()
                        {
                            new Switch(1, value), new Clear(ClearType.Multi)
                        }, "Switch Reset")
                    }));
                }

                return(new Switch(target, value));
            }
            else if (t == typeof(Tone))
            {
                return(new Tone(
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble(),
                           reader.ReadDouble()
                           ));
            }

            else if (t == typeof(Color))
            {
                byte red   = reader.ReadByte();
                byte green = reader.ReadByte();
                byte blue  = reader.ReadByte();

                if (version == 24)
                {
                    if (red > 0)
                    {
                        red = (byte)((red - 1) * 62.0 / 126 + 1);
                    }
                    if (green > 0)
                    {
                        green = (byte)((green - 1) * 62.0 / 126 + 1);
                    }
                    if (blue > 0)
                    {
                        blue = (byte)((blue - 1) * 62.0 / 126 + 1);
                    }
                }

                return(new Color(red, green, blue));
            }
            else if (t == typeof(Frame))
            {
                Time time;
                if (version <= 2)
                {
                    time = new Time(
                        reader.ReadBoolean(),
                        Decode(reader, version),
                        reader.ReadInt32()
                        );
                }
                else
                {
                    time = Decode(reader, version);
                }

                Color[] screen;
                if (version <= 19)
                {
                    List <Color> oldScreen = (from i in Enumerable.Range(0, 100) select(Color) Decode(reader, version)).ToList();
                    oldScreen.Insert(99, new Color(0));
                    screen = oldScreen.ToArray();
                }
                else
                {
                    screen = (from i in Enumerable.Range(0, 101) select(Color) Decode(reader, version)).ToArray();
                }

                return(new Frame(time, screen));
            }
            else if (t == typeof(Length))
            {
                return(new Length(
                           reader.ReadInt32()
                           ));
            }

            else if (t == typeof(Offset))
            {
                int x = reader.ReadInt32();
                int y = reader.ReadInt32();

                bool absolute = false;
                int  ax       = 5;
                int  ay       = 5;
                if (version >= 25)
                {
                    absolute = reader.ReadBoolean();
                    ax       = reader.ReadInt32();
                    ay       = reader.ReadInt32();
                }

                return(new Offset(x, y, absolute, ax, ay));
            }
            else if (t == typeof(Time))
            {
                return(new Time(
                           reader.ReadBoolean(),
                           Decode(reader, version),
                           reader.ReadInt32()
                           ));
            }

            throw new InvalidDataException();
        }
        public void Should_ReturnGridTypeFromString(string gridType)
        {
            var result = GridType.FromString(gridType);

            Assert.Equal(result.ToString(), gridType.ToString());
        }
Esempio n. 43
0
 GridUnitData()
 {
     gridType = GridType.None;
 }
 public GridModeItem(GridType gridType, string title)
 {
     this.gridType = gridType;
     this.title    = title;
 }
Esempio n. 45
0
 public override void ExecuteCard(CardTier _tier, GridType _moveType)
 {
     MovementJokerPanelControls.sJokerTier = _tier;
 }
Esempio n. 46
0
 GoLHeightMap()
 {
     game      = new GoL_logic();
     heightMap = new GridType <int>(game.GetBoard().Width(), game.GetBoard().Height());
     means     = new HashSet <float>();
 }
Esempio n. 47
0
        Stream(ArrayList data, GridType gridType)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(GridType)));

            // no data at this level
        }
Esempio n. 48
0
        public override string ToString()
        {
            StringBuilder strRet = new StringBuilder();

            strRet.Append("_emptyField: ''");
            if (DataType != string.Empty)
            {
                strRet.AppendFormat(", datatype:'{0}'", DataType);
            }
            if (GridType != null)
            {
                strRet.AppendFormat(", GridType:'{0}'", GridType.ToString());
            }
            if (URL != string.Empty)
            {
                strRet.AppendFormat(", url:'{0}'", URL);
            }
            if (MType != string.Empty)
            {
                strRet.AppendFormat(", mtype:'{0}'", MType.Trim());
            }
            if (Height != null)
            {
                strRet.AppendFormat(", height:'{0}'", Height.ToString());
            }
            if (Sortable != string.Empty)
            {
                strRet.AppendFormat(", sortable:'{0}'", Sortable);
            }
            if (Width != null)
            {
                strRet.AppendFormat(", width:'{0}'", Width);
            }
            if (IsDynamic != null)
            {
                strRet.AppendFormat(", isdynamic:{0}", (bool)IsDynamic ? "true" : "false");
            }
            if (IsMultiSelect != null)
            {
                strRet.AppendFormat(", multiselect:{0}", (bool)IsMultiSelect ? "true" : "false");
            }
            if (Caption != string.Empty)
            {
                strRet.AppendFormat(", caption:'{0}'", Caption);
            }
            if (ForceFit != string.Empty)
            {
                strRet.AppendFormat(", forceFit:'{0}'", ForceFit);
            }
            if (RowNum != null)
            {
                strRet.AppendFormat(", rowNum:{0}", RowNum);
            }
            if (RowNumber != null)
            {
                strRet.AppendFormat(", rownumbers:{0}", (bool)RowNumber ? "true" : "false");
            }
            if (RowNumWidth != string.Empty)
            {
                strRet.AppendFormat(", rownumWidth:{0}", RowNumWidth);
            }
            if (SubGrid != null)
            {
                strRet.AppendFormat(", subGrid:{0}", (bool)RowNumber ? "true" : "false");
            }
            if (FooterSummary != null)
            {
                strRet.AppendFormat(", footerSummary:{0}", (bool)FooterSummary ? "true" : "false");
            }
            // column != 0 => fixed column
            if (FixedColumn != 0)
            {
                strRet.AppendFormat(", fixedcolumn:{0}", FixedColumn);
            }
            strRet.AppendFormat(", allowEdit:{0}", AllowEdit ? "true" : "false");
            strRet.AppendFormat(", allowDelete:{0}", AllowDelete ? "true" : "false");
            strRet.AppendFormat(", allowAddRow:{0}", AllowAddRow ? "true" : "false");
            strRet.AppendFormat(", numberEmptyRow:{0}", NumberEmptyRow);

            if (AdditionAttribute != string.Empty && AdditionAttribute != null)
            {
                string[] arr = AdditionAttribute.Split(',');
                if (arr.Length > 0)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        strRet.AppendFormat(", {0}: {1}", arr[i].Split(':')[0], arr[i].Split(':')[1]);
                    }
                }
            }
            return(strRet.ToString());
        }
Esempio n. 49
0
 public MazeGridStart(GridType type, Vector2 <int> xy) : base(type, xy)
 {
 }
Esempio n. 50
0
        public NuGenGrid(GridType grid)
        {

        }
Esempio n. 51
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[floorBorders.Count];

            rand = new Random(seed);

            MapArray = new Tile[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];
            GridArray = new GridType[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];

            Rooms = new DungeonArrayRoom[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"]]; //array of all rooms
            VHalls = new DungeonArrayHall[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"] - 1]; //vertical halls
            HHalls = new DungeonArrayHall[entry.FloorSettings["CellX"] - 1, entry.FloorSettings["CellY"]]; //horizontal halls
            StartRoom = new Loc2D(-1, -1);     //marks spawn point

            bool isDone;   // bool used for various purposes

            //initialize map array to empty
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    GridArray[x, y] = GridType.Blocked;
                }
            }

            //initialize all rooms+halls to closed by default
            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    Rooms[x, y] = new DungeonArrayRoom();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"] - 1; y++) {
                    VHalls[x, y] = new DungeonArrayHall();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"] - 1; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    HHalls[x, y] = new DungeonArrayHall();
                }
            }

            // path generation algorithm
            StartRoom = new Loc2D(rand.Next(0, entry.FloorSettings["CellX"]), rand.Next(0, entry.FloorSettings["CellY"])); // randomly determine start room
            Loc2D wanderer = StartRoom;

            int pathsMade = 0;
            int pathsNeeded = rand.Next(0, 6) + 5; // magic numbers, determine what the dungeon looks like (in general, paths)
            Direction4 prevDir = Direction4.None; // direction of movement
            do {
                if (rand.Next(0, (2 + pathsMade)) == 0) {//will end the current path and start a new one from the start
                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                    pathsMade++;
                    wanderer = StartRoom;
                    prevDir = Direction4.None;
                } else {
                    bool working = true;
                    do {
                        Loc2D sample = wanderer;
                        Direction4 nextDir = (Direction4)rand.Next(0, 4);
                        if (nextDir != prevDir) {//makes sure there is no backtracking
                            Operations.MoveInDirection4(ref sample, nextDir, 1);
                            prevDir = Operations.ReverseDir(nextDir);
                            if (sample.X >= 0 && sample.X < entry.FloorSettings["CellX"] && sample.Y >= 0 && sample.Y < entry.FloorSettings["CellY"]) {// a is the room to be checked after making a move between rooms
                                openHallBetween(wanderer, sample);
                                wanderer = sample;
                                working = false;
                            }
                        } else {
                            prevDir = Direction4.None;
                        }
                    } while (working);

                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                }
            } while (pathsMade < pathsNeeded);

            Rooms[StartRoom.X, StartRoom.Y].Opened = DungeonArrayRoom.RoomState.Open;

            //Determine key rooms
            isDone = false;
            do { //determine ending room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    EndRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            StartRoom = new Loc2D(-1, -1);

            isDone = false;
            do { //determine starting room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    StartRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            // begin part 2, creating ASCII map
            //create rooms

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        createRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        drawRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        padSingleRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        createVHall(i, j);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        createHHall(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        DrawHalls(VHalls[i, j]);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        DrawHalls(HHalls[i, j]);
                    }
                }
            }

            addSEpos(StartRoom, true);
            addSEpos(EndRoom, false);

            //texturing
            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    if (GridArray[x, y] == GridType.End) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.ChangeFloor, 1, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    } else if (GridArray[x, y] == GridType.Blocked) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Blocked, 0, 0, 0);

                        bool[] blockedDirs = new bool[8];
                        for (int n = 0; n < 8; n++) {
                            blockedDirs[n] = IsBlocked(x, y, (Direction8)n);
                        }
                        if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 0;
                            if (!blockedDirs[(int)Direction8.DownLeft])
                                layer += 8 * 2;

                            if (!blockedDirs[(int)Direction8.UpLeft])
                                layer += 1;

                            if (!blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            if (!blockedDirs[(int)Direction8.DownRight])
                                layer += 2;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 6;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 7;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 4;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 5;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 34;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 35;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 32;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 33;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(36, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(37, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(38, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(39, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(44, 0), 0);
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(45, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(46, 0), 0);

                    } else {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                }
            }

            GenItems();
            SpawnNpcs();
        }
Esempio n. 52
0
        public void Register(GridType type, GameObject obj)
        {
            int index = (int)type;

            m_Dic_Prefab.Add(index, obj);
        }
Esempio n. 53
0
        public GridPoint( Point pt , GridType type )
        {
            location = new Ellipse();
            location.Height = 1.5;
            location.Width = 1.5;
            location.Fill = Brushes.Black;
            location.Stroke = Brushes.Black;
            location.Visibility = Visibility.Hidden;
            location.Margin = new Thickness( pt.X - 0.75 , pt.Y - 0.75 , 0 , 0 );

            this.type = type;
        }
Esempio n. 54
0
 public GameObject GetGrid(GridType type, Transform parent, bool isworld = false)
 {
     return(GetGrid((int)type, parent, isworld));
 }
Esempio n. 55
0
        private void Stream(ArrayList data, GridType gridType)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(GridType)));

             // no data at this level
        }
Esempio n. 56
0
 /// <summary>
 /// Send merge command to the view. Will add parameter grid to the existing view structure of specific grid type.
 /// Will transform grid based on injected IGridTransform.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="grid"></param>
 public void DispatchMergeGrid(GridType type, IPartialGrid <CellDataModel> grid)
 {
     mergeGridInView.Dispatch(type, transform.GridToWorld(grid.pos), MapToViewData(grid));
 }
        public Bitmap GetEmbroidery(Bitmap image, int resolutionCoefficient, int cellsCount, Color[] palette, char[] symbols, Color symbolColor, GridType type)
        {
            log.WriteEntry(@"Come in the GetEmbroidery(...)" + Environment.NewLine +
                             "    cells count = " + cellsCount + Environment.NewLine +
                             "    resolution coefficient = " + resolutionCoefficient);
            Bitmap result = null;
            try
            {
                result = CreateEmbroidery(image, resolutionCoefficient, cellsCount, palette, symbols, symbolColor, type);
            }
            catch (Exception ex)
            {
                log.WriteEntry(@"Exception in GetEmbroidery(...) occurred
                                    Message: " + ex.Message);
                return null;
            }

            log.WriteEntry(@"GetEmbroidery was executed" + Environment.NewLine +
                            "    Result image = " + result.ToString());

            return result;
        }
Esempio n. 58
0
 public static void SetTo(this Container2D <GenSpace> cont, Point p, GridType type, Theme theme)
 {
     SetTo(cont, p.x, p.y, type, theme);
 }
Esempio n. 59
0
 public GridCell(int index, GridType gridType, Vector3 pos)
 {
     this.index = index;
     this.edges = new float[(int)gridType];
     this.position = pos;
 }
Esempio n. 60
0
 public static void SetTo(this Container2D <GenSpace> cont, int x, int y, GridType type, Theme theme)
 {
     cont[x, y] = new GenSpace(type, theme, x, y);
 }