예제 #1
0
        public void Parse_ValidValue(string inputValue, double value, GridUnitType unit)
        {
            var length = GridUtil.Parse(inputValue);

            Assert.AreEqual(value, length.Value);
            Assert.AreEqual(unit, length.GridUnitType);
        }
예제 #2
0
        public NodeGrid(Sz2 <int> strides, IEnumerable <P1V <int, float> > tuples, int generation, int seed)
        {
            Strides = strides;
            Values  = new float[Strides.Count()];
            foreach (var tup in tuples)
            {
                Values[tup.X] = tup.V;
            }

            Generation = generation;

            Seed = seed;
            var randy = GenV.Twist(Seed);

            Noise    = GenS.NormalSF32(randy, 0.0f, 1.0f).Take(Strides.Count()).ToArray();
            NextSeed = randy.Next();

            var Offhi = new P2 <int>(0, -1);
            var Offlo = new P2 <int>(0, 1);
            var Offlf = new P2 <int>(-1, 0);
            var Offrt = new P2 <int>(1, 0);

            Top    = GridUtil.OffsetIndexes(Strides, Offhi);
            Bottom = GridUtil.OffsetIndexes(Strides, Offlo);
            Left   = GridUtil.OffsetIndexes(Strides, Offlf);
            Right  = GridUtil.OffsetIndexes(Strides, Offrt);
        }
        private void Ribbon_Loaded(object sender, RoutedEventArgs e)
        {
            var ribbon1 = GridUtil.GetVisualChild <Ribbon>(sender as FrameworkElement);

            // To add the ribbon button in View tab,

            if (ribbon1 != null)
            {
                var        ribbonTab = ribbon1.Items[0] as RibbonTab;
                StackPanel panel     = new StackPanel();
                Button     Button1   = new Button();
                Button1.Content = "Undo All";
                Button Button2 = new Button();
                Button2.Content     = "Redo All";
                Button1.Background  = Brushes.White;
                Button2.Background  = Brushes.White;
                Button1.BorderBrush = Brushes.Transparent;
                Button2.BorderBrush = Brushes.Transparent;
                Button1.Margin      = new Thickness(5, 10, 5, 5);
                Button2.Margin      = new Thickness(5, 0, 5, 15);
                Button1.Padding     = new Thickness(2);
                Button2.Padding     = new Thickness(2);
                Button1.FontFamily  = new FontFamily("Segoe UI");
                Button1.Click      += button_Click;
                Button2.Click      += button1_Click;
                panel.Children.Add(Button1);
                panel.Children.Add(Button2);

                ribbonTab.Items.Add(panel);
            }
        }
        void OnCheckboxFilterControlLoaded(object sender, RoutedEventArgs e)
        {
			//Set the scrollviewer when checkboxcontrol loaded instead itemscontrol loaded event. Because template is applied after itemscontrol loaded.
            if (this.PART_ItemsControl != null)
                PartScrollViewer = GridUtil.GetChildObject<ScrollViewer>(this.PART_ItemsControl, "");
            WireEvents();
        }
        // Displays team on the next row
        // Only this function and Reset should mutate rowPosition
        private void DisplayTeam(int teamId)
        {
            // On backspace, teams dict is reset butthe handler is not removed. Buzzers that register after
            // backspace still trigger handler  but are not present in teams dict, leading to an exception.
            // Ignore click if not present in teams dict
            if (!teams.ContainsKey(teamId))
            {
                return;
            }

            TeamData teamData = teams[teamId];

            var border = GridUtil.GetUiElement <Border>(grid, rowPosition, 1);

            border.Background = teamData.Colour;

            // Write team's name on border
            var textblock = (TextBlock)border.Child;

            textblock.Text     = teamData.Name;
            textblock.FontSize = border.ActualHeight / 4;

            // Increment rowPosition in preparation for next display
            rowPosition += 2;
        }
예제 #6
0
    private static void ExpandNode(Node current, NVector2 to, ref PriorityQueue <Node> openlist, ref HashSet <Node> closedlist, int heurFactor = 1)
    {
        for (int i = 0; i < NeighborOffset.Length; ++i)
        {
            var offset = NeighborOffset[i];
            var child  = new Node(current.point + offset);
            child.parent = current;

            // check if point available
            if (!GridUtil.IsPassable(child.point))
            {
                continue;
            }

            if (closedlist.Contains(child))
            {
                continue;
            }
            child.distance = current.distance + 1;
            var heur = heurFactor * (int)currentHeuristicFunc(child.point, to);
            if (openlist.Contains(child, heur))
            {
                continue;
            }

            openlist.Enqueue(child, heur);
        }
    }
예제 #7
0
        public void TestCoordsForGridIndex()
        {
            var colCount = 7;

            var row    = 1;
            var col    = 2;
            var dex    = row * colCount + col;
            var coords = GridUtil.CoordsForGridIndex(colCount, dex);

            Assert.AreEqual(col, coords.X);
            Assert.AreEqual(row, coords.Y);

            row    = 11;
            col    = 5;
            dex    = row * colCount + col;
            coords = GridUtil.CoordsForGridIndex(colCount, dex);
            Assert.AreEqual(col, coords.X);
            Assert.AreEqual(row, coords.Y);

            row    = 9;
            col    = 1;
            dex    = row * colCount + col;
            coords = GridUtil.CoordsForGridIndex(colCount, dex);
            Assert.AreEqual(col, coords.X);
            Assert.AreEqual(row, coords.Y);
        }
예제 #8
0
    public static List <NVector2> Path(NVector2 from, NVector2 to, int max_depth = 10, int distance = 0, int heurFactor = 1)
    {
        PriorityQueue <Node> openlist   = new PriorityQueue <Node>();
        HashSet <Node>       closedlist = new HashSet <Node>();

        openlist.Enqueue(new Node(from));

        distance = GridUtil.IsPassable(to) ? 0 : distance;

        do
        {
            var current = openlist.Dequeue();
            if (current.point == to || currentHeuristicFunc(current.point, to) <= distance)
            {
                List <NVector2> outlist = new List <NVector2>();
                outlist.Add(current.point);
                while (current.parent != null)
                {
                    current = current.parent;
                    outlist.Insert(0, current.point);
                }
                return(outlist);
            }
            closedlist.Add(current);

            if (current.distance >= max_depth)
            {
                break;
            }
            ExpandNode(current, to, ref openlist, ref closedlist, heurFactor: heurFactor);
        } while (!openlist.Empty);

        return(new List <NVector2>());
    }
예제 #9
0
        internal Rect GetCellPosition(int index)
        {
            var visibleLines = this.DataGrid.VisualContainer.ScrollColumns.GetVisibleLines();

            // below condition is added to avoid the crash if parent grid visible columns count is less
            if (visibleLines.firstBodyVisibleIndex == visibleLines.Count)
            {
                return(Rect.Empty);
            }
            if (this.DataGrid.View != null && index == this.DataGrid.View.GroupDescriptions.Count + 1 + (this.DataGrid.showRowHeader ? 1 : 0))
            {
                return(GetDetailsViewContentPosition());
            }
            var visibleRow    = this.DataGrid.VisualContainer.ScrollRows.GetVisibleLineAtLineIndex(RowIndex);
            var visivleColumn = this.DataGrid.VisualContainer.ScrollColumns.GetVisibleLineAtLineIndex(index);

            if (visibleRow != null && visivleColumn != null)
            {
                var rect = GridUtil.FromLTRB(visivleColumn.ClippedOrigin, visibleRow.ClippedOrigin, visivleColumn.ClippedCorner, visibleRow.ClippedCorner);
                rect.Y = 0;
                if (!visibleRow.IsClipped && visibleRow.isLastLine && visibleRow.ClippedCornerExtent < 0)
                {
                    rect.Height += visibleRow.ClippedCornerExtent;
                }
                return(rect);
            }
            return(Rect.Empty);
        }
예제 #10
0
        private Rect GetDetailsViewContentPosition()
        {
            var visibleLines = this.DataGrid.VisualContainer.ScrollColumns.GetVisibleLines();
            var visibleRow   = this.DataGrid.VisualContainer.ScrollRows.GetVisibleLineAtLineIndex(RowIndex);
            var startIndex   = (this.DataGrid.View != null ? this.DataGrid.View.GroupDescriptions.Count : 0) + 1 + (this.DataGrid.showRowHeader ? 1 : 0);
            int repeatValue;

            if (this.DataGrid.VisualContainer.ColumnWidths.GetHidden(startIndex, out repeatValue))
            {
                startIndex += repeatValue;
            }
            var firstVisibleColumn = this.DataGrid.VisualContainer.ScrollColumns.GetVisibleLineAtLineIndex(startIndex) ?? visibleLines[visibleLines.FirstBodyVisibleIndex];
            var lastVisibleColumn  = visibleLines[visibleLines.LastBodyVisibleIndex];

            if (visibleRow != null && firstVisibleColumn != null && lastVisibleColumn != null)
            {
                var rect = GridUtil.FromLTRB(firstVisibleColumn.ClippedOrigin, visibleRow.ClippedOrigin, lastVisibleColumn.ClippedCorner, visibleRow.ClippedCorner);
                rect.Y = 0;
                if (!visibleRow.IsClipped && visibleRow.isLastLine && visibleRow.ClippedCornerExtent < 0)
                {
                    rect.Height += visibleRow.ClippedCornerExtent;
                }
                return(rect);
            }
            return(Rect.Empty);
        }
예제 #11
0
        private void DrawPageNumberinRect(Rectangle rect, int pageNo, PaintEventArgs pe)
        {
            if (rect.Width > 100 && rect.Height > 100)
            {
                string s = string.Format("page {0}", pageNo);
                using (Font f = new Font(grid.Font.FontFamily, 40))
                {
                    Size      sz = TextRenderer.MeasureText(s, f);
                    Rectangle r  = GridUtil.CenterInRect(rect, sz);

                    DrawPageNumberEventArgs e = new DrawPageNumberEventArgs(pe, r, s);
                    OnDrawPageNumber(e);
                    if (!e.Cancel)
                    {
                        using (Brush b = new SolidBrush(TextColor))
                        {
                            Region region = pe.Graphics.Clip;
                            pe.Graphics.Clip = new Region(grid.RangeInfoToRectangle(grid.ViewLayout.VisibleCellsRange));
                            pe.Graphics.DrawString(s, f, b, r);
                            pe.Graphics.Clip = region;
                        }
                    }
                }
            }
        }
예제 #12
0
        /// <override/>
        protected override Rectangle OnLayout(int rowIndex, int colIndex, GridStyleInfo style, Rectangle innerBounds, Rectangle[] buttonsBounds)
        {
            ButtonEditStyleProperties sp = new ButtonEditStyleProperties(style);
            bool isRightToLeft           = false;

            if (this.Grid.RightToLeft == RightToLeft.Inherit && Grid.IsRightToLeft() || style.RightToLeft == RightToLeft.Yes)
            {
                isRightToLeft = true;
            }

            // Here you specify where the button should be drawn within the cell.
            if (sp.ButtonEditInfo.IsLeft ^ isRightToLeft)
            {
                // Draw left
                Rectangle rightArea = Rectangle.FromLTRB(innerBounds.Left, innerBounds.Top, innerBounds.Left + sp.ButtonEditInfo.Width, innerBounds.Bottom);
                buttonsBounds[0] = GridUtil.CenterInRect(rightArea, new Size(sp.ButtonEditInfo.Width, 20));

                // Here you return the area where the text should be drawn/edited.
                innerBounds.Width -= sp.ButtonEditInfo.Width;
                innerBounds.Offset(sp.ButtonEditInfo.Width, 0);
            }
            else
            {
                // Draw right
                // Here you specify where the button should be drawn within the cell.
                Rectangle rightArea = Rectangle.FromLTRB(innerBounds.Right - sp.ButtonEditInfo.Width, innerBounds.Top, innerBounds.Right, innerBounds.Bottom);
                buttonsBounds[0] = GridUtil.CenterInRect(rightArea, new Size(sp.ButtonEditInfo.Width, 20));

                // Here you return the area where the text should be drawn/edited.
                innerBounds.Width -= sp.ButtonEditInfo.Width;
            }
            return(innerBounds);
        }
예제 #13
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            // No teams on screen
            if (lastActiveRowPosition < FIRST_DATA_ROW)
            {
                MessageBox.Show("At least 1 team is required.",
                                "Press Esc to close this message box");

                return;
            }

            for (int i = 0; i <= MainPageUtil.GridRowToId(lastActiveRowPosition); i++)
            {
                // Team has no registered mouse
                if (deviceIds[i] == -1)
                {
                    var textBox = GridUtil.GetUiElement <MultipointTextBox>(mainWindowGrid, MainPageUtil.RowIdToGridRow(i), TEXTBOX_COL);

                    MessageBox.Show("The team '" + textBox.Text +
                                    "' at row " + (i + 1) + " does not have a mouse registered. Please register a mouse or delete the team before starting.",
                                    "Press Esc to close this message box");

                    return;
                }
            }

            KeyDown   -= KeyDown_Event_Main;
            KeyDown   += KeyDown_Event_Game;
            gameWindow = new GameWindow();
            // Remember team entries
            mainPageContent = Content;
            Content         = gameWindow.Content;
        }
예제 #14
0
        private bool IsKeyboardFocusWithin <T>(T uiElement, T focusedElement) where T : DependencyObject
        {
            List <DependencyObject> childrens = new List <DependencyObject>();

            GridUtil.Descendant(uiElement, ref childrens);
            return(childrens.Contains(focusedElement));
        }
예제 #15
0
        private void ribbon_Loaded(object sender, RoutedEventArgs e)
        {
            sfribbon = GridUtil.GetVisualChild <Ribbon>(sender as SfSpreadsheetRibbon);
            var backstage = sfribbon.BackStage;

            foreach (var item in backstage.Items)
            {
                if (item is BackStageCommandButton)
                {
                    var button = item as BackStageCommandButton;
                    var header = button.Header;
                    if (button.Header.Contains("Open"))
                    {
                        button.Click += FileOpen;
                    }
                    else if (button.Header.Contains("Save As"))
                    {
                        button.Click += SaveAs;;
                    }
                    else if (button.Header.Contains("Save"))
                    {
                        button.Click += Save;;
                    }
                }
            }
        }
예제 #16
0
        protected override void OnEditElementLoaded(object sender, RoutedEventArgs e)
        {
            var combobox = ((ComboBox)sender);

#if WPF
            combobox.Focus();

            TextBox comboTextBox = (TextBox)GridUtil.FindDescendantChildByType(combobox, typeof(TextBox));

            if (combobox.IsEditable)
            {
                if (this.TreeGrid.EditorSelectionBehavior == EditorSelectionBehavior.SelectAll)
                {
                    comboTextBox.SelectAll();
                }
                else
                {
                    comboTextBox.Select(comboTextBox.SelectedText.Length, 0);
                }
            }
#endif
#if UWP
            combobox.Focus(FocusState.Programmatic);
#endif

            combobox.SelectionChanged += SelectionChangedinComboBox;
            //#if WPF
            //            combobox.PreviewMouseDown += PreviewMouseDown;
            //#endif
        }
예제 #17
0
        public void Paint(Graphics g, Rectangle clipRectangle)
        {
            var enumer = GridUtil.EnumerateCoveringIndices(
                clipRectangle,
                new Size(this.tileSize, this.tileSize),
                new Size(this.map.Width, this.map.Height));

            using (Brush backgroundBrush = new SolidBrush(this.BackgroundColor))
            {
                foreach (var p in enumer)
                {
                    var img = this.map.Get(p.X, p.Y);
                    if (img != null)
                    {
                        g.DrawImageUnscaled(
                            this.map.Get(p.X, p.Y),
                            p.X * this.tileSize,
                            p.Y * this.tileSize);
                    }
                    else
                    {
                        g.FillRectangle(
                            backgroundBrush,
                            p.X * this.tileSize,
                            p.Y * this.tileSize,
                            this.tileSize,
                            this.tileSize);
                    }
                }
            }
        }
예제 #18
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         tryAddNode();
     }
     if (Input.GetMouseButtonDown(1))
     {
         tryRemoveNode();
     }
     //spawn train at highlighted node.
     if (Input.GetKeyDown(KeyCode.T))
     {
         GameObject obj = GridUtil.getGameObjectAtCursor(m_camera);
         if (obj != null && obj.layer == LayerMask.NameToLayer("Nodes"))
         {
             m_lineEditor.addTrainForCurrentLineAtNode(obj, false);
         }
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.Quit();
     }
     if (Input.GetKeyDown(KeyCode.P))
     {
         PausableMonoBehavior.m_paused = !PausableMonoBehavior.m_paused;
     }
     if (Input.GetKeyDown(KeyCode.N))
     {
         m_lineEditor.startNewLine();
     }
 }
예제 #19
0
 protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
 {
     activeControl        = Grid.Model[rowIndex, colIndex].Tag as Control;
     clientRectangle.Size = GridUtil.Max(clientRectangle.Size, activeControl.Size);
     style.Control        = activeControl;
     base.OnDraw(g, clientRectangle, rowIndex, colIndex, style);
 }
예제 #20
0
    void OnEnterField(bool step)
    {
        if (!step)
        {
            return;
        }
        if (!this.enabled)
        {
            return;
        }

        if (PlayerActor.Instance.GridPosition != GridUtil.WorldToGrid(terminalField.position))
        {
            animator.SetBool("Active", false);

            if (currentActiveTerminal == this)
            {
                currentActiveTerminal = null;
            }
            return;
        }

        animator.SetBool("Active", true);
        currentActiveTerminal = this;
    }
예제 #21
0
        private void ColourSelect_Click(object sender, RoutedEventArgs e)
        {
            SolidColorBrush fill;

            try
            {
                fill = GetNextUnassignedColour();
            }
            // Should never happen since num colours > num teams
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Press Esc to close this message box");
                return;
            }

            var btn     = (MultipointButton)sender;
            var gridRow = Grid.GetRow(btn);
            var rowId   = MainPageUtil.GridRowToId(gridRow);

            var colourSelectBtn = GridUtil.GetUiElement <MultipointButton>(mainWindowGrid, gridRow, COLOUR_SELECT_COL);

            var rect = (Rectangle)btn.Content;

            rect.Fill = fill;

            // Mark current fill as unused
            coloursUsed.Remove(rowColours[rowId]);

            // Mark new fill as used
            coloursUsed.Add(fill.Color);
            rowColours[rowId] = fill.Color;
        }
예제 #22
0
        // Mouse registration
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            int btnRow   = Grid.GetRow((MultipointButton)sender);
            int rowId    = MainPageUtil.GridRowToId(btnRow);
            int deviceId = ((MultipointMouseEventArgs)e).DeviceInfo.Id;

            // If mouse already registered for a different team
            if (DataStore.teams.ContainsKey(deviceId) && deviceIds[rowId] != deviceId)
            {
                MessageBox.Show("This mouse has already been assigned to team '" + DataStore.teams[deviceId].Name +
                                "'. Please delete the team entry before re-assigning this mouse.",
                                "Press Esc to close this message box");
            }
            else
            {
                var didSave = SaveTeam(deviceId, btnRow, rowId);
                if (didSave)
                {
                    // Remove confirm button so user doesn't think device registration can be overriden
                    GridUtil.RemoveUiElement <MultipointButton>(mainWindowGrid, btnRow, REGISTER_BTN_COL);
                    // Lock team colour
                    var colourSelect = GridUtil.GetUiElement <MultipointButton>(mainWindowGrid, btnRow, COLOUR_SELECT_COL);
                    colourSelect.MultipointClick -= ColourSelect_Click;
                }
            }
        }
예제 #23
0
        //Used to create own footer
        void pd_DrawGridPrintFooter(object sender, Syncfusion.GridHelperClasses.GridPrintHeaderFooterTemplateArgs e)
        {
            //Get the rectangle area to draw
            Rectangle footer = e.DrawRectangle;

            //Draw copy right
            StringFormat format = new StringFormat();

            format.LineAlignment = StringAlignment.Center;
            format.Alignment     = StringAlignment.Center;
            Font       font  = new Font("Helvetica", 8);
            SolidBrush brush = new SolidBrush(Color.Red);

            e.Graphics.DrawString("@copyright", font, brush, GridUtil.CenterPoint(footer), format);

            //Draw page number
            format.LineAlignment = StringAlignment.Far;
            format.Alignment     = StringAlignment.Far;
            e.Graphics.DrawString(string.Format("page {0} of {1}", e.PageNumber, e.PageCount), font, brush, new Point(footer.Right - 100, footer.Bottom - 20), format);

            //Dispose resources
            format.Dispose();
            font.Dispose();
            brush.Dispose();
        }
예제 #24
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            int btnRow = Grid.GetRow((MultipointButton)sender);
            int rowId  = MainPageUtil.GridRowToId(btnRow);

            // Remove controls
            GridUtil.RemoveUiElement <MultipointButton>(mainWindowGrid, btnRow, DEL_BTN_COL);
            GridUtil.RemoveUiElement <MultipointTextBox>(mainWindowGrid, btnRow, TEXTBOX_COL);
            GridUtil.RemoveUiElement <MultipointButton>(mainWindowGrid, btnRow, REGISTER_BTN_COL);
            GridUtil.RemoveUiElement <MultipointButton>(mainWindowGrid, btnRow, COLOUR_SELECT_COL);

            // Shift controls up
            var elements = mainWindowGrid.Children;

            for (int i = 0; i < elements.Count; i++)
            {
                for (int row = btnRow + 2; row <= MAX_LAST_ACTIVE_ROW_POS; row += 2)
                {
                    if (Grid.GetRow(elements[i]) == row)
                    {
                        Control control = (Control)elements[i];
                        Grid.SetRow(control, row - 2);
                        break;
                    }
                }
            }

            DataStore.teams.Remove(deviceIds[MainPageUtil.GridRowToId(btnRow)]);
            Util.LeftShiftArray(deviceIds, rowId, -1);

            coloursUsed.Remove(rowColours[rowId]);
            Util.LeftShiftArray(rowColours, rowId, default(Color));

            lastActiveRowPosition -= 2;
        }
예제 #25
0
        private void Tick(object sender, EventArgs e)
        {
            User32.GetCursorPos(out var p);
            this.Text = $"({p.X}, {p.Y})";

            using (var screenshot = this.tracker.GetScreenshot())
            {
                var grid   = GridUtil.GetGridFromScreeshot(screenshot, this.CurrentGameMode);
                var blocks = Analizer.AnalizeGridImage(this.templates, grid);
                this.lastGrid = blocks;

                (var output, var overlay) = GenerateOutput(blocks);

                this.pcGrid.Image   = grid;
                this.pcOutput.Image = output;

                if (this.overlayForm != null)
                {
                    this.overlayForm.SetImage(overlay);
                    var offset = GridLocator.LocateGrid(this.CurrentGameMode);
                    var rect   = this.tracker.GetWindowRect();
                    this.overlayForm.Location = new Point(rect.Left + offset.X, rect.Top + offset.Y);
                }
            }
        }
예제 #26
0
        private void UndoOverlapRelativeToComponent(int x, int y, ModelView model)
        {
            int positionX = GridUtil.TransformPositionRelative(Bounds.CenterX, x, model.gridSize);
            int positionY = GridUtil.TransformPositionRelative(Bounds.CenterY, y, model.gridSize);

            if (positionX >= 0 && positionX <= model.gridSize - 1 &&
                positionY >= 0 && positionY <= model.gridSize - 1)
            {
                foreach (Block block in model.Grid[positionX, positionY].ToArray())
                {
                    if (block.Bounds.Equals(Bounds))
                    {
                        continue;
                    }
                    if (!IsIntersection(block.Bounds, Bounds))
                    {
                        continue;
                    }

                    switch (block.Type)
                    {
                    case BlockType.GROUND:
                    case BlockType.OBSTACLE:
                        HandleGroundCollision(block);
                        break;

                    case BlockType.ENEMY:
                        if (IsIntersection(block.Bounds, Hitbox))
                        {
                            onEnemyCollision?.Invoke(block, null);
                        }
                        break;

                    case BlockType.PLAYER:
                        break;

                    case BlockType.BOMB:
                        onBombCollision?.Invoke(this, null);
                        if (!(this is Player))
                        {
                            HandleGroundCollision(block);
                        }
                        break;

                    case BlockType.PORTAL:
                        onPortalCollision?.Invoke(block, null);
                        break;

                    case BlockType.ITEM:
                        onItemCollision?.Invoke(block, null);
                        break;

                    case BlockType.INVISIBLE_ENEMY_BARRIER:
                        HandleInvisibleEnemyBarrierCollision(block);
                        break;
                    }
                }
            }
        }
예제 #27
0
        private void OnSceneGUI()
        {
            var up_quat = Quaternion.Euler(90, 0, 0);

            var     points = serializedObject.FindProperty("waypoints").FindPropertyRelative("points");
            Vector3 p1 = Vector3.zero, p2 = Vector3.zero;

            Handles.color = Color.red;
            for (int i = 0; i < points.arraySize; ++i)
            {
                var point = points.GetArrayElementAtIndex(i);
                var x     = point.FindPropertyRelative("x").intValue;
                var y     = point.FindPropertyRelative("y").intValue;

                p2 = GridUtil.GridToWorld(new Vector2(x, y));
                if (i != 0)
                {
                    Handles.DrawLine(p1, p2);
                }
                p1 = p2;
                Handles.RectangleHandleCap(i, p1, up_quat, 0.2f, EventType.Repaint);
            }

            // --------------
            if (!visualmode)
            {
                return;
            }

            var plane = new Plane(Vector3.up, Vector3.zero);

            float enter;
            var   ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

            plane.Raycast(ray, out enter);
            var hitpoint = ray.GetPoint(enter);
            var tile     = GridUtil.WorldToGrid(hitpoint);

            Handles.color = new Color(1f, 0.45f, 0f);
            Handles.DrawDottedLine(p1, GridUtil.GridToWorld(tile), 5);

            if (Handles.Button(GridUtil.GridToWorld(tile) + Vector3.up * 0.1f, up_quat, 0.5f, 0.5f, Handles.RectangleHandleCap))
            {
                //active.Tiles[tile_y*active.TileMapWidth + tile_x] = selectedTile;
                //active.OnValidate();
                var selected_point = new NVector2(tile);
                var pat            = (target as PatrouilleBehaviour);
                if (pat.waypoints.points.Contains(selected_point))
                {
                    pat.waypoints.points.Remove(selected_point);
                }
                else
                {
                    pat.waypoints.points.Add(selected_point);
                }
                SceneView.RepaintAll();
                EditorUtility.SetDirty(target);
            }
        }
예제 #28
0
 private void HeaderBackground()
 {
     if (headerBg.SelectedItem != null)
     {
         this.grid.Model.HeaderStyle.Background = new SolidColorBrush(GridUtil.GetXamlConvertedValue<Color>(headerBg.SelectedItem.ToString()));
         this.grid.InvalidateCells();
     }
 }
예제 #29
0
        private void Awake()
        {
            grids        = FindObjectsOfType <MyGrid>();
            myProperties = FindObjectOfType <MapDesignerProperties>();
            gridUtil     = GetComponent <GridUtil>();

            sV = FindObjectOfType <SharedVariables>();
        }
예제 #30
0
 void selectLineForNode()
 {
     GameObject obj = GridUtil.getGameObjectAtCursor(m_camera);
     //TransportLine = obj.getCop
     //hitcast a node and select the associated route for the node.
     //if node has multiple routes associated, cycle nodes on click.
     //OR popup a UI to select?
 }