当前位置: 首页>>代码示例>>C#>>正文


C# Coords.Equals方法代码示例

本文整理汇总了C#中Coords.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Coords.Equals方法的具体用法?C# Coords.Equals怎么用?C# Coords.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coords的用法示例。


在下文中一共展示了Coords.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayXML

        internal static void DisplayXML(ListBox ListBox1, ObjectXML table)
        {
            ListBox1.Items.Clear();

            StackPanel panel1 = new StackPanel();
            panel1.Orientation = Orientation.Horizontal;
            ListBox1.VerticalAlignment = VerticalAlignment.Center;
            ListBox1.HorizontalAlignment = HorizontalAlignment.Center;

            for (int col = 0; col < table.colNum; col++)
            {
                Button button = new Button();
                Coords coords = new Coords(0, col);

                button.Name = "field" + '_' + (col + 1).ToString() + '_' + 0.ToString();
                button.DataContext = MainWindow.objectXML.header[coords.GetHashCode()];
                button.SetBinding(Button.ContentProperty, new Binding("headerCellHeader"));
                button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));

                button.Click += EditHeaderClick;
                button.Foreground = Brushes.Black;

                AlignChange(ref button, coords);
                getRes(button);

                button.Padding = new Thickness(5, 0, 5, 0);
                button.Background = Brushes.LightGray;
                button.BorderBrush = Brushes.Black;

                if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                panel1.Children.Add(button);
            }

            ListBox1.Items.Add(panel1);

            for (int row = 1; row < table.rowNum; row++)
            {

                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                for (int col = 0; col < table.colNum; col++)
                {
                    Button button = new Button();
                    Coords coords = new Coords(row, col);
                    Binding bindParam = new Binding();
                    bindParam.Source = MainWindow.objectXML.cells[coords.GetHashCode()];
                    bindParam.Path = new PropertyPath("tabCellParametr");
                    button.Name = "field" + '_' + (col + 1).ToString() + '_' + row.ToString();
                    button.SetBinding(Button.ContentProperty,bindParam);
                    button.DataContext = MainWindow.objectXML.header[new Coords(0, col).GetHashCode()];
                    button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                    button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                    button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));
                    button.Foreground = Brushes.Black;
                    button.Padding = new Thickness(5, 0, 5, 0);
                    button.Click += EditCellClick;
                    getRes(button);
                    AlignChange(ref button, coords);

                    button.Background = Brushes.LightGray;
                    button.BorderBrush = Brushes.Black;

                    if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                    panel.Children.Add(button);
                }

                ListBox1.Items.Add(panel);
            }
        }
开发者ID:KirillChernoff,项目名称:Studio,代码行数:73,代码来源:Logic.cs

示例2: isOnExplosionPath

        public bool isOnExplosionPath(Coords coord)
        {
            //check all live bombs and bomb radius
            //if coord is on the explosion path, return true
            //otherwise false
            foreach (Coords bomb in this.liveBombs) {
                LocationData datum = GetLocationData (bomb);
                int radius = datum.ExplosionRadius;
                bool test = (coord.Equals(bomb) || coord.isCardinalEastOf (bomb, radius) || coord.isCardinalNorthOf (bomb, radius) || coord.isCardinalSouthOf (bomb, radius) || coord.isCardinalWestOf (bomb, radius));
                if (test) {
                    return true;
                }
            }

            return false;
        }
开发者ID:vermagav,项目名称:bombersquad,代码行数:16,代码来源:GameState.cs

示例3: PathTo

        /// <summary>
        /// Find a path between two tiles (not necessarily only or shortest route!)
        /// </summary>
        /// <param name="from">Tile to start from</param>
        /// <param name="to">Tile to move to </param>
        /// <param name="result">List to put result path into</param>
        /// <param name="visited">TIles visited on current path (avoid circles)</param>
        /// <param name="maxlength">Maximum length of path</param>
        public void PathTo(Coords from, Backend.Coords to, out List<Coords> result, ref HashSet<Coords> visited, int maxlength = 20)
        {
            result = null;
            if (visited == null)
            {
                visited = new HashSet<Coords>();
            }
            visited.Add(from);

            if ((
                (from.x >= 0) &&
                (to.x >= 0)) &&
                (from.y >= 0) &&
                (to.y >= 0) &&
                (to.x < _width) &&
                (from.x < _width) &&
                (to.y < _height) &&
                (from.y < _height)
                && (maxlength > 0))
            {
                if (from.Equals(to))
                {
                    result = new List<Coords>();
                    result.Add(to);
                    visited.Remove(from);
                    return;
                }

                Direction dir = WhichWayIs(to, from, true); // start by direct route
                int count = 0;
                while (count < 4)
                {
                    Backend.Coords tmp = Map.DirectionTile(from, dir);

                    if ((this[tmp.x, tmp.y].canEnter) && (!visited.Contains(tmp)))
                    {
                        // System.Diagnostics.Debug.WriteLine(indent + "Looking " + dir + " of " + from + " to " + tmp);

                        PathTo(tmp, to, out result, ref visited, maxlength - 1);
                        if (result != null)
                        {
                            //   System.Diagnostics.Debug.WriteLine(indent + " - " + from.x + "/" + from.y);
                            if (result.Count > 1)
                            {
                                if ((Math.Abs(result[1].x - from.x) < 2) && (Math.Abs(result[1].y - from.y) < 2) && (CanMove(result[1], WhichWayIs(result[1], from))))
                                    result[0] = from; // Diagonals preferred

                                else result.Insert(0, from);
                            }
                            else
                            {

                                result.Insert(0, from); // Only starting point in list
                            }
                            visited.Remove(from);

                            // System.Diagnostics.Debug.WriteLine(indent + "*" + from.x + "/" + from.y + " leads over " + dir.ToString() + " to " + to.x + " / " + to.y);
                            return;

                        }
                        /*    else
                            {
                                System.Diagnostics.Debug.WriteLine(indent + from.x + "/" + from.y + " no exit " + dir.ToString() + " to " + to.x + " / " + to.y);
                            } */
                    }
                    /*    else
                        {
                            if (!visited.Contains(tmp))
                            {
                                System.Diagnostics.Debug.WriteLine(indent + dir.ToString() + " of " + from.x + "/" + from.y + " is blocked");
                            }
                        } */
                    dir = NextDirection(dir, true);
                    count += 1;
                }

            }
            //PathTo(from, to, maxlength - 1);
            visited.Remove(from);

            return;
        }
开发者ID:propra13-orga,项目名称:gruppe22,代码行数:90,代码来源:Map.cs

示例4: getBombOnExplosionPath

        public Coords getBombOnExplosionPath(Coords coord)
        {
            //check all live bombs and bomb radius
            //if coord is on the explosion path, return the bomb that's going to explode
            //otherwise return null
            foreach (Coords bomb in this.liveBombs)
            {
                LocationData datum = GetLocationData(bomb);
                int radius = datum.ExplosionRadius;
                bool test = (coord.Equals(bomb) || coord.isCardinalEastOf(bomb, radius) || coord.isCardinalNorthOf(bomb, radius) || coord.isCardinalSouthOf(bomb, radius) || coord.isCardinalWestOf(bomb, radius));
                if (test)
                {
                    return bomb;
                }
            }

            return null;
        }
开发者ID:vermagav,项目名称:bombersquad,代码行数:18,代码来源:GameState.cs


注:本文中的Coords.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。