Exemple #1
0
        public TerrainRenderer(ITerrainMap terrainMap, IGameParameters gameParameters)
        {
            _terrainMap     = terrainMap;
            _gameParameters = gameParameters;

            _terrainMap.CollectionChanged += (s, e) => _dirty = true;
        }
Exemple #2
0
 public MiniMapDelegate(ILayout trackLayout, IPixelMapper pixelMapper, ITerrainMap terrainMap)
 {
     _trackLayout = trackLayout;
     _pixelMapper = pixelMapper;
     _terrainMap  = terrainMap;
     _pixelMapper.ViewPortChanged   += (s, e) => _redraw = true;
     _trackLayout.CollectionChanged += (s, e) => _redraw = true;
     _terrainMap.CollectionChanged  += (s, e) => _redraw = true;
 }
Exemple #3
0
 protected TestBase(ITestOutputHelper output)
 {
     Storage     = new NullStorage();
     Timer       = new TestTimer();
     TrackLayout = new Layout();
     TerrainMap  = new TerrainMap();
     GameBoard   = new GameBoard(TrackLayout, TerrainMap, Storage, Timer);
     _output     = output;
 }
        public TerrainMapRenderer(ITerrainMap terrainMap, IImageFactory imageFactory, IImageCache imageCache, IPixelMapper pixelMapper)
        {
            _terrainMap   = terrainMap;
            _imageFactory = imageFactory;
            _imageCache   = imageCache;
            _pixelMapper  = pixelMapper;

            _terrainMap.CollectionChanged += (s, e) => _imageCache.SetDirty(this);
        }
Exemple #5
0
 public GameBoard(ITerrainMap terrainMap, IUnitList unitList, IShortestPath shortestPath, IAlliedEnemyMatrix alliedEnemyMatrix,
                  IVictoryCalculator victoryCalculator, IEnemyPlan enemyPlan)
 {
     _terrainMap        = terrainMap;
     _units             = unitList;
     _shortestPath      = shortestPath;
     _alliedEnemyMatrix = alliedEnemyMatrix;
     _endOfGame         = victoryCalculator;
     _enemyPlan         = enemyPlan;
 }
        public TerrainRenderer(ITerrainMap terrainMap, IPixelMapper pixelMapper, ITrackParameters trackParameters)
        {
            _terrainMap      = terrainMap;
            _pixelMapper     = pixelMapper;
            _trackParameters = trackParameters;

            _paintBrush = new PaintBrush
            {
                Color       = Colors.LightGray,
                StrokeWidth = 1,
                Style       = PaintStyle.Stroke
            };
        }
Exemple #7
0
 public GameBoard(ILayout trackLayout, ITerrainMap terrainMap, IGameStorage?storage, ITimer?timer)
 {
     _layout        = trackLayout;
     _gameLoopTimer = timer;
     _terrainMap    = terrainMap;
     _storage       = storage;
     if (_gameLoopTimer != null)
     {
         _gameLoopTimer.Interval = GameLoopInterval;
         _gameLoopTimer.Elapsed += GameLoopTimerElapsed;
         _gameLoopTimer.Start();
     }
 }
Exemple #8
0
        public void ComputeShortestPath(ITerrainMap terrainMap, int startCol, int startRow, int endCol, int endRow,
                                        int unitType)
        {
            _endCol     = endCol;
            _endRow     = endRow;
            _startCol   = startCol;
            _startRow   = startRow;
            _unitType   = unitType;
            _terrainMap = terrainMap;
            _iterations = 0;

            _openList   = new AStarNodeList();
            _closedList = new AStarNodeList();
            WayPoint    = new List <Offset>();

            // push the starting cell
            var currentNode = new AStarNode(startCol, startRow, startCol, startRow, _endCol, _endRow, 0);

            _openList.Push(currentNode);

            FindPath();
        }
Exemple #9
0
        public void CreateDistricts(ITerrainMap terrain, Rectangle[] _districts, bool silent)
        {
            if (!silent && !(_districts.Length > 0))
            {            // show confirmation message
                string text = Core.resources["world.create_districts_prompt"].stringValue;
                if (!UIUtil.ConfirmMessage(text, UIMessageType.warning, UIInformLevel.normal))
                {
                    return;
                }
            }
            // reset map
            for (int y = 0; y < districtMap.GetUpperBound(1); y++)
            {
                for (int x = 0; x < districtMap.GetUpperBound(0); x++)
                {
                    districtMap[x, y] = -1;
                }
            }

            for (int i = 0; i < _districts.Length; i++)
            {
                Rectangle           r    = _districts[i];
                ProvisionalDistrict dist = new ProvisionalDistrict(this, terrain, r);
                int n = districts.Add(dist);
                for (int y = r.Top; y <= r.Bottom; y++)
                {
                    for (int x = r.Left; x <= r.Right; x++)
                    {
                        if (districtMap[x, y] != -1)
                        {
                            throw new ArgumentException("detect overraped rectangles in districts array.");
                        }
                        districtMap[x, y] = n;
                    }
                }
            }
        }
Exemple #10
0
 public BridgeFactory(ITerrainMap terrainMap)
 {
     _terrainMap = terrainMap;
 }
Exemple #11
0
 public TIntersectionFactory(ITerrainMap terrainMap)
 {
     _terrainMap = terrainMap;
 }
 public SignalFactory(ITerrainMap terrainMap)
 {
     _terrainMap = terrainMap;
 }
 public NatureLayoutRenderer(ILayout <Tree> layout, IRenderer <Tree> renderer, IImageFactory imageFactory, ITerrainMap terrainMap)
     : base(layout, renderer, imageFactory, terrainMap)
 {
     this.Name             = "Nature";
     this.Enabled          = true;
     this.IsScaledByHeight = true;
 }
 public UnitList(IBattleCalculator battleCalculator, ITerrainMap terrainMap)
 {
     _battleCalculator = battleCalculator;
     _terrainMap       = terrainMap;
 }
 public TrackLayoutRenderer(ILayout <Track> layout, IEnumerable <IRenderer <Track> > renderers, IImageFactory imageFactory, ITerrainMap terrainMap)
     : base(layout, renderers, imageFactory, terrainMap)
 {
     this.Name    = "Tracks";
     this.Enabled = true;
 }
Exemple #16
0
 public TreeTool(ILayout <Tree> trackLayout, ITerrainMap terrainMap, IEnumerable <IStaticEntityFactory <Tree> > entityFactories)
 {
     _entityCollection = trackLayout;
     _terrainMap       = terrainMap;
     _entityFactories  = entityFactories;
 }
 public EnemyPlan(ITerrainMap map, IUnitList units, IAlliedEnemyMatrix alliedEnemyMatrix)
 {
     _map               = map;
     _units             = units;
     _alliedEnemyMatrix = alliedEnemyMatrix;
 }
 public CachableLayoutRenderer(ILayout <T> layout, IEnumerable <IRenderer <T> > renderers, IImageFactory imageFactory, ITerrainMap terrainMap)
     : base(layout, renderers, imageFactory, terrainMap)
 {
     layout.CollectionChanged += (s, e) => _dirty = true;
 }
 public CachableLayoutRenderer(ILayout <T> layout, IRenderer <T> renderer, IImageFactory imageFactory, ITerrainMap terrainMap)
     : this(layout, new[] { renderer }, imageFactory, terrainMap)
 {
 }
 public CrossTrackFactory(ITerrainMap terrainMap, ILayout <Track> layout)
 {
     _terrainMap = terrainMap;
     _layout     = layout;
 }
Exemple #21
0
 public VictoryCalculator(ITerrainMap terrainMap, IUnitList units)
 {
     _terrainMap = terrainMap;
     _units      = units;
 }
 public TunnelRenderer(ITerrainMap terrainMap, ILayout <Track> layout, IGameBoard gameBoard)
 {
     _terrainMap  = terrainMap;
     _trackLayout = layout;
     _gameBoard   = gameBoard;
 }
Exemple #23
0
 public SignalFactory(ITerrainMap terrainMap, ILayout <Track> layout)
 {
     _terrainMap = terrainMap;
     _layout     = layout;
 }
Exemple #24
0
 public ProvisionalDistrict(World w, ITerrainMap map, Rectangle area) : base(w, map, area)
 {
 }
        public TerrainRenderer(ITerrainMap terrainMap)
        {
            _terrainMap = terrainMap;

            _terrainMap.CollectionChanged += (s, e) => _dirty = true;
        }
 public BridgeRenderer(ITerrainMap terrainMap, IPathFactory pathFactory)
 {
     _terrainMap      = terrainMap;
     _cornerPlankPath = BuildCornerPlankPath(pathFactory);
     _cornerRailPath  = BuildCornerRailPath(pathFactory);
 }
Exemple #27
0
        public MainPage(IGame game,
                        IEnumerable <ITool> tools,
                        IEnumerable <ILayerRenderer> layers,
                        IEnumerable <ICommand> commands,
                        ITrainController trainControls,
                        ILayout trackLayout,
                        IGameStorage gameStorage,
                        ITerrainMap terrainMap,
                        MiniMapDelegate miniMapDelegate,
                        TrainsDelegate trainsDelegate)
        {
            this.Title("Trains - " + ThisAssembly.AssemblyInformationalVersion);

            _game            = game;
            _controlDelegate = trainsDelegate;
            _miniMapDelegate = miniMapDelegate;

            this.Body = () =>
            {
                return(new HStack()
                {
                    new VStack()
                    {
                        _configurationShown?null:
                        new Button(trainControls.BuildMode ? "Building" : "Playing", () => SwitchGameMode()),
                        new Spacer(),
                        _configurationShown ?
                        CreateConfigurationControls(layers) :
                        CreateToolsControls(tools, _controlDelegate, trainControls.BuildMode.Value),
                        new Spacer(),
                        _configurationShown || !trainControls.BuildMode ? null :
                        CreateCommandControls(commands),
                        new Spacer(),
                        new HStack()
                        {
                            new Button(" - ", () => _game.Zoom(-1))
                            .Frame(40),
                            new Spacer(),
                            new Button(" + ", () => _game.Zoom(1))
                            .Frame(40),
                        },
                        new Spacer(),
                        new Button("Snapshot", () => Snapshot()),
                        new Button("Configuration", () => _configurationShown.Value = !_configurationShown.Value),
                        new DrawableControl(_miniMapDelegate).Frame(height: 100)
                    }.Frame(100, alignment: Alignment.Top),
                    new VStack()
                    {
                        new TrainControllerPanel(trainControls),
                        new DrawableControl(_controlDelegate)
                    }
                }.FillHorizontal());
            };

            _trackLayout = trackLayout;
            _gameStorage = gameStorage;

            _ = PresentLoop();

            void SwitchGameMode()
            {
                trainControls.ToggleBuildMode();

                if (_controlDelegate == null)
                {
                    return;
                }

                _controlDelegate.CurrentTool.Value = tools.FirstOrDefault(t => ShouldShowTool(trainControls.BuildMode, t));
            }

            void Snapshot()
            {
                (int width, int height) = _game.GetSize();
                using var bitmap        = new SKBitmap(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul);
                using var skCanvas      = new SKCanvas(bitmap);
                using (ICanvas canvas = new SKCanvasWrapper(skCanvas))
                {
                    canvas.Save();
                    _game.Render(canvas);
                    canvas.Restore();
                }
                Clipboard.SetImage(bitmap.ToWriteableBitmap());
            }

            _terrainMap = terrainMap;
        }
 public TerrainMapRenderer(ITerrainMap terrainMap, IImageFactory imageFactory)
 {
     _terrainMap   = terrainMap;
     _imageFactory = imageFactory;
     _terrainMap.CollectionChanged += (s, e) => _dirty = true;
 }
Exemple #29
0
 public TrackTool(ILayout <Track> trackLayout, ITerrainMap terrainMap)
 {
     _entityCollection = trackLayout;
     _terrainMap       = terrainMap;
 }
Exemple #30
0
 public TrackFactory(ITerrainMap terrainMap)
 {
     _terrainMap = terrainMap;
 }