コード例 #1
0
ファイル: Level.cs プロジェクト: pauldavisf/Sokoban
 public Level(string label, double scoresMultiplier, string soundFileName, IGameMap map)
 {
     Label                   = label;
     ScoresMultiplier        = scoresMultiplier;
     BackgroundSoundFileName = soundFileName;
     Map = map;
 }
コード例 #2
0
        public void Draw(Graphics graphics, IGameMap map)
        {
            var size = graphics.ClipBounds.Size;

            start = new Point((int)size.Width / 2, (int)size.Height / 2) - (Size)map.Player.Position;
            //currentShaking = (currentShaking + 1) % shaking.Length;

            foreach (var(tile, x, y) in map.Tiles.IterateDoubleArray())
            {
                graphics.DrawImage(pictureLibrary.GetTileImage(tile),
                                   new Rectangle(start.Y + y * ImageSize, start.X + x * ImageSize, ImageSize, ImageSize));
            }

            var image = pictureLibrary.GetBodyImage(map.Player);

            if (!map.Player.isLying)
            {
                image = image.Rotate(-map.Player.CurrentDirection.ToAngle());
            }
            graphics.DrawImage(image,
                               new Rectangle(start + (Size)map.Player.Position + new Size((int)(-ImageSize * 8.5), (int)(ImageSize * 5.5)),
                                             new Size(ImageSize * 2, ImageSize * 2)));

            foreach (var body in map.Bodies)
            {
                var bodyImage = pictureLibrary.GetBodyImage(body).Rotate(body.CurrentDirection.ToAngle());
                graphics.DrawImage(bodyImage, new Rectangle(start + (Size)body.Position, new Size(ImageSize, ImageSize)));
            }
        }
コード例 #3
0
 public void PerceptiveCharacterAndTargetCharacterThatsIsFarAway()
 {
     Map        = MapFactory.ActiveGameMap;
     Viewer     = Factory.BaseCharacter;
     Target     = Factory.BaseCharacter;
     Target.Hex = new GameHex(1, 1, 22);
 }
コード例 #4
0
        public void PrintMap(IGameMap map)
        {
            if (IsPrintingMap && map.Tiles?.Length > 0)
            {
                foreach (ITile tile in map.Tiles)
                {
                    if (tile.HasChanged)
                    {
                        Console.CursorLeft = tile.XPos;
                        Console.CursorTop  = tile.YPos;
                        switch (tile.Value)
                        {
                        case TileValues.Empty:
                            Console.ForegroundColor = ConsoleColor.Gray;
                            Console.Write("0");
                            break;

                        case TileValues.Food:
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.Write("F");
                            break;

                        case TileValues.Snake:
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write("S");
                            break;
                        }
                        Console.ResetColor();

                        tile.HasChanged = false;
                    }
                }
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: FunFunFine/saviors
        //private SoundPlayer player = new SoundPlayer();

        public MainForm(IGameMap map, IDrawer drawer)
        {
            this.map    = map;
            this.drawer = drawer;

            BackgroundImage = Properties.Resources.neon_beer;


            WindowState = FormWindowState.Maximized;

            timer.Interval = 30;
            timer.Tick    += (sender, args) =>
            {
                Invalidate();
                try
                {
                    if (!map.Player.Update())
                    {
                        drawer.SetImage(map.Player, Properties.Resources.dead);
                    }
                }
                catch (WinException e)
                {
                    if (!isWin)
                    {
                        drawer.SetImage(map.Player, Properties.Resources.drink);
                    }
                    isWin = true;
                }
            };
            timer.Start();
            DoubleBuffered = true;
        }
コード例 #6
0
 public SelectUnitState(IGameBattle gameBattle, IGameMap gameMap, IUnitSummaryWindow unitSummaryWindow, IInputStateFactory inputStateFactory)
 {
     _gameBattle        = gameBattle;
     _gameMap           = gameMap;
     _unitSummaryWindow = unitSummaryWindow;
     _inputStateFactory = inputStateFactory;
 }
コード例 #7
0
 public void Construct(
     IGameMap gameMap,
     ITurn turn)
 {
     _gameMap = gameMap;
     _turn    = turn;
 }
コード例 #8
0
 public Mouse(
     IGameMap gameMap,
     IReposition reposition)
 {
     _gameMap    = gameMap;
     _reposition = reposition;
 }
コード例 #9
0
ファイル: MapLoaderXml.cs プロジェクト: lennyhans/OpenMB
 public void LoadAsync(IGameMap map, string mapFile)
 {
     fileLoader = new DotSceneLoader.DotSceneLoader((GameMap)map);
     fileLoader.LoadSceneFinished += FileLoader_LoadSceneFinished;
     LoadMapStarted?.Invoke();
     loadedMapName = mapFile;
     fileLoader.ParseDotSceneAsync(mapFile, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, ((GameMap)map).SceneManager);
 }
コード例 #10
0
        public PreviewMoveUnitState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unit, IUnitSummaryWindow unitSummaryWindow)
        {
            _gameBattle = gameBattle;
            _gameMap    = gameMap;

            _unit = unit;
            _unitSummaryWindow = unitSummaryWindow;
        }
コード例 #11
0
        public IGameMap GameMap;                        // The game map reference


        public AbilityExecuteParameters(IGameUnit unit, IAbility ability, IGameMapObject target, IEnumerable <IGameMapObject> targets, MapPoint targetPoint, IGameMap gameMap)
        {
            UnitExecuting    = unit;
            AbilityExecuting = ability;
            Target           = target;
            AllTargets       = targets;
            TargetPoint      = targetPoint;
            GameMap          = gameMap;
        }
コード例 #12
0
        public MovingUnitState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unit, IGameMapMovementRoute route, IInputStateFactory inputStateFactory)
        {
            _gameBattle = gameBattle;
            _gameMap    = gameMap;
            _unit       = unit;
            _route      = route;

            _inputStateFactory = inputStateFactory;
        }
コード例 #13
0
        private void GameMap_HoverUnitChanged(IGameMap map, UnitSelectedEventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

            _unitSummaryWindow.SelectedUnit = e.Unit;
        }
コード例 #14
0
        public UnitSelectActionState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unit, IUnitActionWindow unitActionWindow, IInputStateFactory inputStateFactory)
        {
            _gameBattle       = gameBattle;
            _gameMap          = gameMap;
            _unit             = unit;
            _unitActionWindow = unitActionWindow;

            _inputStateFactory = inputStateFactory;
        }
コード例 #15
0
        public TargetAbilityState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unitCasting, IAbility abilityTargeting, IInputStateFactory inputStateFactory)
        {
            _gameBattle       = gameBattle;
            _gameMap          = gameMap;
            _unitCasting      = unitCasting;
            _abilityTargeting = abilityTargeting;

            _inputStateFactory = inputStateFactory;
        }
コード例 #16
0
 public PlayerShopingState(
     IPlayerFogOfWar playerFogOfWar,
     IMouse mouse,
     IGameMap gameMap)
 {
     _playerFogOfWar = playerFogOfWar;
     _gameMap        = gameMap;
     _mouse          = mouse;
 }
コード例 #17
0
ファイル: GameMapExtensions.cs プロジェクト: twobob/CSRogue
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>	Notify the user that the player was blocked. </summary>
 ///
 /// <remarks>	Darrellp, 10/15/2011. </remarks>
 ///
 /// <param name="creature">			The creature. </param>
 /// <param name="blockedLocation">	The blocked location. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void NotifyOfBlockage(this IGameMap map, Creature creature, MapCoordinates blockedLocation)
 {
     map.Game.InvokeEvent(EventType.CreatureMove, map,
                          new CreatureMoveEventArgs(
                              map,
                              creature,
                              creature.Location,
                              blockedLocation,
                              isBlocked: true));
 }
コード例 #18
0
ファイル: GameBattle.cs プロジェクト: kuraselache/SizeEmblem
        public void LoadMap(IGameMap map)
        {
            UpdateState(BattleStates.Initialize);
            // Load the current map data
            RefreshUnits(map);

            // Now that we have our map reference we can create our input state factory (since it has a dependency on the map)
            CreateStateFactory();

            StartBattle();
        }
コード例 #19
0
ファイル: GameMapExtensions.cs プロジェクト: twobob/CSRogue
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>	Marks the newly lit and formerly lit spots on the map. </summary>
 ///
 /// <remarks>	Darrellp, 10/15/2011. </remarks>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public static void Relight(this IGameMap map)
 {
     foreach (var newlyLitLocation in map.Fov.NewlySeen)
     {
         map[newlyLitLocation].LitState = LitState.InView;
     }
     foreach (var previouslyLitLocation in map.Fov.NewlyUnseen)
     {
         map[previouslyLitLocation].LitState = LitState.Remembered;
     }
 }
コード例 #20
0
 public PlayerMoveState(
     IFogOfWar fogOfWar,
     IPlayerFogOfWar playerFogOfWar,
     IMouse mouse,
     IAbility ability,
     IGameMap gameMap)
 {
     _fogOfWar       = fogOfWar;
     _playerFogOfWar = playerFogOfWar;
     _mouse          = mouse;
     _ability        = ability;
     _gameMap        = gameMap;
 }
コード例 #21
0
ファイル: Level.cs プロジェクト: twobob/CSRogue
        public Level(int depth, IGameMap map, Game game = null, IExcavator excavator = null, int seed = -1)
        {
            _game = game;
            Map   = map ?? new CsRogueMap(_game);

            Depth = depth;
            if (excavator == null)
            {
                excavator = new GridExcavator(seed);
            }
            excavator.Excavate(Map);
            DistributeItems();
        }
コード例 #22
0
 public PlayerMovement(
     IFogOfWar fogOfWar,
     IPlayerFogOfWar playerFogOfWar,
     IPlayerMoney playerMoney,
     IMouse mouse,
     IGameMap gameMap)
 {
     _fogOfWar       = fogOfWar;
     _playerFogOfWar = playerFogOfWar;
     _playerMoney    = playerMoney;
     _mouse          = mouse;
     _gameMap        = gameMap;
 }
コード例 #23
0
ファイル: GameMapManager.cs プロジェクト: TYoung86/OpenMB
        public void LoadWorldMap(string file, IGameMapLoader loader)
        {
            if (maps.Count > 0)
            {
                maps.Dequeue().Destroy();
            }
            GameWorldMap map = new GameWorldMap(world, file, loader);

            map.LoadAsync();
            maps.Enqueue(map);
            map.LoadMapStarted  += Map_LoadMapStarted;
            map.LoadMapFinished += Map_LoadMapFinished;
            currentMap           = map;
        }
コード例 #24
0
        /// <summary>
        /// Generic path finding. Works on any map type.
        /// </summary>
        /// <returns>A list of paths to take to move from the start node to the goal node using the minimum number of paths, or null if no such list exists.</returns>
        public static List<Path> Find(IGameMap map, IMapNode start, IMapNode goal)
        {
            if (start == goal)
                return new List<Path>();
            Dictionary<IMapNode, int> distance = new Dictionary<IMapNode, int>();
            Dictionary<IMapNode, Path> previous = new Dictionary<IMapNode, Path>();

            ICollection<IMapNode> unvisited = new HashSet<IMapNode>();

            foreach (IMapNode node in map.Nodes)
            {
                distance.Add(node, Int32.MaxValue);
                previous.Add(node, null);
                unvisited.Add(node);
            }

            distance[start] = 0;

            while (unvisited.Count > 0)
            {
                IMapNode currentNode = unvisited.First(x => distance[x] == unvisited.Min(y => distance[y]));
                unvisited.Remove(currentNode);

                if (currentNode == goal)
                    break;

                foreach (Path p in map.GetPathsFrom(currentNode))
                {
                    IMapNode neighbor = p.To;
                    int alternateDistance = distance[currentNode] + 1;
                    if (alternateDistance < distance[neighbor])
                    {
                        distance[neighbor] = alternateDistance;
                        previous[neighbor] = p;
                    }
                }
            }

            List<Path> path = new List<Path>();
            Path prevPath = previous[goal];

            do
            {
                path.Insert(0, prevPath);
                prevPath = previous[prevPath.From];
            } while (prevPath != null);

            return path;
        }
コード例 #25
0
ファイル: GameMapManager.cs プロジェクト: TYoung86/OpenMB
        public void Load(string name, List <GameMapEntryPoint> mapEntryPoints, List <GameTeam> teams, string logicScriptFile, IGameMapLoader loader)
        {
            if (maps.Count > 0)
            {
                maps.Dequeue().Destroy();
            }
            GameMap map = new GameMap(world, mapEntryPoints, teams, logicScriptFile, loader);

            map.LoadMap(name);
            maps.Enqueue(map);
            map.LoadMapStarted  += Map_LoadMapStarted;
            map.LoadMapFinished += Map_LoadMapFinished;
            currentMap           = map;
            map.LoadAsync();
        }
コード例 #26
0
ファイル: GameBattle.cs プロジェクト: kuraselache/SizeEmblem
 public void FindGameMap()
 {
     if (_gameMap == null)
     {
         var foundMap = Component.FindObjectOfType <SizeEmblem.Scripts.GameMap.GameMap>();
         _gameMap = foundMap;
         // If the map has been loaded then we can immediately process it. Otherwise we want to wait until it's loaded
         if (_gameMap.IsLoaded)
         {
             LoadMap(_gameMap);
         }
         else
         {
             _gameMap.Loaded += GameMapLoaded;
         }
     }
 }
コード例 #27
0
        public InputStateFactory(
            IGameBattle gameBattle,
            IGameMap gameMap,
            IUnitSummaryWindow unitSummaryWindow,
            IUnitDetailsWindow unitDetailsWindow,
            IUnitActionWindow unitActionWindow,
            IUnitAbilitiesWindow selectedUnitAbilitiesWindow,
            IEndPhaseWindow endPhaseWindow)
        {
            _gameBattle = gameBattle;
            _gameMap    = gameMap;

            _unitSummaryWindow   = unitSummaryWindow;
            _unitDetailsWindow   = unitDetailsWindow;
            _unitActionWindow    = unitActionWindow;
            _unitAbilitiesWindow = selectedUnitAbilitiesWindow;
            _endPhaseWindow      = endPhaseWindow;
        }
コード例 #28
0
ファイル: FullModule.cs プロジェクト: schmidtgit/SC2Abathur
 /// IModules can take any number of these in the constructor and in any order.
 /// It is all handled using Dependency Injection.
 public FullModule(ILogger log, IIntelManager intelManager, ICombatManager combatManager,
                   IProductionManager productionManager, IRawManager rawManager, IAbilityRepository abilityRepository,
                   IUnitTypeRepository unitTypeRepository, IUpgradeRepository upgradeRepository, IBuffRepository buffRepository,
                   ISquadRepository squadRepository, IGameMap gameMap, ITechTree techTree, GameSettings gameSettings)
 {
     this.log                = log;
     this.intelManager       = intelManager;
     this.combatManager      = combatManager;
     this.productionManager  = productionManager;
     this.rawManager         = rawManager;
     this.abilityRepository  = abilityRepository;
     this.unitTypeRepository = unitTypeRepository;
     this.upgradeRepository  = upgradeRepository;
     this.buffRepository     = buffRepository;
     this.squadRepository    = squadRepository;
     this.gameMap            = gameMap;
     this.techTree           = techTree;
 }
コード例 #29
0
 public CreatureMoveEventArgs(
     IGameMap gameMap,
     Creature creature,
     MapCoordinates previousCreatureLocation,
     MapCoordinates creatureDestination,
     bool isFirstTimePlacement             = false,
     bool isBlocked                        = false,
     bool isRunning                        = false,
     List <MapCoordinates> litAtStartOfRun = null)
 {
     GameMap = gameMap;
     PreviousCreatureLocation = previousCreatureLocation;
     CreatureDestination      = creatureDestination;
     IsFirstTimePlacement     = isFirstTimePlacement;
     IsPlayer        = creature.IsPlayer;
     IsBlocked       = isBlocked;
     IsRunning       = isRunning;
     LitAtStartOfRun = litAtStartOfRun;
 }
コード例 #30
0
ファイル: GameMapExtensions.cs プロジェクト: twobob/CSRogue
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>	Move creature to a new location. </summary>
        ///
        /// <remarks>	Darrellp, 10/15/2011. </remarks>
        ///
        /// <param name="creature">					The creature. </param>
        /// <param name="newLocation">				The new location. </param>
        /// <param name="firstTimeHeroPlacement">	true when placing the hero the first time. </param>
        /// <param name="run">						true when this is part of a run. </param>
        /// <param name="litAtStartOfRun">			A list of lit locations at the start of a run. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static void MoveCreatureTo(
            this IGameMap map,
            Creature creature,
            MapCoordinates newLocation,
            bool firstTimeHeroPlacement = false,
            bool run = false,
            List <MapCoordinates> litAtStartOfRun = null)
        {
            // Get the data from the current location
            var data        = map[creature.Location];
            var oldPosition = creature.Location;

            // Remove the creature from this location
            data.RemoveItem(creature);

            // Place the creature at the new location
            creature.Location = newLocation;
            map[creature.Location].AddItem(creature);

            // If it's the player and there's a FOV to be calculated
            if (creature.IsPlayer && !run && map.Fov != null)
            {
                // Rescan for FOV
                map.Fov.Scan(creature.Location);
                map.Relight();
            }

            // If we've got a game object
            // Invoke the move event through it
            map.Game?.InvokeEvent(EventType.CreatureMove, map,
                                  new CreatureMoveEventArgs(
                                      map,
                                      creature,
                                      oldPosition,
                                      newLocation,
                                      firstTimeHeroPlacement,
                                      isBlocked: false,
                                      isRunning: run,
                                      litAtStartOfRun: litAtStartOfRun));
        }
コード例 #31
0
        public void DrawMap(IGameMap gameMap,
                            Dictionary <string, Texture2D> texturesDectionary,
                            bool blur)
        {
            for (int x = 0; x < gameMap.Width; x++)
            {
                for (int y = 0; y < gameMap.Height; y++)
                {
                    if (gameMap[x, y].DefaultImageFileName != null)
                    {
                        spriteBatch.Draw(texturesDectionary[gameMap[x, y].DefaultImageFileName],
                                         new Rectangle(x + x * Config.CellSize + Config.DefaultFrameOffset,
                                                       y + y * Config.CellSize + Config.DefaultFrameOffset,
                                                       Config.CellSize,
                                                       Config.CellSize),
                                         blur ? Color.White : Color.CornflowerBlue);
                    }
                }
            }

            DrawFrame();
        }
コード例 #32
0
 protected GameWorld(IGameMap map)
 {
     Map = map;
     Players = new List<Player>();
 }