Esempio n. 1
0
 public Level(string label, double scoresMultiplier, string soundFileName, IGameMap map)
 {
     Label                   = label;
     ScoresMultiplier        = scoresMultiplier;
     BackgroundSoundFileName = soundFileName;
     Map = map;
 }
Esempio n. 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)));
            }
        }
 public void PerceptiveCharacterAndTargetCharacterThatsIsFarAway()
 {
     Map        = MapFactory.ActiveGameMap;
     Viewer     = Factory.BaseCharacter;
     Target     = Factory.BaseCharacter;
     Target.Hex = new GameHex(1, 1, 22);
 }
Esempio n. 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;
                    }
                }
            }
        }
Esempio n. 5
0
        //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;
        }
Esempio n. 6
0
 public SelectUnitState(IGameBattle gameBattle, IGameMap gameMap, IUnitSummaryWindow unitSummaryWindow, IInputStateFactory inputStateFactory)
 {
     _gameBattle        = gameBattle;
     _gameMap           = gameMap;
     _unitSummaryWindow = unitSummaryWindow;
     _inputStateFactory = inputStateFactory;
 }
Esempio n. 7
0
 public void Construct(
     IGameMap gameMap,
     ITurn turn)
 {
     _gameMap = gameMap;
     _turn    = turn;
 }
Esempio n. 8
0
 public Mouse(
     IGameMap gameMap,
     IReposition reposition)
 {
     _gameMap    = gameMap;
     _reposition = reposition;
 }
Esempio n. 9
0
 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);
 }
        public PreviewMoveUnitState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unit, IUnitSummaryWindow unitSummaryWindow)
        {
            _gameBattle = gameBattle;
            _gameMap    = gameMap;

            _unit = unit;
            _unitSummaryWindow = unitSummaryWindow;
        }
        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;
        }
Esempio n. 12
0
        public MovingUnitState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unit, IGameMapMovementRoute route, IInputStateFactory inputStateFactory)
        {
            _gameBattle = gameBattle;
            _gameMap    = gameMap;
            _unit       = unit;
            _route      = route;

            _inputStateFactory = inputStateFactory;
        }
Esempio n. 13
0
        private void GameMap_HoverUnitChanged(IGameMap map, UnitSelectedEventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

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

            _inputStateFactory = inputStateFactory;
        }
Esempio n. 15
0
        public TargetAbilityState(IGameBattle gameBattle, IGameMap gameMap, IGameUnit unitCasting, IAbility abilityTargeting, IInputStateFactory inputStateFactory)
        {
            _gameBattle       = gameBattle;
            _gameMap          = gameMap;
            _unitCasting      = unitCasting;
            _abilityTargeting = abilityTargeting;

            _inputStateFactory = inputStateFactory;
        }
Esempio n. 16
0
 public PlayerShopingState(
     IPlayerFogOfWar playerFogOfWar,
     IMouse mouse,
     IGameMap gameMap)
 {
     _playerFogOfWar = playerFogOfWar;
     _gameMap        = gameMap;
     _mouse          = mouse;
 }
Esempio n. 17
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <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));
 }
Esempio n. 18
0
        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();
        }
Esempio n. 19
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <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;
     }
 }
Esempio n. 20
0
 public PlayerMoveState(
     IFogOfWar fogOfWar,
     IPlayerFogOfWar playerFogOfWar,
     IMouse mouse,
     IAbility ability,
     IGameMap gameMap)
 {
     _fogOfWar       = fogOfWar;
     _playerFogOfWar = playerFogOfWar;
     _mouse          = mouse;
     _ability        = ability;
     _gameMap        = gameMap;
 }
Esempio n. 21
0
        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();
        }
 public PlayerMovement(
     IFogOfWar fogOfWar,
     IPlayerFogOfWar playerFogOfWar,
     IPlayerMoney playerMoney,
     IMouse mouse,
     IGameMap gameMap)
 {
     _fogOfWar       = fogOfWar;
     _playerFogOfWar = playerFogOfWar;
     _playerMoney    = playerMoney;
     _mouse          = mouse;
     _gameMap        = gameMap;
 }
Esempio n. 23
0
        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;
        }
Esempio n. 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;
        }
Esempio n. 25
0
        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();
        }
Esempio n. 26
0
 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;
         }
     }
 }
Esempio n. 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;
        }
Esempio n. 28
0
 /// 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;
 }
Esempio n. 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;
 }
Esempio n. 30
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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));
        }
Esempio n. 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();
        }
 protected GameWorld(IGameMap map)
 {
     Map = map;
     Players = new List<Player>();
 }