예제 #1
0
        internal override bool Write(XmlWriter writer)
        {
            writer.WriteStartElement("sheetData", Constants.MainNamespace);
            foreach (var row in AllCells.OrderBy(r => r.Key))
            {
                if (row.Value.Any())
                {
                    var currentRow   = row.Value[0].Row;
                    var postWriteRow = currentRow.Write(writer);

                    foreach (var cell in row.Value)
                    {
                        if (cell.Write(writer))
                        {
                            cell.PostWrite(writer);
                        }
                    }

                    if (postWriteRow)
                    {
                        currentRow.PostWrite(writer);
                    }
                }
            }
            writer.WriteEndElement();

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Adds cells to the sheet without checking for its existance.
        /// The method is used by Importing Bulk data methods exposed by OpenXmlPackaging
        /// </summary>
        /// <param name="row">Cell Row</param>
        /// <param name="column">Cell Column</param>
        /// <param name="value">Value of the cell</param>
        internal void AddCell(int row, int column, string value)
        {
            // Get the current row
            var cellRow = AllCells.ContainsKey(row) ? AllCells[row] : null;

            // Add one if the row does not exist
            if (cellRow == null)
            {
                cellRow = new List <Cell>();
                AllCells.Add(row, cellRow);
            }

            // Create a cell
            var cell = new Cell(row, column)
            {
                Stylesheet = _styleSheet, Value = value
            };

            // Assign the Row property of the cell
            if (cellRow.Count == 0)
            {
                cell.Row = new Row(row);
            }
            else
            {
                cell.Row = cellRow[0].Row;
            }

            // Add the cell to the row
            cellRow.Add(cell);
        }
예제 #3
0
    void Update()
    {
        while (AllCells.Remove(null))
        {
        }

        if (AllCells.Count < 1)
        {
            FadeCameraController.Lose();
            Destroy(this);
            return;
        }

        var mousePos = getMouseWorldPos();

        if (Input.GetMouseButtonDown(0))
        {
            cachedSelection.Clear();
            if (Input.GetKey(KeyCode.LeftShift))
            {
                cachedSelection.AddRange(selectedCells);
            }

            selectoid    = (Instantiate(selectoidPrefab, null) as GameObject).GetComponent <SelectoidController>();
            selectionPtA = mousePos;
        }

        if (Input.GetMouseButton(0))
        {
            selectionPtB = mousePos;
            selectoid.transform.position = (selectionPtA + selectionPtB) / 2f;
            selectoid.SetSize((selectionPtB - selectionPtA).Abs());

            updateSelection();
        }

        if (Input.GetMouseButtonUp(0))
        {
            Destroy(selectoid.gameObject);
            selectoid = null;
        }

        if (shouldUpdateSelectedCells || Input.GetMouseButtonDown(1))
        {
            shouldUpdateSelectedCells = false;
            updateAttractionListInAllCells();
        }

        if (Input.GetMouseButton(1))
        {
            updateSeekPointInSelectedCells(mousePos);
        }

        if (Input.GetKey(KeyCode.Space))
        {
            ApoptosisSelection();
        }

        updateCameraPosition();
    }
예제 #4
0
        private void CreateCells(string puzzleString)
        {
            var parsedString = ParseString(puzzleString);

            for (var i = 1; i <= 9; i++)
            {
                Rows.Add(CreateCellCollection(i));
                Columns.Add(CreateCellCollection(i));
                Groups.Add(CreateCellCollection(i));
            }

            for (var i = 0; i < 9; i++)
            {
                for (var j = 0; j < 9; j++)
                {
                    var cell = string.IsNullOrEmpty(puzzleString) ? GetCell(i, j) :
                               GetCell(i, j, parsedString[i, j]);
                    cell.Puzzle = this;
                    Rows[i].Cells.Add(cell);
                    Columns[j].Cells.Add(cell);
                    AllCells.Add(cell);

                    var k = GetGroupIndex(i, j);
                    cell.Location.Group = Groups[k];
                    Groups[k].Cells.Add(cell);
                }
            }
            NonInitialCells = AllCells.Where(cell => !cell.IsInitialCell);
        }
예제 #5
0
        /// <summary>
        /// Returns a cell at a given row, column.
        /// It creates a new cell if it does not exist.
        /// It will return the cell if it already exists
        /// </summary>
        /// <param name="rowNumber">Row Number</param>
        /// <param name="columnIndex">Column Index</param>
        /// <returns></returns>
        private Cell GetCell(int rowNumber, int columnIndex)
        {
            string reference = Utilities.BuildReference(rowNumber, columnIndex);
            var    row       = AllCells.FirstOrDefault(c => c.Key == rowNumber).Value;

            // Check if the cell already exists
            var cell = row == null ? null : row.FirstOrDefault(c => c.ColumnNumber == columnIndex);

            // Cell does not exist. Create one.
            if (cell == null)
            {
                cell = new Cell(reference)
                {
                    Stylesheet = _styleSheet
                };

                var currentRow = Rows.FirstOrDefault(r => r.Index == rowNumber);

                // If the row already exists, get the row. Else, create a new row
                List <Cell> thisRow = null;
                if (AllCells.ContainsKey(rowNumber))
                {
                    thisRow = AllCells[rowNumber];
                }
                else
                {
                    thisRow = new List <Cell>();
                    AllCells.Add(rowNumber, thisRow);
                }

                // Add cell to the current row.
                thisRow.Add(cell);

                // Add the current row to the list of rows if it does not exist in the list.
                if (currentRow == null)
                {
                    cell.Row = new Row(rowNumber);
                    Rows.Add(cell.Row);
                }
                else
                {
                    cell.Row = currentRow;
                }

                // Add the current column to the list of columns if it does not exist in the list.
                if (!Columns.ColumnsList.Any(c => c.Index == columnIndex))
                {
                    Columns.ColumnsList.Add(new Column {
                        Index = columnIndex
                    });
                }
            }

            return(cell);
        }
 public Level(int level)
 {
     this.level = level;
     Members    = new();
     for (int i = 0; i < 24; i++)
     {
         var n = new Cell();
         Members.Add(n);
         AllCells.Add(n);
     }
 }
예제 #7
0
 public void AddUnitInRandomPosition()
 {
     if (AllCells.Any(x => x.IsEmpty))
     {
         var randomPoint = GetRandomPoint();
         var cell        = map[randomPoint.x, randomPoint.y];
         while (!cell.IsEmpty)
         {
             randomPoint = GetRandomPoint();
             cell        = map[randomPoint.x, randomPoint.y];
         }
         var newUnit = new Unit(this, randomPoint.x, randomPoint.y);
         newUnit.UnitWalked += OnUnitWalked;
         cell.AddUnit(newUnit);
     }
 }
예제 #8
0
파일: Map.cs 프로젝트: potsh/RimWorld
        public IEnumerator <IntVec3> GetEnumerator()
        {
            using (IEnumerator <IntVec3> enumerator = AllCells.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    IntVec3 c = enumerator.Current;
                    yield return(c);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_00b9:
            /*Error near IL_00ba: Unexpected return in MoveNext()*/;
        }
예제 #9
0
            public void Update(bool extraSurrounding)
            {
                ulong steamId;

                if (SteamId == null || !ulong.TryParse(SteamId, out steamId))
                {
                    throw new InvalidDataException(
                              $"The Steam ID ({SteamId ?? "NULL"}) for the zone '{Name}' is invalid.");
                }
                var identity = GameManager.Instance.GetIdentity(steamId);

                if (identity == null)
                {
                    throw new InvalidDataException($"Couldn't find the Identity for {SteamId} in the zone '{Name}'.");
                }
                if (MainCell <= 0)
                {
                    throw new InvalidDataException(
                              $"The Cell ({SteamId ?? "NULL"}) for the zone '{Name}' is invalid.");
                }
                var cluster = BuildConnectedOwnedCellCluster(identity, MainCell);

                Stakes.Clear();
                foreach (var cell in cluster)
                {
                    var stake = GetStakeOnCell(cell);
                    if (stake != null)
                    {
                        Stakes.Add(stake);
                    }
                }
                if (extraSurrounding)
                {
                    var surroundingCells = GetUniqueSurroundingUnownedCells(cluster);
                    foreach (var surroundingCell in surroundingCells)
                    {
                        cluster.Add(surroundingCell);
                    }
                }
                Bounds.Clear();
                AllCells.Clear();
                foreach (var cell in cluster)
                {
                    Bounds.Add(GetCellBounds(cell));
                    AllCells.Add(cell);
                }
            }
예제 #10
0
        private ICell AddCell(IWebElement webElement, int colNum, int rowNum, string colName, string rowName)
        {
            var cell = (Cell)_allCells.FirstOrDefault(c => c.ColumnNum == colNum && c.RowNum == rowNum);

            if (cell != null)
            {
                cell.WebElement = webElement;
                return(cell.UpdateData(colName, rowName));
            }
            cell = new Cell(colNum, rowNum, colName, rowName, CellLocatorTemplate, this, -1, webElement: webElement);

            if (Cache)
            {
                AllCells.Add(cell);
            }
            return(cell);
        }
예제 #11
0
        private ICell AddCell(int colIndex, int rowIndex, int colNum, int rowNum, string colName, string rowName)
        {
            var cell = (Cell)AllCells.FirstOrDefault(c => c.ColumnNum == colNum && c.RowNum == rowNum);

            if (cell != null)
            {
                return(cell.UpdateData(colName, rowName));
            }
            cell = new Cell(colNum, rowNum, colName, rowName, CellLocatorTemplate, this, colIndex, rowIndex);
            cell.SetAvatar((GetElementModule)cell.Get().Avatar);

            if (Cache)
            {
                AllCells.Add(cell);
            }
            return(cell);
        }
예제 #12
0
    public bool HasLegalMove(Board board)
    {
        foreach (var from in AllCells.Where(c => c > 3))
        {
            if (board[from] != White)
            {
                continue;
            }

            if (HasLegalMove(board, from))
            {
                return(true);
            }
        }

        return(false);
    }
예제 #13
0
    void ApoptosisSelection()
    {
        foreach (CellController apoptosisCell in selectedCells)
        {
            foreach (CellController otherCell in AllCells)
            {
                otherCell.attraction.Remove(apoptosisCell);
            }
            apoptosisCell.Apoptosis();
            AllCells.Remove(apoptosisCell);
        }
        cachedSelection.Clear();
        selectedCells.Clear();
        unselectedCells.Clear();

        Audio.Play("squishSmall");
    }
예제 #14
0
 public static int GetPredictionsCount(Func <PredictionAggregate, IEnumerable <BasePrediction> > func)
 {
     return(AllCells.Sum(x => func(x.Predictions).Count()));
 }
예제 #15
0
 public static List <BasePrediction> GetPredictions(Func <PredictionAggregate, IEnumerable <BasePrediction> > func)
 {
     return(AllCells.SelectMany(x => func(x.Predictions)).ToList());
 }
예제 #16
0
 public IEnumerator <PdfReportCellModel> GetEnumerator() => AllCells.GetEnumerator();
예제 #17
0
 public void AddPlayerTrayOriginMove(Coords coords)
 {
     AllCells.Add(new Cell(coords));
     OriginCells.Add(new Cell(coords));
 }
예제 #18
0
 /// <summary>
 /// Empties the Worksheet
 /// </summary>
 internal void ClearCells()
 {
     AllCells.Clear();
     Columns.ColumnsList.Clear();
     Rows.Clear();
 }