Exemplo n.º 1
0
        public void EntityFired(IEntityModel model)
        {
            if (FieldModel.BonusEntities.Contains(model))
            {
                FieldModel.BonusEntities.Remove(model);
                var entityController = MapperService.GetController(model);
                entityController.SetBonus(false);
            }

            if (isFiring)
            {
                return;
            }

            isFiring = true;

            var hasBonus = false;

            var bonusEntitiesSnapshot = FieldModel.BonusEntities.ToList();

            foreach (var fieldModelBonusEntity in bonusEntitiesSnapshot)
            {
                var firedEntityPosition = FieldDimensionModel.GetFieldPositionFromWorld(model.WorldPosition);
                var position            = FieldDimensionModel.GetFieldPositionFromWorld(fieldModelBonusEntity.WorldPosition);
                if ((position + new Vector2Int(0, 1)) != firedEntityPosition)
                {
                    continue;
                }

                hasBonus = true;
            }

            if (hasBonus)
            {
                var bottomRow = FieldModel.GetRow(0).ToList();

                MessageSender.Send(new ActivateBonusMessage {
                    FiredEntitiesByBonus = bottomRow
                });

                foreach (var fireEntity in bottomRow)
                {
                    FieldController.FireEntity(fireEntity);
                }
            }

            isFiring = false;
        }
Exemplo n.º 2
0
        public void FallEntities()
        {
            var map = FieldModel.GenerateEntityMap();

            var fallEntities = FieldModel.GetFallEntities(map);

            foreach (var entity in fallEntities)
            {
                var entityFieldPosition = FieldDimensionModel.GetFieldPositionFromWorld(entity.WorldPosition);
                var downWorldPosition   = FieldDimensionModel.GetFieldWorldPosition(entityFieldPosition + Vector2Int.down);

                EntityMapperService.GetController(entity).Fall(downWorldPosition, ConfigModel.UpdateInterval);
            }
        }