Ejemplo n.º 1
1
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            scoreStorage = new ScoreStorage();
            HighScores = new ObservableCollection<Score>(scoreStorage.GetScores());
            game = new Game();
            game.PlayerLost += GameOnPlayerLost;
            game.PlayerTooFast += GameOnPlayerTooFast;
            game.PlayerWon += GameOnPlayerWon;
            game.CountdownTick += GameOnCountdownTick;
            game.WaitForItStarted += GameOnWaitForItStarted;
            game.TapDanceStarted += GameOnTapDanceStarted;
            game.ButtonsCanBeClickedChanged += GameOnButtonsCanBeClickedChanged;

            patternTimer = new DispatcherTimer();
            patternTimer.Tick += PatternTimerOnTick;
            patternTimer.Interval = buttonLightingTime;

            Button1Command = new RelayCommand(() => game.ButtonClicked(0), () => game.ButtonsCanBeClicked);
            Button2Command = new RelayCommand(() => game.ButtonClicked(1), () => game.ButtonsCanBeClicked);
            Button3Command = new RelayCommand(() => game.ButtonClicked(2), () => game.ButtonsCanBeClicked);
            Button4Command = new RelayCommand(() => game.ButtonClicked(3), () => game.ButtonsCanBeClicked);
            StartRetryCommand = new RelayCommand(() => StartNewPattern(game.GetNewPattern()), () => true);

            Button1BackColor = new SolidColorBrush(Colors.Black);
            Button2BackColor = new SolidColorBrush(Colors.Black);
            Button3BackColor = new SolidColorBrush(Colors.Black);
            Button4BackColor = new SolidColorBrush(Colors.Black);
            StartRetryText = "Start";
            SetNumberButtonsToDefault();
        }
Ejemplo n.º 2
1
 public HardBall(IGame game, Vector2 position)
     : base(game, game.ContentProvider.GetBallSprite(0), position, 5)
 {
     Velocity = 2;
     var target = new Vector2(Game.Random.Next() - Game.Random.Next(), Game.Random.Next() - Game.Random.Next());
     MoveTo(target);
 }
        public void Handle(string logLine, IHsGameState gameState, IGame game)
        {
            if (logLine[9] != 'R' && logLine[16] != 'r') // [Bob] ---Register
                return;

            if (logLine.Length == 29 && logLine[23] == 'B' && logLine[25] == 'x') // ---RegisterScreenBox---
            {
                if (game.CurrentGameMode == GameMode.Spectator)
                    gameState.GameEnd();
            }
            else if (logLine.Length == 31 && logLine[23] == 'F' && logLine[27] == 'e') // ---RegisterScreenForge---
            {
                gameState.GameHandler.SetGameMode(GameMode.Arena);
                game.ResetArenaCards();
            }
            else if (logLine.Length == 34)
            {
                if (logLine[23] == 'P' && logLine[30] == 'e') // ---RegisterScreenPractice---
                    gameState.GameHandler.SetGameMode(GameMode.Practice);
                else if (logLine[23] == 'T' && logLine[30] == 's') // ---RegisterScreenTourneys---
                    gameState.GameHandler.SetGameMode(GameMode.Casual);
                else if (logLine[23] == 'F' && logLine[30] == 'y') // ---RegisterScreenFriendly---
                    gameState.GameHandler.SetGameMode(GameMode.Friendly);
                else if (logLine[23] == 'e' && logLine[24] == 'N' && logLine[30] == 's') // RegisterProfileNotices
                    gameState.GameLoaded = true;
            }
            else if (logLine.Length == 35 && logLine[17] == 'F' && logLine[22] == 'd' && logLine[23] == 'C') // RegisterFriendChallenge
            {
                gameState.GameHandler.HandleInMenu();
            }
            else if (logLine.Length == 43 && logLine[23] == 'C' && logLine[32] == 'n' && logLine[33] == 'M' && logLine[39] == 'r')// ---RegisterScreenCollectionManager---
                gameState.GameHandler.ResetConstructedImporting();
        }
        public override void Trigger(IGame game, IEffectHandle handle)
        {
            var defeatedEnemies = new List<IEnemyInPlay>();

            foreach (var enemy in game.StagingArea.CardsInStagingArea.OfType<IEnemyInPlay>())
            {
                if (enemy.Damage >= enemy.Card.PrintedHitPoints)
                {
                    defeatedEnemies.Add(enemy);
                }
            }

            foreach (var player in game.Players)
            {
                foreach (var enemy in player.EngagedEnemies)
                {
                    if (enemy.Damage >= enemy.Card.PrintedHitPoints)
                    {
                        defeatedEnemies.Add(enemy);
                    }
                }
            }

            foreach (var enemy in defeatedEnemies)
            {
                var defeatedEffect = new EnemyDefeatedEffect(game, enemy, attackers);
                var defeatedHandle = defeatedEffect.GetHandle(game);
                game.AddEffect(defeatedEffect);
                game.TriggerEffect(defeatedHandle);
            }

            handle.Resolve(GetCompletedStatus());
        }
Ejemplo n.º 5
0
        public override CommandResponseDto Execute(IGame game)
        {
            game.Stop();
            game.Start(_size, new ClassicGameMode(game, _physics, _stateTracker, _playerRepository));

            return Success;
        }
        /// <summary>
        /// Initialize this system to a working state.
        /// </summary>
        /// <param name="game">
        /// The <see cref="IGame"/> game, that requested the initialization. That is the game,
        /// the system will be running in.
        /// </param>
        public override void Initialize(IGame game)
        {
            base.Initialize(game);
            this.Game.ComponentSystem.RegisterComponentType<DestructableComponent>();

            this.Game.EventManager.RegisterListener(CollisionEvents.CollisionEntered, this.OnCollisionEntered);
        }
Ejemplo n.º 7
0
 public GameEngine(IGame game, IBatBowlDecision batBowlDecision, ICoinToss coinToss, IDeliveryEngine deliveryEngine )
 {
     _game = game;
     _batBowlDecision = batBowlDecision;
     _coinToss = coinToss;
     _deliveryEngine = deliveryEngine;
 }
		public void Handle(string logLine, IHsGameState gameState, IGame game)
		{
			if(HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
			{
				var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
				if(game.CurrentGameMode == GameMode.Arena)
					gameState.GameHandler.HandlePossibleArenaCard(id);
				else
					gameState.GameHandler.HandlePossibleConstructedCard(id, false);
			}
			else if(HsLogReaderConstants.GoldProgressRegex.IsMatch(logLine) && (DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
			        && game.CurrentGameMode != GameMode.Spectator)
			{
				int wins;
				var rawWins = HsLogReaderConstants.GoldProgressRegex.Match(logLine).Groups["wins"].Value;
				if(int.TryParse(rawWins, out wins))
				{
					var timeZone = GetTimeZoneInfo(game.CurrentRegion);
					if(timeZone != null)
						UpdateGoldProgress(wins, game, timeZone);
				}
			}
			else if(HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
			{
				int amount;
				if(int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
					gameState.GameHandler.HandleDustReward(amount);
			}
			else if(HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
			{
				int amount;
				if(int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
					gameState.GameHandler.HandleGoldReward(amount);
			}
		}
Ejemplo n.º 9
0
		public void Handle(LogLineItem logLine, IHsGameState gameState, IGame game)
		{
			var match = HsLogReaderConstants.GameModeRegex.Match(logLine.Line);
			if(match.Success)
			{
				game.CurrentMode = GetMode(match.Groups["curr"].Value);
				game.PreviousMode = GetMode(match.Groups["prev"].Value);

				if((DateTime.Now - logLine.Time).TotalSeconds < 5 && _lastAutoImport < logLine.Time
					&& game.CurrentMode == Mode.TOURNAMENT)
				{
					_lastAutoImport = logLine.Time;
					var decks = DeckImporter.FromConstructed();
					if(decks.Any() && (Config.Instance.ConstructedAutoImportNew || Config.Instance.ConstructedAutoUpdate))
						DeckManager.ImportDecks(decks, false, Config.Instance.ConstructedAutoImportNew,
							Config.Instance.ConstructedAutoUpdate);
				}

				if(game.PreviousMode == Mode.GAMEPLAY && game.CurrentMode != Mode.GAMEPLAY)
					gameState.GameHandler.HandleInMenu();

				if(game.CurrentMode == Mode.HUB && !_checkedMirrorStatus && (DateTime.Now - logLine.Time).TotalSeconds < 5)
					CheckMirrorStatus();
			}
			else if(logLine.Line.Contains("Gameplay.Start"))
			{
				gameState.Reset();
				gameState.GameHandler.HandleGameStart(logLine.Time);
			}
		}
Ejemplo n.º 10
0
            private IGame m_gameState; // Game state variable

            public FormGame()
            {
                InitializeComponent();

                try
                {
                // Load the remoting configuration file
                RemotingConfiguration.Configure("remoting.config", false);

                // TODO: Remove this for the remoting.config
                m_gameState = (IGame)Activator.GetObject(typeof(IGame),
                    "http://localhost:10000/gamestate.soap");

                // Register callback
                m_gameState.RegisterClientCallback(new Callback(this));

                // TEST CODE
                m_gameState.revealCell(2, 2);
                foreach (Cell cell in m_gameState.Board.ClientCells)
                {
                    MessageBox.Show("Is Mine? " + cell.IsMine.ToString() + "\nPerimitive Mines: " + cell.PerimitiveMines + "\nLocation: " + cell.LocX + "," + cell.LocY);
                }
                }
                catch (Exception ex)
                {
                MessageBox.Show(ex.Message);
                }
            }
Ejemplo n.º 11
0
        public PlayerActionWindow(IGame game, IPlayer player)
            : base("Player Action Window", GetDescription(player), game)
        {
            this.player = player;

            player.IsActivePlayer = true;
        }
 public void Handle(string logLine, IHsGameState gameState, IGame game)
 {
     if (gameState.AwaitingRankedDetection)
     {
         gameState.LastAssetUnload = DateTime.Now;
         gameState.WaitingForFirstAssetUnload = false;
     }
     if (logLine.Contains("Medal_Ranked_"))
     {
         var match = Regex.Match(logLine, "Medal_Ranked_(?<rank>(\\d+))");
         if (match.Success)
         {
             int rank;
             if (int.TryParse(match.Groups["rank"].Value, out rank))
                 gameState.GameHandler.SetRank(rank);
         }
     }
     else if (logLine.Contains("rank_window"))
     {
         gameState.FoundRanked = true;
         gameState.GameHandler.SetGameMode(GameMode.Ranked);
     }
     else if (HsLogReaderConstants.UnloadCardRegex.IsMatch(logLine))
     {
         var id = HsLogReaderConstants.UnloadCardRegex.Match(logLine).Groups["id"].Value;
         if (game.CurrentGameMode == GameMode.Arena)
             gameState.GameHandler.HandlePossibleArenaCard(id);
         else
             gameState.GameHandler.HandlePossibleConstructedCard(id, true);
     }
 }
Ejemplo n.º 13
0
 public override void FixedTimePassed(Unit unit, IGame game)
 {
     if (OnGround)
     {
         unit.VX = 0.90 * unit.VX;
     }
 }
Ejemplo n.º 14
0
            private void HealOneDamageOnCharacter(IGame game, IEffectHandle handle, IPlayer player, ICharacterInPlay glorfindel, ICharacterInPlay character)
            {
                glorfindel.Resources -= 1;
                character.Damage -= 1;

                handle.Resolve(string.Format("{0} chose to heal 1 damage on '{1}'", player.Name, character.Title));
            }
Ejemplo n.º 15
0
 public void InitGame(IGame game)
 {
     // 1. Fetch Player Character
     game.LoadPlayer();
     // 2. Load game assets
     game.LoadAssets();
 }
Ejemplo n.º 16
0
        public override bool CanBeAttachedTo(IGame game, ICanHaveAttachments cardInPlay)
        {
            if (cardInPlay == null)
                throw new ArgumentNullException("cardInPlay");

            return (cardInPlay is IHeroCard);
        }
 public void Handle(string logLine, IHsGameState gameState, IGame game)
 {
     if (HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
     {
         var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
         if (game.CurrentGameMode == GameMode.Arena)
             gameState.GameHandler.HandlePossibleArenaCard(id);
         else
             gameState.GameHandler.HandlePossibleConstructedCard(id, false);
     }
     else if (HsLogReaderConstants.GoldProgressRegex.IsMatch(logLine)
              && (DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
              && game.CurrentGameMode != GameMode.Spectator)
     {
         int wins;
         var rawWins = HsLogReaderConstants.GoldProgressRegex.Match(logLine).Groups["wins"].Value;
         if (int.TryParse(rawWins, out wins))
         {
             TimeZoneInfo timeZone = null;
             switch (game.CurrentRegion)
             {
                 case Region.EU:
                     timeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
                     break;
                 case Region.US:
                     timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
                     break;
                 case Region.ASIA:
                     timeZone = TimeZoneInfo.FindSystemTimeZoneById("Korea Standard Time");
                     break;
             }
             if (timeZone != null)
             {
                 var region = (int)game.CurrentRegion - 1;
                 var date = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZone).Date;
                 if (Config.Instance.GoldProgressLastReset[region].Date != date)
                 {
                     Config.Instance.GoldProgressTotal[region] = 0;
                     Config.Instance.GoldProgressLastReset[region] = date;
                 }
                 Config.Instance.GoldProgress[region] = wins == 3 ? 0 : wins;
                 if (wins == 3)
                     Config.Instance.GoldProgressTotal[region] += 10;
                 Config.Save();
             }
         }
     }
     else if (HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
     {
         int amount;
         if (int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
             gameState.GameHandler.HandleDustReward(amount);
     }
     else if (HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
     {
         int amount;
         if (int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value, out amount))
             gameState.GameHandler.HandleGoldReward(amount);
     }
 }
Ejemplo n.º 18
0
 public override void AddToGame(IGame game)
 {
     games = game.GetNodeList<GameNode>();
     spaceships = game.GetNodeList<SpaceshipCollisionNode>();
     asteroids = game.GetNodeList<AsteroidCollisionNode>();
     bullets = game.GetNodeList<BulletCollisionNode>();
 }
Ejemplo n.º 19
0
        public virtual void Travel(IGame game)
        {
            if (game.QuestArea.ActiveLocation != null)
                return;

            game.AddEffect(this);
        }
Ejemplo n.º 20
0
 public List<IPlayerMove> MakeMoves(IGame game)
 {
     PrintAllMoves(game);
     while (true)
     {
         Console.WriteLine("Please type instruction:");
         Console.WriteLine("(i=InternetLink, c=Campus, u=Upgrade, x=eXchange, t=TryStartUp, Enter=end turn)");
         Console.WriteLine("(s=Save, l=Load, -=Undo, p=stats, /=suggest, .=use suggest, m=moves)");
         var instruction = Console.ReadLine();
         try
         {
             List<IPlayerMove> moves = GetMoves(game, instruction);
             if (moves != null)
             {
                 return moves;
             }
             DoSystemAction(game, instruction);
             //return null;
         }
         catch (Exception ex)
         {
             ColorConsole.WriteLine(ConsoleColor.Red,
                                    "Unknown command: '{0}'. Details error: {1}",
                                    instruction,
                                    ex.Message);
         }
         // otherwise, continue;
     }
 }
Ejemplo n.º 21
0
 public override void RemoveFromGame(IGame game)
 {
     players = null;
     asteroids = null;
     bullets = null;
     games = null;
 }
Ejemplo n.º 22
0
 public SourceCodeListViewModel(IGame game)
 {
     this.game = game;
     List<DirectoryListing> baseListings = new List<DirectoryListing>();
     foreach (ISourceCode source in game.Sources)
     {
         string dn = Path.GetDirectoryName(source.RelativeName);
         string[] dirs = Regex.Split(dn, @"[\\/]");
         DirectoryListing d = null;
         foreach (var baseListing in baseListings)
         {
             if (baseListing.Name == dirs[0])
             {
                 d = baseListing;
             }
         }
         if (d == null)
         {
             d = new DirectoryListing();
             d.Name = dirs[0];
             baseListings.Add(d);
         }
         d.GetOrCreateDirectoryListing(dirs).Sources.Add(source);
     }
     DirectoryListings = baseListings;
 }
Ejemplo n.º 23
0
 public override void AddToGame(IGame game)
 {
     games = game.GetNodeList<GameNode>();
     players = game.GetNodeList<PlayerCollisionNode>();
     asteroids = game.GetNodeList<AsteroidCollisionNode>();
     bullets = game.GetNodeList<BulletCollisionNode>();
 }
 public void Handle(string logLine, IHsGameState gameState, IGame game)
 {
     if (HsLogReaderConstants.CardAlreadyInCacheRegex.IsMatch(logLine))
     {
         var id = HsLogReaderConstants.CardAlreadyInCacheRegex.Match(logLine).Groups["id"].Value;
         if (game.CurrentGameMode == GameMode.Arena)
             gameState.GameHandler.HandlePossibleArenaCard(id);
         else
             gameState.GameHandler.HandlePossibleConstructedCard(id, false);
     }
     else if ((DateTime.Now - gameState.LastGameStart) > TimeSpan.FromSeconds(10)
              && game.CurrentGameMode != GameMode.Spectator)
     {
         GoldTracking(logLine, game);
     }
     else if (HsLogReaderConstants.DustRewardRegex.IsMatch(logLine))
     {
         int amount;
         if (int.TryParse(HsLogReaderConstants.DustRewardRegex.Match(logLine).Groups["amount"].Value,
             out amount))
             gameState.GameHandler.HandleDustReward(amount);
     }
     else if (HsLogReaderConstants.GoldRewardRegex.IsMatch(logLine))
     {
         int amount;
         if (int.TryParse(HsLogReaderConstants.GoldRewardRegex.Match(logLine).Groups["amount"].Value,
             out amount))
             gameState.GameHandler.HandleGoldReward(amount);
     }
 }
Ejemplo n.º 25
0
        public void Initialize(IGame game, int starCount)
        {
            rand = new Random();
            this.game = game;

            int starCount1 = starCount;
            int starCount2 = starCount / Star2Divisor;
            int starCount3 = starCount / Star3Divisor;

            stars1 = new List<Vector2>(starCount1);
            stars2 = new List<Vector2>(starCount2);
            stars3 = new List<Vector2>(starCount3);

            for (int i = 0; i < starCount1; ++i)
            {
                int x = rand.Next(game.Width);
                int y = rand.Next(game.Height);
                stars1.Add(new Vector2(x, y));
            }

            for (int i = 0; i < starCount2; ++i)
            {
                int x = rand.Next(game.Width);
                int y = rand.Next(game.Height);
                stars2.Add(new Vector2(x, y));
            }

            for (int i = 0; i < starCount3; ++i)
            {
                int x = rand.Next(game.Width);
                int y = rand.Next(game.Height);
                stars3.Add(new Vector2(x, y));
            }
        }
Ejemplo n.º 26
0
        public override void Update(Unit unit, IGame game)
        {
            base.Update(unit, game);

            if ((game.Time - unit.BirthTime) > FleeTime)
                unit.setState(UnitFactories.States.Create(unit.Name, "fleeing"), game);
        }
Ejemplo n.º 27
0
        public bool TryGetGame(string hash, out IGame game)
        {
            GameSetup _setup;
            Game _game;

            if (setups.TryGetValue(hash, out _setup))
            {
                game = _setup;
                return true;
            }
            else if (games.TryGetValue(hash, out _game))
            {
                game = _game;
                return true;
            }
            else
            {
                string filepath = getFilePath(hash);
                if (!File.Exists(filepath))
                {
                    game = null;
                    return false;
                }
                else
                {
                    _game = Game.FromFile(filepath);
                    games.Add(hash, _game);
                    game = _game;
                    return true;
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        ///  default constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // set default year
            _year = DateTime.Now.Year;

            // create game class
            _game = new Game(_points);

            // set event hanlders
            _game.Message += OnMessage;
            _game.Budget += OnBudget;

            // create check class
            _check = new Check();

            // set events
            _check.Attack += OnAttack;
            _check.Assault += OnAssault;
            _check.EconomyCrises += OnEconomyCrises;

            // change points
            OnChangePoints();
        }
 /// <summary>
 /// Initializes a new instance of the CommandContext class.
 /// </summary>
 /// <param name="game">Command context's IGame.</param>
 /// <param name="scoreboard">Command context'sIScoreboard.</param>
 /// <param name="boardHistory">Command context's IMemento.</param>
 public CommandContext(IGame game, IScoreboard scoreboard, IMemento boardHistory)
 {
     this.Game = game;
     this.ScoreboardInfo = scoreboard;
     this.BoardHistory = boardHistory;
     this.Moves = 0;
 }
Ejemplo n.º 30
0
 public override void RemoveFromGame(IGame game)
 {
     spaceships = null;
     asteroids = null;
     bullets = null;
     games = null;
 }
Ejemplo n.º 31
0
 void GameEvent.IStartGame.OnStartGame(IGame game) => ElevatorAnimations.GoToWithNoPlayer();
Ejemplo n.º 32
0
 public void SetHideGame(IGame game, bool state)
 {
     game.Hidden = state;
     database.UpdateGameInDatabase(game);
 }
Ejemplo n.º 33
0
 public ClassicRules(IGame game)
     : this(game, new ConfigurationProvider())
 {
 }
Ejemplo n.º 34
0
 public GameController(IGame _service)
 {
     service = _service;
 }
Ejemplo n.º 35
0
 public CheckForDefeatedEnemiesEffect(IGame game)
     : this(game, Enumerable.Empty <IAttackingInPlay>())
 {
 }
Ejemplo n.º 36
0
            public override void Trigger(IGame game, IEffectHandle handle)
            {
                game.QuestArea.AddProgress(1);

                handle.Resolve(GetCompletedStatus());
            }
Ejemplo n.º 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerWalkNortheastHandler"/> class.
 /// </summary>
 /// <param name="gameInstance">A reference to the game instance.</param>
 /// <param name="creatureFinder">A reference to the creature finder.</param>
 public PlayerWalkNortheastHandler(IGame gameInstance, ICreatureFinder creatureFinder)
     : base(gameInstance, creatureFinder, Direction.NorthEast)
 {
 }