Пример #1
0
        /// <summary>
        /// Initializes the characters
        /// </summary>
        /// <param name="index">Index of character which should be initialized</param>
        private void InitCharacters(int index)
        {
            if (index == 0)
            {
                _characterList = new List <GameObject>(Datasheet.Heroes());
            }
            else
            {
                _characterList = new List <GameObject>(Datasheet.Mobs());
            }

            _totalCharacters = _characterList.Count;
            Debug.Log("[CharacterSelection.cs]: Number of heroes: " + _characterList.Count);
            _basicScales = new List <Vector3>(_totalCharacters);
            for (int i = 0; i < _totalCharacters; i++)
            {
                _basicScales.Add(new Vector3());
            }

            _currentCharacter = 0;
            float arc        = 2 * Mathf.PI / _totalCharacters;
            float currentArc = 0;

            _positions = new List <Vector3>(_totalCharacters);
            for (int i = 0; i < _totalCharacters; i++)
            {
                _positions.Add(new Vector3((-80) * Mathf.Sin(currentArc), 0, (-80) * Mathf.Cos(currentArc)));
                currentArc += arc;
            }

            for (int i = 0; i < _totalCharacters; i++)
            {
                _characterList[i] = (GameObject)Instantiate(_characterList[i]);
                _characterList[i].GetComponent <Character>().Type = Character.Types.CHARACTER_SELECTION;
                if (index == 0)
                {
                    _basicScales[i] = _characterList[i].transform.localScale / 1.6f;
                    _characterList[i].transform.position = _positions[i] + (new Vector3(0, 0, 0) * _basicScales[i].y);
                }
                else
                {
                    _basicScales[i] = _characterList[i].transform.localScale / 1.6f;
                    _characterList[i].transform.position = _positions[i] + (new Vector3(0, 0, 0) * _basicScales[i].y);
                }

                SetScaleToBackground(i);
            }

            SetScaleToForeground(_currentCharacter);
        }
Пример #2
0
        /// <summary>
        /// Sets the selected Character in GameManager and Loads the nextScene
        /// </summary>
        private void SetCharacter()
        {
            Character chosenCharacter;

            if (_toolbarSelectionNew == 0)
            {
                chosenCharacter             = Datasheet.Heroes()[_currentCharacter].GetComponent <Hero>();
                chosenCharacter.DisplayName = _characterList[_currentCharacter].GetComponent <Hero>().DisplayName;
                chosenCharacter.Type        = Character.Types.HUMAN;
                Debug.Log("Chosen character: " + chosenCharacter.Type);
                Hero animator = _characterList[_currentCharacter].GetComponent <Hero>();
                if (animator.animation != null)
                {
                    List <string> specialAttackNames = animator.SpecialAttacks();
                    if (specialAttackNames.Count > 0)
                    {
                        string animationName = specialAttackNames[Random.Range(0, specialAttackNames.Count)];
                        animator.animation.Play(animationName);
                        StartCoroutine(Wait(animator.animation[animationName].length / animator.animation[animationName].speed, chosenCharacter));
                        return;
                    }
                }
            }
            else
            {
                chosenCharacter      = Datasheet.Mobs()[_currentCharacter].GetComponent <Mob>();
                chosenCharacter.Type = Character.Types.HUMAN;

                Mob animator = _characterList[_currentCharacter].GetComponent <Mob>();
                if (animator.animation != null)
                {
                    animator.animation.Play("Attacking");
                    StartCoroutine(Wait(animator.animation["Attacking"].length / animator.animation["Attacking"].speed, chosenCharacter));
                    return;
                }
            }

            // If we reach this, then there wasn't an animation to play. Bummer.
            // Continue and add this character without playing an animation.
            AddCharacter(chosenCharacter);
        }