private byte OnCharacterSelectTask()
        {
            LastTask        = Tasks.CharacterSelect;
            CharacterSelect = (Task <CharacterSelect, CharacterSelectTaskState> *) * State.CurrentTask;
            OnCharacterSelect?.Invoke(CharacterSelect);
            var result = _onCharaSelectHook.OriginalFunction();

            AfterCharacterSelect?.Invoke(CharacterSelect);
            return(result);
        }
Exemple #2
0
    /// <summary>
    /// Tries to select a character at the grid location the user just clicked on. If successful, show that characters move/attack ranges
    /// </summary>
    /// <param name="selNode">The node that was just selected</param>
    private void AttemptSelect(Node selNode)
    {
        // Try to get the MoveAttack script off the character
        _charSelected = _mAContRef.GetCharacterMAByNode(selNode);
        // Make sure the MoveAttack script is valid and that the character is active in the hierarchy
        if (_charSelected != null && _charSelected.gameObject.activeInHierarchy)
        {
            // Set the recent selected character
            _recentCharSel = _charSelected;
            // If it hasn't moved this turn yet or hasn't attacked this turn
            if (!(_charSelected.HasMoved && _charSelected.HasAttacked))
            {
                //Debug.Log("Select character");
                // Calculate its valid tiles
                _charSelected.CalculateAllTiles();
                // Set the visuals of it to be on
                _mAContRef.SetActiveVisuals(_charSelected);
            }

            // Call the character selected event
            OnCharacterSelect?.Invoke(_charSelected);
        }
    }
Exemple #3
0
        protected bool TryFinishChangeState(State target, params object[] args)
        {
            switch (target)
            {
            case State.Menu:
                _state = target;
                return(true);

            case State.CharacterSelection:
                OnCharacterSelectHandler?.Invoke(true);
                _state = target;
                return(true);

            case State.Begin:
                _podium.Clear();

                foreach (var c in _controllers)
                {
                    if (c == null)
                    {
                        continue;
                    }

                    _podium.Add(c, c._characterResource);
                }

                _podium.gameObject.SetActive(false);

                OnLevelSelectHandler.Invoke(false);

                foreach (World.Level level in _levels)
                {
                    if (level == null)
                    {
                        continue;
                    }

                    if (level == _selectedLevel)
                    {
                        continue;
                    }

                    level.gameObject.SetActive(false);
                }


                _selectedLevel.gameObject.SetActive(false);

                _state = target;
                return(TryChangeState(State.Round, _roundTime));


            case State.Transition:

                _transition = (State)args[0];
                _transitionTimer.Start();

                _transitionEffect.Perform();

                _state = target;
                return(true);


            case State.Podium:
                _podium.gameObject.SetActive(true);
                OnPodiumHandler?.Invoke();
                _state = target;
                return(true);

            case State.FinalPodium:
                _podium.gameObject.SetActive(true);
                OnFinalPodiumHandler?.Invoke();
                _state = target;
                return(true);

            case State.LevelSelection:

                _state = target;

                foreach (World.Level lv in _levels)
                {
                    lv.gameObject.SetActive(true);
                    lv.OnLevelSelect();
                }

                OnLevelSelect();
                OnLevelSelected(0);

                return(true);

            case State.Round:

                // TODO enable

                _selectedLevel.TargetPosition     = Vector3.zero;
                _selectedLevel.transform.position = Vector3.zero;

                _selectedLevel.gameObject.SetActive(true);

                _currentLevel =
                    Instantiate(
                        _selectedLevel.gameObject,
                        Vector3.zero, Quaternion.identity,
                        gameObject.transform).GetComponent <World.Level>();

                _selectedLevel.gameObject.SetActive(false);


                _currentLevel.OnScoreValueAddedHandler += OnScoreValueAdded;

                _currentLevel.OnLevelCompletedHandler += OnLevelCompleted;

                List <Placeholder> placeholders = new List <Placeholder>();
                placeholders.AddRange(_currentLevel._characterPlaceholders);

                int i = 0;
                while (!placeholders.IsEmpty())
                {
                    Placeholder placeholder = placeholders.RemoveRandom();

                    _controllers[i]._character = _controllers[i]
                                                 ._characterResource.Create(
                        _currentLevel.GridToWorld(placeholder._gridPosition),
                        _currentLevel.transform);

                    _controllers[i]._character.Number = _controllers[i].Number;

                    _controllers[i]._character.Color = _controllers[i].Color;

                    _controllers[i]._character._level = _currentLevel;

                    _controllers[i]._character.TryChangeState(Character.State.Disabled);

                    _controllers[i].Score = 0;

                    _controllers[i]._assignedNumber = placeholder.Number;

                    i++;

                    Destroy(placeholder.gameObject);
                }

                _round =
                    new Round(
                        _countDown,
                        _roundTime,
                        _countDownTime,
                        _intermissionTime,
                        _roundIndex);

                StartCoroutine(NewRoundCoroutine());

                _state = target;

                return(true);

            case State.Score:

                _state = target;

                return(true);

            case State.WaitingNextRound:
                //Lobby.Characters.Clear();
                //Lobby.Characters.AddRange(_selectedLevel.Characters);

                foreach (Controller ctrl in Lobby.Controllers)
                {
                    if (ctrl == null)
                    {
                        continue;
                    }

                    //ctrl.Character = null;
                }

                _state = target;

                OnWaiting();
                return(true);


            default:
                return(false);
            }
        }