Exemplo n.º 1
0
        public void AttackCurrentMonster()
        {
            if (CurrentPlayer.CurrentWeapon == null)
            {
                RaiseMessage("You must select a weapon, to attack.");
                return;
            }

            CurrentPlayer.UseCurrentWeaponOn(CurrentMonster);

            if (CurrentMonster.IsDead)
            {
                // Get another monster to fight
                GetMonsterAtLocation();
            }
            else
            {
                CurrentMonster.UseCurrentWeaponOn(CurrentPlayer);
            }
        }
Exemplo n.º 2
0
        private void Mark(object sender, EventArgs e)
        {
            Button senderButton = (Button)sender;

            if (CurrentPlayer == CurrentPlayer.Cross)
            {
                senderButton.Text = "X";
                CurrentPlayer     = CurrentPlayer.Circle;
            }
            else
            {
                senderButton.Text = "O";
                CurrentPlayer     = CurrentPlayer.Cross;
            }
            if (checkForWinner())
            {
                showWiner();
            }
            changeLabel();
        }
Exemplo n.º 3
0
        public void AttackCurrentMonster()
        {
            if (CurrentWeapon == null)
            {
                RaiseMessage("You must select a weapon to attack!");
                return;
            }

            // Determine damage to the monster
            int damageToMonster = RandomNumberGenerator.NumberBetween(CurrentWeapon.MinimumDamage, CurrentWeapon.MaximumDamage);

            if (damageToMonster == 0)
            {
                RaiseMessage($"You missed the {CurrentMonster.Name}!");
            }
            else
            {
                RaiseMessage($"You hit the {CurrentMonster.Name} for {damageToMonster}!");
                CurrentMonster.TakeDamage(damageToMonster);
            }
            if (CurrentMonster.IsDead)
            {
                //Spawn new monster
                GetMonsterAtLocation();
            }
            else
            {
                //Monster attacks the player
                int damageToPlayer = RandomNumberGenerator.NumberBetween(CurrentMonster.MinimumDamage, CurrentMonster.MaximumDamage);

                if (damageToPlayer == 0)
                {
                    RaiseMessage($"The {CurrentMonster.Name} attacks but misses you.");
                }
                else
                {
                    RaiseMessage($"The {CurrentMonster.Name} hits you for {damageToPlayer}.");
                    CurrentPlayer.TakeDamage(damageToPlayer);
                }
            }
        }
Exemplo n.º 4
0
        private NotificationObject GetInventoryCrateExpirationNotification()
        {
            uint            time          = ServerTime.Time;
            CurrentPlayer   currentPlayer = Service.Get <CurrentPlayer>();
            InventoryCrates crates        = currentPlayer.Prizes.Crates;
            uint            num           = (uint)(GameConstants.CRATE_EXPIRATION_WARNING_NOTIF * 60);
            uint            cRATE_EXPIRATION_WARNING_NOTIF_MINIMUM = (uint)GameConstants.CRATE_EXPIRATION_WARNING_NOTIF_MINIMUM;
            CrateData       nextInventoryCrateToExpire             = GameUtils.GetNextInventoryCrateToExpire(crates, time + cRATE_EXPIRATION_WARNING_NOTIF_MINIMUM);

            if (nextInventoryCrateToExpire == null)
            {
                return(null);
            }
            uint expiresTimeStamp = nextInventoryCrateToExpire.ExpiresTimeStamp;
            uint num2             = expiresTimeStamp - time;

            if (num2 > num)
            {
                num2 -= num;
                if (num2 < num)
                {
                    num2 = num;
                }
            }
            else
            {
                num2 = 10u;
            }
            string             text = "crate_expiration_warning";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            string             id                = "notif_" + text;
            string             message           = this.lang.Get(id, new object[0]);
            string             inProgressMessage = this.lang.Get("notif_" + text + "_progress", new object[0]);
            DateTime           time2             = DateTime.get_Now().AddSeconds(num2);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            return(new NotificationObject(text, inProgressMessage, message, notificationTypeVO.SoundName, time2, text, text));
        }
Exemplo n.º 5
0
        public void GrantUnlockShards(string shardId, int count)
        {
            CurrentPlayer            currentPlayer        = Service.CurrentPlayer;
            Dictionary <string, int> shards               = currentPlayer.Shards;
            StaticDataController     staticDataController = Service.StaticDataController;
            ShardVO shardVO       = staticDataController.Get <ShardVO>(shardId);
            string  targetType    = shardVO.TargetType;
            string  targetGroupId = shardVO.TargetGroupId;
            int     num           = count;

            if (shards.ContainsKey(shardId))
            {
                num += shards[shardId];
            }
            currentPlayer.ModifyShardAmount(shardId, num);
            int upgradeLevelOfDeployable = this.GetUpgradeLevelOfDeployable(targetType, targetGroupId);

            if (upgradeLevelOfDeployable == 0)
            {
                this.AttemptToUpgradeUnitWithShards(shardId, 1);
            }
            else
            {
                IDeployableVO deployableVOForLevelInGroup = this.GetDeployableVOForLevelInGroup(upgradeLevelOfDeployable, targetType, targetGroupId);
                if (deployableVOForLevelInGroup == null)
                {
                    Service.Logger.ErrorFormat("No deployableVO found for targetType: {0}, targetGroup: {1}, upgradeLevel: {2}", new object[]
                    {
                        targetType,
                        targetGroupId,
                        upgradeLevelOfDeployable
                    });
                    return;
                }
                if (num - count < deployableVOForLevelInGroup.UpgradeShardCount && num >= deployableVOForLevelInGroup.UpgradeShardCount)
                {
                    this.AllowResearchBuildingBadging = true;
                    Service.EventManager.SendEvent(EventId.ShardUnitNowUpgradable, deployableVOForLevelInGroup.Uid);
                }
            }
        }
Exemplo n.º 6
0
        private void CompleteQuestsAtLocation()
        {
            foreach (Quest quest in CurrentLocation.QuestsAvailableHere)
            {
                QuestStatus questToComplete = CurrentPlayer.Quests.FirstOrDefault(q => q.PlayerQuest.ID == quest.ID && !q.IsCompleted);

                if (questToComplete != null)
                {
                    if (CurrentPlayer.HasAllTheseItems(quest.ItemsToComplete))
                    {
                        foreach (ItemQuantity itemQuantity in quest.ItemsToComplete)
                        {
                            for (int i = 0; i < itemQuantity.Quantity; i++)
                            {
                                CurrentPlayer.RemoveItemFromInventory(CurrentPlayer.Inventory.First(item => item.ItemTypeID == itemQuantity.ItemID));
                            }
                        }

                        RaiseMessage("");
                        RaiseMessage($"You completed the {quest.Name} quest.");

                        RaiseMessage($"You receive {quest.RewardExperiencePoints} experience points.");
                        CurrentPlayer.AddExperience(quest.RewardExperiencePoints);

                        RaiseMessage($"You receive {quest.RewardGold} gold.");
                        CurrentPlayer.ReceiveGold(quest.RewardGold);

                        foreach (ItemQuantity itemQuantity in quest.RewardItems)
                        {
                            GameItem rewardItem = ItemFactory.CreateGameItem(itemQuantity.ItemID);

                            RaiseMessage($"You receieve a {rewardItem.Name}!");
                            CurrentPlayer.AddItemToInventory(rewardItem);
                        }

                        //Mark quest as completed
                        questToComplete.IsCompleted = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void BuySelectedItem()
        {
            if (itemChoice <= CurrentTrader.Inventory.Count)
            {
                var toBuy = CurrentTrader.Inventory[itemChoice];

                if (CurrentPlayer.Gold < toBuy.Price)
                {
                    messageLog.Add($"You don't have enough gold to buy {toBuy.Name}!");
                }
                else
                {
                    CurrentPlayer.AddItemToInventory(toBuy);
                    CurrentLocation.TraderHere.RemoveItemFromInventory(toBuy);
                }
            }
            else
            {
                gui.CloseItemSelected();
            }
        }
Exemplo n.º 8
0
 private void FindAllUpgradableEquipment(CurrentPlayer player, EquipmentUpgradeCatalog catalog)
 {
     this.equipmentToDisplay.Clear();
     foreach (string current in catalog.AllUpgradeGroups())
     {
         int         level       = player.UnlockedLevels.Equipment.GetLevel(current);
         EquipmentVO equipmentVO = catalog.GetByLevel(current, level);
         if (equipmentVO == null)
         {
             equipmentVO = catalog.GetMaxLevel(current);
         }
         if (equipmentVO.PlayerFacing)
         {
             if (equipmentVO.Faction == player.Faction)
             {
                 this.equipmentToDisplay.Add(equipmentVO);
             }
         }
     }
     this.equipmentToDisplay.Sort(new Comparison <EquipmentVO>(this.CompareBySortOrder));
 }
Exemplo n.º 9
0
        void _sim_BuildingDestroyed(Building b)
        {
            if (_selectedBuilding == b)
            {
                _selectedBuilding = null;
            }
            /* Play fight music */
            if (b.ObjectID.PlayerID == CurrentPlayer.Id)
            {
                DecreaseBuildingCounter(b.TypeID);
            }

            /* Play sound */
            if (CurrentPlayer.IsVisible(b))
            {
                AudioEngine.Instance.Sound.PlayMisc(MiscSoundType.StructureExplosion);
            }

            AudioEngine.Instance.Music.Play(MusicType.Fight);
            this.CheckGameEndCondition();
        }
Exemplo n.º 10
0
    void NextPlayer()
    {
        CurrentPlayer.SetActivePlayer(false);

        currentPlayerIndex = (currentPlayerIndex + 1) % numPlayers;

        CurrentPlayer.SetActivePlayer(true);

        currentBoard.HighlightPlayer(currentPlayerIndex + 1);
        Signals.Invoke(ESignalType.PlayerTurn, currentPlayerIndex);

        if (currentSelectedPiece != null)
        {
            currentSelectedPiece.LockRotation();
            if (numPlayers == 1)
            {
                lastSelectedPiece = currentSelectedPiece;
            }
            currentSelectedPiece = null;
        }
    }
Exemplo n.º 11
0
        private string GetCurrentPlayingText(CurrentPlayer player)
        {
            string retVal = string.Empty;

            switch (player)
            {
            case Constants.CurrentPlayer.User:
                retVal = "It's your turn.";
                break;

            case Constants.CurrentPlayer.Dealer:
                retVal = "It's the Dealers turn.";
                break;

            case Constants.CurrentPlayer.NoOne:
                retVal = "Nobody";
                break;
            }

            return(retVal);
        }
Exemplo n.º 12
0
    public void ChooseFirstSide(int playerId)
    {
        CurrentPlayer player = (CurrentPlayer)playerId;

        if (player == CurrentPlayer.PlayerX)
        {
            _playerXButton.SetActive(true);
            _playerOButton.SetActive(false);
            _gameController.CurrentPlayer = player;
        }
        else
        {
            _playerXButton.SetActive(false);
            _playerOButton.SetActive(true);
            _gameController.CurrentPlayer = player;
        }

        DeactivatePlayersButton();
        _infoPanel.SetActive(false);
        _gameController.SetFieldInteractable(true);
    }
Exemplo n.º 13
0
        public EpisodeTaskProgressInfo GetCurrentEpisodeTaskProgress()
        {
            CurrentPlayer       currentPlayer       = Service.CurrentPlayer;
            EpisodeProgressInfo episodeProgressInfo = currentPlayer.EpisodeProgressInfo;

            if (episodeProgressInfo == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(episodeProgressInfo.uid))
            {
                return(null);
            }
            EpisodeTaskProgressInfo currentTask = episodeProgressInfo.currentTask;

            if (currentTask == null)
            {
                return(null);
            }
            return(currentTask);
        }
Exemplo n.º 14
0
    public void SomeoneScored(CurrentPlayer looser)
    {
        string looserSide, winnerSide;

        if (looser == CurrentPlayer.PlayerOne)
        {
            looserSide    = "Bot";
            winnerSide    = "Top";
            _looserSprite = Bot3;
            _winnerSprite = Top5;
        }
        else
        {
            looserSide    = "Top";
            winnerSide    = "Bot";
            _looserSprite = Top3;
            _winnerSprite = Bot5;
        }
        ChangeLooser(looserSide);
        ChangeWinner(winnerSide);
    }
Exemplo n.º 15
0
 private void NewTraining()
 {
     if (_Worker == null || !_Worker.IsBusy)
     {
         IsVioletWinner = false;
         IsOrangeWinner = false;
         GameState      = new GameState()
         {
             OrangePlayer = this.OrangePlayer, VioletPlayer = this.VioletPlayer
         };
         RefreshUI();
         OrangePlayer.OnGameStart(GameState);
         VioletPlayer.OnGameStart(GameState);
         StartGameTrainer();
     }
     else
     {
         CurrentPlayer.CancelMove(GameState);
         _Worker.CancelAsync();
     }
 }
Exemplo n.º 16
0
        private void Mark(object sender, EventArgs e)
        {
            Button senderButton = (Button)sender;

            if (currentPlayer == CurrentPlayer.Cross)
            {
                senderButton.Text = "x";
                currentPlayer     = CurrentPlayer.Circle;
            }
            else
            {
                senderButton.Text = "o";
                currentPlayer     = CurrentPlayer.Cross;
            }
            changeLabel();
            checkForWinner();
            checkForWinner2();

            //Form2 victoryscreen = new Form2();
            //victoryscreen.Show();
        }
        private void OnShareReplayClicked(UXButton btn)
        {
            CurrentPlayer currentPlayer        = Service.Get <CurrentPlayer>();
            BattleEntry   latestValidPvPBattle = currentPlayer.BattleHistory.GetLatestValidPvPBattle();

            if (latestValidPvPBattle != null)
            {
                string text = this.shareInputBox.Text;
                if (string.IsNullOrEmpty(text))
                {
                    text = this.defaultShareText;
                }
                SquadMsg        message         = SquadMsgUtils.CreateSendReplayMessage(latestValidPvPBattle.RecordID, text);
                SquadController squadController = Service.Get <SquadController>();
                squadController.TakeAction(message);
                this.shareInputBox.Text = string.Empty;
                this.shareInputBox.InitText(this.defaultShareText);
                btn.Enabled           = false;
                this.shareButtonTimer = Service.Get <ViewTimerManager>().CreateViewTimer(5f, false, new TimerDelegate(this.OnShareButtonTimer), btn);
            }
        }
Exemplo n.º 18
0
        private void Start()
        {
            _playerQueue = new Queue <Player>();
            _players     = new List <Player>();
            for (var i = 0; i < AmountOfPlayers; i++)
            {
                var newPlayer = Instantiate(prefab, transform);
                newPlayer.ActivateChildren(false);
                newPlayer.Color = (Player.TeamColor)i;

                newPlayer.Name = i % 2 == 0 ? "Richard" : "Blueyard";

                _playerQueue.Enqueue(newPlayer);
                _players.Add(newPlayer);
            }

            CurrentPlayer = _playerQueue.Dequeue();
            CurrentPlayer.PlayerStartTurn();
            currentPlayerText.text = $"[{CurrentTeam}] {CurrentPlayer.Name}";
            _targetRotation        = camera.transform.rotation;
        }
        //Entire game (Both Single And Multiplayer) runs from here.
        public void Play(string file = null)
        {
            string input;

            while (!GameOver())
            {
                Console.WriteLine("{0}'s Turn", CurrentPlayer.Name);
                PlayerGrids[Opponent].DisplayGrid();
                do
                {
                    //Will pass a basic grid if it's an AI.
                    if (CurrentPlayer.GetType() == typeof(AI))
                    {
                        ConvertGrid();
                    }
                    input = CurrentPlayer.SelectMove();
                } while (!ValidInput(input));
                PlayMove(input);
            }
            return;
        }
Exemplo n.º 20
0
        /// <summary>
        /// Activate player object, start enemy spawn
        /// </summary>
        /// <param name="defaultPosition">use default player position</param>
        /// <param name="defaultVehicleSpeed">if false, speed of player's vehicle will be zero</param>
        void ActivateGameplay(bool defaultVehicleSpeed, bool defaultPosition, bool activateSpawners = true)
        {
            State = GameState.Game;

            // restart player
            if (defaultPosition)
            {
                CurrentPlayer.Reinit(defaultPlayerPosition, defaultVehicleSpeed);
            }
            else
            {
                CurrentPlayer.Reinit(CurrentPlayer.transform.position, defaultVehicleSpeed);
            }

            if (activateSpawners)
            {
                spawnersController.RestartSpawn();
            }

            OnGameplayActivate();
        }
Exemplo n.º 21
0
        private void ResolveAttack(Unit enemy)
        {
            if (CurrentPlayer.Owns(enemy))
            {
                CurrentPlayer.SetWeapon(enemy);
                machine.Fire(Trigger.AssignWeapon);
            }
            else
            {
                enemy.AttackWith(CurrentPlayer.Weapon());

                if (players[1].LivingUnits() == 0)
                {
                    machine.Fire(Trigger.PlayerDead);
                }
                else
                {
                    machine.Fire(Trigger.NextTurn);
                }
            }
        }
Exemplo n.º 22
0
        public bool GameOver()
        {
            bool gameOver = false;

            if (CurrentPlayer.IsLoose() || WaitingPlayer.Tie(CurrentPlayer))
            {
                gameOver = !gameOver;  // true
                CalcFinalScore();
                EndOfGameEventArgs e = new EndOfGameEventArgs();
                EndOfGame.Invoke(this, e);

                if (!e.m_GameOver)
                {
                    PlayerHasScored.Invoke(this, new EventArgs());
                    Checkers.Board.ClearLogicBoard();
                    ResetGame();
                }
            }

            return(gameOver);
        }
Exemplo n.º 23
0
        public void AttackCurrentMonster()
        {
            if (CurrentWeapon == null)
            {
                RaiseMessage("Moras odabrat weapon da udaras");
                return;
            }

            int damageToMonster = RandomNumberGenerator.NumberBetween(CurrentWeapon.MinimumDamage, CurrentWeapon.MaximumDamage);

            if (damageToMonster == 0)
            {
                RaiseMessage($"Promasio si {CurrentMonster.Name}.");
            }
            else
            {
                RaiseMessage("");
                RaiseMessage($"Udario si {CurrentMonster.Name} za {damageToMonster}.");
                CurrentMonster.TakeDamage(damageToMonster);
            }

            if (CurrentMonster.IsDead)
            {
                GetMonsterAtLocation();
            }
            else
            {
                int damageToPlayer = RandomNumberGenerator.NumberBetween(CurrentMonster.MinimumDamage, CurrentMonster.MaximumDamage);

                if (damageToPlayer == 0)
                {
                    RaiseMessage("Monster je promasio hehe gade srecni");
                }
                else
                {
                    RaiseMessage($"{CurrentMonster.Name} te udario za {damageToPlayer}");
                    CurrentPlayer.TakeDamage(damageToPlayer);
                }
            }
        }
Exemplo n.º 24
0
        public int MakePlayerCardPlacement(CardPlacement placement, Card newCard)
        {
            switch (placement)
            {
            case CardPlacement.H1:
            {
                int oldVal = CurrentPlayer.CardDict["H1"].Number;
                DiscardCard(CurrentPlayer.SwapCard("H1", newCard));
                return(newCard.Number - oldVal);
            }

            case CardPlacement.H2:
            {
                int oldVal = CurrentPlayer.CardDict["H2"].Number;
                DiscardCard(CurrentPlayer.SwapCard("H2", newCard));
                return(newCard.Number - oldVal);
            }

            case CardPlacement.V1:
            {
                int oldVal = CurrentPlayer.CardDict["V1"].Number;
                DiscardCard(CurrentPlayer.SwapCard("V1", newCard));
                return(newCard.Number - oldVal);
            }

            case CardPlacement.V2:
            {
                int oldVal = CurrentPlayer.CardDict["V2"].Number;
                DiscardCard(CurrentPlayer.SwapCard("V2", newCard));
                return(newCard.Number - oldVal);
            }

            case CardPlacement.Discard:
            {
                DiscardCard(newCard);
                return(0);
            }
            }
            return(0);
        }
Exemplo n.º 25
0
        private NotificationObject GetNextDailyCrateNotification()
        {
            if (!GameConstants.CRATE_DAILY_CRATE_ENABLED)
            {
                return(null);
            }
            if (!Service.IsSet <CurrentPlayer>() || Service.Get <CurrentPlayer>().CampaignProgress == null || Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress)
            {
                return(null);
            }
            CurrentPlayer currentPlayer      = Service.Get <CurrentPlayer>();
            uint          nextDailyCrateTime = currentPlayer.Prizes.Crates.NextDailyCrateTime;

            if (nextDailyCrateTime == 0u)
            {
                Service.Get <StaRTSLogger>().Error("Did not schedule next daily crate notif due to invalid scheduled time");
                return(null);
            }
            uint time = ServerTime.Time;
            uint num  = nextDailyCrateTime + (uint)(GameConstants.CRATE_DAILY_CRATE_NOTIF_OFFSET * 60);
            uint num2 = num - time;

            if (num2 <= 0u)
            {
                return(null);
            }
            string             text = "daily_crate_next";
            NotificationTypeVO notificationTypeVO = Service.Get <IDataController>().Get <NotificationTypeVO>(text);
            DateTime           time2 = DateTime.get_Now().AddSeconds(num2);

            if (!this.CheckValidNotificationTime(notificationTypeVO, time2))
            {
                return(null);
            }
            if ((ulong)num2 > (ulong)((long)notificationTypeVO.MinCompletionTime))
            {
                return(this.CreateReengagementNotification(text, time2, false));
            }
            return(null);
        }
Exemplo n.º 26
0
        private List <EquipmentVO> GenerateInactiveEquipmentList()
        {
            CurrentPlayer             currentPlayer           = Service.CurrentPlayer;
            IDictionary <string, int> levels                  = currentPlayer.UnlockedLevels.Equipment.Levels;
            EquipmentUpgradeCatalog   equipmentUpgradeCatalog = Service.EquipmentUpgradeCatalog;
            List <string>             iDCollection            = equipmentUpgradeCatalog.GetIDCollection();
            List <SortableEquipment>  list = new List <SortableEquipment>();
            EquipmentTab currentTab        = (EquipmentTab)this.equipmentTabs.CurrentTab;
            int          i     = 0;
            int          count = iDCollection.Count;

            while (i < count)
            {
                string text  = iDCollection[i];
                int    level = 1;
                if (levels.ContainsKey(text))
                {
                    level = levels[text];
                }
                EquipmentVO byLevel = equipmentUpgradeCatalog.GetByLevel(text, level);
                if (currentPlayer.Faction == byLevel.Faction && !currentPlayer.ActiveArmory.Equipment.Contains(byLevel.Uid))
                {
                    if (this.equipmentTabs.IsEquipmentValidForTab(byLevel, currentTab))
                    {
                        list.Add(new SortableEquipment(currentPlayer, byLevel));
                    }
                }
                i++;
            }
            ArmorySortUtils.SortWithPriorityList(list, new List <EquipmentSortMethod>
            {
                EquipmentSortMethod.UnlockedEquipment,
                EquipmentSortMethod.RequirementsMet,
                EquipmentSortMethod.Quality,
                EquipmentSortMethod.CurrentPlanet,
                EquipmentSortMethod.CapacitySize,
                EquipmentSortMethod.Alphabetical
            });
            return(ArmorySortUtils.RemoveWrapper(list));
        }
Exemplo n.º 27
0
        public void AttackCurrentMonster()
        {
            if (CurrentWeapon == null)
            {
                RaiseMessage("You must select a weapon to attack.");
                return;
            }

            int damageToMonster = RandomNumberGenerator.NumberBetween(CurrentWeapon.MinimumDamage, CurrentWeapon.MaximumDamage);

            if (damageToMonster == 0)
            {
                RaiseMessage($"You missed the {CurrentMonster.Name}.");
            }
            else
            {
                RaiseMessage($"You hit the {CurrentMonster.Name} for {damageToMonster}");
                CurrentMonster.TakeDamage(damageToMonster);
            }

            if (CurrentMonster.IsDead)
            {
                GetMonsterAtLocation();
            }
            else
            {
                int damageToPlayer = RandomNumberGenerator.NumberBetween(CurrentMonster.MinimumDamage, CurrentMonster.MaximumDamage);

                if (damageToPlayer == 0)
                {
                    RaiseMessage("The monster attacks, but misses you.");
                }

                else
                {
                    RaiseMessage($"The {CurrentMonster.Name} hit you for {damageToPlayer} points.");
                    CurrentPlayer.TakeDamage(damageToPlayer);
                }
            }
        }
Exemplo n.º 28
0
        private void capturerPiece(Pawn currentPiece)
        {
            int nbO = countNeighbor(CurrentPlayer, CurrentPlayer.getCurrentPawn());
            int nbX = countNeighborOp(CurrentPlayer.getCurrentPawn(), IndicePlayer);

            CurrentPlayer.resetVisitedToFalse();
            _opponentPlayer.resetVisitedToFalse();

            Console.WriteLine(nbO);
            Console.WriteLine(nbX);
            if (nbX != 0)
            {
                if (nbO < nbX)
                {
                    _map.Sectors[currentPiece.Location.X, currentPiece.Location.Y].GamePiece = null;
                    _currentPlayer.removePawn(currentPiece);
                }
                else if (nbX < nbO)
                {
                    _map.Sectors[XPawn.Location.X, XPawn.Location.Y].GamePiece = null;
                    _opponentPlayer.removePawn(XPawn);//probleme
                    _currentPlayer.updateIndice();
                }
                else if (nbX == nbO)
                {
                    _map.Sectors[currentPiece.Location.X, currentPiece.Location.Y].GamePiece = null;
                    _currentPlayer.removePawn(currentPiece);

                    _map.Sectors[XPawn.Location.X, XPawn.Location.Y].GamePiece = null;
                    _opponentPlayer.removePawn(XPawn);//probleme
                }
            }
            else
            {
                _currentPlayer.updateIndice();
            }

            Console.WriteLine("player 1 : " + Player1.Piece.Count);
            Console.WriteLine("player 2 : " + Player2.Piece.Count);
        }
Exemplo n.º 29
0
        public static bool CheckAvailableMove(string i_Move)
        {
            bool validMove    = false;
            char fromCol      = i_Move[0];
            char fromRow      = i_Move[1];
            char toCol        = i_Move[3];
            char toRow        = i_Move[4];
            int  indexFromCol = fromCol - 'A';
            int  indexFromRow = fromRow - 'a';
            int  indexToCol   = toCol - 'A';
            int  indexToRow   = toRow - 'a';

            if (CurrentPlayer.JustCaptured == true)
            {
                validMove = false;
                bool captureWithSameTool = (i_Move.Substring(0, 2) == m_LastMove);
                bool ableToCapture       = IsLeaglCaptureMove(indexToCol, indexToRow, indexFromCol, indexFromRow);

                if (captureWithSameTool && ableToCapture)
                {
                    validMove = true;
                }
            }

            else if (CurrentPlayer.IsPlayerAbleToCapture())
            {
                validMove = IsLeaglCaptureMove(indexToCol, indexToRow, indexFromCol, indexFromRow);
            }

            else
            {
                if (IsLeaglRegularMove(indexToCol, indexToRow, indexFromCol, indexFromRow) ||
                    IsLeaglCaptureMove(indexToCol, indexToRow, indexFromCol, indexFromRow))
                {
                    validMove = true;
                }
            }

            return(validMove);
        }
Exemplo n.º 30
0
        private void CompleteQuestsAtLocation()
        {
            foreach (Quest quest in CurrentLocation.QuestsAvailableHere)
            {
                QuestStatus questToComplete = CurrentPlayer.Quests.FirstOrDefault(q =>
                                                                                  q.PlayerQuest.ID == quest.ID && !q.IsCompleted);

                if (questToComplete != null)
                {
                    if (CurrentPlayer.HasAllTheseItems(quest.QuestItems))
                    {
                        //remove items from player's inventory
                        foreach (ItemQuantity iq in quest.QuestItems)
                        {
                            for (int i = 0; i < iq.Quantity; i++)
                            {
                                CurrentPlayer.RemoveItemFromInventory(
                                    CurrentPlayer.Inventory.First(
                                        item => item.ItemTypeID == iq.ItemId));
                            }
                        }
                        RaiseMessage("");
                        RaiseMessage($"Yuo completed the {quest.Name} quest.");

                        //give player the rewards
                        CurrentPlayer.ExperiencePoints += quest.RewardXP;
                        CurrentPlayer.Gold             += quest.RewardGold;
                        RaiseMessage($"You received {quest.RewardXP} EXP \n and {quest.RewardGold} gold.");

                        foreach (ItemQuantity iq in quest.RewardItems)
                        {
                            GameItem reward = ItemFactory.CreateGameItem(iq.ItemId);
                            CurrentPlayer.AddItemToInventory(reward);
                            RaiseMessage($"You received {reward.Name}.");
                        }
                        questToComplete.IsCompleted = true;
                    }
                }
            }
        }