コード例 #1
0
ファイル: THero.cs プロジェクト: qakowski/Strategy-master
        private void FindPath(TCell desiredCell)
        {
            var treePath = new List <TCell>();

            treePath.Add(CurrentCell);
            if (desiredCell == CurrentCell)
            {
                return;
            }

            for (var i = 0; i < treePath.Count; i++)
            {
                var cell       = treePath[i];
                var neighbours = cell.Neighbours;

                if (cell == desiredCell)
                {
                    break;
                }
                foreach (var neighbour in neighbours)
                {
                    if (neighbour.Piece == null || neighbour == desiredCell)
                    {
                        neighbour.Parent = cell;
                        treePath.Add(neighbour);
                    }
                }
            }
            Path = new List <TCell>();
            var parentCell = desiredCell;

            while (parentCell != null)
            {
                Path.Add(parentCell);
                parentCell = parentCell.Parent;
            }

            Path.Reverse();

            foreach (var cell in treePath)
            {
                cell.Parent = null;
            }
        }
コード例 #2
0
ファイル: TBoard.cs プロジェクト: qakowski/Strategy-master
 public void MoveToCell(TCell cell)
 {
     ScrollPos = new PointF((float)cell.X / Game.Map.Width, (float)cell.Y / Game.Map.Height);
 }