Esempio n. 1
0
        /// <summary>
        /// Renders this shape on the specified map. If map is set to null, the shape will be removed.
        /// </summary>
        /// <param name="map"></param>
        public async Task SetMap(MapComponent map)
        {
            await _jsRuntime.JsonNetInvokeAsync <bool>(
                "googleMapPolygonJsFunctions.setMap",
                _guid,
                map?.DivId);

            _map = map;
        }
Esempio n. 2
0
        // https://github.com/rwmt/Multiplayer/blob/7aac8b54727d8626ec39429b97225fc88c807ab8/Source/Client/Sync/SyncHandlers.cs#L760
        // Synced helper method, similarly to MP (IStoreSettingsParent is the closest to what we're dealing with in here, but there's not much difference)
        private static void ThingFilter_AllowCategory_HelperRestaurant(MapComponent controller, ThingCategoryDef categoryDef, bool allow)
        {
            var menu                = controllerMenuField.GetValue(controller);
            var filter              = menuFilterField.GetValue(menu);
            var parentFilter        = menuGlobalFilterField.GetValue(menu);
            var hiddenSpecialFilter = hiddenSpecialThingFiltersMethod.Invoke(null, Array.Empty <object>());

            allowCategoryHelperMethod.Invoke(null, new object[] { filter, categoryDef, allow, parentFilter, null, hiddenSpecialFilter });
        }
Esempio n. 3
0
        /// <summary>
        /// Renders the rectangle on the specified map. If map is set to null, the rectangle will be removed.
        /// </summary>
        /// <param name="map"></param>
        public Task SetMap(MapComponent map)
        {
            _map = map;

            return(_jsRuntime.InvokeWithDefinedGuidAndMethodAsync <bool>(
                       "googleMapRectangleJsFunctions.setMap",
                       _guid.ToString(),
                       map.DivId));
        }
Esempio n. 4
0
        /// <summary>
        /// Renders the heatmap on the specified map. If map is set to null, the heatmap will be removed.
        /// </summary>
        /// <param name="map"></param>
        public Task SetMap(MapComponent map)
        {
            _map = map;

            return(_jsRuntime.InvokeWithDefinedGuidAndMethodAsync <object>(
                       $"{jsObjectName}.setMap",
                       _guid.ToString(),
                       map.DivId));
        }
Esempio n. 5
0
        public override void Process(Entity entity)
        {
            SpriteBatch  spriteBatch = EntitySystem.BlackBoard.GetEntry <SpriteBatch>("SpriteBatch");
            MapComponent map         = entity.GetComponent <MapComponent>();

            map.Map.Draw(
                spriteBatch,
                new Rectangle(0, 0, map.Map.Width * map.Map.TileWidth, map.Map.Height * map.Map.TileHeight));
        }
Esempio n. 6
0
 public void Initialize()
 {
     _player         = _playerFilter.Components1[0];
     _map            = _world.CreateEntityWith <MapComponent>();
     _map.LastCoords = new CubeCoords(0, 0);
     _map.PoolB      = PoolContainer.CreatePool(Utils.BackPrefabPath);
     _map.PoolF      = PoolContainer.CreatePool(Utils.ForePrefabPath);
     MapGenRandomNeighbours.GenerateMap(out _map.MapB, out _map.MapF, MapSize, MapSeed);
     RenderFull(new CubeCoords(0, 0), Fow);
 }
        private void UpdateMapComponent(MapComponent mapcomponent, int yearId)
        {
            if (mapcomponent.Id <= 0)
            {
                throw new MapException(Properties.Settings.Default.ExceptionMapComponentInvalid);
            }

            u_repo.UpdateMapComponent(mapcomponent);
            UpdateMapComponentYears(mapcomponent, yearId);
        }
 static void SyncWorkerForCleaningArea(SyncWorker sw, ref MapComponent comp)
 {
     if (sw.isWriting)
     {
         sw.Write(comp.map);
     }
     else
     {
         comp = sw.Read <Map>().GetComponent(CleaningAreaMapComponentType);
     }
 }
Esempio n. 9
0
        public int CreateEntity(string entityName, Dictionary <string, string> otherParameters)
        {
            var newEntityId = GetNewEntityId();
            Dictionary <string, string> allParameters;
            List <Trait> allTraits;

            if (otherParameters.ContainsKey("Material"))
            {
                allParameters = CombineParameterDictionaries(otherParameters,
                                                             ECSDatabase.GetComponentData(entityName, otherParameters["Material"]));
                allTraits = ECSDatabase.GetTraitData(entityName, otherParameters["Material"]);
            }
            else
            {
                allParameters = CombineParameterDictionaries(otherParameters,
                                                             ECSDatabase.GetComponentData(entityName));
                allTraits = ECSDatabase.GetTraitData(entityName);
            }

            if (allParameters.ContainsKey("BackgroundComponent"))
            {
                var component = new BackgroundComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("ForegroundComponent"))
            {
                var component = new ForegroundComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("MapComponent"))
            {
                var component = new MapComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("PositionComponent"))
            {
                var component = new PositionComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            // TODO: Setup all the components here.

            foreach (Trait trait in allTraits)
            {
                AddTrait(newEntityId, trait);
            }

            GameEvents.CreateEntityEvent.NewCreateEntityEvent(newEntityId);

            return(newEntityId);
        }
Esempio n. 10
0
 private void ForceInitialization()
 {
     if (_tileMapChildrensList is null)
     {
         _tileMapChildrensList = this.GetComponentsInChildren <TileMapComponnent>().ToList();
     }
     if (_mapComponent is null)
     {
         _mapComponent = this.GetComponentInParent <MapComponent>();
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Constructor, that creates a new instance of PacmanMovementBehaviour
 /// and initializes its fields.
 /// </summary>
 /// <param name="pacman">Instance of pacman.</param>
 /// <param name="mapTransform"><see cref="MapTransformComponent"/>
 /// of pacman.</param>
 /// <param name="translateModifier">Value to be a compensation of the
 /// map stretch when printed.</param>
 public PacmanMovementBehaviour(
     GameObject pacman,
     MapTransformComponent mapTransform,
     int translateModifier = 1)
 {
     keyReader         = pacman.GetComponent <KeyReaderComponent>();
     transform         = pacman.GetComponent <TransformComponent>();
     this.mapTransform = mapTransform;
     map = pacman.GetComponent <MapComponent>();
     this.translateModifier = translateModifier;
     previousDirection      = Direction.None;
 }
Esempio n. 12
0
        protected override void OnInitialize()
        {
            List <Scene> scenes = builder.BuildScenes(Owner);

            MapComponent mapComponent = new MapComponent(Owner, scenes);

            Owner.AddComponent(mapComponent);

            InitializeSpriteRenderers();

            CreateWalls();
        }
Esempio n. 13
0
 /// <summary>
 /// Constructor, that creates a new instance of
 /// GhostTargetMovementBehaviour and initializes its fields.
 /// </summary>
 /// <param name="ghost">Instance of the ghost to be moved.</param>
 /// <param name="map">Map in which the gameobjects are placed.</param>
 /// <param name="mapTransform"><see cref="MapTransformComponent"/>
 /// for the ghost.</param>
 /// <param name="translateModifier">Value to be a compensation of the
 /// map stretch when printed.</param>
 protected GhostTargetMovementBehaviour(
     GameObject ghost,
     MapComponent map,
     MapTransformComponent mapTransform,
     int translateModifier = 1)
 {
     this.ghost             = ghost;
     ghostTransform         = ghost.GetComponent <TransformComponent>();
     this.mapTransform      = mapTransform;
     this.translateModifier = translateModifier;
     this.map = map;
 }
Esempio n. 14
0
        public static string MapDivAndScript(MapComponent map)
        {
            var divScriptGuidConnector = Guid.NewGuid();

            var tag =
                $"<div id=\"MapComponent-{divScriptGuidConnector}\" class=\"leaflet-container leaflet-retina leaflet-fade-anim leaflet-grab leaflet-touch-drag point-content-map\"></div>";

            var script =
                $"<script>lazyInit(document.querySelector(\"#MapComponent-{divScriptGuidConnector}\"), () => mapComponentInit(document.querySelector(\"#MapComponent-{divScriptGuidConnector}\"), \"{map.ContentId}\"));</script>";

            return(tag + script);
        }
Esempio n. 15
0
        IEnumerator InitializeMapComponent(MapComponent mapComponent)
        {
            var handler = Addressables.InstantiateAsync("map");

            yield return(handler);

            var mapHandlerObject = handler.Result;

            MapHandlerComponent = mapHandlerObject.GetComponent <MapHandlerComponent>();

            mapComponent.Initialized += MapHandlerComponent.OnInitialized;
        }
Esempio n. 16
0
        public void SpawnNewRandomMap()
        {
            List <MapComponent> mapsWithEmptySlots = _mapComponentList.Where(e => e.HasEmptySlots).ToList();

            MapComponent mapComponent = mapsWithEmptySlots[UnityEngine.Random.Range(0, mapsWithEmptySlots.Count())];

            if (mapComponent is null)
            {
                return;
            }
            mapComponent.SpawnNewMap(_mapPrefab);
        }
Esempio n. 17
0
        static void SyncWorkerForMapComp(SyncWorker sync, ref MapComponent comp)
        {
            if (sync.isWriting)
            {
                sync.Write(comp.map);
            }
            else
            {
                Map map = sync.Read <Map>();

                comp = (MapComponent)GetMapCompMethod.Invoke(null, new object[] { map });
            }
        }
        void SyncWorkerForGrowZoneManager(SyncWorker sync, ref MapComponent obj)
        {
            if (sync.isWriting)
            {
                sync.Write(obj.map);
            }
            else
            {
                var map = sync.Read <Map>();

                obj = map.GetComponent(GrowZoneManagerType);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Creates a DrawingManager that allows users to draw overlays on the map, and switch between the type of overlay to be drawn with a drawing control.
        /// </summary>
        public DrawingManager(IJSRuntime jsRuntime, DrawingManagerOptions opt = null)
            : base(jsRuntime)
        {
            if (opt?.Map != null)
            {
                _map = opt.Map;
            }

            _jsRuntime.JsonNetInvokeAsync <bool>(
                "googleMapDrawingManagerJsFunctions.init",
                _guid,
                opt);
        }
Esempio n. 20
0
        public override void Draw(GameTime gameTime)
        {
            foreach (int entity in ActiveEntities)
            {
                MapComponent     mapComponent = _mapMapper.Get(entity);
                TiledMapRenderer renderer     = _renderers.ContainsKey(entity) ? (TiledMapRenderer)_renderers[entity] : createRenderer(entity, mapComponent);
                if (mapComponent.MapChanged)
                {
                    renderer.LoadMap(mapComponent.Map);
                }

                renderer.Draw();
            }
        }
Esempio n. 21
0
        public void AddMapComponent(MapComponent map)
        {
            if (_miniMapList is null)
            {
                _miniMapList = new List <MiniMapDTO>();
            }
            if (_mapComponentList is null)
            {
                _mapComponentList = new List <MapComponent>();
            }

            _mapComponentList.Add(map);
            _miniMapList.Add(new MiniMapDTO(map));
        }
 /// <summary>
 /// Constructor, that creates a new instance of
 /// ScatterMovementBehaviour and initializes its fields.
 /// </summary>
 /// <param name="ghost">Instance of the ghost to be moved.</param>
 /// <param name="map">Map in which the gameobjects are placed.</param>
 /// <param name="targetMapTransform">
 /// <see cref="MapTransformComponent"/> for the target to
 /// be chased.</param>
 /// <param name="mapTransform"><see cref="MapTransformComponent"/>
 /// for the ghost.</param>
 /// <param name="translateModifier">Value to be a compensation of the
 /// map stretch when printed.</param>
 public ScatterMovementBehaviour(
     GameObject ghost,
     MapComponent map,
     MapTransformComponent targetMapTransform,
     MapTransformComponent mapTransform,
     int translateModifier = 1)
     : base(
         ghost,
         map,
         mapTransform,
         translateModifier)
 {
     this.targetMapTransform = targetMapTransform;
 }
Esempio n. 23
0
        public CompanyComponent Create(MapComponent mapComponent)
        {
            Component.HiringCost        = TypeObject.HiringCost;
            Component.CartCost          = TypeObject.CartCost;
            Component.WagePerHour       = TypeObject.WagePerHour;
            Component.EmployeeTemplates = TypeObject.Employees;
            Component.CartTemplates     = TypeObject.Carts;

            var locationFactory   = new LocationFactory(TypeObject.Location.Value, GameObject);
            var locationComponent = locationFactory.Create();

            var buildingComponent = GameObject.GetComponent <BuildingComponent>();

            var companyEntryCell = mapComponent.MapLayout.PlaceBuilding(buildingComponent.Building);

            if (!companyEntryCell.HasValue)
            {
                this.Log($"Could not create company: No build space available.", LogType.Warning);
                Object.Destroy(GameObject);
                return(null);
            }

            locationComponent.EntityArrived += Component.OnEntityArrived;
            locationComponent.EntityLeft    += Component.OnEntityLeft;
            if (Locator.Time)
            {
                Locator.Time.WorkingHourTicked += Component.OnWorkingHourTicked;
            }

            mapComponent.Register(locationComponent);
            locationComponent.EntryCell = companyEntryCell.Value;

            if (TypeObject.Production.Value)
            {
                var productionFactory = new ProductionFactory(TypeObject.Production.Value, GameObject);
                productionFactory.Create();
            }

            Component.HireEmployee();
            Component.HireCart();

            if (TypeObject.Master.Value)
            {
                var masterFactory = new MasterFactory(TypeObject.Master.Value, GameObject);
                masterFactory.Create();
            }

            return(Component);
        }
        /// <summary>
        /// Adds the map component year if it doesn't exist
        /// </summary>
        /// <param name="mapcomponent"></param>
        /// <param name="yearId"></param>
        private void UpdateMapComponentYears(MapComponent mapcomponent, int yearId)
        {
            MapComponent      old     = u_repo.GetMapComponent(mapcomponent.Id);
            MapComponentYears current = old.MapComponentYears.SingleOrDefault(t => t.YearsId == yearId);

            if (current.Id <= 0)
            {
                Years y = mapcomponent.Map.Years.SingleOrDefault(t => t.Id == yearId);
                current.MapComponentId = mapcomponent.Id;
                current.MapComponent   = mapcomponent;
                current.Year           = y;
                current.YearsId        = y.Id;
                u_repo.SaveMapComponentYear(current);
            }
        }
Esempio n. 25
0
    private void InitializeBirthPoint(int num, int[] componentSize)
    {
        _components[MapComponentType.BIRTH_POINT] = new List <MapComponent>();

        int[, ][] possiblePoints = new int[3, 3][];
        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                possiblePoints[x, y] = new int[2] {
                    ((width - 1) * x) / 2 - ((componentSize[0] - 1) * x) / 2, ((height - 1) * y) / 2 - ((componentSize[1] - 1) * y) / 2
                }
            }
        }
        ;

        List <int> points = new List <int>();

        while (points.Count < num)
        {
            int point = 4;
            while (point == 4 || points.Contains(point))
            {
                point = GenerateRandomInt(0, 8);
            }

            bool isValid = true;
            foreach (int previousPoint in points)
            {
                int diffX = Mathf.Abs((previousPoint % 3) - (point % 3));
                int diffY = Mathf.Abs(previousPoint - point) / 3;
                if (diffY == 1 || (diffY == 0 && diffX == 1))
                {
                    isValid = false;
                    break;
                }
            }

            if (isValid)
            {
                int[]        position   = possiblePoints[point % 3, point / 3];
                MapComponent birthPoint = new MapComponent(MapComponentType.BIRTH_POINT, position[0], position[1], componentSize);

                points.Add(point);
                _components[MapComponentType.BIRTH_POINT].Add(birthPoint);
            }
        }
    }
        public MapComponentEditorWindow(MapComponent toLoad)
        {
            InitializeComponent();
            StatusContext = new StatusControlContext();

            StatusContext.RunFireAndForgetBlockingTaskWithUiMessageReturn(async() =>
            {
                MapComponentContent = await MapComponentEditorContext.CreateInstance(StatusContext, toLoad);

                MapComponentContent.RequestContentEditorWindowClose += (_, _) => { Dispatcher?.Invoke(Close); };
                AccidentalCloserHelper = new WindowAccidentalClosureHelper(this, StatusContext, MapComponentContent);

                await ThreadSwitcher.ResumeForegroundAsync();
                DataContext = this;
            });
        }
Esempio n. 27
0
        public Marker(IJSRuntime jsRuntime,
                      MapEventJsInterop jsEventInterop,
                      MarkerOptions opt = null)
            : base(jsRuntime)
        {
            if (opt?.Map != null)
            {
                _map = opt.Map;
            }

            _jsRuntime.JsonNetInvokeAsync <bool>("googleMapMarkerJsFunctions.init",
                                                 _guid,
                                                 opt);

            _jsEventInterop = jsEventInterop;
        }
Esempio n. 28
0
 /// <summary>
 /// Constructor, that creates a new instance of PinkyChaseBehaviour
 /// and initializes its fields.
 /// </summary>
 /// <param name="targetMovementBehaviour">Movement behaviour for
 /// the target.</param>
 /// <param name="ghost">Instance of the ghost to be moved.</param>
 /// <param name="map">Map in which the gameobjects are placed.</param>
 /// <param name="targetMapTransform">
 /// <see cref="MapTransformComponent"/> for the target to
 /// be chased.</param>
 /// <param name="mapTransform"><see cref="MapTransformComponent"/>
 /// for the ghost.</param>
 /// <param name="translateModifier">Value to be a compensation of the
 /// map stretch when printed.</param>
 public PinkyChaseBehaviour(
     PacmanMovementBehaviour targetMovementBehaviour,
     GameObject ghost,
     MapComponent map,
     MapTransformComponent targetMapTransform,
     MapTransformComponent mapTransform,
     int translateModifier = 1)
     : base(
         ghost,
         map,
         mapTransform,
         translateModifier)
 {
     this.targetMovementBehaviour = targetMovementBehaviour;
     this.targetMapTransform      = targetMapTransform;
 }
Esempio n. 29
0
 /// <summary>
 /// Constructor, that creates a new instance of
 /// FrightenedMovementBehaviour and initializes its fields.
 /// </summary>
 /// <param name="ghost">Instance of the ghost to be moved.</param>
 /// <param name="map">Map in which the gameobjects are placed.</param>
 /// <param name="targetMapTransform">
 /// <see cref="MapTransformComponent"/> for the target to
 /// be chased.</param>
 /// <param name="mapTransform"><see cref="MapTransformComponent"/>
 /// for the ghost.</param>
 /// <param name="random">Instance of a pseudo-random number
 /// generator.</param>
 /// <param name="translateModifier">Value to be a compensation of the
 /// map stretch when printed.</param>
 public FrightenedMovementBehaviour(
     GameObject ghost,
     MapComponent map,
     MapTransformComponent targetMapTransform,
     MapTransformComponent mapTransform,
     Random random,
     int translateModifier = 1)
     : base(
         ghost,
         map,
         mapTransform,
         translateModifier)
 {
     this.map    = map;
     this.random = random;
 }
        public void DeleteMapComponentForYear(int mapcomponentId, int yearId)
        {
            MapComponent      mapcomponent = u_repo.GetMapComponent(mapcomponentId);
            MapComponentYears mapcompyear  = mapcomponent.MapComponentYears.SingleOrDefault(t => t.YearsId == yearId);

            if (mapcomponent == null)
            {
                throw new MapException(Properties.Settings.Default.ExceptionMapComponentInvalid);
            }

            if (mapcompyear.Answers.HasAny() || mapcompyear.Fates.HasAny() || !mapcompyear.Comments.IsNullOrWhiteSpace())
            {
                throw new MapException(Properties.Settings.Default.ExceptionMapComponentYear);
            }

            u_repo.DeleteMapComponentYear(mapcompyear);
        }