Beispiel #1
0
 /// <summary>
 /// Client Size 변경 이벤트 발생 시
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void WANIGrid_ClientSizeChanged(object sender, EventArgs e)
 {
     rc = new Rectangle(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);
     ActiveCell.Clear();
     InitializeScollBar();
     CalcVisibleRange();
     ReCalcScrollBars();
     Invalidate();
 }
Beispiel #2
0
        public void SetCellCoin(Vector2 worldCellPos)
        {
            Vector3Int cellPos = grid.WorldToCell(worldCellPos);

            if (IsOutOfBounds(cellPos) || IsTooHigh(cellPos))
            {
                return;
            }
            Cell       cell  = cells[cellPos.x, cellPos.y];
            ActiveCell state = (ActiveCell)cell.CurrentState;

            state?.ActivateCoin(cell);
        }
Beispiel #3
0
 public void OnDestory()
 {
     OnHide();
     if (Trigger.TryGetTarget(out ToggleButton trigger) && trigger != null)
     {
         trigger.Visibility = Visibility.Collapsed;
         trigger.RemoveFromParent(out _, out _);
     }
     if (Selector.TryGetTarget(out Popup selector) && selector != null)
     {
         selector.Visibility = Visibility.Collapsed;
         selector.RemoveFromParent(out _, out _);
     }
     Unhook();
     ActiveCell.SetTarget(null);
     Trigger.SetTarget(null);
     Selector.SetTarget(null);
     GC.Collect();
 }
        internal Selection ToSelection()
        {
            var s = new Selection();

            if (Pane != PaneValues.TopLeft)
            {
                s.Pane = Pane;
            }

            if ((ActiveCell.Length > 0) && !ActiveCell.Equals("A1", StringComparison.OrdinalIgnoreCase))
            {
                s.ActiveCell = ActiveCell;
            }

            if (ActiveCellId != 0)
            {
                s.ActiveCellId = ActiveCellId;
            }

            if (SequenceOfReferences.Count > 0)
            {
                if (SequenceOfReferences.Count == 1)
                {
                    // not equal to A1
                    if ((SequenceOfReferences[0].StartRowIndex != 1) ||
                        (SequenceOfReferences[0].StartColumnIndex != 1) ||
                        (SequenceOfReferences[0].EndRowIndex != 1) ||
                        (SequenceOfReferences[0].EndColumnIndex != 1))
                    {
                        s.SequenceOfReferences = SLTool.TranslateCellPointRangeToSeqRef(SequenceOfReferences);
                    }
                }
                else
                {
                    s.SequenceOfReferences = SLTool.TranslateCellPointRangeToSeqRef(SequenceOfReferences);
                }
            }

            return(s);
        }
Beispiel #5
0
        public static List <Vector2Int> FindPath(Vector2Int start, Vector2Int end)
        {
            List <Vector2Int> path = new List <Vector2Int>();

            PathContext context = new PathContext(curr.pathGrid, end);
            ActiveCell  c       = new ActiveCell(curr.pathGrid.cells[start.x, start.y]);

            c.gCost = 0;
            c.hCost = context.Distance(c.gridPos, end);
            context.Open.Add(c);

            while (context.Open.Count != 0)
            {
                // find lowest f-cost
                ActiveCell current = context.Open.RemoveFirst();
                context.Closed.Add(current);
                if (current.gridPos == end)
                {
                    if (curr.debugPaths)
                    {
                        Debug.Log(string.Format("Path from {0},{1} to {2},{3} complete", start.x, start.y, end.x, end.y));
                        Debug.Log("Path finished after " + context.Closed.Count + " finished cells and " + context.Open.Count + " started cells");
                    }
                    //thats the path
                    current.PathTrain(ref context.Closed, ref path);
                    return(path);
                }

                context.GetNeighbors(current);
            }
            //throw new Exception( "Impossible Path" );
            return(new List <Vector2Int>()
            {
                ClampToGrid(PlayerBaseClass.current.transform.position)
            });
        }
Beispiel #6
0
 /// <summary>
 /// Determines whether the specified cell is located in the collection
 /// </summary>
 /// <param name="subItem">An ActiveRow.ActiveCell representing the subitem to locate in the collection</param>
 /// <returns>true if the cell is contained in the collection; otherwise, false</returns>
 public bool Contains(ActiveCell subItem)
 {
     return base.Contains(subItem);
 }
Beispiel #7
0
 /// <summary>
 /// Adds an array of ActiveRow.ActiveCell objects to the collection
 /// </summary>
 /// <param name="items">An array of ActiveRow.ActiveCell objects to add to the collection</param>
 public void AddRange(ActiveCell[] items)
 {
     base.AddRange(items);
 }
Beispiel #8
0
 /// <summary>
 /// Adds an existing ActiveRow.ActiveCell to the collection
 /// </summary>
 /// <param name="item">The ActiveRow.ActiveCell to add to the collection</param>
 /// <returns>The ActiveRow.ActiveCell that was added to the collection</returns>
 public ActiveCell Add(ActiveCell item)
 {
     return base.Add(item) as ActiveCell;
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the ActiveRow class with the specified subitems, image, and group.
 /// </summary>
 /// <param name="subItems">An array of ListViewItem.ListViewSubItem objects that represent the subitems of the ListViewItem.</param>
 /// <param name="imageKey">The name of the image within the ImageList of the owning ListView to display in the item.</param>
 /// <param name="group">The ListViewGroup to assign the item to.</param>
 public ActiveRow(ActiveCell[] subItems, string imageKey, ListViewGroup group)
     : base(subItems, imageKey, group)
 {
     Initialize();
 }
Beispiel #10
0
 /// <summary>
 /// Initializes a new instance of the ActiveRow class with the image index position of the item's icon and an array of ListViewItem.ListViewSubItem objects, and assigns the item to the specified group.
 /// </summary>
 /// <param name="subItems">An array of type ListViewItem.ListViewSubItem that represents the subitems of the item.</param>
 /// <param name="imageIndex">The zero-based index of the image within the ImageList associated with the ListView that contains the item</param>
 /// <param name="group">The ListViewGroup to assign the item to.</param>
 public ActiveRow(ActiveCell[] subItems, int imageIndex, ListViewGroup group)
     : base(subItems, imageIndex, group)
 {
     Initialize();
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the ActiveRow class with the specified subitems and image. 
 /// </summary>
 /// <param name="subItems">An array of ListViewItem.ListViewSubItem objects.</param>
 /// <param name="imageKey">The name of the image within the ImageList of the owning ListView to display in the ListViewItem.</param>
 public ActiveRow(ActiveCell[] subItems, string imageKey)
     : base(subItems, imageKey)
 {
     Initialize();
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the ActiveRow class with an array of ActiveCell objects and the image 
 /// index position of the item's icon. 
 /// </summary>
 /// <param name="subItems">An array of type ActiveCell that represents the subitems of the item. </param>
 /// <param name="imageIndex">The zero-based index of the image within the ImageList associated with the ListView that contains the item.</param>
 public ActiveRow(ActiveCell[] subItems, int imageIndex)
     : base(subItems, imageIndex)
 {
     Initialize();
 }
 public void EndTurn()
 {
     ActiveCell.TurnEnd();
 }
 public void TurnStart()
 {
     ActiveCell = UnitCells.First(x => x.Unit == _battleController.UnitsList[0]);
     ActiveCell.TurnStart();
 }
Beispiel #15
0
        private void GetNeighbors(ActiveCell from)
        {
            Vector2Int           gridPos   = from.gridPos;
            List <PathGrid.Cell> neighbors = new List <PathGrid.Cell>();

            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    if (x == 0 && y == 0)
                    {
                        continue;
                    }
                    int tryX = gridPos.x + x;
                    int tryY = gridPos.y + y;
                    if (tryX > 0 && tryX < cells.GetLength(0) && tryY > 0 && tryY < cells.GetLength(1))
                    {
                        //the cell exists
                        if (cells[from.gridPos.x, tryY].traversable && cells[tryX, from.gridPos.y].traversable)
                        {
                            neighbors.Add(cells[tryX, tryY]);
                        }
                    }
                }
            }

            List <ActiveCell> fin = new List <ActiveCell>();

            foreach (PathGrid.Cell c in neighbors)
            {
                bool found = false;
                foreach (ActiveCell act in Closed)
                {
                    if (c.gridPos == act.gridPos)
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    continue;
                }
                foreach (ActiveCell act in Open.items)
                {
                    if (act == null)
                    {
                        break;
                    }
                    if (c.gridPos == act.gridPos)
                    {
                        fin.Add(act);
                        found = true;
                        break;
                    }
                }

                if (found)
                {
                    continue;
                }

                //we havent made it yet
                //is it valid?
                if (!c.traversable)
                {
                    continue;
                }
                //its valid, lets make it!

                ActiveCell a = new ActiveCell(c);
                a.hCost = Distance(a.gridPos, target);
                a.gCost = uint.MaxValue;
                fin.Add(a);
            }
            foreach (ActiveCell a in fin)
            {
                Vector2Int diff     = from.gridPos - a.gridPos;
                bool       diagonal = (diff.x * diff.x + diff.y * diff.y) == 2;
                uint       newCost  = from.gCost + (uint)(diagonal ? 14 : 10);
                if (a.gCost > newCost)
                {
                    a.bestFrom = gridPos;
                    a.gCost    = newCost;
                }
                if (!Open.Contains(a))
                {
                    Open.Add(a);
                }
            }
            return;
        }