Пример #1
0
        public int Apply(PlayerView view)
        {
            if (_unitIndex < 0)
            {
                return(-1);
            }

            var unit            = view.world.unitSet.GetActiveUnit(_unitIndex, out int masterListIndex);
            var placeAtPosition = unit.position;

            view.AddChange(
                new WorldUnitSetChange(
                    view.world,
                    new UnitSetUnitChange(
                        view.world.unitSet,
                        masterListIndex,
                        new UnitNewOrder(
                            view.world.unitSet.GetUnit(masterListIndex),
                            new UnitOrderBuildCity()
                            )
                        )
                    )
                );

            return(9);
        }
        public int Apply(PlayerView view)
        {
            if (_cityIndex < 0)
            {
                return(-1);
            }

            view.AddChange(
                new WorldCitySetChange(
                    view.world,
                    new CitySetCityChange(
                        view.world.citySet,
                        _masterIndex,
                        new CityNewOrder(
                            view.world.citySet.GetCity(_masterIndex),
                            new CityOrderBuildUnit()
                            )
                        )
                    )
                );

            return(9);
        }
        public int Apply(PlayerView view)
        {
            if (_unitIndex < 0)
            {
                return(-1);
            }

            var unit = view.world.unitSet.GetActiveUnit(_unitIndex, out int masterListIndex);

            /* Vector2Int diff = _newPosition - unit.position;
             * Vector2Int move =
             *  new Vector2Int(
             *      System.Math.Sign(diff.x),
             *      System.Math.Sign(diff.y)
             *      );
             * Vector2Int useNewPosition = unit.position + move; */

            view.AddChange(
                new WorldUnitSetChange(
                    view.world,
                    new UnitSetUnitChange(
                        view.world.unitSet,
                        masterListIndex,
                        new UnitNewOrder(
                            view.world.unitSet.GetUnit(masterListIndex),
                            new UnitOrderMove(masterListIndex, unit.position, _newPosition)
                            )
                        )
                    )
                );

            /* view.AddChange(
             *  new WorldUnitSetChange(
             *      view.world,
             *      new UnitSetUnitChange(
             *          view.world.unitSet,
             *          masterListIndex,
             *          new UnitPositionChange(
             *              unit,
             *              useNewPosition
             *              )
             *          )
             *      )
             *  );
             *
             * view.AddChange(
             *  new WorldTilemapUnitsChange(
             *      view.world,
             *      new TilemapTileChange(
             *          view.world.tilemapUnits,
             *          useNewPosition,
             *          // new Vector2Int(60, 30)
             *          view.unitTile
             *          )
             *      )
             *  ); */

            {
                return(unit.position.SquareTileDistance(_newPosition));
            }
        }