Exemplo n.º 1
0
        private static void ParseGlobalData(string line, ref MapConfiguration mc)
        {
            string[] elements = line.Split();
            if (elements.Length > 2)
            {
                throw new ParseLineException("Too many arguments");
            }
            if (!double.TryParse(elements[1].Replace('.', ','), out double va))
            {
                throw new ParseLineException("Value has to be a floating point number");
            }
            switch (elements[0])
            {
            case "przyrost_naturalny":
                mc.Birthrate = va;
                break;

            case "stopien_rozwoju":
                mc.DevelopmentLevel = (int)va;
                break;

            case "srednia_temperatura":
                mc.AvgTemperature = va;
                break;

            case "srednia_wysokosc":
                mc.AvgHeight = va;
                break;

            default:
                throw new ParseLineException("Definition unrecognised");
            }
        }
Exemplo n.º 2
0
    public void generate_floor()
    {
        MapConfiguration config = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>();

        width         = config.width;
        height        = config.height;
        cell_size     = config.cell_size;
        texture_scale = config.floor_texture_scale;
        wall_height   = config.wall_height;

        Vector3 offset = new Vector3(width / (2f * cell_size), 0.0f, height / (2f * cell_size));

        offset.y = wall_height;

        Vector3 v00 = new Vector3(0f, 0f, 0f) - offset;
        Vector3 v01 = new Vector3(width * cell_size, 0f, 0f) - offset;
        Vector3 v10 = new Vector3(0f, 0f, height * cell_size) - offset;
        Vector3 v11 = new Vector3(width * cell_size, 0f, height * cell_size) - offset;

        Vector2 n00 = new Vector2(0f, 0f);
        Vector2 n01 = new Vector2(width / texture_scale, 0f);
        Vector2 n10 = new Vector2(0f, height / texture_scale);
        Vector2 n11 = new Vector2(width / texture_scale, height / texture_scale);

        Vector3[] vertices  = { v00, v01, v10, v11 };
        Vector2[] uvs       = { n00, n01, n10, n11 };
        int[]     triangles = { 3, 1, 0, 2, 3, 0 };

        MeshFilter mf = GetComponent <MeshFilter>();

        mf.mesh.vertices  = vertices;
        mf.mesh.uv        = uvs;
        mf.mesh.triangles = triangles;
        mf.mesh.RecalculateNormals();
    }
Exemplo n.º 3
0
        public void Map_Orders_Custom_Expression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id           = o.Id,
                OrderNo      = o.OrderNo,
                OrderDetails = o.OrderDetails.Select(od => new OrderDetailDTO {
                    Id       = od.Id,
                    Product  = mc.Map <Product, ProductDTO>(od.Product),
                    SubPrice = od.UnitPrice * od.Count
                }).ToList(),
                Price = Math.Round(o.Price)
            });
            config.RegisterMap <Product, ProductDTO>();
            config.RegisterMap <Company, CompanyDTO>();

            var dtoList = config.Map <Order, OrderDTO>(_orders).ToList();

            Assert.Equal(
                dtoList[3].OrderDetails.ToList()[2].SubPrice,
                _orders[3].OrderDetails[2].UnitPrice * _orders[3].OrderDetails[2].Count
                );

            Assert.Equal(
                dtoList[3].OrderDetails.ToList()[2].Product.Supplier.CompanyName,
                _orders[3].OrderDetails[2].Product.Supplier.CompanyName
                );
        }
Exemplo n.º 4
0
        public void Map_Existing_With_Non_MemberInitExpression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>((c, mc) => mc.Map <Customer, CustomerDTO>(c));
            Assert.Throws <InvalidOperationException>(() => config.MapTo(new Customer(), new CustomerDTO()));
        }
Exemplo n.º 5
0
        public void Map_With_Non_MemberInitExpression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>((c, mc) => null);
            Assert.Null(config.Map <CustomerDTO>(new Customer(), true));
        }
Exemplo n.º 6
0
        public void Project_Orders_Custom_Expression()
        {
            // we aren't registering OrderDetail-OrderDetailDTO because we declare the custom mapping
            // even we don't include OrderDetail in the query, it will be mapped
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id           = o.Id,
                OrderNo      = o.OrderNo,
                OrderDetails = o.OrderDetails.Select(od => new OrderDetailDTO {
                    Id       = od.Id,
                    Product  = mc.Map <Product, ProductDTO>(od.Product),
                    SubPrice = od.UnitPrice * od.Count
                }).ToList(),
                Price = o.Price
            });

            var mockContext      = new Mock <TestEntities>();
            var observableOrders = new ObservableCollection <Order>(_orders);

            mockContext.Setup(p => p.Orders).Returns(GetMockSet(observableOrders).Object);

            var query    = mockContext.Object.Orders;
            var dtoQuery = config.ProjectTo <OrderDTO>(query, new IncludePath[] { });
            var dtoList  = dtoQuery.ToList();

            Assert.IsNotNull(dtoList[3].OrderDetails);
            Assert.AreEqual(dtoList[3].OrderDetails.Count, _orders[3].OrderDetails.Count);
            Assert.IsTrue(dtoList.All(o => o.OrderDetails.All(od => od.Product == null)));
        }
Exemplo n.º 7
0
        public void Project_Orders_Custom_Expression_2()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id           = o.OrderDetails.ToList().Select(od => od.OrderId).First(),
                OrderNo      = o.OrderNo,
                Price        = o.OrderDetails.Sum(od => od.UnitPrice),
                OrderDetails = mc.MapToList <OrderDetail, OrderDetailDTO>(o.OrderDetails)
            });
            config.RegisterMap <OrderDetail, OrderDetailDTO>();
            config.RegisterMap <Product, ProductDTO>();
            config.RegisterMap <Company, CompanyDTO>();

            var projector = config.GetProjector <Order, OrderDTO>(o => o.OrderDetails.Select(od => od.Product.Supplier));
            var func      = Helper.CreateProjector(projector);
            var dtoList   = _orders.Select(func).ToList();

            Assert.Equal(
                dtoList[3].Price,
                _orders[3].OrderDetails.Sum(od => od.UnitPrice)
                );

            Assert.Equal(
                dtoList[3].OrderDetails.ToList()[2].Product.Supplier.CompanyName,
                _orders[3].OrderDetails[2].Product.Supplier.CompanyName
                );
        }
Exemplo n.º 8
0
        public void Project_Orders_Custom_Expression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id           = o.Id,
                OrderNo      = o.OrderNo,
                OrderDetails = o.OrderDetails.Select(od => new OrderDetailDTO {
                    Id       = od.Id,
                    Product  = mc.Map <Product, ProductDTO>(od.Product),
                    SubPrice = od.UnitPrice * od.Count
                }).ToList(),
                Price = o.Price
            });

            var mockContext      = new Mock <TestEntities>();
            var observableOrders = new ObservableCollection <Order>(_orders);

            mockContext.Setup(p => p.Orders).Returns(GetMockSet(observableOrders).Object);

            var query    = mockContext.Object.Orders;
            var dtoQuery = config.ProjectTo <OrderDTO>(query, new IncludePath[] { });
            var dtoList  = dtoQuery.ToList();

            Assert.IsNull(dtoList[3].OrderDetails);
        }
Exemplo n.º 9
0
        public void Project_Orders_With_Details_Product_Custom_Expression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id           = o.Id,
                OrderNo      = o.OrderNo,
                OrderDetails = o.OrderDetails.Select(od => new OrderDetailDTO {
                    Id       = od.Id,
                    Product  = mc.Map <Product, ProductDTO>(od.Product),
                    SubPrice = od.UnitPrice * od.Count
                }).ToList(),
                Price = o.Price
            });
            config.RegisterMap <Product, ProductDTO>();
            config.RegisterMap <Company, CompanyDTO>();

            var mockContext      = new Mock <TestEntities>();
            var observableOrders = new ObservableCollection <Order>(_orders);

            mockContext.Setup(p => p.Orders).Returns(GetMockSet(observableOrders).Object);

            var query    = mockContext.Object.Orders;
            var dtoQuery = config.ProjectTo <Order, OrderDTO>(query, o => o.OrderDetails.Select(od => od.Product).Select(p => p.Supplier));
            var dtoList  = dtoQuery.ToList();

            Assert.AreEqual(
                dtoList[3].OrderDetails.ToList()[2].Product.Supplier.CompanyName,
                _orders[3].OrderDetails[2].Product.Supplier.CompanyName
                );
        }
Exemplo n.º 10
0
        void HandleCreateClicked(object Sender, EventArgs E)
        {
            try
            {
                var height = Convert.ToInt32(_HeightInput.Value);
                var width  = Convert.ToInt32(_WidthInput.Value);
                if (height < 1 || width < 1)
                {
                    throw new FormatException();
                }

                MapConfiguration configuration = null;
                if (_GenerateRandomCheckbox.Value)
                {
                    configuration = new RandomMapConfiguration(width, height, _MatchSettingsSelect.Value.Value);
                }
                else
                {
                    configuration = new BlankMapConfiguration(width, height);
                }
                if (OnCreate != null)
                {
                    OnCreate(this, new ValuedEventArgs <MapConfiguration>(configuration));
                }

                ClearError();
            }
            catch (FormatException)
            {
                SetError("Input a number greater than 0.");
            }
        }
Exemplo n.º 11
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddDbContext <UsuarioDbContext>(options =>
                                                     options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            ////Registrando serviço do Repository e criando uma instância do serviço a cada requisição
            services.AddTransient <IUsuarioRepository, UsuarioRepository>();

            MapConfiguration.RegisterMapProfile();

            //Adicionando serviço de Cookies a aplicação
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
                       options.LoginPath = "/Login/Index"
                       );

            services.AddMvc();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
    // Start is called before the first frame update
    void Start()
    {
        MapConfiguration mapConfiguration = new MapConfiguration(players);

        mapConfiguration.Seed = 123123;
        mapConfiguration.DormantsPerPlayer       = 3;
        mapConfiguration.MaxiumumOutpostDistance = 130;
        mapConfiguration.MinimumOutpostDistance  = 30;
        mapConfiguration.OutpostsPerPlayer       = 3;


        GameConfiguration config = new GameConfiguration(players, DateTime.Now, mapConfiguration);

        Dictionary <String, GameConfiguration> puzzleList = new Dictionary <string, GameConfiguration>();

        puzzleList.Add("SampleGameNoNetwork", config);


        foreach (var puzzle in puzzleList)
        {
            // Create a new templated item
            GameRoomButton scrollItem = (GameRoomButton)Instantiate(scrollItemTemplate);
            scrollItem.gameObject.SetActive(true);
            scrollItem.GetComponent <Button>().onClick.AddListener(delegate { GoToGameLobby(puzzle.Value); });

            // Set the text
            Text text = scrollItem.GetComponentInChildren <Text>();
            text.text = puzzle.Key;

            // Set the button's parent to the scroll item template.
            scrollItem.transform.SetParent(scrollItemTemplate.transform.parent, false);
        }
    }
Exemplo n.º 13
0
        public Map GenerateMap(MapConfiguration mapConfiguration)
        {
            var roomCount = _dice.RollBetween(mapConfiguration.RoomCountBetween.Item1, mapConfiguration.RoomCountBetween.Item2);
            var origin    = GetNewRandomRoom();

            var rooms          = new List <Room>();
            var neighbourQueue = new Queue <Room>();

            neighbourQueue.Enqueue(origin);
            rooms.Add(origin);
            roomCount--;

            while (roomCount != 0)
            {
                var room = neighbourQueue.Dequeue();
                int maxNeighboursCount = (mapConfiguration.MaxRoomNeighboursCount > roomCount) ? roomCount : mapConfiguration.MaxRoomNeighboursCount;
                var newRooms           = GenerateNeighbours(room, mapConfiguration.MinRoomNeighboursCount, maxNeighboursCount);

                roomCount -= newRooms.Count;
                newRooms.ForEach(neighbourQueue.Enqueue);
                rooms.AddRange(newRooms);
            }

            rooms.ForEach(room => room.SpawnMonsters(1));

            SpawnShrines(rooms, mapConfiguration.HealingShrines);

            return(new Map
            {
                Rooms = rooms
            });
        }
Exemplo n.º 14
0
        public void Project_Orders_Custom_Expression2()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>((o, mc) => new OrderDTO {
                Id      = o.Id,
                OrderNo = o.OrderNo,
                // ReSharper disable once ConvertClosureToMethodGroup
                // it will fail for method group because it must be an "Expression" to be handled
                // mc.Map will be included in the final expression because we are using "Select" for "OrderDetails" navigation
                // using "Select" is equal of saying "always map this property my way"
                // if we want it to be dynamically decided for plural navigations we should have used: "mc.MapToList<OrderDetail, OrderDetailDTO>"
                OrderDetails = o.OrderDetails.Select(od => mc.Map <OrderDetail, OrderDetailDTO>(od)).ToList(),
                Price        = o.Price
            });
            // similar custom mapping. but this time we need to register OrderDetail-OrderDetailDTO to allow MapContext to do the mapping
            config.RegisterMap <OrderDetail, OrderDetailDTO>();

            var mockContext      = new Mock <TestEntities>();
            var observableOrders = new ObservableCollection <Order>(_orders);

            mockContext.Setup(p => p.Orders).Returns(GetMockSet(observableOrders).Object);

            var query    = mockContext.Object.Orders;
            var dtoQuery = config.ProjectTo <OrderDTO>(query, new IncludePath[] { });
            var dtoList  = dtoQuery.ToList();

            Assert.IsNotNull(dtoList[3].OrderDetails);
            Assert.AreEqual(dtoList[3].OrderDetails.Count, _orders[3].OrderDetails.Count);
            Assert.IsTrue(dtoList.All(o => o.OrderDetails.All(od => od.Product == null)));
        }
    public static List <TileMapGenerator> getTileMapGenerators(MapConfiguration mapConfiguration, List <string> groupIds)
    {
        List <TileMapGenerator> tileMapGenerators = new List <TileMapGenerator>();

        foreach (MapConfiguration.MapEntry mapGroup in mapConfiguration.configurations)
        {
            if (groupIds.Contains(mapGroup.groupId))
            {
                if (mapGroup.simpleConfigurations != null)
                {
                    tileMapGenerators.AddRange(mapGroup.simpleConfigurations);
                }
                if (mapGroup.standardConfigurations != null)
                {
                    tileMapGenerators.AddRange(mapGroup.standardConfigurations);
                }
                if (mapGroup.relativePathConfigurations != null)
                {
                    tileMapGenerators.AddRange(mapGroup.relativePathConfigurations);
                }
            }
        }

        return(tileMapGenerators);
    }
Exemplo n.º 16
0
 public static Int32 DMSGetMapConfSize(DMSMapConf?ObjPtr)
 {
     if (ObjPtr != null)
     {
         return(12 + 12 * MapConfiguration.DMSGetMapConfMember(ObjPtr.Value, DMSMapConfMember.DMS_MAPCONF_LIGHTCOUNT) + 8 * MapConfiguration.DMSGetMapConfMember(ObjPtr.Value, DMSMapConfMember.DMS_MAPCONF_CHARCOUNT) + 2 * MapConfiguration.DMSGetMapConfMember(ObjPtr.Value, DMSMapConfMember.DMS_MAPCONF_EVTCOUNT));
     }
     return(-1);
 }
Exemplo n.º 17
0
    void set_config_variables()
    {
        MapConfiguration config = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>();

        this.texture_scale = config.surface_texture_scale;
        this.cell_size     = config.cell_size;
        this.mesh_target   = GetComponent <MeshFilter>();
    }
Exemplo n.º 18
0
        public void Map_Without_Destination_With_Null()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>();

            Assert.Null(config.Map(null, true));
        }
Exemplo n.º 19
0
        public void Map_Generic_With_Null()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>();

            Assert.Null(config.Map <CustomerDTO>(null));
        }
Exemplo n.º 20
0
        public void Map_With_Null()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>();

            Assert.Null(config.Map(null, typeof(CustomerDTO)));
        }
    void set_config_variables()
    {
        MapConfiguration config = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>();

        this.cell_size   = config.cell_size;
        this.wall_height = config.wall_height;
        this.target_mesh = GetComponent <MeshFilter>();
    }
        public MapController(ApplicationDbContext context, IOptions <MapConfiguration> mapConfiguration)
        {
            _context = context;

            MapConfiguration = mapConfiguration.Value;

            AccessToken = MapConfiguration.MapBoxToken; //GetAccessToken().GetAwaiter().GetResult();
        }
Exemplo n.º 23
0
        public MainView()
        {
            AutoMapper.Mapper.Initialize(cfg => MapConfiguration.Configure(cfg));

            var v = WebNomenclatorsCache.Instance;

            InitializeComponent();
        }
    // set all map configuration variables
    private void set_config_variables()
    {
        MapConfiguration config = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfiguration>();

        this.width     = config.width;
        this.height    = config.height;
        this.cell_size = config.cell_size;
    }
Exemplo n.º 25
0
        public void Map_Enumerable_With_Null()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>();

            Assert.Null(config.Map <Customer, CustomerDTO>((IEnumerable <Customer>)null));
        }
Exemplo n.º 26
0
        public void Map_Empty_Dictionary_Returns_Empty()
        {
            var config = new MapConfiguration();

            var dict = new Dictionary <int, Customer>();

            Assert.Equal(config.Map <int, Customer, int, CustomerDTO>(dict).Count, 0);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Initializes all required modules for the game.
        /// </summary>
        protected virtual void InitializeModules()
        {
            UnityThread.Initialize();

            Dependencies.CacheAs <IGame>(this);

            Dependencies.CacheAs <IPlatformHost>(platformHost = PlatformHost.CreateHost());
            Dependencies.CacheAs <DeepLinker>(deepLinker      = platformHost.CreateDeepLinker());

            Dependencies.CacheAs <IEnvConfiguration>(envConfiguration = new EnvConfiguration(EnvType.Production));

            Dependencies.CacheAs <IModeManager>(modeManager = new ModeManager());

            Dependencies.CacheAs <INotificationBox>(notificationBox = new NotificationBox());

            Dependencies.CacheAs <IGameConfiguration>(gameConfiguration     = new GameConfiguration());
            Dependencies.CacheAs <IMapConfiguration>(mapConfiguration       = new MapConfiguration());
            Dependencies.CacheAs <IMapsetConfiguration>(mapsetConfiguration = new MapsetConfiguration());

            Dependencies.CacheAs <IFontManager>(fontManager       = new FontManager());
            Dependencies.CacheAs <IAtlas <Sprite> >(spriteAtlas   = new ResourceSpriteAtlas());
            Dependencies.CacheAs <IAtlas <AudioClip> >(audioAtlas = new ResourceAudioAtlas());

            Dependencies.CacheAs <IMusicCacher>(musicCacher           = new MusicCacher());
            Dependencies.CacheAs <IBackgroundCacher>(backgroundCacher = new BackgroundCacher());
            Dependencies.CacheAs <IWebImageCacher>(webImageCacher     = new WebImageCacher());
            Dependencies.CacheAs <IWebMusicCacher>(webMusicCacher     = new WebMusicCacher());

            Dependencies.CacheAs <IMusicController>(musicController = MusicController.Create());

            Dependencies.CacheAs <ISoundTable>(soundTable = new DefaultSoundTable(audioAtlas));
            Dependencies.CacheAs <ISoundPool>(soundPool   = new SoundPool(soundTable));

            Dependencies.CacheAs <IMapsetStore>(mapsetStore   = new MapsetStore(modeManager));
            Dependencies.CacheAs <IMapSelection>(mapSelection = new MapSelection(musicCacher, backgroundCacher, gameConfiguration, mapsetConfiguration, mapConfiguration));
            Dependencies.CacheAs <IMapManager>(mapManager     = new MapManager(mapsetStore, notificationBox, mapSelection));
            Dependencies.CacheAs <IMetronome>(metronome       = new Metronome()
            {
                AudioController = musicController
            });
            Dependencies.CacheAs <IMusicPlaylist>(musicPlaylist = new MusicPlaylist());

            Dependencies.CacheAs <IDownloadStore>(downloadStore = new DownloadStore());
            Dependencies.CacheAs <IApi>(api = new Api(envConfiguration, notificationBox, deepLinker));

            Dependencies.CacheAs <IUserManager>(userManager = new UserManager(api, Dependencies));
            Dependencies.CacheAs <IRecordStore>(recordStore = new RecordStore());

            Dependencies.CacheAs <IRootMain>(rootMain                 = RootMain.Create(Dependencies));
            Dependencies.CacheAs <IRoot3D>(root3D                     = Root3D.Create(Dependencies));
            Dependencies.CacheAs <IColorPreset>(colorPreset           = new ColorPreset());
            Dependencies.CacheAs <IAnimePreset>(animePreset           = new AnimePreset());
            Dependencies.CacheAs <IScreenNavigator>(screenNavigator   = new ScreenNavigator(rootMain));
            Dependencies.CacheAs <IOverlayNavigator>(overlayNavigator = new OverlayNavigator(rootMain));
            Dependencies.CacheAs <IDropdownProvider>(dropdownProvider = new DropdownProvider(rootMain));

            Dependencies.CacheAs <ITemporaryStore>(temporaryStore = new TemporaryStore());
        }
Exemplo n.º 28
0
        public void Map_Two_Generic_With_Null()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>(b => b.MapMember(c => c.Address, (c, mc) => mc.Map <Address, AddressDTO>(c.MainAddress)));

            Assert.Null(config.Map <Customer, CustomerDTO>((Customer)null));
            Assert.Null(config.Map <Customer, CustomerDTO>(new Customer()).Address);
        }
Exemplo n.º 29
0
 public DataForm(MapConfiguration mc)
 {
     InitializeComponent();
     birthBox.Text  = mc.Birthrate.ToString();
     devLvlBox.Text = mc.DevelopmentLevel.ToString();
     tempBox.Text   = mc.AvgTemperature.ToString();
     heiBox.Text    = mc.AvgHeight.ToString();
     this.mc        = mc;
 }
Exemplo n.º 30
0
        /// <inheritdoc/>
        public IGuildMap CreateGuildMap(ushort id, MapDefinition definition, MapConfiguration config, int guildId)
        {
            if (definition.CreateType == CreateType.GRB)
            {
                return(new GRBMap(guildId, _guildRankingManager, id, definition, config, _logger, _databasePreloader, _mobFactory, _npcFactory, _obeliskFactory, _timeService));
            }

            return(new GuildHouseMap(guildId, _guildRankingManager, id, definition, config, _logger, _databasePreloader, _mobFactory, _npcFactory, _obeliskFactory, _timeService));
        }
Exemplo n.º 31
0
 public Map(MapConfiguration mapConfiguration)
 {
     _mapConfiguration = mapConfiguration;
     _dimensions = new Size(_mapConfiguration.MAP_SIZE.Width / _mapConfiguration.FLOOR_TILE_SIZE.Width, _mapConfiguration.MAP_SIZE.Height / _mapConfiguration.FLOOR_TILE_SIZE.Height);
     _map = new long[_dimensions.Width, _dimensions.Height];
     Utilities = new MapUtilities(_mapConfiguration.MAP_SIZE, _mapConfiguration.FLOOR_TILE_SIZE);
     _requestValidator = new RequestValidator(this);
     _collisionChecker = new CollisionChecker(this);
     _mapMarker = new MapMarker(this);
 }
Exemplo n.º 32
0
 public GameConfigurationManager()
 {
     bulletConfig = new BulletConfiguration();
     gameConfig = new GameConfiguration();
     shipConfig = new ShipConfiguration();
     mapConfig = new MapConfiguration();
     screenConfig = new ScreenConfiguration();
     leaderboardConfig = new LeaderboardConfiguration();
     healthPackConfig = new HealthPackConfiguration();
     abilityConfig = new AbilityConfiguration();
     shipMovementControllerConfig = new ShipMovementControllerConfiguration();
 }
Exemplo n.º 33
0
 public override Map generate(MapConfiguration config)
 {
     return generate(config, SIZE);
 }
Exemplo n.º 34
0
        private MapConfiguration GetCorrectionFactorForMap(int id, bool isM44, bool isLH242)
        {
            MapConfiguration mc = new MapConfiguration();
            mc.Correctionfactor = 1;
            mc.Correctionoffset = 0;
            mc.Description = "Unknown: " + id.ToString("X2");
            switch (id)
            {
                case 0x31:
                    if (isLH242)
                    {
                        mc.Description = "Engine speed";
                        mc.Correctionfactor = 40;
                        mc.Units = "RPM";
                    }
                    break;
                case 0x36: // Battery voltage
                    mc.Correctionfactor = 0.0704F;
                    mc.Description = "Battery voltage";
                    mc.Units = "Volt";
                    break;
                case 0x38: // Coolant temperature
                    mc.Correctionfactor = 1;
                    mc.Correctionoffset = -80;
                    mc.Description = "Coolant temperature";
                    mc.Units = "Degrees celcius";
                    break;
                case 0x3B: // Engine speed (rpm)

                    mc.Correctionfactor = 40;
                    if (isM44)
                    {
                        mc.Correctionfactor = 30;
                    }
                    mc.Correctionoffset = 0;
                    mc.Description = "Engine speed";
                    mc.Units = "RPM";
                    break;
                case 0x40: // Internal load signal
                    mc.Correctionfactor = 0.05F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Internal load signal";
                    mc.Units = "ms";
                    break;
                case 0x4C: // MAF sensor signal (Mass Air Flow)
                    mc.Correctionfactor = 0.01952F;
                    mc.Correctionoffset = 0;
                    mc.Description = "MAF signal";
                    mc.Units = "Volt";
                    break;
                case 0x4F: // Internal load signal LH242
                    if (isLH242)
                    {
                        mc.Correctionfactor = 0.05F;
                        mc.Correctionoffset = 0;
                        mc.Description = "Internal load signal";
                        mc.Units = "ms";
                    }
                    break;
                case 0x55: // Ignition advance
                    if (isLH242)
                    {
                        mc.Description = "Coolant temperature";
                        mc.Units = "Degrees";
                        //mc.Correctionoffset = 70;
                        //mc.Correctionfactor = 2.0714F;
                        //mc.Correctionoffset = -40;
                        //mc.Correctionfactor = 0.55F;

                    }
                    else
                    {
                        mc.Correctionfactor = -0.75F;
                        mc.Correctionoffset = 78;
                        mc.Description = "Ignition advance";
                        mc.Units = "Degrees";
                    }
                    break;
                case 0x67: // IAC valve opening (Idle Air Control)
                //case 0x68:
                    mc.Correctionfactor = 0.0125F;
                    mc.Correctionoffset = 0;
                    mc.Description = "IAC position";
                    mc.Units = "%";
                    break;
                case 0x6F: // Injection time
                //case 0x70:
                    mc.Correctionfactor = 0.001513F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Injection duration";
                    mc.Units = "ms";
                    break;
                case 0x8E: // EVAP duty cycle
                    mc.Correctionfactor = 1.4730F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Injection duration";
                    mc.Units = "ms";
                    break;
                case 0x99: // Airmass
                    mc.Correctionfactor = 1.6F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Airmass";
                    mc.Units = "kg/h";
                    break;
                case 0xB8: // Vehicle speed
                    mc.Correctionfactor = 1;
                    mc.Correctionoffset = 0;
                    mc.Description = "Vehicle speed";
                    mc.Units = "km/h";
                    break;
                case 0xBC: // Turbo duty cycle (solenoid valve)
                    mc.Correctionfactor = 0.391F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Boost valve DC";
                    mc.Units = "%";
                    break;
                case 0x00: // long term fuel trim
                    mc.Correctionfactor = 0.0078125F;
                    mc.Correctionoffset = -128;
                    mc.Description = "Long term fuel trim";
                    mc.Units = "";
                    break;
                case 0x03: // idle fuel trim
                    mc.Correctionfactor = 0.0078125F;
                    mc.Correctionoffset = -128;
                    mc.Description = "Idle fuel trim";
                    mc.Units = "";
                    break;
                case 0x0F: // short term fuel trim
                    mc.Correctionfactor = 0.0078125F;
                    mc.Correctionoffset = -128;
                    mc.Description = "Short term fuel trim";
                    mc.Units = "";
                    break;
                case 0x49: // IAC adaption, Airmass
                    mc.Correctionfactor = 0.0078125F;
                    mc.Correctionoffset = -128;
                    mc.Description = "IAC airmass adaption";
                    mc.Units = "";
                    break;
                case 0x75: // A/C pressure
                    mc.Correctionfactor = 13.5351F;
                    mc.Correctionoffset = -175.9823F;
                    mc.Description = "A/C Pressure";
                    mc.Units = "kPa";
                    break;
                case 0xC4: // ECT signal sensor
                    mc.Correctionfactor = 1F;
                    mc.Correctionoffset = 0;
                    mc.Description = "ECT signal sensor";
                    mc.Units = "Volt";
                    break;
                case 0xD1: // ECU temperature
                    mc.Correctionfactor = 2.0714F;
                    mc.Correctionoffset = -176.4268F;
                    mc.Description = "ECU temperature";
                    mc.Units = "Degrees celcius";
                    break;
                case 0x22: // TPS angle
                    mc.Correctionfactor = 0.41667F;
                    mc.Correctionoffset = -5.34F;
                    mc.Description = "Throttle position angle";
                    mc.Units = "Degrees";
                    break;
                case 0x2D: // TPS voltage
                    mc.Correctionfactor = 0.01952F;
                    mc.Correctionoffset = 0;
                    mc.Description = "TPS voltage";
                    mc.Units = "Volt";
                    break;
                case 0x70: // front O2 sensor voltage
                    mc.Correctionfactor = 0.0049F;
                    mc.Correctionoffset = -0.1772F;
                    mc.Description = "Front O2 sensor";
                    mc.Units = "Volt";
                    break;
                case 0x79: // rear O2 sensor voltage
                    mc.Correctionfactor = 0.0049F;
                    mc.Correctionoffset = -0.1772F;
                    mc.Description = "Rear O2 sensor";
                    mc.Units = "Volt";
                    break;
                case 0x89: //EGR duty cycle
                    mc.Correctionfactor = 1.5625F;
                    mc.Correctionoffset = -1.5625F;
                    mc.Description = "EGR duty cycle";
                    mc.Units = "%";
                    break;
                case 0x8D: //EGR temperature
                    mc.Correctionfactor = 1F;
                    mc.Correctionoffset = -80F;
                    mc.Description = "EGR temperature";
                    mc.Units = "Degrees celcius";
                    break;
                case 0x92: //EGR voltage
                    mc.Correctionfactor = 0.01952F;
                    mc.Correctionoffset = 0;
                    mc.Description = "EGR sensor voltage";
                    mc.Units = "Volt";
                    break;
                case 0xD4: //Accelerometer
                    mc.Correctionfactor = 0.01952F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Accelerometer DC";
                    mc.Units = "DC Volt";
                    break;
                case 0x17: //Rear knock sensor signal
                    mc.Correctionfactor = -1;
                    mc.Correctionoffset = 6;
                    mc.Description = "Rear knock sensor";
                    mc.Units = "";
                    break;
                case 0x19: //Front knock sensor signal
                    mc.Correctionfactor = -1;
                    mc.Correctionoffset = 6;
                    mc.Description = "Front knock sensor";
                    mc.Units = "";
                    break;
                case 0xA2: //Ignition retard by knock
                    mc.Correctionfactor = 0.15F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Ignition retard (knock)";
                    mc.Units = "Degrees";
                    break;
                case 0xAD: //Boost pressure reduce
                    mc.Correctionfactor = 1;
                    mc.Correctionoffset = 0;
                    mc.Description = "Boost pressure reduce (knock)";
                    mc.Units = "";
                    break;
                case 0xB0: //Fuel enrichment
                    mc.Correctionfactor = 1;
                    mc.Correctionoffset = 0;
                    mc.Description = "Fuel enrichment";
                    mc.Units = "";
                    break;
                case 0x44: //Accelerometer AC voltage
                    mc.Correctionfactor = 0.0195F;
                    mc.Correctionoffset = -2.5F;
                    mc.Description = "Accelerometer AC";
                    mc.Units = "Volt";
                    break;
                case 0xC0: //Front lambda max voltage
                    mc.Correctionfactor = 0.0049F;
                    mc.Correctionoffset = -0.1772F;
                    mc.Description = "Front O2 sensor max voltage";
                    mc.Units = "Volt";
                    break;
                case 0xC1: //Front lambda min voltage
                    mc.Correctionfactor = 0.0049F;
                    mc.Correctionoffset = -0.1772F;
                    mc.Description = "Front O2 sensor min voltage";
                    mc.Units = "Volt";
                    break;
                case 0xC9: //Front lambda switching period
                    mc.Correctionfactor = 0.04F;
                    mc.Correctionoffset = 0;
                    mc.Description = "Front O2 sensor switching period";
                    mc.Units = "seconds";
                    break;

            }
            return mc;
            /*            else if (this.m_identifier == 0x4F)
            {
                m_factor = 1;
                m_descr = "Unknown";
            }
            else if (this.m_identifier == 0x40)
            {
                // Load
                m_factor = 0.05F;
                //m_factor = 0.075F; ??
                m_descr = "Load (ms inj)";
            }
            else if (this.m_identifier == 0x3B)
            {
                // RPM
                m_factor = 40;
                m_descr = "RPM";
            }
            else if (this.m_identifier == 0x37 || this.m_identifier == 0x38)
            {
                m_factor = 1;
                m_descr = "IAT/ECT";
            }*/
        }
Exemplo n.º 35
0
        public void CalculateRealValues()
        {
            float m_factor = 1;
            if (this.Length > 0)
            {
                // depends on identifier
                /*
                 * 3B is Engine speed
                 * 40 is Engine load
                 * 37 or 38 is ECT or IAT
                 * * */
                m_calculcatedValues = new float[this.m_length];
                m_calculcatedIntValues = new int[this.m_length];
                MapConfiguration mc = new MapConfiguration();
                mc.GetCorrectionFactorForMap(this.Identifier, m_IsMotronic44, m_IsLH242, m_IsM18);
                m_descr = mc.Description;
                if(mc.Units != "") m_descr += " [" + mc.Units + "]";

                if (!this.IsMotronic44)
                {
                    //GetCorrectionFactorForMap(this.m_identifier);
                    // get the max value in the list, last value
                    float max_value = (int)m_values.GetValue(this.m_length - 1);
                    //max_value += mc.Correctionoffset;
                    //(256-100)x40

                    float max_calculated_value = ((float)(256 - max_value) * mc.Correctionfactor);
                    float actual_max_calculated_value = max_calculated_value + mc.Correctionoffset;
                    /*if (this.m_identifier == 0x40)
                    {
                        // different for load
                        max_calculated_value = ((float)(max_value) * m_factor);
                    }*/
                    m_calculcatedValues.SetValue((float)Convert.ToDouble(actual_max_calculated_value.ToString("F2")), this.m_length - 1);
                    m_calculcatedIntValues.SetValue(Convert.ToInt32(actual_max_calculated_value), this.m_length - 1);
                    float m_prev_value = max_calculated_value;
                    for (int p = this.m_length - 2; p >= 0; p--)
                    {
                        int this_value = (int)m_values.GetValue(p);

                        if (this.m_addressinfile == 0xefbc) Console.WriteLine("value: " + this_value.ToString("X2"));

                        float this_calculated_value = m_prev_value - ((float)this_value * mc.Correctionfactor);
                        if (this.m_addressinfile == 0xefbc) Console.WriteLine("prev_value: " + m_prev_value.ToString("F2"));
                        if (this.m_addressinfile == 0xefbc) Console.WriteLine("this_calculated_value: " + this_calculated_value.ToString("F2"));
                        float actually_calculated_value = this_calculated_value + mc.Correctionoffset;
                        if (this.m_addressinfile == 0xefbc) Console.WriteLine("actually_calculated_value: " + actually_calculated_value.ToString("F2"));
                        m_calculcatedValues.SetValue((float)Convert.ToDouble(actually_calculated_value.ToString("F2")), p);
                        m_calculcatedIntValues.SetValue(Convert.ToInt32(actually_calculated_value), p);
                        m_prev_value = this_calculated_value;
                        //6240-(16x40)
                    }
                }
                else
                {
                    // do all * correction factor + correction offset
                    for (int p = 0; p < m_length; p++)
                    {
                        float calcvalue = (float)Convert.ToDouble(m_values.GetValue(p));
                        calcvalue *= mc.Correctionfactor;
                        calcvalue += mc.Correctionoffset;
                        m_calculcatedValues.SetValue(calcvalue, p);
                        m_calculcatedIntValues.SetValue(Convert.ToInt32(calcvalue), p);
                    }

                }
            }
        }
 public InstanceMapperProvider(MapConfiguration configuration)
 {
     _configuration = configuration;
 }
Exemplo n.º 37
0
        public int[] CalculateOriginalValues(float[] newvalues)
        {
            int[] retval = new int[newvalues.Length];
            MapConfiguration mc = new MapConfiguration();
            mc.GetCorrectionFactorForMap(this.Identifier, m_IsMotronic44, m_IsLH242, m_IsM18);
            int[] tempvals = new int[newvalues.Length];

            for (int i = 0; i < newvalues.Length; i++)
            {
                float val = newvalues[i];
                val -= mc.Correctionoffset;
                val /= mc.Correctionfactor;
                tempvals.SetValue(Convert.ToInt32(val), i);
            }

            foreach (int v in tempvals)
            {
                Console.WriteLine("phase1: " + v.ToString());
            }

            // 256 - x = 175
            // x = -175 + 256

            int _bmaxValue = (int)tempvals.GetValue(tempvals.Length -1);
            _bmaxValue = 256 - _bmaxValue;
            retval[tempvals.Length - 1] = _bmaxValue;
            int bPrevValue = _bmaxValue;
            for (int p = tempvals.Length - 2; p >= 0; p--)
            {
                int diff = tempvals[p + 1] - tempvals[p];
                retval.SetValue(diff, p);
            }
            foreach (int v in retval)
            {
                Console.WriteLine("phase2: " + v.ToString());
            }
            return retval;
        }
Exemplo n.º 38
0
 public GameConfiguration(CycleConfiguration cycleConfig, MapConfiguration mapConfig)
 {
     CycleConfig = cycleConfig;
     MapConfig = mapConfig;
 }