Ejemplo n.º 1
0
        public void EnterCharacter(Character character, Sprite sprite, float xPosition, float fadeInTime = 0.5f, bool nextNode = false, bool waitForFinish = false, bool isInvert = false)
        {
            if (TryGetCharacter(character) != null)
            {
                Debug.LogWarning("CNovell: Не пытайтесь ввести два одинаковых символа.");

                SceneManager sceneManager = SceneManager.GetInstance();
                if (sceneManager != null && nextNode)
                {
                    sceneManager.NextNode();
                }
                return;
            }

            GameObject characterObject = Object.Instantiate(m_characterPrefab, m_backgroundPanel);

            if (isInvert)
            {
                m_characterTransformer.SetCharacterScale(characterObject, new Vector2(-1, 1));
            }

            SetSprite(characterObject, sprite);

            m_characterTransformer.SetCharacterPosition(characterObject, new Vector2(xPosition, 0));

            Components.CharacterInfo characterInfo = characterObject.GetComponent <Components.CharacterInfo>();
            characterInfo.SetCharacter(character);

            m_characters.Add(characterObject);


            m_characterComponent.StartCoroutine(FadeIn(characterObject, fadeInTime, nextNode, waitForFinish));
        }
Ejemplo n.º 2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="character"></param>
            /// <param name="sprite"></param>
            /// <param name="xPosition"></param>
            /// <param name="fadeInTime"></param>
            /// <param name="waitForFinish"></param>
            /// <param name="nextNode"></param>
            /// <param name="isInvert"></param>
            public void EnterCharacter(Character character, Sprite sprite, float xPosition,
                                       float fadeInTime = 0.5f, bool nextNode = false, bool waitForFinish = false, bool isInvert = false)
            {
                // check to see if the character already exists in the scene
                if (TryGetCharacter(character) != null)
                {
                    Debug.LogWarning("DEVN: Do not attempt to enter two of the same characters.");

                    SceneManager sceneManager = SceneManager.GetInstance();
                    if (sceneManager != null && nextNode)
                    {
                        sceneManager.NextNode();
                    }
                    return;
                }

                // create new character and parent it to canvas
                GameObject characterObject = Object.Instantiate(m_characterPrefab, m_backgroundPanel);

                // invert if necessary
                if (isInvert)
                {
                    m_characterTransformer.SetCharacterScale(characterObject, new Vector2(-1, 1));
                }

                // set sprite
                SetSprite(characterObject, sprite);

                // set position
                m_characterTransformer.SetCharacterPosition(characterObject, new Vector2(xPosition, 0));

                // set character info
                Components.CharacterInfo characterInfo = characterObject.GetComponent <Components.CharacterInfo>();
                characterInfo.SetCharacter(character);

                m_characters.Add(characterObject);

                // perform fade-in
                m_characterComponent.StartCoroutine(FadeIn(characterObject, fadeInTime, nextNode, waitForFinish));
            }