Exemplo n.º 1
0
 public ContentHelper(IPlatoHelper helper)
     : base(helper)
 {
     Textures   = new TextureHelper(helper);
     Injections = new InjectionHelper(helper);
     Maps       = new MapHelper(helper);
 }
Exemplo n.º 2
0
 public MoveLocationHandler(ILogger <MoveLocationHandler> log,
                            IResponseBuilder responseBuilder,
                            IMessageProvider messageProvider,
                            ILocationProvider locationProvider,
                            IAdventureContextHelper advHelper,
                            IMapHelper mapHelper,
                            AdventureContext context)
     : base(log, responseBuilder, messageProvider, locationProvider, advHelper, mapHelper)
 {
 }
Exemplo n.º 3
0
 public BaseHandler(ILogger <BaseHandler> log,
                    IResponseBuilder responseBuilder,
                    IMessageProvider messageProvider,
                    ILocationProvider locationProvider,
                    IAdventureContextHelper advHelper,
                    IMapHelper mapHelper)
 {
     _log              = log;
     _responseBuilder  = responseBuilder;
     _messageProvider  = messageProvider;
     _locationProvider = locationProvider;
     _advHelper        = advHelper;
     _mapHelper        = mapHelper;
 }
Exemplo n.º 4
0
        protected void ListMenuItemsSelected(List <string> Items)
        {
            if (Items == null)
            {
                return;
            }

            for (int I = 0; I < Items.Count; I++)
            {
                switch (ItemSelectionChoice)
                {
                case ItemSelectionChoices.Map:
                    string MapLogicName = Items[0].Substring(0, Items[0].Length - 4).Substring(24);
                    BattleMapViewer.Preload();
                    DeathmatchMap NewMap = new DeathmatchMap(MapLogicName, string.Empty, new Dictionary <string, List <Core.Units.Squad> >());
                    Helper = new DeathmatchMapHelper(NewMap);
                    NewMap.ListGameScreen = new List <GameScreen>();
                    NewMap.Content        = BattleMapViewer.content;
                    NewMap.Load();
                    NewMap.TogglePreview(false);
                    NewMap.CursorPositionVisible = new Vector3(-1, -1, 0);

                    BattleMapViewer.SetListMapScript(NewMap.ListMapScript);
                    BattleMapViewer.Helper.OnSelect = (SelectedObject, RightClick) =>
                    {
                        if (RightClick && SelectedObject != null)
                        {
                            BattleMapViewer.cmsScriptMenu.Show(BattleMapViewer, PointToClient(Cursor.Position));
                        }
                    };

                    for (int S = NewMap.ListMapScript.Count - 1; S >= 0; --S)
                    {
                        BattleMapViewer.Helper.InitScript(NewMap.ListMapScript[S]);
                    }

                    for (int T = 0; T < TerrainAttribute.ListTerrainChangeLocation.Count; T++)
                    {
                        Vector3 NewDestinationPoint = TerrainAttribute.ListTerrainChangeLocation[T].Position;
                        NewMap.LayerManager[0].ListSingleplayerSpawns.Add(new EventPoint(NewDestinationPoint, T.ToString(), 255, 255, 255));
                    }

                    Matrix Projection      = Matrix.CreateOrthographicOffCenter(0, BattleMapViewer.Width, BattleMapViewer.Height, 0, 0, -1f);
                    Matrix HalfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);

                    Matrix projectionMatrix = HalfPixelOffset * Projection;

                    NewMap.fxOutline.Parameters["Projection"].SetValue(projectionMatrix);

                    #region Tiles

                    for (int T = 0; T < TerrainAttribute.ListTileset.Count; ++T)
                    {
                        bool AlreadyExist = false;
                        for (int P = 0; P < NewMap.ListTilesetPreset.Count; ++P)
                        {
                            if (TerrainAttribute.ListTileset[T] == NewMap.ListTilesetPreset[P].TilesetName)
                            {
                                AlreadyExist = true;
                                break;
                            }
                        }

                        if (!AlreadyExist)
                        {
                            Texture2D sprTileset = NewMap.Content.Load <Texture2D>("Maps/Tilesets/" + TerrainAttribute.ListTileset[T]);
                            if (!NewMap.ListTileSet.Contains(sprTileset))
                            {
                                NewMap.ListTilesetPreset.Add(new Terrain.TilesetPreset(TerrainAttribute.ListTileset[T], sprTileset.Width, sprTileset.Height, NewMap.TileSize.X, NewMap.TileSize.Y, NewMap.ListTilesetPreset.Count));
                                NewMap.ListTileSet.Add(sprTileset);
                            }
                        }
                    }

                    for (int T = 0; T < NewMap.ListTilesetPreset.Count; T++)
                    {
                        if (!TerrainAttribute.ListTileset.Contains(NewMap.ListTilesetPreset[T].TilesetName))
                        {
                            TerrainAttribute.ListTileset.Add(NewMap.ListTilesetPreset[T].TilesetName);
                        }

                        ItemInfo Item = BaseEditor.GetItemByKey(BaseEditor.GUIRootPathMapTilesetImages, NewMap.ListTilesetPreset[T].TilesetName);

                        if (Item.Path != null)
                        {
                            if (Item.Name.StartsWith("Tileset presets"))
                            {
                                cboTiles.Items.Add(Item.Name);
                            }
                            else
                            {
                                cboTiles.Items.Add(Item.Name);
                            }
                        }
                        else
                        {
                            MessageBox.Show(NewMap.ListTilesetPreset[T].TilesetName + " not found, loading default tileset instead.");
                            cboTiles.Items.Add("Default");
                        }
                    }

                    #endregion

                    for (int T = 0; T < TerrainAttribute.ListTerrainChangeLocation.Count; T++)
                    {
                        Terrain      ActiveTerrain = TerrainAttribute.ListTerrainChangeLocation[T];
                        int          PosX          = (int)ActiveTerrain.Position.X;
                        int          PosY          = (int)ActiveTerrain.Position.Y;
                        DrawableTile ActiveTile    = TerrainAttribute.ListTileChangeLocation[T];
                        Helper.ReplaceTerrain(PosX, PosY, ActiveTerrain, 0);
                        Helper.ReplaceTile(PosX, PosY, ActiveTile, 0);
                    }

                    BattleMapViewer.ActiveMap = NewMap;

                    BattleMapViewer.RefreshScrollbars();

                    if (NewMap.ListTilesetPreset.Count > 0)
                    {
                        cboTiles.SelectedIndex = 0;
                    }

                    if (cboTiles.SelectedIndex >= 0)
                    {
                        TilesetViewer.InitTileset(NewMap.ListTileSet[cboTiles.SelectedIndex], NewMap.TileSize);
                    }
                    else
                    {
                        TilesetViewer.InitTileset(string.Empty, NewMap.TileSize);
                    }

                    TileAttributesEditor = Helper.GetTileEditor();

                    break;

                case ItemSelectionChoices.Tile:
                    string TilePath = Items[I];
                    if (TilePath != null)
                    {
                        if (TilePath.StartsWith("Content/Maps/Tileset Presets"))
                        {
                            string Name = TilePath.Substring(0, TilePath.Length - 4).Substring(29);
                            Terrain.TilesetPreset NewTileset = Terrain.TilesetPreset.FromFile(Name, BattleMapViewer.ActiveMap.ListTilesetPreset.Count);
                            string Output = BaseEditor.GetItemPathInRoot(BaseEditor.GUIRootPathMapTilesets, NewTileset.TilesetName);
                            BattleMapViewer.ActiveMap.ListTilesetPreset.Add(NewTileset);
                            BattleMapViewer.ActiveMap.ListTileSet.Add(TilesetViewer.content.Load <Microsoft.Xna.Framework.Graphics.Texture2D>("Maps/Tilesets/" + NewTileset.TilesetName));

                            cboTiles.Items.Add(Name);
                            TerrainAttribute.ListTileset.Add(Name);
                        }
                        else
                        {
                            string Name = TilePath.Substring(0, TilePath.Length - 4).Substring(22);
                            if (cboTiles.Items.Contains(Name))
                            {
                                MessageBox.Show("This tile is already listed.\r\n" + Name);
                                return;
                            }
                            Microsoft.Xna.Framework.Graphics.Texture2D Tile = TilesetViewer.content.Load <Microsoft.Xna.Framework.Graphics.Texture2D>("Maps/Tilesets/" + Name);

                            BattleMapViewer.ActiveMap.ListTilesetPreset.Add(new Terrain.TilesetPreset(Name, Tile.Width, Tile.Height, BattleMapViewer.ActiveMap.TileSize.X, BattleMapViewer.ActiveMap.TileSize.Y, BattleMapViewer.ActiveMap.ListTilesetPreset.Count));
                            BattleMapViewer.ActiveMap.ListTileSet.Add(Tile);
                            //Add the file name to the tile combo box.
                            cboTiles.Items.Add(Name);
                            TerrainAttribute.ListTileset.Add(Name);
                        }

                        cboTiles.SelectedIndex = BattleMapViewer.ActiveMap.ListTilesetPreset.Count - 1;

                        if (BattleMapViewer.ActiveMap.ListTileSet.Count == 1)
                        {
                            Terrain      PresetTerrain = ActiveMap.ListTilesetPreset[0].ArrayTerrain[0, 0];
                            DrawableTile PresetTile    = ActiveMap.ListTilesetPreset[0].ArrayTiles[0, 0];

                            //Asign a new tile at the every position, based on its atribtues.
                            for (int X = BattleMapViewer.ActiveMap.MapSize.X - 1; X >= 0; --X)
                            {
                                for (int Y = BattleMapViewer.ActiveMap.MapSize.Y - 1; Y >= 0; --Y)
                                {
                                    Helper.ReplaceTerrain(X, Y, new Terrain(PresetTerrain), 0);
                                    Helper.ReplaceTile(X, Y, new DrawableTile(PresetTile), 0);
                                }
                            }
                        }
                    }
                    break;

                case ItemSelectionChoices.TileAsBackground:
                    string TileAsBackgroundPath = Items[I];
                    if (TileAsBackgroundPath != null)
                    {
                        string TileName = Path.GetFileNameWithoutExtension(TileAsBackgroundPath);
                        if (cboTiles.Items.Contains(TileName))
                        {
                            MessageBox.Show("This tile is already listed.\r\n" + TileName);
                            return;
                        }

                        BattleMapViewer.ActiveMap.ListTileSet.Add(TilesetViewer.content.Load <Texture2D>("Maps/Tilesets/" + TileName));
                        //Add the file name to the tile combo box.
                        cboTiles.Items.Add(TileName);
                        TerrainAttribute.ListTileset.Add(TileName);
                        cboTiles.SelectedIndex = BattleMapViewer.ActiveMap.ListTileSet.Count - 1;

                        //Asign a new tile at the every position, based on its atribtues.
                        for (int X = BattleMapViewer.ActiveMap.MapSize.X - 1; X >= 0; --X)
                        {
                            for (int Y = BattleMapViewer.ActiveMap.MapSize.Y - 1; Y >= 0; --Y)
                            {
                                Helper.ReplaceTerrain(X, Y, new Terrain(X, Y,
                                                                        0, 0, 1, new TerrainActivation[0], new TerrainBonus[0], new int[0]),
                                                      0);

                                Helper.ReplaceTile(X, Y,
                                                   new DrawableTile(
                                                       new Rectangle((X % (ActiveMap.ListTilesetPreset.Last().ArrayTerrain.GetLength(0))) * ActiveMap.TileSize.X,
                                                                     (Y % (ActiveMap.ListTilesetPreset.Last().ArrayTerrain.GetLength(1))) * ActiveMap.TileSize.Y,
                                                                     ActiveMap.TileSize.X, ActiveMap.TileSize.Y),
                                                       cboTiles.Items.Count - 1),
                                                   0);
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get the coordinate file and process the data to build Simio map route objects.
        /// If any are found, return is true, but unfound addresses are reported in explanation
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public bool ProcessPairDataFile(string path, IMapHelper mapHelper, string mapKey,
                                        out SimioMapRoutes mapRoutes,
                                        out string explanation)
        {
            explanation = "";
            string marker  = "Begin";
            int    lineNbr = 0;

            mapRoutes = null;

            StringBuilder sbErrors = new StringBuilder();

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                string name = Path.GetFileNameWithoutExtension(path);
                mapRoutes = new SimioMapRoutes(name);

                mapRoutes.ProviderInformation = mapHelper.GetProviderInformation();

                //Todo: Add processing
                if (string.IsNullOrEmpty(comboGisSource.Text))
                {
                    alert($"Please select a GIS Source");
                    return(false);
                }

                if (!LoadAddressPairsFile(textAddressPairsFilepath.Text, out List <GisFromToPair> pairList, out explanation))
                {
                    explanation = $"Cannot Load Pairs File={explanation}";
                    return(false);
                }

                foreach (GisFromToPair pair in pairList)
                {
                    lineNbr++;
                    marker           = $"Line={lineNbr} Loading Pair={pair}";
                    labelStatus.Text = marker;

                    if (!mapHelper.GetRoute(mapKey, pair.FromLocation.ToString(), pair.ToLocation.ToString(),
                                            out SimioMapRoute mapRoute,
                                            out string requestUrl, out explanation))
                    {
                        sbErrors.AppendLine($"Cannot Get Route. Err={explanation}");
                    }

                    mapRoutes.RouteList.Add(mapRoute);
                }

                explanation = sbErrors.ToString();
                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Marker={marker} Err={ex.Message}";
                return(false);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }