Example #1
0
 public void MapBuilder_ShouldMapPublicAndPrivateProperties()
 {
     var mapBuilder = new MapBuilder(false);
     var maps = mapBuilder.BuildColumns<UnmappedPerson>();
     Assert.IsTrue(maps.MappedColumns.Count == 6);
     Assert.IsTrue(_mapRepository.Columns[_personType].Count == 6);
 }
Example #2
0
 public void MapBuilder_Relationships_ShouldMapPublicProperties_ThatAreSpecified()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildRelationships<UnmappedPerson>("Pets");
     Assert.IsTrue(maps.Count == 1);
     Assert.IsNotNull(maps["Pets"]);
 }
Example #3
0
 public void MapBuilder_ShouldMapPublicProperties_ThatAreSpecified()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildColumns<UnmappedPerson>("Name");
     Assert.IsTrue(maps.Count == 1);
     Assert.IsNotNull(maps["Name"]);
 }
Example #4
0
 public void MapBuilder_ShouldMapPublicProperties_ThatAreOfTypeDateTime()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildColumns<UnmappedPerson>(m => 
         m.MemberType == MemberTypes.Property && (m as PropertyInfo).PropertyType == typeof(DateTime));
     
     Assert.IsTrue(maps.Count == 1);
     Assert.IsTrue(maps[0].FieldType == typeof(DateTime));
 }
Example #5
0
 public void MapBuilder_ShouldMapPublicProperties_MinusExclusions()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildColumnsExcept<UnmappedPerson>("ID", "Name");
     Assert.IsTrue(maps.Count == 4);
     Assert.IsNotNull(maps["Age"]);
     Assert.IsNotNull(maps["BirthDate"]);
     Assert.IsNotNull(maps["IsHappy"]);
     Assert.IsNotNull(maps["Pets"]);
 }
Example #6
0
 public Form1()
 {
     InitializeComponent();
     this.PictureBoxHeight = pictureBox1.Height;
     this.PictureBoxWidth = pictureBox1.Width;
     this.pictureBoxTheseus.Image = this.theseus;
     this.pictureBoxMinotaur.Image = this.minotaur;
     myMouseHandler = new MouseHandler();
     drawer = new Drawer();
     mapBuilder = new MapBuilder();
 }
Example #7
0
 public void MapBuilder_ShouldMapPublicProperties_MinusExclusions()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildColumnsExcept<UnmappedPerson>("ID", "Name");
     Assert.IsTrue(maps.MappedColumns.Count == 4);
     Assert.IsNotNull(maps.MappedColumns.GetByColumnName("Age"));
     Assert.IsNotNull(maps.MappedColumns.GetByColumnName("BirthDate"));
     Assert.IsNotNull(maps.MappedColumns.GetByColumnName("IsHappy"));
     Assert.IsNotNull(maps.MappedColumns.GetByColumnName("Pets"));
     Assert.IsNotNull(_mapRepository.Columns[_personType].GetByColumnName("Age"));
     Assert.IsNotNull(_mapRepository.Columns[_personType].GetByColumnName("BirthDate"));
     Assert.IsNotNull(_mapRepository.Columns[_personType].GetByColumnName("IsHappy"));
     Assert.IsNotNull(_mapRepository.Columns[_personType].GetByColumnName("Pets"));
 }
Example #8
0
        public void InitMappings()
        {
            MapBuilder builder = new MapBuilder();

            builder.BuildTable<Person>("PersonTable");

            builder.BuildColumnsFromSimpleTypes<Person>()
                .For(p => p.ID)
                    .SetPrimaryKey()
                    .SetReturnValue()
                    .SetAutoIncrement();

            builder.BuildRelationships<Person>();

            builder.BuildColumns<Pet>()
                .For(p => p.ID)
                    .SetPrimaryKey()
                    .SetAltName("Pet_ID")
                .For(p => p.Name)
                    .SetAltName("Pet_Name");
        }
Example #9
0
        public void AdventurerAlone_MoveAdventurer_AdventurerMovedToWest()
        {
            string     adventurerName = "adv";
            int        initialX       = 1;
            int        initialY       = 1;
            int        stepX          = 1;
            int        stepY          = 0;
            int        expectedX      = 2;
            int        expectedY      = 1;
            MapBuilder builder        = new MapBuilder(new MapSizeEntry("C", new[] { "5", "5" }));

            builder.AddEntries(new[] { new MapAdventurerEntry("A", new[] { adventurerName, initialX.ToString(), initialY.ToString(), "O", string.Empty }) });
            Map map = builder.GetMap();

            string initialType = map.GetCellType(expectedX, expectedY);

            map.MoveAdventurer(adventurerName, stepX, stepY);
            string finalType = map.GetCellType(expectedX, expectedY);

            Assert.That(initialType, Is.EqualTo(string.Empty));
            Assert.That(finalType, Is.EqualTo("A"));
        }
Example #10
0
        public IContract GetItem <T>(IContract lookupItem) where T : IContract
        {
            var item = ((Bank)lookupItem);

            var bankItem = db.ExecuteSprocAccessor(DBRoutine.SELECTBANK,
                                                   MapBuilder <Bank>
                                                   .MapAllProperties()
                                                   .DoNotMap(c => c.BankAddress)
                                                   .Build(),
                                                   item.BankCode).FirstOrDefault();

            if (bankItem == null)
            {
                return(null);
            }

            bankItem.BankAddress = GetBankAddress(bankItem);



            return(bankItem);
        }
Example #11
0
        public IEnumerable <RegistroC190> GetRegistrosC190(string codChaveNotaFiscal)
        {
            try
            {
                if (regC190Accessor == null)
                {
                    regC190Accessor =
                        UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                            SqlExpressionsFiscalRepository.GetSelectRegistrosC190(),
                            new FilterByCdEmpresaPkNotaFisParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                            MapBuilder <RegistroC190> .MapAllProperties().Build());
                }

                return(regC190Accessor.Execute(
                           UndTrabalho.CodigoEmpresa,
                           codChaveNotaFiscal).ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Problema encontrado na nota {0} com as casas decimais dos campos VL_OPR e VL_BC_ICMS, ref a PROCEDURE: SP_SPED_FISCAL_REGISTROC190.{1}{2}", codChaveNotaFiscal, Environment.NewLine, ex.Message));
            }
        }
Example #12
0
        public IContract GetItem <T>(IContract lookupItem) where T : IContract
        {
            var item = ((Operator)lookupItem);

            var operatorItem = db.ExecuteSprocAccessor(DBRoutine.SELECTOPERATOR,
                                                       MapBuilder <Operator>
                                                       .MapAllProperties()
                                                       .DoNotMap(x => x.Nationality).Build(),
                                                       item.MobileNo).FirstOrDefault();

            if (operatorItem == null)
            {
                return(null);
            }


            operatorItem.AddressList        = new AddressDAL().GetList(operatorItem.OperatorID);
            operatorItem.OperatorDriverList = new OperatorDriverDAL().GetSelectList(operatorItem.OperatorID);
            operatorItem.OperatorVehicle    = new OperatorVehicleDAL().GetOperatorVehicleListById(operatorItem.OperatorID);
            operatorItem.BankDetails        = new BankDetailsDAL().GetList(operatorItem.OperatorID);
            return(operatorItem);
        }
Example #13
0
        public IContract GetItem <T>(IContract lookupItem) where T : IContract
        {
            var item = ((APCreditNote)lookupItem);

            var apcreditnoteItem = db.ExecuteSprocAccessor(DBRoutine.SELECTAPCREDITNOTE,
                                                           MapBuilder <APCreditNote> .MapAllProperties()
                                                           .DoNotMap(d => d.APCreditNoteDetails)
                                                           .Build(),
                                                           item.DocumentNo).FirstOrDefault();

            if (apcreditnoteItem == null)
            {
                return(null);
            }


            if (apcreditnoteItem != null)
            {
                apcreditnoteItem.APCreditNoteDetails = new POSAccount.DataFactory.APCreditNoteDetailDAL().GetListByDocumentNo(apcreditnoteItem.DocumentNo);
            }
            return(apcreditnoteItem);
        }
Example #14
0
        /// <summary>
        /// Obtiene un mapedo de lote
        /// </summary>
        /// <returns></returns>
        internal static IMapBuilderContext <LoteInfo> ObtenerMapeoLote()
        {
            try
            {
                Logger.Info();
                IMapBuilderContext <LoteInfo> mapeoLote = MapBuilder <LoteInfo> .MapNoProperties();

                mapeoLote.Map(x => x.Lote).ToColumn("Lote");
                mapeoLote.Map(x => x.LoteID).ToColumn("LoteID");
                mapeoLote.Map(x => x.Cabezas).ToColumn("Cabezas");
                mapeoLote.Map(x => x.CabezasInicio).ToColumn("CabezasInicio");
                mapeoLote.Map(x => x.OrganizacionID).ToColumn("OrganizacionID");
                mapeoLote.Map(x => x.Activo).WithFunc(x => Convert.ToBoolean(x["LoteActivo"]).BoolAEnum());
                MapeoCorralOrganizacionTipoCorralGrupoCorral(mapeoLote);
                return(mapeoLote);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Example #15
0
        public List <Extension> getSubscribeInfo(string EId)
        {
            List <Extension> list = null;

            try
            {
                IParameterMapper         ipmapper = new getSubscribeInfoParameterMapper();
                DataAccessor <Extension> tableAccessor;
                string strSql = @" select e.CompanyId,e.Datetime,e.Econtent,e.EditMan,e.EId,e.Etype,e.OrderNo,e.Title ,p.Name
from extension  e , Company p where  e.CompanyId=p.id   and  e.EId=@EId ";

                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <Extension> .
                                                           MapAllProperties().Build());
                list = tableAccessor.Execute(new string[] { EId }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }
//        public List<Restaurant> getRestaurantListInfoData(string companyid)
//        {
//            List<Restaurant> list = null;
//            try
//            {
//                DataAccessor<Restaurant> tableAccessor;
//                string strSql = @"select a.Id
//      ,a.Name
//      ,a.CompanyId
//      ,a.Address
//      ,a.ContactPhone
//      ,a.Description
//      ,a.BankId
//      ,a.BankAccount
//      ,a.OpenDate
//      ,a.BusinessStartDate
//      ,a.BusinessEndtDate
//      ,a.RegSN
//      ,a.ReserveModel
//      ,a.UseState
//      ,a.PublicKey
//      ,a.PrivateKey from Restaurant a where a.CompanyId='"+companyid+"'";
//                tableAccessor = db.CreateSqlStringAccessor(strSql, MapBuilder<Restaurant>.MapAllProperties()
//                     .Map(t => t.Id).ToColumn("Id")
//                     .Map(t => t.Name).ToColumn("Name")
//                     .Map(t => t.CompanyId).ToColumn("CompanyId")
//                     .Map(t => t.Address).ToColumn("Address")
//                     .Map(t => t.ContactPhone).ToColumn("ContactPhone")
//                     .Map(t => t.Description).ToColumn("Description")
//                     .Map(t => t.BankId).ToColumn("BankId")
//                     .Map(t => t.BankAccount).ToColumn("BankAccount")
//                     .Map(t => t.OpenDate).ToColumn("OpenDate")
//                     .Map(t => t.BusinessStartDate).ToColumn("BusinessStartDate")
//                     .Map(t => t.BusinessEndtDate).ToColumn("BusinessEndtDate")
//                     .Map(t => t.RegSN).ToColumn("RegSN")
//                     .Map(t => t.ReserveModel).ToColumn("ReserveModel")
//                     .Map(t => t.UseState).ToColumn("UseState")
//                     .Map(t => t.PublicKey).ToColumn("PublicKey")
//                     .Map(t => t.PrivateKey).ToColumn("PrivateKey")

//                    .Build());
//                list = tableAccessor.Execute().ToList();
//                return list;

//            }
//            catch (Exception ex)
//            {
//                return null;
//            }
//        }
        #endregion
        #region getImageRst

        public List <RestaurantAbstract> getImageRst(string id)
        {
            List <RestaurantAbstract> list = null;

            try
            {
                IParameterMapper ipmapper = new getRestaurantListInfoDataParameterMapper();
                DataAccessor <RestaurantAbstract> tableAccessor;
                string strSql = @"select ro.photo
 from  ReceiveOrder   ro
 where ro.RstId=@SourceAccountId";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <RestaurantAbstract> .MapAllProperties()
                                                           .DoNotMap(t => t.Id)
                                                           .DoNotMap(t => t.isAcceptOrder)
                                                           .DoNotMap(t => t.MapUrl)
                                                           .DoNotMap(t => t.MaxTime)
                                                           //.DoNotMap(t => t.TypeId)
                                                           .DoNotMap(t => t.Name)
                                                           .DoNotMap(t => t.RstType)
                                                           .DoNotMap(t => t.VirtualUrl)
                                                           .DoNotMap(t => t.Address)
                                                           .DoNotMap(t => t.BusinessEndtDate)
                                                           .DoNotMap(t => t.BusinessStartDate)
                                                           .DoNotMap(t => t.ContactPhone)
                                                           .DoNotMap(t => t.name)

                                                           .Map(t => t.Photo).ToColumn("Photo")

                                                           .Build());
                list = tableAccessor.Execute(new string[] { id }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }
Example #17
0
        public static List <Vector2> GetPath(this SceneViewModel scene, Vector2 startPoint, Vector2 endPoint)
        {
            var points = new List <Vector2>();

            try
            {
                var mapBuilder = new MapBuilder();

                foreach (var component in scene.Components.Where(c => c.CollisionDetectionEnabled).ToList())
                {
                    mapBuilder.AddObstacle(component);
                }

                mapBuilder.SetStart(startPoint);
                mapBuilder.SetEnd(endPoint);
                mapBuilder.SetDimensions(scene.Size);

                var mapResult = mapBuilder.Build();
                if (mapResult.Success && mapResult.Map != null)
                {
                    var pathFinder =
                        new PathFinder.Algorithm.PathFinder(mapResult.Map,
                                                            DefaultNeighbourFinder.Straight(0.5f));

                    points.AddRange(pathFinder.FindPath());
                }
                else
                {
                    Console.WriteLine(mapResult.Message.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(points);
        }
    public override void OnInspectorGUI()
    {
        MapBuilder builder = MapBuilder.I;

        if (DrawDefaultInspector())
        {
            if (builder.autoUpdate)
            {
                builder.GenerateMesh();
            }
        }

        if (GUILayout.Button("Generate Map"))
        {
            builder.GenerateMesh();
        }

        if (GUILayout.Button("Save Region Values"))
        {
            string data = builder.GetAllRegionData();
            System.IO.File.WriteAllText(savePath + "data" + GetFileNumber() + ".txt", data);
        }
    }
Example #19
0
        public List <RandomProduct> getRandomProduct(string RestaurantId, string peopleCount)
        {
            List <RandomProduct> list = null;

            try
            {
                IParameterMapper             ipmapper = new getRandomProductParameterMapper();
                DataAccessor <RandomProduct> tableAccessor;
                string strSql = @"select top " + peopleCount + "  p.ProductName  , p.id , p.Price,ap.Hot, ap.Popular,ap.ADescription from  product p , Restaurant r, AutoMenusProduct ap" +

                                "  where  p.RestaurantId=r.Id   and p.Id=ap.ProductId and r.id=@RestaurantId and p.Status=1 order by newid() order by p.Code asc";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <RandomProduct> .
                                                           MapAllProperties().Build());
                list = tableAccessor.Execute(new string[] { RestaurantId }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
            #endregion
        }
Example #20
0
        public void buildMap()
        {
            GameEntityList    = new List <GameEntity>();
            NodeEntityList    = new List <NodeEntity>();
            PathEntityList    = new List <PathEntity>();
            DynamicEntityList = new List <DynamicEntity>();
            PathSelectionList = new List <PathSelectionEntity>();
            OrderList         = new List <GameEntity>();
            TopEnd            = null;
            MidEnd            = null;
            BotEnd            = null;

            this.EntityFactory = new EntityFactory();
            this.Player        = new Player();
            this.Player.Game   = this;
            this.Enemy         = new Enemy(this);

            MapBuilder MapBuilder = new MapBuilder();

            MapBuilder.BuildMap(this);

            this.Enemy.initPaths();
        }
    private float dimensions;            //Dimensions of each room, assumes square rooms


    // Use this for initialization
    void Start()
    {
        mapBuilder     = GameObject.Find("MapBuilder").GetComponent <MapBuilder>();
        dimensions     = mapBuilder.dimensions;
        roomObjects    = mapBuilder.GetAllRooms();
        enemiesSpawned = new GameObject[roomObjects.Length];
        if (mapBuilder)
        {
            if (enemies.Length > 0)
            {
                for (int i = 0; i < roomObjects.Length; i++)
                {
                    if (roomObjects[i] != null && roomObjects[i].GetComponent <Room>().shouldSpawnEnemies) //Check if the room exists and if you should spawn enemies in it
                    {
                        int     rand     = Random.Range(0, enemies.Length);
                        Vector3 position = new Vector3(roomObjects[i].transform.position.x + Random.Range(0, dimensions), roomObjects[i].transform.position.y + Random.Range(-dimensions / 2, dimensions / 2), roomObjects[i].transform.position.z); //Spawn somewhere within room kinda
                        enemies[rand].transform.SetPositionAndRotation(position, Quaternion.identity);
                        enemiesSpawned[i] = Instantiate(enemies[rand]);                                                                                                                                                                              //spawn enemy inside room dimensions
                    }
                }
            }
        }
    }
        /// <summary>
        /// Obtiene un mapeo para AlmacenMovimientoSubProductoModel
        /// </summary>
        /// <returns></returns>
        internal static IMapBuilderContext <AlmacenMovimientoSubProductosModel> ObtenerMapeoAlmacenMovimientoSubProductos()
        {
            try
            {
                Logger.Info();
                IMapBuilderContext <AlmacenMovimientoSubProductosModel> mapeoAlmacenMovimientoSubProductos =
                    MapBuilder <AlmacenMovimientoSubProductosModel> .MapNoProperties();

                mapeoAlmacenMovimientoSubProductos.Map(x => x.AlmacenID).ToColumn("AlmacenID");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.AlmacenMovimientoID).ToColumn("AlmacenMovimientoID");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.Cantidad).ToColumn("Cantidad");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.FechaMovimiento).ToColumn("FechaMovimiento");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.Importe).ToColumn("Importe");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.Precio).ToColumn("Precio");
                mapeoAlmacenMovimientoSubProductos.Map(x => x.ProductoID).ToColumn("ProductoID");
                return(mapeoAlmacenMovimientoSubProductos);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Example #23
0
 private void button6_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex != -1)
     {
         var temp = listBox1.SelectedItem;
         if (temp.GetType() == typeof(NPCMoveToCommand))
         {
             MapBuilder.controls.startTileSelect(AssignDestinationFromSelectedTile);
         }
         else if (temp.GetType() == typeof(NPCChangeMap))
         {
             var temp2 = listBox1.SelectedItem as NPCChangeMap;
             if (temp2.MapToMoveToID == temp2.mapID)
             {
                 MessageBox.Show("Please, first select a valid map to move to.");
                 goto Skip;
             }
             MapBuilder.ReloadActiveMap(BasicMap.allMapsGame().Find(map => map.identifier == temp2.MapToMoveToID));
             MapBuilder.controls.startTileSelect(AssignDestinationFromSelectedTile);
             Skip : { }
         }
     }
 }
Example #24
0
    void Start()
    {
        var        map        = GameObject.FindWithTag("Map");
        MapBuilder mapBuilder = map.GetComponent <MapBuilder> ();
        Vector2    spawn      = mapBuilder.GetRandomSpawnPoint();

        this.Player       = (GameObject)Instantiate(Resources.Load("Prefabs/Player"), new Vector3(spawn.x, spawn.y, 0), new Quaternion(0, 0, 0, 0));
        this.Player.name  = "Player";
        this.playerHp     = Player.GetComponent <UnitHealth> ();
        this.playerShield = Player.GetComponent <UnitShield> ();

        this.Enemies = new List <GameObject>();
        GameObject enemyContainer = new GameObject("Enemies");

        for (int i = 0; i < 100; i++)
        {
            spawn = mapBuilder.GetRandomSpawnPoint();
            GameObject catClone = Instantiate(Resources.Load("Prefabs/viciousCat"), new Vector3(spawn.x, spawn.y, 0), Quaternion.identity) as GameObject;
            catClone.name             = "Vicious Cat " + i;
            catClone.transform.parent = enemyContainer.transform;

            EnemyAI catAi = catClone.GetComponent <EnemyAI> ();
            catAi.Player = this.Player;

            Enemies.Add(catClone);
        }

        //Spawn the boss !
        spawn = mapBuilder.GetRandomSpawnPoint();
        GameObject henriClone = Instantiate(Resources.Load("Prefabs/HenriTheDrizzle"), new Vector3(spawn.x, spawn.y, 0), Quaternion.identity) as GameObject;

        henriClone.name = "Henri The Drizzle";

        EnemyAI henriAi = henriClone.GetComponent <EnemyAI> ();

        henriAi.Player = this.Player;
    }
Example #25
0
    public static void Initialize()
    {
        foreach (GameObject obj in GameObject.FindObjectsOfType(typeof(GameObject)))
        {
            prefabs[obj.name] = obj;
            if (obj.CompareTag("Hitable"))
            {
                objectives.Add(obj);
            }
            if (obj.name == "Player")
            {
                player = obj;
            }
            if (disables.Contains(obj.name))
            {
                obj.SetActive(false);
            }
        }



        //reset map until find a valid map
        while (MapBuilder.resetMap() < 0)
        {
            ;
        }
        //create time detection colliders
        for (int x = 0; x < 8; x++)
        {
            for (int y = 0; y < 8; y++)
            {
                var collider = GameObject.Instantiate(prefabs["PositionDetect"]);
                collider.transform.position = new Vector3(x * 5, 0, y * 5 + 10);
                collider.SetActive(true);
            }
        }
    }
Example #26
0
        /// <summary>
        /// Loads the components to this playable scene, and loads a new player instance.
        /// </summary>
        /// <param name="game">Current game instance.</param>
        /// <param name="mapPath">String path of the map being read from directory.</param>
        private void LoadMap(Game game, string mapPath)
        {
            //Create new player object and add to scene components
            Player = new Player(game);
            GameObjects.Add(Player);

            //Default position is (1,1) --> (64, 64)
            var yCount = 1;
            var xCount = 1;

            MapBuilder builder = new MapBuilder(game, _texture, TextureDictionary);

            //Reads text map file line by line
            using (StreamReader rdr = new StreamReader(File.OpenRead(mapPath)))
            {
                while (rdr.Peek() > 0)
                {
                    var row = rdr.ReadLine();

                    //Foreach character in the read line, build the game object it represents (See 'MapBuilder.cs')
                    foreach (var c in row.ToCharArray())
                    {
                        var gameObject = builder.BuildGameObject(c);
                        if (gameObject != null)
                        {
                            //Each character represents it's location times 64 (Since tiles are assumed 64x64)
                            gameObject.X = 64 * xCount;
                            gameObject.Y = 64 * yCount;
                            GameObjects.Add(gameObject);
                        }
                        xCount++;
                    }
                    xCount = 1;
                    yCount++;
                }
            }
        }
        public RegistroI010 GetRegistroI010()
        {
            DataAccessor <RegistroI010> regI010Accessor =
                UndTrabalho.DBArquivoSpedContabil.CreateSqlStringAccessor(
                    SqlExpressionsContabilRepository.GetSelectRegistroI010(),
                    new FilterByCdEmpresaParameterMapper(UndTrabalho.DBArquivoSpedContabil),
                    MapBuilder <RegistroI010> .MapAllProperties()
                    .DoNotMap(p => p.IND_ESC)
                    .Build());

            RegistroI010 regI010 = regI010Accessor.Execute(UndTrabalho.CodigoEmpresa).First();

            switch (UndTrabalho.TipoArquivo)
            {
            case TipoArquivo.ContabilDiarioCompleto:
                regI010.IND_ESC = "G";
                break;

            case TipoArquivo.ContabilDiarioEscrituracaoResumida:
                regI010.IND_ESC = "R";
                break;

            case TipoArquivo.ContabilDiarioAuxiliar:
                regI010.IND_ESC = "A";
                break;

            case TipoArquivo.ContabilLivroBalancetes:
                regI010.IND_ESC = "B";
                break;

            case TipoArquivo.ContabilRazaoAuxiliar:
                regI010.IND_ESC = "Z";
                break;
            }

            return(regI010);
        }
        /// <summary>
        /// Obtiene un mapeo basico de la clase Almacen Movimiento Costo
        /// </summary>
        /// <returns></returns>
        private static IMapBuilderContext <AlmacenMovimientoCostoInfo> MapeoBasico()
        {
            try
            {
                Logger.Info();
                IMapBuilderContext <AlmacenMovimientoCostoInfo> mapAlmacenMovimientoCosto =
                    MapBuilder <AlmacenMovimientoCostoInfo> .MapNoProperties();

                mapAlmacenMovimientoCosto.Map(x => x.AlmacenMovimientoCostoId).ToColumn("AlmacenMovimientoCostoID");
                mapAlmacenMovimientoCosto.Map(x => x.AlmacenMovimientoId).ToColumn("AlmacenMovimientoID");
                mapAlmacenMovimientoCosto.Map(x => x.TieneCuenta).ToColumn("TieneCuenta");
                mapAlmacenMovimientoCosto.Map(x => x.ProveedorId).ToColumn("ProveedorID");
                mapAlmacenMovimientoCosto.Map(x => x.CuentaSAPID).ToColumn("CuentaSAPID");
                mapAlmacenMovimientoCosto.Map(x => x.CostoId).ToColumn("CostoID");
                mapAlmacenMovimientoCosto.Map(x => x.Cantidad).ToColumn("Cantidad");
                mapAlmacenMovimientoCosto.Map(x => x.Importe).ToColumn("Importe");
                return(mapAlmacenMovimientoCosto);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex);
            }
        }
Example #29
0
        public ResourceMapper(MapBuilder builderType = MapBuilder.Delegate)
        {
            switch (builderType)
            {
            case MapBuilder.Delegate:
                _builder = new DelegateBuilder <TContext>(this);
                break;

            case MapBuilder.Emit:
                _builder = new EmitBuilder <TContext>(this);
                break;

            default:
                throw new ArgumentOutOfRangeException("builderType");
            }
            _memberConsumers.Add(new DefaultMemberConsumer());
            _memberResolvers.Add(new IgnoreCaseNameMatcher());
            _defaultMaps.Add(new MapList <TContext>(this));
            _defaultMaps.Add(new MapArray <TContext>(this));
            _defaultMaps.Add(new MapEnum <TContext>());
            _defaultMaps.Add(new MapByVal <TContext>());
            _defaultMaps.Add(new MapNonNullableToNullable <TContext>(this));
            _defaultMaps.Add(new MapNullableToNullable <TContext>(this));
        }
Example #30
0
    //Создание новой игры (дописать для онлайна и разых городов)
    public void CreateNewGame(int countOfPlayers, int startMoney, string NameOfGame, bool online, string nameOfTown,
                              string nickName)
    {
#if UNITY_EDITOR
        File.Copy(@"Assets\StreamingAssets\" + nameOfTown, @"Assets\SavedGames\Network\" + nameOfTown + "_" + NameOfGame + ".db");
#else
        File.Copy(Application.persistentDataPath + @"\StreamingAssets\" + nameOfTown, Application.persistentDataPath + @"/SavedGames/Network/" + nameOfTown + "_" + NameOfGame + ".db");
#endif

        dataService = new DataService(nameOfTown + "_" + NameOfGame + ".db", true);
        nameOfGane  = NameOfGame + ".db";

        GetEverithing();
        players = new NetworkPlayer[countOfPlayers + 1];

        for (int i = 1; i < countOfPlayers + 1; i++)
        {
            NetworkPlayer player;
            if (i == 1)
            {
                player = new NetworkPlayer(i, nickName, startMoney, false, false,
                                           MapBuilder.GetCenter(paths[1].start, paths[1].end));
            }
            else
            {
                player = new NetworkPlayer(i, names[Random.Range(0, names.Count)], startMoney, false, true,
                                           MapBuilder.GetCenter(paths[1].start, paths[1].end));
            }
            players[i] = player;
            dataService.AddPlayer(player);
        }

        GetEverithing();

        this.nameOfTown = nameOfTown;
    }
        public List <ProductConfigure> SelProductConfigureById(string ProductId)
        {
            List <ProductConfigure> list = null;

            try
            {
                IParameterMapper ipmapper = new SelProductConfigureParameterMapper();
                DataAccessor <ProductConfigure> tableAccessor;
                string strSql = @"select p.ProductId, p.LoveCount,p.Count from ProductConfigure p
                            where p.ProductId=@ProductId";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <ProductConfigure> .MapAllProperties()
                                                           .Map(t => t.ProductId).ToColumn("ProductId")
                                                           .Map(t => t.LoveCount).ToColumn("LoveCount")
                                                           .Map(t => t.Count).ToColumn("Count")
                                                           .Build());
                list = tableAccessor.Execute(new string[] { ProductId }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }
Example #32
0
    public void GenerateNewMap()
    {
        string strAlgo = DropdownAlgo.options[DropdownAlgo.value].text;
        var    algo    = (MapFloorAlgorithm)System.Enum.Parse(typeof(MapFloorAlgorithm), strAlgo);
        int    w       = 50;
        int    h       = 50;

        switch (algo)
        {
        case MapFloorAlgorithm.SingleRoom:
            w = Random.Range(5, 15);
            h = Random.Range(4, 12);
            break;

        case MapFloorAlgorithm.RandomWalkers:
            break;

        case MapFloorAlgorithm.CaveLike1:
            break;
        }

        MapBuilder.GenerateMapFloor(w, h, algo);
        MapBuilder.BuildMap(MapBuilder.MapSource, mapScript_, MapStyle);
    }
Example #33
0
        public List <ProductMenu> getImageProductMenu(string id)
        {
            List <ProductMenu> list = null;

            try
            {
                IParameterMapper           ipmapper = new getMemProductsParameterMapper();
                DataAccessor <ProductMenu> tableAccessor;
                string strSql = @"select b.ThumbImage
      from ProductMenu b where 1=1 and b.Status=1 and b.Id=@CompanyId";
                tableAccessor = db.CreateSqlStringAccessor(strSql, ipmapper, MapBuilder <ProductMenu> .MapAllProperties()

                                                           .Map(t => t.ThumbImage).ToColumn("ThumbImage")

                                                           .Build());
                list = tableAccessor.Execute(new string[] { id }).ToList();
                return(list);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                return(null);
            }
        }
Example #34
0
        public Map Load(string mapPath)
        {
            mapPath = mapPath.Replace('\\', '/');
            baseDir = Directory.GetParent(Path.GetDirectoryName(mapPath)) + "/";
            if (!File.Exists(mapPath))
            {
                Log.WriteLine(LogLevel.Fatal, "'{0}' was not found!", mapPath);
                return null;
            }
            builder = new MapBuilder();
            var reader = new StreamReader(mapPath);
            parser = new TextParser(reader) {AutoMultiline = true};

            parser.ReadLine(); // all those are for skipping the junk
            var lightCount = parser.ReadInt();
            parser.ReadLine();
            var clipPlanes = parser.ReadVector3(); // clip planes. no idea what they are and what is their purpose
            SetupCamera();
            SetupLight();
            while (parser.NextLine() != null)
                ParseObject();
            reader.Close();
            return builder.GetMap();
        }
        public static List <Vector2> GetPath(this DesignerViewModel designer, Vector2 startPoint, Vector2 endPoint,
                                             INeighbourFinder neighbourFinder = null)
        {
            var points = new List <Vector2>();

            try
            {
                var mapBuilder = new MapBuilder();

                foreach (var item in designer.ConnectedComponents.ToList())
                {
                    mapBuilder.AddObstacle(item.Position - Vector2.One, item.Size + (Vector2.One * 2));
                }

                mapBuilder.SetStart(startPoint);
                mapBuilder.SetEnd(endPoint);
                mapBuilder.SetDimensions(designer.Width, designer.Height);
                var mapResult = mapBuilder.Build();
                if (!mapResult.Success)
                {
                    throw new Exception(mapResult.Message);
                }

                var pathFinder =
                    new PathFinder.Algorithm.PathFinder(mapResult.Map,
                                                        neighbourFinder ?? DefaultNeighbourFinder.Straight(0.5f));

                points.AddRange(pathFinder.FindPath());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(points);
        }
Example #36
0
        public void Can_Find_Column_Manual_Map()
        {
            const string connectionString = "Data Source=(local);Initial Catalog=BulkWriterTest;Integrated Security=SSPI";
            const string tableName        = "TempTestTable";

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[ManualColumnName] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            IMapBuilderContext <MyTestClass> mapping = MapBuilder
                                                       .MapAllProperties <MyTestClass>()
                                                       .DestinationTable(tableName)
                                                       .MapProperty(x => x.Name, x => x.ToColumnName("ManualColumnName"));

            IEnumerable <PropertyMapping> propertyMappings = ((MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            AutoDiscover.Mappings(connectionString, tableName, propertyMappings);

            TestHelpers.ExecuteNonQuery(connectionString, "DROP TABLE " + tableName);

            foreach (PropertyMapping propertyMapping in propertyMappings)
            {
                Assert.IsTrue(propertyMapping.ShouldMap);

                if (propertyMapping.ShouldMap)
                {
                    for (int i = 0; i < MappingDestination.PropertyIndexCount; i++)
                    {
                        Assert.IsTrue(propertyMapping.Destination.IsPropertySet((MappingProperty)i));
                    }
                }
            }
        }
Example #37
0
        public MainWindow()
        {
            glyphRecogniser = new GlyphRecognitionStudio.MainForm();
            glyphRecogniser.frameProcessed += glyphRecogniser_frameProcessed;
            glyphRecogniser.Show();
            glyphRecogniser.Hide();

            carController       = new CarController.DefaultCarController();
            carControllerWindow = new CarController.MainWindow(carController);
            carControllerWindow.Show();

            InitializeComponent();

            Canvas_trackPlanner.Children.Add(plannerBackGround); //REMOVE IT FROM HERE

            MarkerFinder    markerFinder    = new MarkerFinder();
            ObstaclesFinder obstaclesFinder = new ObstaclesFinder();
            ObjectsToTrace  objectsToTrace  = new ObjectsToTrace(new List <string>()
            {
                "s1", "s2"
            }, "car", "parking");

            mapBuilder = new MapBuilder(markerFinder, obstaclesFinder, objectsToTrace);
        }
        public IEnumerable <RegistroA170> GetRegistrosA170(string codChaveNotaFiscal, string codEmp)
        {
            if (regA170Accessor == null)
            {
                regA170Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsPisCofinsRepository.GetSelectRegistrosA170(),
                        new FilterByCdEmpresaPkNotaFisParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder <RegistroA170> .MapAllProperties()
                        .DoNotMap(p => p.NUM_ITEM)
                        .Build());
            }

            List <RegistroA170> resultado = regA170Accessor.Execute(
                codEmp,
                codChaveNotaFiscal).ToList();
            int numeroItem = 0;

            foreach (RegistroA170 regA170 in resultado)
            {
                regA170.NUM_ITEM = ++numeroItem;
            }
            return(resultado);
        }
Example #39
0
 public static bool Prefix(MapBuilder __instance)
 {
     __instance.Map.gatedEntrancePrefab = __instance.compoundConfig.gateEntrace;
     __instance.Map.postBuildDetailSolver.enemyPrefab        = __instance.compoundConfig.enemyPrefab;
     __instance.Map.postBuildDetailSolver.interiorModuleData = __instance.ModuleData;
     __instance.Map.postBuildDetailSolver.midpointGateSlots  = __instance.Map.midpointGateSlots;
     __instance.Map.postBuildDetailSolver.InitializeDetailSolver(__instance, __instance.propSolver, __instance.shouldBuildProps);
     CrunchySdk.Map = __instance.Map;
     Events.Instance.InvokePreProcessingEvent(__instance, out var allowPreProcess);
     if (!allowPreProcess)
     {
         return(false);
     }
     foreach (MapBuilder.ProcessingStep processingStep in __instance.postProcessingSteps)
     {
         if (!processingStep.ignore && (!processingStep.onlyMaster || PhotonNetwork.IsMasterClient))
         {
             if (processingStep.pauseBefore)
             {
                 Debug.Break();
             }
             Events.Instance.InvokePostProcessingStepEvent(processingStep, __instance, out var allowPostProcess);
             if (!allowPostProcess)
             {
                 continue;
             }
             processingStep.step.Process(__instance.Map.postBuildDetailSolver);
             Events.Instance.InvokeFinalizePostProcessingStepEvent(processingStep, __instance);
             if (processingStep.pauseAfter)
             {
                 Debug.Break();
             }
         }
     }
     return(false);
 }
Example #40
0
        public void MapBuilder_ShouldSuffixAltNames_But_ShouldNotSuffixNames()
        {
            var mapBuilder = new MapBuilder();
            var columns = mapBuilder.BuildColumns<Person>()
                .MappedColumns.SuffixAltNames("_p");

            Assert.IsTrue(columns.All(c => c.ColumnInfo.AltName.EndsWith("_p")));
            Assert.IsFalse(columns.All(c => c.ColumnInfo.Name.EndsWith("_p")));
        }
Example #41
0
        public void MapBuilder_IgnoringAnAlreadyExcludedColumn_ShouldNotThrowAnException()
        {
            var mapBuilder = new MapBuilder();
            var columns = mapBuilder.BuildColumnsFromSimpleTypes<EntityWithSimpleAndComplexProperties>()
                .Ignore(e => e.OneToOneChild) // Should already be ignored because it is not a simple type
                .Ignore(e => e.Collection); // Should already be ignored because it is an ICollection

            Assert.AreEqual(2, columns.MappedColumns.Count);
        }
Example #42
0
 public void MapBuilder_Relationships_ShouldMapPublicProperties_ThatAreICollection()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildRelationships<UnmappedPerson>();
     Assert.IsTrue(maps.Relationships.Count == 1);
     Assert.IsNotNull(maps.Relationships["Pets"]);
     Assert.IsTrue(_mapRepository.Relationships[_personType].Count == 1);
     Assert.IsNotNull(_mapRepository.Relationships[_personType]["Pets"]);
 }
Example #43
0
        public void MapBuilder_ShouldOnlyMapSimpleTypes()
        {
            var mapBuilder = new MapBuilder();
            var columns = mapBuilder.BuildColumnsFromSimpleTypes<EntityWithSimpleAndComplexProperties>();

            Assert.AreEqual(2, columns.MappedColumns.Count);
        }
Example #44
0
 public RobotControl()
 {
     MapBuilder = new MapBuilder();
     Localization = new Localization();
 }
        public virtual void Index(string scope, string documentType, IDocument document)
        {
            var core = GetCoreName(scope, documentType);
            if (!_pendingDocuments.ContainsKey(core))
            {
                _pendingDocuments.Add(core, new List<ESDocument>());
            }

            string mapping = null;
            if (!_mappings.ContainsKey(core))
            {
                // Get mapping info
                if (Client.IndexExists(new IndexExistsCommand(scope)))
                {
                    try
                    {
                        mapping = Client.GetMapping(new GetMappingCommand(scope, documentType));
                    }
                    catch (OperationException ex)
                    {
                        if (ex.HttpStatusCode != 404 || !ex.Message.Contains("TypeMissingException"))
                        {
                            throw;
                        }
                    }

                    if (mapping != null)
                        _mappings.Add(core, mapping);
                }
            }
            else
            {
                mapping = _mappings[core];
            }

            var submitMapping = false;

            var properties = new Properties<ESDocument>();
            var localDocument = new ESDocument();

            for (var index = 0; index < document.FieldCount; index++)
            {
                var field = document[index];

                var key = field.Name.ToLower();

                if (localDocument.ContainsKey(key))
                {
                    var objTemp = localDocument[key];
                    object[] objListTemp;
                    var temp = objTemp as object[];
                    if (temp != null)
                    {
                        var objList = new List<object>(temp) { field.Value };
                        objListTemp = objList.ToArray();
                    }
                    else
                    {
                        objListTemp = new[] { objTemp, field.Value };
                    }

                    localDocument[key] = objListTemp;
                }
                else
                {
                    if (String.IsNullOrEmpty(mapping) || !mapping.Contains(String.Format("\"{0}\"", key)))
                    {
                        var type = field.Value != null ? field.Value.GetType() : null;
                        var propertyMap = new CustomPropertyMap<ESDocument>(field.Name, type)
                        .Store(field.ContainsAttribute(IndexStore.YES))
                        .When(field.ContainsAttribute(IndexType.NOT_ANALYZED), p => p.Index(IndexState.not_analyzed))
                        .When(field.ContainsAttribute(IndexType.NO), p => p.Index(IndexState.no));

                        properties.CustomProperty(field.Name, p => propertyMap);

                        submitMapping = true;
                    }

                    localDocument.Add(key, field.Value);
                }
            }

            // submit mapping
            if (submitMapping)
            {
                if (!Client.IndexExists(new IndexExistsCommand(scope)))
                {
                    var response = Client.CreateIndex(new IndexCommand(scope));
                    if (response.error != null)
                        throw new IndexBuildException(response.error);
                }

                var mapBuilder = new MapBuilder<ESDocument>();
                var mappingNew = mapBuilder.RootObject(documentType, d => d.Properties(p => properties)).Build();

                var result = Client.PutMapping(new PutMappingCommand(scope, documentType), mappingNew);
                if (!result.acknowledged && result.error != null)
                    throw new IndexBuildException(result.error);
            }

            _pendingDocuments[core].Add(localDocument);

            // Auto commit changes when limit is reached
            if (AutoCommit && _pendingDocuments[core].Count > AutoCommitCount)
            {
                Commit(scope);
            }
        }
Example #46
0
 public void MapBuilder_ShouldMapPublicAndPrivateProperties()
 {
     var mapBuilder = new MapBuilder(false);
     var maps = mapBuilder.BuildColumns<UnmappedPerson>();
     Assert.IsTrue(maps.Count == 7);
 }
Example #47
0
 public void MapBuilder_ShouldMapPublicProperties()
 {
     var mapBuilder = new MapBuilder();
     var maps = mapBuilder.BuildColumns<UnmappedPerson>();
     Assert.IsTrue(maps.Count == 6);
 }
        public virtual void Index(string scope, string documentType, IDocument document)
        {
            var core = GetCoreName(scope, documentType);
            if (!_pendingDocuments.ContainsKey(core))
            {
                _pendingDocuments.Add(core, new List<ESDocument>());
            }

            string mapping = null;
            if (!_mappings.ContainsKey(core))
            {
                // Get mapping info
                if (Client.IndexExists(new IndexExistsCommand(scope)))
                {
                    mapping = GetMappingFromServer(scope, documentType, core);
                }
            }
            else
            {
                mapping = _mappings[core];
            }

            var submitMapping = false;

            var properties = new Properties<ESDocument>();
            var localDocument = new ESDocument();

            for (var index = 0; index < document.FieldCount; index++)
            {
                var field = document[index];

                var key = field.Name.ToLower();

                if (localDocument.ContainsKey(key))
                {
                    var objTemp = localDocument[key];
                    object[] objListTemp;
                    var temp = objTemp as object[];
                    if (temp != null)
                    {
                        var objList = new List<object>(temp) { field.Value };
                        objListTemp = objList.ToArray();
                    }
                    else
                    {
                        objListTemp = new[] { objTemp, field.Value };
                    }

                    localDocument[key] = objListTemp;
                }
                else
                {
                    if (String.IsNullOrEmpty(mapping) || !mapping.Contains(String.Format("\"{0}\"", field.Name)))
                    {
                        var type = field.Value != null ? field.Value.GetType() : null;
                        var propertyMap = new CustomPropertyMap<ESDocument>(field.Name, type)
                        .Store(field.ContainsAttribute(IndexStore.Yes))
                        .When(field.ContainsAttribute(IndexType.NotAnalyzed), p => p.Index(IndexState.not_analyzed))
                        .When(field.Name.StartsWith("__content", StringComparison.OrdinalIgnoreCase), p => p.Analyzer(SearchAnalyzer))
                        .When(Regex.Match(field.Name, "__content_en.*").Success, x => x.Analyzer("english"))
                        .When(Regex.Match(field.Name, "__content_de.*").Success, x => x.Analyzer("german"))
                        .When(Regex.Match(field.Name, "__content_ru.*").Success, x => x.Analyzer("russian"))
                        .When(field.ContainsAttribute(IndexType.No), p => p.Index(IndexState.no));

                        properties.CustomProperty(field.Name, p => propertyMap);

                        submitMapping = true;
                    }

                    localDocument.Add(key, field.Value);
                }
            }

            // submit mapping
            if (submitMapping)
            {
                //Use ngrams analyzer for search in the middle of word
                //http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/ngrams-compound-words.html
                var settings = new IndexSettingsBuilder()
                    .Analysis(als => als
                        .Analyzer(a => a.Custom(SearchAnalyzer, custom => custom
                            .Tokenizer(DefaultTokenizers.standard)
                            .Filter("trigrams_filter", DefaultTokenFilters.lowercase.ToString())))
                        .Filter(f => f.NGram("trigrams_filter", ng => ng
                                .MinGram(3)
                                .MaxGram(3)))).Build();

                if (!Client.IndexExists(new IndexExistsCommand(scope)))
                {
                    var response = Client.CreateIndex(new IndexCommand(scope), settings);
                    _settingsUpdated = true;
                    if (response.error != null)
                        throw new IndexBuildException(response.error);
                }
                else if (!_settingsUpdated)
                {
                    // We can't update settings on active index.
                    // So we need to close it, then update settings and then open index back.
                    Client.Close(new CloseCommand(scope));
                    Client.UpdateSettings(new UpdateSettingsCommand(scope), settings);
                    Client.Open(new OpenCommand(scope));
                    _settingsUpdated = true;
                }

                var mapBuilder = new MapBuilder<ESDocument>();
                var mappingNew = mapBuilder.RootObject(documentType, d => d.Properties(p => properties)).Build();

                var result = Client.PutMapping(new PutMappingCommand(scope, documentType), mappingNew);
                if (!result.acknowledged && result.error != null)
                    throw new IndexBuildException(result.error);

                GetMappingFromServer(scope, documentType, core);
            }

            _pendingDocuments[core].Add(localDocument);

            // Auto commit changes when limit is reached
            if (AutoCommit && _pendingDocuments[core].Count > AutoCommitCount)
            {
                Commit(scope);
            }
        }
Example #49
0
            public void GameInitialization( PgController pgController, 
                                            AIController aiController,
                                            IMapViewer mapViewer,
                                            IAtomListener singleMsgListener,
                                            IAnimationViewer animationViewer,
                                            List<IAtomListener> atomListeners,
                                            List<ISheetViewer> sheetViews,
                                            List<IBackpackViewer> backpackViewers,
                                            List<ISpellbookViewer> spellbookViewers,
                                            List<IAtomListener> secondarySpellsViewers)
            {
                // Map generation
                var mapBuilder = new MapBuilder();

                mapBuilder.AddViewer(mapViewer);
                mapBuilder.AddSingleMessageListener(singleMsgListener);

#if DEBUG_MAP
                mapBuilder.Explored = TernaryValue.Unexplored;
                mapBuilder.Lightened = true;
#if RANDOM_MAP_GENERATION
                mapBuilder.Height = 40;
                mapBuilder.Width = 30;

                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.Random;
#else
#if !DEBUG_MAP_FROM_FILE
                mapBuilder.Height = 30;
                mapBuilder.Width = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    mapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                mapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = 0 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = 0, Y = mapBuilder.Height - 1 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = mapBuilder.Width - 1, Y = 0 }));
                mapBuilder.AddAtom(new Wall(new Coord() { X = mapBuilder.Width - 1, Y = mapBuilder.Height - 1 }));

                mapBuilder.PlayerInitialPosition = new Coord() { X = 1, Y = 1 };

                mapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                mapBuilder.AddAtom(new LongSword(position: new Coord() { X = 7, Y = 4 }));
                mapBuilder.AddAtom(new Leather(position: new Coord() { X = 7, Y = 3 }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            mapBuilder.AddAtom(new LongSword(position: new Coord() { X = i, Y = j }));
                        }
                        else
                        {
                            mapBuilder.AddAtom(new FlamingLongSword(position: new Coord() { X = i, Y = j }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));
                mapBuilder.AddAtom(book1);

                mapBuilder.AddAtom(new WoodenShield(position: Coord.Random(mapBuilder.Width, mapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();
                mapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;
                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();
                mapBuilder.AddAtom(orc2);

                currentPg = new PgCreator() { God = Gods.Ares }.Create();
                
                currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
                //aiController.Register(orc1);
                //aiController.Register(orc2);
#endif
#endif
#else
                mapBuilder.LoadFromFile("");
#endif
#if DEBUG_MAP_FROM_FILE
                mapBuilder.MapCreationMode = MapBuilder.TableCreationMode.FromFile;
#endif
                var map = mapBuilder.Create();
#if !DEBUG_MAP_FROM_FILE
                if (currentPg == null)
                {
                    currentPg = new PgCreator() { God = Gods.Ares }.Create();
                }
                CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
#else
                currentPg = map.CurrentPg;

                if (currentPg == null)
                {
                    currentPg = new PgCreator() { God = Gods.Ares }.Create();
                    CurrentPg.InsertInMap(map, map.PlayerInitialPosition, overwrite: false);
                }
                else
                {
                    CurrentPg.InsertInMap(map, currentPg.Position, overwrite: true);
                }
#endif
                var aiCharacters = map.AICharacters.ToList();

                atomListeners.ForEach(listener => currentPg.RegisterListener(listener));
                aiCharacters.ForEach(aiC => currentPg.Listeners.ForEach(listener => aiC.RegisterListener(listener)));
                sheetViews.ForEach(sheet => currentPg.RegisterSheet(sheet));
                backpackViewers.ForEach(viewer => currentPg.Backpack.RegisterViewer(viewer));
                spellbookViewers.ForEach(viewer => currentPg.Spellbook.RegisterViewer(viewer));
                secondarySpellsViewers.ForEach(secondarySpellsViewer => currentPg.Spellbook.RegisterSecondaryView(secondarySpellsViewer));

                pgController.Register(CurrentPg);
                pgController.BackpackController.Register(CurrentPg.Backpack);
                pgController.SpellbookController.Register(CurrentPg.Spellbook);

                aiController.RegisterAll(aiCharacters);
                Animation.RegisterAnimationViewer(animationViewer);
            }
Example #50
0
            public void ResetMapBuilder()
            {
                MapBuilder = new MapBuilder();

                var controllers = new List<Controller>()
                {
                    pgController,
                    aiController,
                };

                controllers.Where(controller => controller != null)
                            .ToList()
                            .ForEach(controller => controller.UnregisterAll());
            }