示例#1
0
        static void Main(string[] args)
        {
            int.TryParse(ConfigurationManager.AppSettings["PointsToWin"], out _pointsToWin);
            _game = new GameCore(new RandomNumberGenerator(), _leaderBoard);

            Console.WriteLine("Please enter your username:"******"Your username is invalid. Quitting");
                return;
            }

            _game.SetUsername(_userName);

            while (true)
            {
                NewGame();
                Console.WriteLine("Play again? y/n");
                if (Console.ReadLine().ToLower().Equals("n"))
                {
                    break;
                }

                _game.ResetGame();
            }
        }
 public void InjectDependencies(
     List <CivilizationDisplayBase> civilizationDisplays, CoreSignals coreSignals,
     IGameCore gameCore, UIStateMachineBrain brain, CitySummaryManager citySummaryManager,
     IPossessionRelationship <IHexCell, ICity> cityLocationCanon, ITechCanon techCanon,
     IExplorationCanon explorationCanon, VisibilitySignals visibilitySignals,
     IFreeGreatPeopleCanon freeGreatPeopleCanon, ICameraFocuser cameraFocuser,
     [Inject(Id = "Free Techs Display")] RectTransform freeTechsDisplay,
     [Inject(Id = "Play Mode Default Panels")] List <RectTransform> defaultPanels,
     [Inject(Id = "Free Great People Notification")] RectTransform freeGreatPeopleNotification
     )
 {
     CivilizationDisplays = civilizationDisplays;
     CoreSignals          = coreSignals;
     GameCore             = gameCore;
     Brain = brain;
     CitySummaryManager          = citySummaryManager;
     CityLocationCanon           = cityLocationCanon;
     TechCanon                   = techCanon;
     ExplorationCanon            = explorationCanon;
     VisibilitySignals           = visibilitySignals;
     FreeGreatPeopleCanon        = freeGreatPeopleCanon;
     CameraFocuser               = cameraFocuser;
     FreeTechsDisplay            = freeTechsDisplay;
     DefaultPanels               = defaultPanels;
     FreeGreatPeopleNotification = freeGreatPeopleNotification;
 }
示例#3
0
        public string OutputGameState(IGameCore game)
        {
            StringBuilder output = new StringBuilder();
            Player        player = game.Player;

            string nameString = string.Format("{0} the {1}", player.PlayerName, player.Title);

            output.AppendFormat("{0,-30}", nameString);

            output.AppendFormat("St:{0,-3}", player.Strength);
            output.AppendFormat("Dx:{0,-3}", player.Dexterity);
            output.AppendFormat("Co:{0,-3}", player.Constitution);
            output.AppendFormat("In:{0,-3}", player.Intelligence);
            output.AppendFormat("Lu:{0,-3}", player.Luck);

            output.AppendLine();

            output.AppendFormat("Dlvl:{0,-4} ", game.Dungeon.CurrentDungeonLevel);
            output.AppendFormat("$:{0} ", "N/A");
            output.AppendFormat("HP:{0}({1}) ", player.CurrentHP, player.MaxHP);
            output.AppendFormat("MP:{0}({1}) ", player.CurrentMP, player.MaxMP);
            output.AppendFormat("AC:{0} ", player.Armour);
            output.AppendFormat("XP:{0} ", "N/A");
            output.AppendFormat("T:{0} ", "N/A");

            output.AppendLine();

            return(output.ToString());
        }
    /// <summary>
    /// Create new GameCorePlayer by the given arguments
    /// </summary>
    /// <param name="gameCore"></param>
    /// <param name="sidePlayer">The side of the player in play world</param>
    /// <returns>new GameCorePlayer that matched to the given arguments</returns>
    public static GameCorePlayer GetGameCorePlayer(IGameCore gameCore, Side sidePlayer)
    {
        if (sidePlayer == Side.Left)
        {
            //Create new struct with relevent player keyconfig (left player)
            KeyConfigPlayer keyConfig = new KeyConfigPlayer
            {
                PlayerUpKey = gameCore.GetKeyConfig().LeftPlayerUpKey,
                PlayerDownKey = gameCore.GetKeyConfig().LeftPlayerDownKey
            };

            return new GameCorePlayer(gameCore.GetPlayerPaddle1(), gameCore.GetBall(), keyConfig,
                gameCore.GetPlayer1Text());
        }
        else
        {
            //Create new struct with relevent player keyconfig (left player)
            KeyConfigPlayer keyConfig = new KeyConfigPlayer
            {
                PlayerUpKey = gameCore.GetKeyConfig().RightPlayerUpKey,
                PlayerDownKey = gameCore.GetKeyConfig().RightPlayerDownKey
            };

            return new GameCorePlayer(gameCore.GetPlayerPaddle2(), gameCore.GetBall(), keyConfig,
                 gameCore.GetPlayer2Text());
        }

    }
示例#5
0
        internal ServiceManager(IGameCore game)
        {
            CurrentGame    = game;
            Services       = new Dictionary <Type, IService>();
            ActiveServices = new Dictionary <Type, IActiveService>();

            CurrentGame.TurnCompleted += GameTurnCompleted;
        }
示例#6
0
        public static void StartGame(IGameCore newGame)
        {
            if (Current != null)
            {
                Current.EndGame();
            }

            Current = newGame;
        }
 public void InjectDependencies(
     UIStateMachineBrain brain, IGameCore gameCore,
     FreeGreatPeopleDisplay freeGreatPeopleDisplay
     )
 {
     Brain    = brain;
     GameCore = gameCore;
     FreeGreatPeopleDisplay = freeGreatPeopleDisplay;
 }
 private void InjectDependencies(
     TechTreeDisplay techTreeDisplay, IGameCore gameCore,
     [Inject(Id = "UI Animator")] Animator uiAnimator
     )
 {
     TechTreeDisplay = techTreeDisplay;
     GameCore        = gameCore;
     UIAnimator      = uiAnimator;
 }
 public void InjectDependencies(
     SocialPoliciesDisplay socialPoliciesDisplay, UIStateMachineBrain brain,
     IGameCore gameCore
     )
 {
     SocialPoliciesDisplay = socialPoliciesDisplay;
     Brain    = brain;
     GameCore = gameCore;
 }
        public CompositeCitySignals(CitySignals signals, IGameCore gameCore,
                                    IPossessionRelationship <ICivilization, ICity> cityPossessionCanon
                                    )
        {
            GameCore            = gameCore;
            CityPossessionCanon = cityPossessionCanon;

            ActiveCivCityClickedSignal = signals.PointerClicked.Where(ActivCivCityFilter);
        }
        public CompositeUnitSignals(UnitSignals signals, IGameCore gameCore,
                                    IPossessionRelationship <ICivilization, IUnit> unitPossessionCanon
                                    )
        {
            GameCore            = gameCore;
            UnitPossessionCanon = unitPossessionCanon;

            ActiveCivUnitClickedSignal = signals.Clicked.Where(ActiveCivUnitFilter);
        }
示例#12
0
        public void Init(IGameInput iInput, IGameCore iGameCore, IGameRender iGameRender)
        {
            theInput      = iInput;
            theGameCore   = iGameCore;
            theGameRender = iGameRender;

            theInput.ModuleInit();
            theGameCore.ModuleInit();
            theGameRender.ModuleInit();
        }
示例#13
0
 public void InjectDependencies(
     IVisibilityCanon visibilityCanon, IExplorationCanon explorationCanon,
     IPlayerFactory playerFactory, IGameCore gameCore
     )
 {
     VisibilityCanon  = visibilityCanon;
     ExplorationCanon = explorationCanon;
     PlayerFactory    = playerFactory;
     GameCore         = gameCore;
 }
 public PlayerComposer(
     IPlayerFactory playerFactory, ICivilizationFactory civFactory,
     IGameCore gameCore, IBrainPile brainPile
     )
 {
     PlayerFactory = playerFactory;
     CivFactory    = civFactory;
     GameCore      = gameCore;
     BrainPile     = brainPile;
 }
示例#15
0
 public void InjectDependencies(
     IWarCanon warCanon, ICivilizationFactory civilizationFactory,
     IGameCore gameCore, DiContainer container
     )
 {
     WarCanon            = warCanon;
     CivilizationFactory = civilizationFactory;
     GameCore            = gameCore;
     Container           = container;
 }
示例#16
0
        public ExplorationCanon(
            IGameCore gameCore, VisibilitySignals visibilitySignals, HexCellSignals cellSignals
            )
        {
            GameCore          = gameCore;
            VisibilitySignals = visibilitySignals;
            CellSignals       = cellSignals;

            CellSignals.MapBeingClearedSignal.Subscribe(unit => Clear());
        }
 public void InjectDependencies(
     IGameCore gameCore, ICivDiscoveryCanon civDiscoveryCanon,
     IDiplomacyCore diplomacyCore, IExchangeBuilder exchangeBuilder
     )
 {
     GameCore          = gameCore;
     CivDiscoveryCanon = civDiscoveryCanon;
     DiplomacyCore     = diplomacyCore;
     ExchangeBuilder   = exchangeBuilder;
 }
示例#18
0
 public void InstantiateCore()
 {
     if (_logger == null)
     {
         _logger = new UniLogger();
     }
     if (_core == null)
     {
         _core = new GameCore(_logger);
     }
 }
        public VisibilityCanon(
            IGameCore gameCore, ITechCanon techCanon, VisibilitySignals visibilitySignals,
            HexCellSignals cellSignals
            )
        {
            GameCore          = gameCore;
            TechCanon         = techCanon;
            VisibilitySignals = visibilitySignals;

            cellSignals.MapBeingClearedSignal.Subscribe(unit => ClearCellVisibility());
        }
示例#20
0
        public string GetMapStateOutput(IGameCore game)
        {
            MapState mapState = game.Dungeon.CurrentMapState;

            char[,] output = new char[mapState.Map.Width, mapState.Map.Height];

            OutputBasicTerrain(mapState.Map, output);
            OutputStairs(mapState.Map, output);
            OutputMonsters(game, output);

            return(BuildOutputString(output, mapState.Map.Width, mapState.Map.Height));
        }
 public void InjectDependencies(
     IGameCore gameCore, IFreeResourcesLogic freeResourcesLogic,
     IResourceExtractionLogic extractionLogic, IResourceTransferCanon resourceTransferCanon,
     [Inject(Id = "Available Resources")] IEnumerable <IResourceDefinition> availableResources
     )
 {
     GameCore              = gameCore;
     FreeResourcesLogic    = freeResourcesLogic;
     ExtractionLogic       = extractionLogic;
     ResourceTransferCanon = resourceTransferCanon;
     AvailableResources    = availableResources;
 }
示例#22
0
        private void OutputMonsters(IGameCore game, char[,] output)
        {
            if (game.Player != null)
            {
                output[game.Player.Position.X, game.Player.Position.Y] = game.Player.Symbol;
            }

            foreach (IMonster m in game.Dungeon.CurrentMapState.Monsters)
            {
                output[m.Position.X, m.Position.Y] = m.Symbol;
            }
        }
示例#23
0
 public ConfigGameViewModel(IGameCore game)
 {
     this.Name            = game.Name;
     this.UseTimeLimit    = game.UseTimeLimit;
     this.MinPlayers      = game.MinPlayers;
     this.MaxPlayers      = game.MaxPlayers;
     this.MaxTimeLimit    = game.MaxTimeLimit;
     this.CanUseTimeLimit = game.CanUseTimeLimit;
     this.Image           = CommonUtils.GetIconGame(game);
     this.FillMaxPlayersItems();
     this.FillMaxTimeLimitItems();
 }
示例#24
0
 public static RoutedUICommand GetRoutedUIConfigGameCommand(IGameCore gameCore, int index)
 {
     return(new RoutedUICommand(
                $"Config {gameCore.Name}", //descripcion
                "Config",                  //accion
                typeof(Commands),
                new InputGestureCollection()
     {
         new KeyGesture((Key)(90 + index), ModifierKeys.Control)
     }
                ));
 }
示例#25
0
        public virtual void Update()
        {
            IGameCore game = Game.Current;
            MapState state = game.Dungeon.CurrentMapState;

            if(state.ArePositionsAdjacent(Position, game.Player.Position))
            {
                AttackTargetAndOutput(game.Player);
            }

            
        }
示例#26
0
 public static Image GetIconGame(IGameCore game)
 {
     using (var ms = new System.IO.MemoryStream(game.Image))
     {
         var image = new BitmapImage();
         image.BeginInit();
         image.CacheOption  = BitmapCacheOption.OnLoad; // here
         image.StreamSource = ms;
         image.EndInit();
         return(new System.Windows.Controls.Image
         {
             Source = image
         });
     }
 }
示例#27
0
        public void SetGameCore(IGameCore game)
        {
            Game = game;

            _startTime = DateTime.Now;

            // Start ticking game
            if (_timer == null)
            {
                _timer = new DispatcherTimer();
                _timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
                _timer.Tick += _timer_Tick;
                _timer.Start();
            }
        }
示例#28
0
 public void InjectDependencies(
     UIStateMachineBrain brain, IMapComposer mapComposer, IVisibilityResponder visibilityResponder,
     IVisibilityCanon visibilityCanon, IExplorationCanon explorationCanon, IGameCore gameCore,
     IUnitMapIconManager unitMapIconManager, List <IPlayModeSensitiveElement> playModeSensitiveElements
     )
 {
     Brain                     = brain;
     MapComposer               = mapComposer;
     VisibilityResponder       = visibilityResponder;
     VisibilityCanon           = visibilityCanon;
     ExplorationCanon          = explorationCanon;
     GameCore                  = gameCore;
     UnitMapIconManager        = unitMapIconManager;
     PlayModeSensitiveElements = playModeSensitiveElements;
 }
示例#29
0
        private void ShowConfigGame()
        {
            var configGameViewModel = new ConfigGameViewModel(this.selectedGame);
            var configGame          = new ConfigGame()
            {
                Game = this.selectedGame, DataContext = configGameViewModel
            };

            configGame.Owner = this;
            configGame.ShowDialog();
            if (configGame.DialogResult ?? true)
            {
                this.selectedGame = configGame.Game;
                FillPlayers();
            }
        }
 public void InstantiateCore()
 {
     if (_logger == null)
     {
         _logger = new UniLogger();
     }
     if (_core == null)
     {
         IGameModuleCollection collection = new DefaultGameModuleCollection();
         if (UseProxy)
         {
             var proxyFactory = new Proxy.DefaultProxyFactory();
             collection = new Proxy.ProxyModuleCollection(collection, proxyFactory);
         }
         _core = new GameCore(_logger, collection);
     }
 }
 public void InjectDependencies(
     IHexGrid grid, ICityConfig config, IUnitPositionCanon unitPositionCanon,
     ICombatExecuter combatExecuter, UIStateMachineBrain brain,
     IPopulationGrowthLogic growthLogic, IProductionLogic productionLogic,
     IYieldGenerationLogic resourceGenerationLogic, IGameCore gameCore,
     IPossessionRelationship <ICivilization, ICity> cityPossessionCanon,
     IPossessionRelationship <IHexCell, ICity> cityLocationCanon,
     [Inject(Id = "UI Animator")] Animator uiAnimator
     )
 {
     Grid                 = grid;
     Config               = config;
     UnitPositionCanon    = unitPositionCanon;
     CombatExecuter       = combatExecuter;
     Brain                = brain;
     GrowthLogic          = growthLogic;
     ProductionLogic      = productionLogic;
     YieldGenerationLogic = resourceGenerationLogic;
     GameCore             = gameCore;
     CityPossessionCanon  = cityPossessionCanon;
     CityLocationCanon    = cityLocationCanon;
     UIAnimator           = uiAnimator;
 }