private void StartEntityTurn(TurnEntities entity)
 {
     ActiveTurnEntity = entity;
     OnTurnEnd?.Invoke(ActiveTurnEntity);
     RefTurnEntity.Value = entity;
     EntityCollection[entity].StartTurn(this);
 }
示例#2
0
            public static OnTurnEnd alloc(ActionPointGUIComponent p_actionPointGUIComponent)
            {
                OnTurnEnd l_instance = new OnTurnEnd();

                l_instance.ActionPointGUIComponent = p_actionPointGUIComponent;
                return(l_instance);
            }
    public void ChangeLocationForward(EventInfo eventInfo)
    {
        CameraAngleChangeInfo floatChangeInfo = (CameraAngleChangeInfo)eventInfo;
        int newIndex      = 0;
        int previousIndex = CurrentIndex;

        if (CurrentIndex + floatChangeInfo.increments <= 3)
        {
            newIndex = CurrentIndex + floatChangeInfo.increments;
        }
        else
        {
            newIndex    = (CurrentIndex + floatChangeInfo.increments) % 4; // % operaattori tarkoitaa jakojäännöstä. Korjaa pari väärän sijainnin antamis bugia.
            turnEndFlag = true;
        }

        setCurrentLocation(newIndex);

        OnLocationChange?.Invoke();

        if (hasTurnCompleted())
        {
            OnTurnEnd?.Invoke();
            turnEndFlag = false;
        }
    }
示例#4
0
 public void ReceiveTurn(OnTurnEnd onTurnEnd)
 {
     if (!isMyTurn)
     {
         this.onTurnEnd = onTurnEnd;
         isMyTurn       = true;
         InitTurn();
     }
 }
示例#5
0
    public void FindMatches()
    {
        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                GameObject select = candyPos[i, j];
                if (select != null)
                {
                    if (i > 0 && i < width - 1)
                    {
                        GameObject left  = candyPos[i - 1, j];
                        GameObject right = candyPos[i + 1, j];
                        if (left != null && right != null)
                        {
                            if (left.name == select.name && right.name == select.name)
                            {
                                select.GetComponent <Candy>().isMatched = true;
                                left.GetComponent <Candy>().isMatched   = true;
                                right.GetComponent <Candy>().isMatched  = true;
                            }
                        }
                    }

                    if (j > 0 && j < height - 1)
                    {
                        GameObject down = candyPos[i, j - 1];
                        GameObject up   = candyPos[i, j + 1];
                        if (down != null && up != null)
                        {
                            if (down.name == select.name && up.name == down.name)
                            {
                                select.GetComponent <Candy>().isMatched = true;
                                up.GetComponent <Candy>().isMatched     = true;
                                down.GetComponent <Candy>().isMatched   = true;
                            }
                        }
                    }
                }
            }
        }
        if (IsMatchedOnBoard())
        {
            AddToMatchedList();
        }
        else
        {
            if (streakValue == 0)
            {
                return;
            }
            OnTurnEnd?.Invoke(this, EventArgs.Empty);
            streakValue = 0;
            ClearDict();
        }
    }
示例#6
0
        private void EndTurn()
        {
            Team team = TurnCounter % 2 == 1 ? Team.Player : Team.Enemy;

            Debug.Log("Ending Turn");
            TurnCounter += 1;
            OnTurnEnd?.Invoke(this, new TurnEventArgs {
                Team = team
            });
        }
示例#7
0
        public void EndTurn()
        {
            OnTurnEnd?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer));

            MoveToNextPlayer();

            m_TurnNumber++;

            OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer));
        }
示例#8
0
        public void EndTurn()
        {
            OnTurnEnd?.Invoke();

            HandleTurnEnd();

            ResetTurnBar();

            BattleManager.Instance.EndTurn();
        }
示例#9
0
        private void Start()
        {
            m_entityRegistrationComponent    = RuntimeObject.FindComponent <EntityRegistrationComponent>();
            cachedActionPointEntityComponent = CachedEntityComponent <ActionPoint> .build(m_entityRegistrationComponent.AssociatedEntity);

            gameObject.SetActive(false);

            MyEvent <Entity> .IEventCallback l_onTurnStart = OnTurnStart.alloc(this);
            MyEvent <Entity> .IEventCallback l_onTurnEnd   = OnTurnEnd.alloc(this);

            MyEvent <Entity> .register(ref m_entityRegistrationComponent.AssociatedEntity.OnEntityTurnStart, ref l_onTurnStart);

            MyEvent <Entity> .register(ref m_entityRegistrationComponent.AssociatedEntity.OnEntityTurnEnd, ref l_onTurnEnd);
        }
示例#10
0
        public void EndTurn()
        {
            OnTurnEnd?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer));

            MoveToNextPlayer(currentPlayer);

            if (playerQueue.Count == 0)
            {
                turnNumber++;
                playerQueue.Enqueue(1);
                playerQueue.Enqueue(2);
            }

            OnTurnStart?.Invoke(this, new TurnEventArgs(turnNumber, currentPlayer));
        }
示例#11
0
    /// <summary>
    /// Proceeds to the next thing in the turn order if
    /// there is one.
    /// </summary>
    private void Next()
    {
        turnEndRequested  = false;
        turnEndInProgress = true;

        // Notify that the current actor's turn is ending
        if (turnOrder.Current != null)
        {
            turnOrder.Current.OnTurnEnd();
            OnTurnEnd?.Invoke(turnOrder.Current);
        }

        // If the round hasn't started notify that a new one
        // is starting
        if (!roundStarted)
        {
            RoundCount++;
            OnRoundStart?.Invoke();
            roundStarted = true;
        }

        // Go to next thing in the turn order
        bool anyMore = turnOrder.MoveNext();

        // If there's nothing left in the order then the round has ended
        if (!anyMore)
        {
            roundStarted = false;
            turnOrder.Reset();
            OnRoundEnd?.Invoke();
        }

        // Otherwise, let the new thing know its turn is
        // starting
        else
        {
            // Notify the turn based thing FIRST - then other listeners.
            turnOrder.Current.OnTurnStart();
            OnTurnStart?.Invoke(turnOrder.Current);
        }

        turnEndInProgress = false;

        if (turnEndRequested)
        {
            Next();
        }
    }
示例#12
0
        public void TurnEnd()
        {
            OnTurnEnd?.Invoke();

            if (IsBattleEnd())
            {
                return;
            }

            if (IsPhaseEnd())
            {
                UnitsList.ForEach(x => x.IsEnded = false);
            }

            TurnStart();
        }
示例#13
0
        void OnSocketMessage(object sender, MessageEventArgs e)
        {
            var parser  = new MessageParser(e.Data);
            var message = parser.GetObject();

            // All events are fired from the main thread
            Dispatcher.Enqueue(() => {
                OnGetMessage.TryInvoke(message);
                switch (parser.Path.ToLower())
                {
                case "turn.start":
                    OnTurnStart.TryInvoke(message as TurnStartMessage);
                    break;

                case "turn.end":
                    m_Socket.Send(BingUtils.TurnEndAcknowledgement());
                    m_Buffer = new byte[0];
                    OnTurnEnd.TryInvoke(message as TurnEndMessage);

                    Status = BingStatus.Disconnecting;
                    m_Socket.CloseAsync(() => {
                        Connect();
                    });
                    break;

                case "speech.enddetected":
                    OnSpeechEndDetected.TryInvoke(message as SpeechEndDetectedMessage);
                    break;

                case "speech.phrase":
                    OnSpeechPhrase.TryInvoke(message as SpeechPhraseMessage);
                    break;

                case "speech.hypothesis":
                    OnSpeechHypothesis.TryInvoke(message as SpeechHypothesisMessage);
                    break;

                case "speech.startdetected":
                    OnSpeechStartDetected.TryInvoke(message as SpeechStartDetectedMessage);
                    break;

                case "speech.fragment":
                    OnSpeechFragment.TryInvoke(message as SpeechFragmentMessage);
                    break;
                }
            });
        }
示例#14
0
        /// <summary>
        /// A callback to progress the current state of the game.
        /// </summary>
        /// <param name="baseObject"></param>
        private void OnProgressTurnButtonLeftClicked(BaseObject baseObject)
        {
            // Change the state of the turn and call any appropriate functions
            switch (TurnState)
            {
            // We are currently in the placing cards state
            case TurnState.kPlaceCards:
            {
                // Change to the battle state
                TurnState = TurnState.kBattle;
                OnBattleStateStarted?.Invoke();

                break;
            }

            // We are currently in the battle state
            case TurnState.kBattle:
            {
                // Change to the place cards state and change the turns
                TurnState = TurnState.kPlaceCards;

                OnTurnEnd?.Invoke();

                NewPlayerTurn();

                OnCardPlacementStateStarted?.Invoke();

                break;
            }

            default:
            {
                Debug.Fail("");
                break;
            }
            }
        }
示例#15
0
        public void ExecuteTurn()
        {
            if (currentState == State.END)
            {
                return;
            }                                          // Don't do anything if battle is over

            if (currentState == State.START)
            {
                //Add effects of all Pokemon Abilities in battle
                foreach (Team team in Teams)
                {
                    foreach (Slot slot in team)
                    {
                        RegisterEffect(slot.Pokemon.Ability.newEffect(this, slot.Pokemon));
                    }
                }

                OnBattleStart?.Invoke(this, BattleArgs);

                currentState = State.IN_PROGRESS;
            }

            OnTurnStart?.Invoke(this, BattleArgs);

            /* First we enqueue BattleActionRequests for all battle slots that are still in play. The
             * purpose of this is to allow move effects to trigger based on the enqueue'ing of the
             * BattleActionRequests. This allows effects from moves like Taunt modify which battlers
             * we make BattleActionRequests for.
             */
            foreach (Team team in Teams)
            {
                foreach (Slot slot in team)
                {
                    if (slot.IsInPlay)
                    {
                        MessageQueue.Enqueue(new Request(slot));
                    }
                }
            }
            actionRequests.Clear();
            Flush();

            RequestInputEventArgs requestInputEventArgs = new RequestInputEventArgs(this, actionRequests);

            OnRequestInput?.Invoke(this, requestInputEventArgs);

            List <IAction> actions = new List <IAction>(InputProvider.ProvideActions(this, actionRequests));

            InputReceivedEventArgs inputReceivedEventArgs = new InputReceivedEventArgs(this, actionRequests, actions);

            OnInputReceived?.Invoke(this, inputReceivedEventArgs);

            actions.Sort(ActionComparer);

            foreach (IAction action in actions)
            {
                MessageQueue.Enqueue(action);
            }

            while (true)
            {
                Flush();

                List <Request> requests = new List <Request>();
                foreach (Team team in Teams)
                {
                    foreach (Slot slot in team)
                    {
                        if (slot.Pokemon.HasFainted() && !slot.Participant.HasLost())
                        {
                            requests.Add(new Request(slot));
                        }
                    }
                }
                if (requests.Count == 0)
                {
                    break;
                }
                IList <SwapPokemon> swapPokemonActions = InputProvider.ProvideSwapPokemon(this, requests);
                foreach (SwapPokemon swapPokemonAction in swapPokemonActions)
                {
                    MessageQueue.Enqueue(swapPokemonAction);
                }
            }

            CurrentWeather.DecrementTurnCounter();
            if (CurrentWeather.IsComplete)
            {
                WeatherCompletedEventArgs weatherCompletedEventArgs = new WeatherCompletedEventArgs(this, CurrentWeather);
                OnWeatherCompleted?.Invoke(this, weatherCompletedEventArgs);

                MessageQueue.AddFirst(new WeatherChange(SurroundingWeather, -1));
                Broadcast();
            }

            OnTurnEnd?.Invoke(this, BattleArgs);

            /*
             * Why is this loop run after OnTurnEnd is called?
             * We need to be able to process events that occur just before the end of the turn.
             */
            while (true)
            {
                Flush();

                List <Request> requests = new List <Request>();
                foreach (Team team in Teams)
                {
                    foreach (Slot slot in team)
                    {
                        if (slot.Pokemon.HasFainted() && !slot.Participant.HasLost())
                        {
                            requests.Add(new Request(slot));
                        }
                    }
                }
                if (requests.Count == 0)
                {
                    break;
                }
                IList <SwapPokemon> swapPokemonActions = InputProvider.ProvideSwapPokemon(this, requests);
                foreach (SwapPokemon swapPokemonAction in swapPokemonActions)
                {
                    MessageQueue.Enqueue(swapPokemonAction);
                }
            }

            if (this.IsComplete())
            {
                BattleEndEventArgs battleEndEventArgs = new BattleEndEventArgs(this, this.Winner());
                OnBattleEnd?.Invoke(this, battleEndEventArgs);

                currentState = State.END;
            }

            TurnCounter += 1;
        }
示例#16
0
 public void TurnEnd()
 {
     OnTurnEnd?.Invoke(this, EventArgs.Empty);
 }
示例#17
0
 private void HandleOnTurnEnd(Player player)
 {
     OnTurnEnd?.Invoke(player);
 }
示例#18
0
 public void AddEndOfTurnEffect(OnTurnEnd onTurnEndEffectFunction)
 {
     this.onTurnEnd        += onTurnEndEffectFunction;
     this.hasEndOTurnEffect = true;
     Debug.Log("End of turn effect added!");
 }
示例#19
0
 public void fireTurnEndEvent()
 {
     Utilities.instance.Debug("Turn ended.");
     OnTurnEnd?.Invoke();
 }
示例#20
0
 private void EndTurn()
 {
     OnTurnEnd?.Invoke();
 }
示例#21
0
 /// <summary>
 /// Ends the player's turn.
 /// </summary>
 public virtual void EndTurn()
 {
     _hasHadTurn = true;
     OnTurnEnd?.Invoke(this, new EventArgs());
 }
示例#22
0
    private IEnumerator FallingDown()
    {
        findMatchesStarted = true;
//        Debug.Log("@@@ Next Move search matches @@@");
        THIS.thrivingBlockDestroyed = false;
        combo = 0;
        AI.THIS.allowShowTip = false;
        var it = field.GetItems();

        for (var i = 0; i < it.Count; i++)
        {
            var item = it[i];
            if (item != null)
            {
                item.anim.StopPlayback();
            }
        }

        destLoopIterations = 0;
        while (true)
        {
            destLoopIterations++;
            checkMatchesAgain = false;

            var destroyItemsListed = field.GetItems().Where(i => i.destroyNext).ToList();
            if (destroyItemsListed.Count > 0)
            {
                yield return(new WaitWhileDestroyPipeline(destroyItemsListed, new Delays()));
            }
            yield return(new WaitWhileDestroying());

            yield return(new WaitWhile(() => StopFall));

            yield return(new WaitWhileFall());

            yield return(new WaitWhileCollect());

//            yield return new WaitWhileFallSide();
            var combineCount = CombineManager.GetCombines(field);
            if ((combineCount.Count <= 0 || !combineCount.SelectMany(i => i.items).Any()) && !field.DestroyingItemsExist() && !field.GetEmptySquares().Any() &&
                !checkMatchesAgain)
            {
                break;
            }

            if (destLoopIterations > 10)
            {
                foreach (var combine in combineCount)
                {
                    if (combine.items.Any())
                    {
                        combine.items.NextRandom().NextType = combine.nextType;
                    }
                }

                combineCount.SelectMany(i => i.items).ToList().ForEach(i => i.destroyNext = true);
            }
        }

        if (combo > 2 && gameStatus == GameState.Playing)
        {
            gratzWords[Random.Range(0, gratzWords.Length)].SetActive(true);
            combo = 0;
            OnCombo?.Invoke();
        }

        //CheckItemsPositions();
        DragBlocked        = false;
        findMatchesStarted = false;
        checkMatchesAgain  = false;
        if (gameStatus == GameState.Playing)
        {
            StartCoroutine(AI.THIS.CheckPossibleCombines());
        }

//        Debug.Log("<-next turn->");
        if (gameStatus == GameState.Playing && !FindObjectsOfType <AnimateItems>().Any())
        {
            OnTurnEnd?.Invoke();
            THIS.CheckWinLose();
        }
    }
示例#23
0
文件: Player.cs 项目: Clarksj4/Hexes
 /// <summary>
 /// Notifies this player that their turn has ended.
 /// </summary>
 public void TurnEnd()
 {
     IsCurrentActor = false;
     OnTurnEnd?.Invoke(this);
 }