Exemplo n.º 1
0
        public void EndTurn()
        {
            if (_gameplayManager.IsGameEnded)
            {
                return;
            }

            if (_gameplayManager.IsLocalPlayerTurn())
            {
                _uiManager.GetPage <GameplayPage>().SetEndTurnButtonStatus(false);

                foreach (BoardUnit card in PlayerBoardCards)
                {
                    card.OnEndTurn();
                }
            }
            else
            {
                foreach (BoardUnit card in OpponentBoardCards)
                {
                    card.OnEndTurn();
                }
            }

            _gameplayManager.CurrentPlayer.InvokeTurnEnded();
            _gameplayManager.OpponentPlayer.InvokeTurnEnded();

            _gameplayManager.CurrentTurnPlayer = _gameplayManager.IsLocalPlayerTurn() ?
                                                 _gameplayManager.OpponentPlayer :
                                                 _gameplayManager.CurrentPlayer;

            _tutorialManager.ReportAction(Enumerators.TutorialReportAction.END_TURN);

            TurnEnded?.Invoke();
        }
Exemplo n.º 2
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
        {
            return;
        }
        CellGridState = new CellGridStateBase(this);

        // End turn for current unit and advance the init tracker
        InitTracker[0].OnTurnEnd();
        AdvanceTracker();
        // Set current player to next player in the initiative
        CurrentPlayerNumber = InitTracker[0].PlayerNumber;

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        // Start next unit's turn
        InitTracker[0].OnTurnStart();
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
        // Select unit
        if (CurrentPlayerNumber == 0)
        {
            CellGridState = new CellGridStateUnitSelected(this, InitTracker[0]);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
//        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
//        {
//            return;
//        }
        CellGridState = new CellGridStateTurnChanging(this);

        bool playerDefeated = GetUnitsOfATeam(CurrentPlayerNumber).Count() == 0;

        //End the turn for all units of this current player
        if (!playerDefeated)
        {
            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });
        }

        CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        bool currentPlayerDefeated = GetUnitsOfATeam(CurrentPlayerNumber).Count() == 0;

        while (currentPlayerDefeated)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        }//Skipping players that are defeated until finding the next player

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
        {
            return;
        }
        // TODO Commit Moves Here
        CellGridState = new CellGridStateTurnChanging(this);

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

        CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        }//Skipping players that are defeated.

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        // This is where AI players play
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 5
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
        {
            return;
        }
        CellGridState = new CellGridStateTurnChanging(this);

        // I don't really expect this to do anything but who knows.
        Skills.ForEach(u => { u.OnTurnEnd(); });

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

        CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        }//Skipping players that are defeated.

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        // Added Skill event so the skills can turn themselves off when a turn starts.
        Skills.ForEach(u => { u.OnTurnStart(); });

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 6
0
        /// <summary>
        /// Method makes turn transitions. It is called by player at the end of his turn.
        /// </summary>
        public void EndTurn()
        {
            if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
            {
                Debug.Log("here");
                return;
            }
            CellGridState = new CellGridStateTurnChanging(this);

            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
            {
                CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            }//Skipping players that are defeated.

            if (TurnEnded != null)
            {
                TurnEnded.Invoke(this, new EventArgs());
            }

            Debug.Log(string.Format("Player {0} turn", CurrentPlayerNumber));
            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
            Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
        }
Exemplo n.º 7
0
 public void EndTurn()
 {
     _yourTurn = false;
     if (TurnEnded != null)
     {
         TurnEnded.Invoke();
     }
 }
Exemplo n.º 8
0
 public void EndTurn()
 {
     TurnEnding?.Invoke(this, new TurnEndedEventArgs());
     CurrentTurn = CurrentTurn.Opposite();
     TurnNumber++;
     SelectedPiece.OnDeselected();
     SelectedPiece = null;
     TurnEnded?.Invoke(this, new TurnEndedEventArgs());
 }
Exemplo n.º 9
0
 private void OnShipPlaced()
 {
     if (currentShip == ships.Count - 1)
     {
         allShipsPlaced = true;
         TurnEnded?.Invoke(this);
     }
     else
     {
         currentShip++;
     }
 }
Exemplo n.º 10
0
        private void EndTurn()
        {
            do
            {
                if (!_FactionTurnEnumerator.MoveNext())
                {
                    _FactionTurnEnumerator.Reset();
                    _FactionTurnEnumerator.MoveNext();
                }
            }while (_DefeatedFactions.Contains(CurrentTurnFaction));

            TurnEnded?.Invoke();
        }
Exemplo n.º 11
0
        protected internal override void Turn(int turn, Action <Intent> agent1, Action <Intent> agent2)
        {
            InvokeOnUIThread(() => TurnStarted?.Invoke(this, new EventArgs()));

            List <Task> tasks = new List <Task>();

            task1 = null;
            task2 = null;

            if (NeedIntent1 == null)
            {
                Console.WriteLine($"{nameof(NeedIntent1)}へのハンドラが登録されていません!!");
                agent1(Intent.StayIntent);
            }
            else
            {
                task1 = new TaskCompletionSource <Intent>();
                tasks.Add(task1.Task);

                InvokeOnUIThread(() => NeedIntent1(this, new EventArgs()));
                task1.Task.Wait();
            }

            if (NeedIntent2 == null)
            {
                Console.WriteLine($"{nameof(NeedIntent2)}へのハンドラが登録されていません!!");
                agent2(Intent.StayIntent);
            }
            else
            {
                task2 = new TaskCompletionSource <Intent>();
                tasks.Add(task2.Task);

                InvokeOnUIThread(() => NeedIntent2(this, new EventArgs()));
                task2.Task.Wait();
            }

            if (task1 != null)
            {
                agent1(task1.Task.Result);
            }

            if (task2 != null)
            {
                agent2(task2.Task.Result);
            }

            InvokeOnUIThread(() => TurnEnded?.Invoke(this, new EventArgs()));
        }
Exemplo n.º 12
0
        public void EndTurn(Selectable sel)
        {
            if (CurrentTurnOwner != sel)
            {
                Debug.LogWarning($"{sel} Selectable is not turn over, thus cannot end turn for another object");
                return;
            }

            TurnEnded?.Invoke(CurrentTurnOwner);

            var first = CurrentTurnOwner;

            m_ObjectQueue.RemoveFirst();
            m_ObjectQueue.AddLast(first);

            TurnStarted?.Invoke(CurrentTurnOwner);
        }
Exemplo n.º 13
0
    public void RealEndTurn()
    {
        for (int i = 0; i < 6; ++i)
        {
            UnitList[Turn].transform.GetChild(2).GetChild(i).GetComponent <OnClickDirectionChoice>().clicked  = false;
            UnitList[Turn].transform.GetChild(2).GetChild(i).GetComponent <OnClickDirectionChoice>().hovering = false;
            UnitList[Turn].transform.GetChild(2).GetChild(i).GetComponent <SpriteRenderer>().sprite           =
                UnitList[Turn].transform.GetChild(2).GetChild(i).GetComponent <OnClickDirectionChoice>().Start;
        }

        UnitListRefresh(UnitList);
        Turn = (Turn + 1) % Units.Count();

        // updating the unitGUI
        UpdateUnitUI();

        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
        {
            return;
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

        // -----------------   ASTR
        if (Turn == 0)
        {
            UnitList = UnitListSort(Units);                // Each Round, re-sort the UnitList
        }
        CurrentPlayerNumber = UnitList[Turn].PlayerNumber; // Get the next playing unit and retrieve its player number

        //
        while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % Units.Count();
        }//Skipping players that are defeated.

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 14
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        /*
         * if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
         * {
         * return;
         * }
         */
        CellGridState = new CellGridStateTurnChanging(this);

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

        /*
         * CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
         * while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
         * {
         *  CurrentPlayerNumber = (CurrentPlayerNumber + 1)%NumberOfPlayers;
         * }//Skipping players that are defeated.
         */
        if (TurnEnded != null)
        {
            modelAnim.SetBool("walk", false);
            TurnEnded.Invoke(this, new EventArgs());
        }

        CurrentUnit.ChargeTime = 0;
        if (CurrentUnit.ActionPoints != 0)
        {
            CurrentUnit.ChargeTime += 20;
        }
        if (CurrentUnit.MovementPoints != 0)
        {
            CurrentUnit.ChargeTime += 20;
        }

        UnitOrderCT = Units.FindAll(c => c.ChargeTime >= 100);         //Makes a list of units with full CT
        UnitNumber  = UnitOrderCT.Count();
        ClockTick();


        //Needs to be commented, otherwise sudden team attack ;D
        //Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        //Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 15
0
    public void EndTurn()
    {
        Resources.UnloadUnusedAssets();
        if (CheckGameEnd())
        {
            return;
        }
        if (UnitEnded != null)
        {
            UnitEnded.Invoke(this, null);
        }
        if (Units.FindAll(u => u.playerNumber == CurrentPlayerNumber && u.UnitEnd == false).Count > 0)    //当前玩家仍有角色未操作。
        {
            Players.Find(p => p.playerNumber.Equals(CurrentPlayerNumber)).Play(this);
        }
        if (Units.FindAll(u => u.playerNumber == CurrentPlayerNumber && u.UnitEnd == false).Count == 0)   //当前Player的所有Unit执行完毕
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            while (Units.FindAll(u => u.playerNumber.Equals(CurrentPlayerNumber)).Count == 0)
            {
                CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            }//Skipping players that are defeated.

            Units.ForEach(u => { u.OnTurnEnd(); });
            if (TurnEnded != null)
            {
                TurnEnded.Invoke(this, new EventArgs());
            }

            if (Units.FindAll(u => u.UnitEnd == false).Count == 0)    //所有Player的所有Unit执行完毕
            {
                EndRound();
            }
            else
            {
                StartCoroutine(TurnStart());
            }
        }
    }
Exemplo n.º 16
0
    public void EndTurn(Transform character)
    {
        if (Units.Select(u => u.playerNumber).Distinct().Count() == 1)
        {
            return;
        }

        if (UnitEnded != null)
        {
            UnitEnded.Invoke(character, null);
        }
        if (Units.FindAll(u => u.playerNumber == CurrentPlayerNumber && u.UnitEnd == false).Count > 0)    //当前玩家仍有角色未操作。
        {
            Players.Find(p => p.playerNumber.Equals(CurrentPlayerNumber)).Play(this);
        }
        if (Units.FindAll(u => u.playerNumber == CurrentPlayerNumber && u.UnitEnd == false).Count == 0)   //当前Player的所有Unit执行完毕
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            while (Units.FindAll(u => u.playerNumber.Equals(CurrentPlayerNumber)).Count == 0)
            {
                CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            }//Skipping players that are defeated.

            if (Units.FindAll(u => u.UnitEnd == false).Count == 0)    //所有Player的所有Unit执行完毕
            {
                EndRound();
            }
            else
            {
                Units.ForEach(u => { u.OnTurnEnd(); });
                if (TurnEnded != null)
                {
                    TurnEnded.Invoke(this, new EventArgs());
                }
                StartCoroutine(TurnStart());
            }
        }
    }
Exemplo n.º 17
0
        public bool HandleMove(PieceMovement pieceMovement)
        {
            if (!CanBeMovedToRequestedPosition(pieceMovement))
            {
                return(false);
            }

            TurnLog turnLog = TurnLog.Create(pieceMovement);

            bool isGameOver = CheckForCapturing(turnLog, pieceMovement);

            MovePiece(turnLog, pieceMovement);
            CheckForCastlingAndMove(turnLog, pieceMovement);

            if (isGameOver)
            {
                turnLog.AddEvent(TurnEvent.CreateGameOverEvent());
            }

            TurnEnded?.Invoke(turnLog);

            return(true);
        }
Exemplo n.º 18
0
        public void Update(GameFightTurnEndMessage message)
        {
            var fighter = GetFighter(message.Id);

            if (fighter == PlayedFighter)
            {
                IsOurTurn = false;
                _totalSpellLaunchs.Clear();
                _totalSpellLaunchsInCells.Clear();

                // Effects
                for (int i = _effectsDurations.Count - 1; i >= 0; i--)
                {
                    int key = _effectsDurations.ElementAt(i).Key;
                    _effectsDurations[key]--;
                    if (_effectsDurations[key] == 0)
                    {
                        _effectsDurations.Remove(key);
                    }
                }

                // Spells
                for (int i = _spellsIntervals.Count - 1; i >= 0; i--)
                {
                    int key = _spellsIntervals.ElementAt(i).Key;
                    _spellsIntervals[key]--;
                    if (_spellsIntervals[key] == 0)
                    {
                        _spellsIntervals.Remove(key);
                    }
                }

                TurnEnded?.Invoke();
            }

            fighter.Update(message);
        }
Exemplo n.º 19
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
        {
            return;
        }
        CellGridState = new CellGridStateTurnChanging(this);

        Units.FindAll(u => (!u.PlayerNumber.Equals(CurrentPlayerNumber))).ForEach(u => { u.HandleCapture(); });
        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });

        CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        while (Players.FindAll(p => p.PlayerNumber.Equals(CurrentPlayerNumber))[0].eliminated)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        }
        //while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
        //{
        //    CurrentPlayerNumber = (CurrentPlayerNumber + 1)%NumberOfPlayers;
        //}//Skipping players that are defeated.

        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
        GameObject.Find("TurnChange").GetComponent <AudioSource>().Play();
        string info = GameObject.Find("Info").GetComponent <Text>().text;

        GameObject.Find("Info").GetComponent <Text>().text = "you are " + (DarkRift.DarkRiftAPI.isConnected? armyNames[DarkRift.DarkRiftAPI.id - 1]:"RED")
                                                             + "\n" + "currTurn: " + armyNames[CurrentPlayerNumber]
                                                             + "\n" + barracksInfo
                                                             + "\n" + "Current Capture: " + (capPoints >= 0?capPoints.ToString():"")
                                                             + "\nmessagecount: " + NetManager.messageIndex;
    }
Exemplo n.º 20
0
    /// <summary>
    /// Method makes turn transitions. It is called by player at the end of his turn.
    /// </summary>
    public void EndTurn()
    {
        if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1 &&

            (Citys.Select(c => c.PlayerNumber).Distinct().Count() == 1 ||
             (Citys.Select(c => c.PlayerNumber).Distinct().Count() == 2 &&
              Citys.FindAll(c => c.PlayerNumber.Equals(-1)).Count > 0)))
        {
            return;
        }
        CellGridState = new CellGridStateTurnChanging(this);

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnEnd(); });
        Citys.FindAll(c => c.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(c => {
            c.OnTurnEnd(this);
            CurrentPlayer.Money += c.UnitCost;
        });

        CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0 &&
               Citys.FindAll(c => c.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
        {
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
        }//Skipping players that are defeated.



        if (TurnEnded != null)
        {
            TurnEnded.Invoke(this, new EventArgs());
        }

        Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
        Citys.FindAll(c => c.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(c => { c.OnTurnStart(); });
        Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
    }
Exemplo n.º 21
0
        public void PerformPlayerAction(IPlayerAction action)
        {
            log.Debug($"Performing player action: {action.GetType().Name}");

            Map.PreUpdate();

            var endsTurn = action.Perform(out var newPosition);

            PlayerPosition = newPosition;

            if (endsTurn)
            {
                ProcessSystemTurn();

                if (GetIfPlayerIsFrozen())
                {
                    ProcessSystemTurn();
                }

                TurnEnded?.Invoke(this, EventArgs.Empty);
            }

            cachedVisibleArea = null;
        }
Exemplo n.º 22
0
 public void EndTurn()
 {
     _foreignNations.BuyGoods();
     TurnEnded?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 23
0
 protected virtual void OnTurnEnded(object sender, DndCharacterEventArgs ea)
 {
     TurnEnded?.Invoke(sender, ea);
 }
Exemplo n.º 24
0
 public void UseCombination(Scoreboard sb, Combination c, IDices dices)
 {
     sb.SetCombinationForPlayer(_player, c, dices);
     TurnEnded?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 25
0
 public void End()
 {
     TurnEnded?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 26
0
 public virtual void EndTurn()
 {
     TurnEnded?.Invoke(this);
 }
 protected virtual void OnTurnEnded() {
     TurnEnded?.Invoke(this);
 }
Exemplo n.º 28
0
        public void EndTurn()
        {
            foreach (var item in Units)
            {
                if (item.TotalArmorPoints > 0)
                {
                    item.ArmorPoints = item.TotalArmorPoints;
                }
                item.blockChecker = false;
            }
            //CellGridState = new CellGridState(this);
            CellGridState = new CellGridStateBlockInput(this);
            _cellGridState.OnStateEnter();
            List <Cell> cellTypeRuins = new List <Cell>();

            if (Units.Select(u => u.PlayerNumber).Distinct().Count() == 1)
            {
                return;
            }

            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
            CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            while (Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).Count == 0)
            {
                CurrentPlayerNumber = (CurrentPlayerNumber + 1) % NumberOfPlayers;
            }

            if (TurnEnded != null)
            {
                TurnEnded.Invoke(this, new EventArgs());
            }
            uiManager.ChangeTurnUi(CurrentPlayerNumber);
            uiManager.CloseScorePanel();
            uiManager.CloseEnemyScorePanel();
            Debug.Log(string.Format("Player{0} turn", CurrentPlayerNumber));
            Units.FindAll(u => u.PlayerNumber.Equals(CurrentPlayerNumber)).ForEach(u => { u.OnTurnStart(); });
            Players.Find(p => p.PlayerNumber.Equals(CurrentPlayerNumber)).Play(this);
            foreach (var item in FindObjectsOfType <NumberUnit>())
            {
                if (item.GetComponent <Unit>().PlayerNumber != CurrentPlayerNumber)
                {
                    var highlighter = item.transform.Find("WhiteTile").GetComponent <SpriteRenderer>();
                    if (highlighter != null)
                    {
                        highlighter.color = new Color(1, 1, 1, 0);
                    }
                }
            }
            foreach (var cell in Cells)
            {
                if (cell.Ruins == true)
                {
                    cellTypeRuins.Add(cell);
                    Debug.Log(cellTypeRuins);
                    // uiManager.UpdateToRuins(cell.gameObject);
                }

                /*if(cell.Temple == true)
                 * {
                 *  cell.Temple = false;
                 *  uiManager.UpdateToRuins(cell.gameObject);
                 *  cell.Ruins = true;
                 * }
                 */
            }
            if (cellTypeRuins.Count() == 4)
            {
                Random random         = new Random();
                var    randomizedCell = random.Next(cellTypeRuins.Count);
                Debug.Log(cellTypeRuins[randomizedCell]);
                cellTypeRuins[randomizedCell].Ruins  = false;
                cellTypeRuins[randomizedCell].Temple = true;

                if (cellTypeRuins[randomizedCell].Ruins == false)
                {
                    uiManager.UpdateToRuins(cellTypeRuins[randomizedCell].gameObject);
                    Debug.Log("Ruiny");
                }
                if (cellTypeRuins[randomizedCell].Temple == true)
                {
                    uiManager.UpdateToTample(cellTypeRuins[randomizedCell].gameObject);
                    Debug.Log("Temple");
                }
            }
        }
Exemplo n.º 29
0
        private void OnMessageRecieved(MessageType messageType, string message)
        {
            switch (messageType)
            {
            case MessageType.StartGame:
            {
                GameStarted?.Invoke();
                break;
            }

            case MessageType.PlayerType:
            {
                PlayerType playerType = (PlayerType)Enum.Parse(typeof(PlayerType), message);
                PlayerTypeRecieved?.Invoke(playerType);
                break;
            }

            case MessageType.Step:
            {
                string[]   moves = message.Split(',');
                BoardIndex from  = BoardIndex.Parse(moves[0]);
                BoardIndex to    = BoardIndex.Parse(moves[1]);
                MoveRecieved?.Invoke(from, to);
                break;
            }

            case MessageType.TurnEnd:
            {
                TurnEnded?.Invoke();
                break;
            }

            case MessageType.StartTurn:
            {
                PlayerType playerType = (PlayerType)Enum.Parse(typeof(PlayerType), message);
                TurnStarted?.Invoke(playerType);
                break;
            }

            case MessageType.QueenAppeared:
            {
                BoardIndex where = BoardIndex.Parse(message);
                QueenAppeared?.Invoke(where);
                break;
            }

            case MessageType.Result:
            {
                PlayerType winner = (PlayerType)Enum.Parse(typeof(PlayerType), message);
                ResultRecieved?.Invoke(winner);
                break;
            }

            case MessageType.Name:
            {
                OpponentName?.Invoke(message);
                break;
            }

            case MessageType.TextMessage:
            {
                TextMessageRecieved?.Invoke(message);
                break;
            }
            }
        }
Exemplo n.º 30
0
 private void OnTurnEnded(EventArgs e)
 {
     //Interlocked.CompareExchange(ref TurnEnded, null, null)?.Invoke(this, e);
     TurnEnded?.Invoke(this, e);
 }