Пример #1
0
        public MapRecord(DlmMap map)
        {
            Id = map.Id;

            Id                      = map.Id;
            Version                 = map.Version;
            RelativeId              = map.RelativeId;
            MapType                 = map.MapType;
            SubAreaId               = map.SubAreaId;
            ClientTopNeighbourId    = map.TopNeighbourId;
            ClientBottomNeighbourId = map.BottomNeighbourId;
            ClientLeftNeighbourId   = map.LeftNeighbourId;
            ClientRightNeighbourId  = map.RightNeighbourId;
            ShadowBonusOnEntities   = map.ShadowBonusOnEntities;
            UseLowpassFilter        = map.UseLowPassFilter;
            UseReverb               = map.UseReverb;
            PresetId                = map.PresetId;
            Cells                   =
                map.Cells.Select(
                    x =>
                    new Cell
            {
                Id            = x.Id,
                Floor         = x.Floor,
                Data          = x.Data,
                MapChangeData = x.MapChangeData,
                MoveZone      = x.MoveZone,
                Speed         = x.Speed
            }).ToArray();
            bool any = Cells.Any(x => x.Walkable);

            BeforeSave(false);
        }
Пример #2
0
        internal override SpacePlan Measure(Size availableSpace)
        {
            if (!Cells.Any())
            {
                return(SpacePlan.FullRender(Size.Zero));
            }

            UpdateColumnsWidth(availableSpace.Width);
            var renderingCommands = PlanLayout(availableSpace);

            if (!renderingCommands.Any())
            {
                return(SpacePlan.Wrap());
            }

            var width     = Columns.Sum(x => x.Width);
            var height    = renderingCommands.Max(x => x.Offset.Y + x.Size.Height);
            var tableSize = new Size(width, height);

            if (tableSize.Width > availableSpace.Width + Size.Epsilon)
            {
                return(SpacePlan.Wrap());
            }

            return(FindLastRenderedRow(renderingCommands) == StartingRowsCount
                ? SpacePlan.FullRender(tableSize)
                : SpacePlan.PartialRender(tableSize));
        }
Пример #3
0
    /// <summary>
    /// Returns true if there is a valid move on the board
    /// </summary>
    /// <returns></returns>
    public bool IsDeadLocked()
    {
        if (Cells.Any(cell => cell.GetValidAdjoinedCells() > 1))
        {
            return(false);
        }

        return(true);
    }
Пример #4
0
 public void RemoveCell(int rowNumber, char columnLetter)
 {
     if (Cells.Any(x => x.RowNumber == rowNumber && x.ColumnLetter == columnLetter))
     {
         Cells.RemoveAll(x => x.RowNumber == rowNumber && x.ColumnLetter == columnLetter);
         return;
     }
     throw new DomainException(ErrorCodes.EmptyCell, $"Cell with coordinates {columnLetter}:{rowNumber} is empty." +
                               $" Empty cell cannot be removed.");
 }
Пример #5
0
        public void AddCell(Guid userId, int rowNumber, char columnLetter, string text)
        {
            var cell = new Cell(userId, rowNumber, columnLetter, text);

            if (Cells.Any(x => x.RowNumber == rowNumber && x.ColumnLetter == columnLetter))
            {
                Cells.RemoveAll(x => x.RowNumber == rowNumber && x.ColumnLetter == columnLetter);
            }
            Cells.Add(cell);
            UpdatedAt = DateTime.UtcNow;
        }
Пример #6
0
        partial void AddDamageProjSpecific(float damage, Vector2 worldPosition)
        {
            if (damage <= 0.0f)
            {
                return;
            }
            Vector2 particlePos = worldPosition;

            if (!Cells.Any(c => c.IsPointInside(particlePos)))
            {
                bool intersectionFound = false;
                foreach (var cell in Cells)
                {
                    foreach (var edge in cell.Edges)
                    {
                        if (MathUtils.GetLineIntersection(worldPosition, cell.Center, edge.Point1 + cell.Translation, edge.Point2 + cell.Translation, out Vector2 intersection))
                        {
                            intersectionFound = true;
                            particlePos       = intersection;
                            break;
                        }
                    }
                    if (intersectionFound)
                    {
                        break;
                    }
                }
            }

            Vector2 particleDir = particlePos - WorldPosition;

            if (particleDir.LengthSquared() > 0.0001f)
            {
                particleDir = Vector2.Normalize(particleDir);
            }
            int particleAmount = MathHelper.Clamp((int)damage, 1, 10);

            for (int i = 0; i < particleAmount; i++)
            {
                var particle = GameMain.ParticleManager.CreateParticle("iceshards",
                                                                       particlePos + Rand.Vector(5.0f),
                                                                       particleDir * Rand.Range(200.0f, 500.0f) + Rand.Vector(100.0f));
            }
        }
Пример #7
0
        public void Bind(IEnumerable <object> items)
        {
            if (!Cells.Any())
            {
                foreach (var item in items)
                {
                    AddCell(item);
                }
            }
            else
            {
                var index = 0;

                foreach (var item in items)
                {
                    Cells[index].SetContent(item);
                    index += 1;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// Creates a level out of the current state and returns that <see cref="LevelData"/> instance.
        /// </summary>
        /// <returns>LevelData.</returns>
        /// <exception cref="InvalidOperationException">Cannot finalize a level if no cells have been added</exception>
        public LevelData CreateLevel()
        {
            if (!Cells.Any())
            {
                throw new InvalidOperationException("Cannot finalize a level if no cells have been added");
            }

            // Build out the level object
            var level = new LevelData
            {
                Id          = LevelId,
                Name        = LevelName,
                PlayerStart = PlayerStart
            };

            // Copy over the cells into the level
            foreach (var cell in Cells)
            {
                level.AddCell(cell);
            }

            // Set the coordinates of the map based on the cells present
            level.UpperLeft  = new Pos2D(level.Cells.Min(c => c.Pos.X), level.Cells.Min(c => c.Pos.Y));
            level.LowerRight = new Pos2D(level.Cells.Max(c => c.Pos.X), level.Cells.Max(c => c.Pos.Y));

            // Mark command requires that the mark pos default to the start location
            level.MarkedPos = PlayerStart;

            // Ensure all walls are marked external that should be
            FinalizePlacedWalls(level);

            // Loop over all door cells and ensure that they have floors without walls on the other side of them.
            FinalizeDoors(level);

            FinalizeFloors(level);

            GenerateActors(level);

            return(level);
        }
Пример #9
0
 protected Boolean checkCoordinates(Int32 x, Int32 y)
 {
     if (x < 0)
     {
         return(false);
     }
     if (y < 0)
     {
         return(false);
     }
     if (Cells.Any())
     {
         if (y < Cells.Count)
         {
             if (x < Cells[0].Count)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #10
0
        internal void AddToTable(Table table, SQLiteConnection connection)
        {
            Cells.CheckColumns(table.Columns);
            if (!Cells.Any())
            {
                throw new InvalidOperationException(Resources.ZeroCellsInsert.FormatExt(table.Name));
            }
            CheckMissedColumns(table);
            CheckPrimaryCells(table);

            var insert = InsertSql.FormatExt(table.Name,
                                             Cells.Select(x => x.Column.Name.EscapeIdentifier()).JoinExt(","),
                                             Cells.Select(x => x.ParamName).JoinExt(","));

            using (var command = new SQLiteCommand(insert, connection))
            {
                command.Parameters.AddRange(Cells.Select(x => x.ToParameter()).ToArray());
                command.ExecuteNonQuery();
            }
            RowId = connection.LastInsertRowId;
            Table = table;
            Reload(connection); // Reload in order to fill auto-filled cells (like autoincrement).
        }
Пример #11
0
        private void SwitchTurn()
        {
            if (RemainingKlops == 0 || !Cells.Any(c => c.Available))
            {
                RemainingKlops = TurnLength;

                if (CurrentPlayerIndex == _players.Length - 1)
                {
                    CurrentPlayerIndex = 0;
                }
                else
                {
                    CurrentPlayerIndex++;
                }

                _history.Clear(); // cannot undo after turn switch

                // Reset availability
                //foreach (KlopCell cell in _cells)
                //{
                //   cell.Available = false;
                //}
            }
        }
Пример #12
0
 public bool Any()
 {
     return(Cells.Any());
 }
Пример #13
0
 public bool IsPointInside(Vector2 point)
 {
     return(Cells.Any(c => c.IsPointInside(point)));
 }
Пример #14
0
 public bool Contains(CellValue value)
 {
     return(Cells.Any(cell => cell.Value == value));
 }
Пример #15
0
 public bool Contains(int _value)
 {
     return(Cells.Any(_cell => _cell.Value == _value));
 }
Пример #16
0
 public bool ContainsCell(int x, int y)
 {
     return(Cells.Any(cell => cell.X == x && cell.Y == y));
 }
Пример #17
0
 private void CellOnSelectedChanged(object sender, BoolEventArgs boolEventArgs)
 {
     SetSelected(boolEventArgs.Bool || Cells.Any(cell => cell.IsSelected));
 }
Пример #18
0
 public bool ContainsNoPieces(IPlayer player)
 {
     return(!Cells.Any(cell => cell.ContainsPlayablePiece && cell.Owner.Equals(player)));
 }
Пример #19
0
 public bool Contains(int num)
 {
     return(Cells.Any(o => o.Value == num));
 }