Inheritance: MonoBehaviour
Esempio n. 1
0
    /// <summary>
    /// Kills the component with sound and effects.
    /// </summary>
    public void Die()
    {
        if (data.deathAnim != null)
        {
            var       deathAnim = ObjectPool.Instance.Spawn(ObjectPool.Types.explosion, transform.position);
            Explosion exp       = deathAnim.GetComponent <Explosion>();

            exp.data = data.deathAnim;
            exp.Initialize();
        }

        if (data.deathText != null)
        {
            GameManager.Instance.Money += data.killReward;

            var        flyingText = ObjectPool.Instance.Spawn(ObjectPool.Types.flyingText, transform.position);
            FlyingText text       = flyingText.GetComponent <FlyingText>();

            text.data = data.deathText;
            text.Initialize(data.killReward);
        }

        if (data.dropHealth)
        {
            if (Random.Range(0, 100f) < data.dropChance)
            {
                ObjectPool.Instance.Spawn(ObjectPool.Types.healthDrop, transform.position);
            }
        }

        AudioManager.Instance.PlaySound(data.deathAudio);
        OnDeath?.Invoke(gameObject);

        Destroy(gameObject);
    }
Esempio n. 2
0
    void Update()
    {
        if (!acceptInput)
        {
            return;
        }

        foreach (var c in Input.inputString)
        {
            if (c == '\b')
            {
                if (enteredText.Length > 0)
                {
                    enteredText = enteredText.Substring(0, enteredText.Length - 1);
                }
            }
            else if (c == '\n' || c == '\r')
            {
                if (enteredText.Length > 0)
                {
                    StartCoroutine(ExplodeText());
                }
            }
            else if (c == '<' || c == '>')
            {
                // do nothing
            }
            else
            {
                enteredText += c;
            }
            FlyingText.UpdateObject(textObject, enteredText + cursorChar);
        }
    }
Esempio n. 3
0
    public static void Create(string msg, Color c, Vector2 pos, Transform parent)
    {
        FlyingText ft = Instantiate(Resources.Load <GameObject>("FlyingText"), parent).GetComponent <FlyingText>().Init(msg, c);

        (ft.transform as RectTransform).anchoredPosition = pos;
        ft.canvasPoint = pos;
    }
Esempio n. 4
0
    public static void CreateFromCharacters(string text, MonoBehaviour m, float delay)
    {
        Vector3 v = m.transform.position;

        v += new Vector3(0, 1f, 0);
        FlyingText.CreateFromCharacters(text, v, delay);
    }
Esempio n. 5
0
    protected virtual void Score(int s, Vector2?pos = null, bool flashBottom = true, int sndIdx = 0)
    {
        int    _score;
        string _text;
        Color  _color;

        switch (s)
        {
        default:
            _score = badScore;
            _text  = "Miss";
            _color = Color.grey;
            ++Scoring.missCount;
            break;

        case 1:
            _score = goodScore;
            _text  = "Good";
            _color = Color.red;    //green
            ++Scoring.goodCount;
            break;

        case 2:
            _score = perfectScore;
            _text  = "Perfect";
            _color = Color.yellow;
            ++Scoring.perfectCount;
            break;
        }
        RhythmGameManager.UpdateScore(_score);
        lastScorePos = pos == null?GetExit().center : pos.Value;

        if (coloringParts.Length > 0 && !noAnim && s >= 1)
        {
            BlockEnlarge.Create(noteImages[sndIdx], _color, lastScorePos.Value, lastScorePos.Value + new Vector2(panel == PanelType.Left ? BlockSize.x : -BlockSize.x, BlockSize.y), rt.parent);
        }

        if (s >= 1)
        {
            if (sound.Length > 0 && allScores.Count == 0 && s == 1)
            {
                sound[0].Play(1);                                                     // 按到good时声效不会按时播放
            }
            if (flashBottom && coloringParts.Length > 0)
            {
                Bottom.SetColor(panel, coloringParts[0].color * 0.75f);                                          // 底边变色
            }
        }
        else
        {
            if (sound.Length > 0 && allScores.Count == 0)
            {
                sound[0].Play(0);                                           // 按到miss时声效不会按时播放
            }
            FlyingText.Create(_text, _color, lastScorePos.Value, rt.parent);
        }
        allScores.Add(new ScoreRecord(Time.time - createTime, s));
        OnScored?.Invoke(s);
    }
Esempio n. 6
0
    public static void Spawn <T>(T text, Color color, Vector3 position)
    {
        GameObject flyingTextObject = Instantiate(instance.flyingTextPrefab, position, Quaternion.identity);
        FlyingText flyingText       = flyingTextObject.GetComponent <FlyingText>();

        flyingText.SetText(text);
        flyingText.SetColor(color);
    }
Esempio n. 7
0
 void InitializeText()
 {
     FlyingText.addRigidbodies = false;
     enteredText = "";
     acceptInput = true;
     textObject  = FlyingText.GetObject("-", new Vector3(-7, 6, 0), Quaternion.identity);
     InvokeRepeating("BlinkCursor", .5f, .5f);
 }
        void recognizer_SaidSomething(object sender, SpeechRecognizer.SaidSomethingEventArgs e)
        {
            FlyingText.NewFlyingText(mWindow.theGraphPlot.Graph_Rect.Width / 100,
                                     new Point(mWindow.theGraphPlot.Graph_Rect.Width / 2, mWindow.theGraphPlot.Graph_Rect.Height / 2), e.Matched);
            switch (e.Verb)
            {
            case SpeechRecognizer.Verbs.Start:
                mWindow.ControlPan.StartButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.Stop:
                mWindow.ControlPan.StopButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.Reset:
                mWindow.ControlPan.ResetButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.Pause:
                mWindow.Voice_Button.Background = Brushes.Red;
                mWindow.Voice_Button.Header     = "Voice Paused";
                break;

            case SpeechRecognizer.Verbs.Resume:
                mWindow.Voice_Button.Background = Brushes.Green;
                mWindow.Voice_Button.Header     = "Voice Running";
                break;

            case SpeechRecognizer.Verbs.AddLine:
                mWindow.ControlPan.AddLine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.AddSineCurve:
                mWindow.ControlPan.AddSine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.AddParabola:
                mWindow.ControlPan.AddParabola.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.EditingMode:
                mWindow.IndicatorPan.EditingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.MatchingMode:
                mWindow.IndicatorPan.MatchingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.TrackingMode:
                mWindow.IndicatorPan.TrackingButton.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;

            case SpeechRecognizer.Verbs.NewRandomLine:
                mWindow.ControlPan.AddLine.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
                break;
            }
        }
Esempio n. 9
0
 void BlinkCursor()
 {
     if (cursorChar == '-')
     {
         cursorChar = ' ';
     }
     else
     {
         cursorChar = '-';
     }
     FlyingText.UpdateObject(textObject, enteredText + cursorChar);
 }
Esempio n. 10
0
    // Use this for initialization
    private void Start()
    {
        GameObject textObject = FlyingText.GetObject("<color=blue>shopping city YETI");



        textObject.transform.parent   = this.transform;
        textObject.transform.rotation = this.transform.rotation;
        textObject.transform.position = this.transform.position;

        this.renderer.enabled = false;
    }
Esempio n. 11
0
    // Use this for initialization
    private void Start()
    {
        GameObject textObject = FlyingText.GetObject("<color=blue>P<color=red>e<color=yellow>t<color=blue>a<color=green>r  <color=blue>P<color=red>a<color=yellow>n");
        GameObject textSchool = FlyingText.GetObject("<color=blue>S<color=red>c<color=yellow>h<color=blue>o<color=green>o<color=blue>l");



        textObject.transform.parent   = this.transform;
        textObject.transform.position = this.transform.position;
        textObject.transform.rotation = this.transform.rotation;
        textSchool.transform.parent   = this.transform;
        //textSchool.transform.transform.Rotate(Vector3.right, 180);
        textSchool.transform.position = this.transform.position + new Vector3(0, -1.5f, 0);
        textSchool.transform.rotation = this.transform.rotation;
        this.renderer.enabled         = false;
    }
 public static void Draw(UIElementCollection children)
 {
     for (int i = 0; i < FlyingTexts.Count; i++)
     {
         FlyingText flyout = FlyingTexts[i];
         if (flyout.alpha <= 0)
         {
             FlyingTexts.Remove(flyout);
             i--;
         }
     }
     foreach (var flyout in FlyingTexts)
     {
         flyout.Advance();
         children.Add(flyout.label);
     }
 }
Esempio n. 13
0
    private void DebugText(string str1)
    {
        KotodamaPos(str1);
        textObject      = FlyingText.GetObjects(str1, PlayerPos, Quaternion.identity);//FlyingTextを生成
        textObject.name = str1;
        Rigidbody rigidbody = textObject.AddComponent <Rigidbody>();

        Rigidbody[] rigidbodies = textObject.GetComponentsInChildren <Rigidbody>();
        textObject.transform.Rotate(CameraAngleX, CameraAngleY + angle, 0);//PlayerControllerのY.rotateを参照
        foreach (var TextChild in rigidbodies)
        {
            TextChild.useGravity = false;
            TextChild.AddForce(textObject.transform.forward * bulletSpeed, ForceMode.Impulse);
            TextChild.tag = "flyingText";
        }
        //textObject.tag = "flyingText";
        Destroy(textObject, 10.0f);
    }
Esempio n. 14
0
        public IEnumerator CreateTextObjects(string text)
        {
            FlyingText.addRigidbodies = true;
            var textObjects = FlyingText.GetObjectsArray(text);

            foreach (var textObject in textObjects)
            {
                textObject.GetComponent <Renderer>().enabled     = false;
                textObject.GetComponent <Rigidbody>().useGravity = false;
            }

            foreach (var textObject in textObjects)
            {
                yield return(new WaitForSeconds(appearanceInterval));

                textObject.AddComponent <TextObjectController>().Initialize();
            }
        }
Esempio n. 15
0
    // Start is called before the first frame update
    void Start()
    {
        animator = GetComponent <Animator>();


        kotodamaScript = PlayerObject.GetComponent <KotodamariScript>();
        FlyingText flyingtext = PlayerObject.GetComponent <FlyingText>();

        EnemyPos    = Bossenemy.transform.position;//プレイヤーの位置を取得
        EnemyPos.x += KotodamaPosX;
        EnemyPos.y += KotodamaPosY;
        EnemyPos.z += KotodamaPosZ;
        for (int i = 1; i < inputText.Length; i++)
        {
            EnemyPos.z -= KotodamaPosZ;
            EnemyPos.z -= KotodamaPosZ;
        }
        elapsedTime = 0f;
    }
Esempio n. 16
0
    public static void CreateFromCharacters(string text, Vector3 position, float duration, float delay)
    {
        float      letterWidth = 12;
        float      letterDelay = .025f;
        GameObject g           = new GameObject("Flying Text");

        g.transform.position = position;
        for (int i = 0; i < text.Length; i++)
        {
            FlyingText f            = g.AddComponent <FlyingText>();
            float      linePosition = i * letterWidth;
            linePosition -= (text.Length * letterWidth / 2f);
            linePosition -= letterWidth / 2f;
            f.Offset      = new Vector2(linePosition, 30);
            f.Delay       = delay + (i * letterDelay);
            f.Duration    = duration - (i * letterDelay);
            f.Text        = text.Substring(i, 1);
        }
    }
Esempio n. 17
0
    IEnumerator Start()
    {
        RenderSettings.fog            = true;
        RenderSettings.fogColor       = Camera.main.backgroundColor;
        RenderSettings.fogMode        = FogMode.Linear;
        RenderSettings.fogEndDistance = 20.0f;

        while (true)
        {
            var gameOverText = FlyingText.GetObjects("GAME<br>OVER").transform;
            var pos          = gameOverText.position;
            pos.z = -6.5f;
            gameOverText.position = pos;
            var rigidbodies = gameOverText.GetComponentsInChildren <Rigidbody>();
            foreach (var rb in rigidbodies)
            {
                rb.useGravity = false;
            }

            for (float i = 0.0f; i < 1.0f; i += Time.deltaTime)
            {
                pos   = gameOverText.position;
                pos.y = Mathf.Lerp(5.0f, -.05f, i);
                gameOverText.position = pos;
                yield return(null);
            }
            StartCoroutine(CameraShake(Camera.main));

            yield return(new WaitForSeconds(1.75f));

            Instantiate(explosion, new Vector3(0.0f, 1.0f, -6.3f), Quaternion.identity);
            foreach (var rb in rigidbodies)
            {
                rb.useGravity = true;
                rb.AddExplosionForce(220.0f, new Vector3(0, 1, -6.5f), 10.0f, 9.0f);
            }

            yield return(new WaitForSeconds(5.0f));

            Destroy(gameOverText.gameObject);
            yield return(new WaitForSeconds(1.0f));
        }
    }
Esempio n. 18
0
    void Start()
    {
        for (int i = 0; i < itemText.Length; i++)
        {
            // Create 3D text object
            var menuObject = FlyingText.GetObject(itemText[i]);
            menuObject.transform.position = itemPositions[i];

            // Create collider (we don't use a collider for the 3D text object because we don't want the collider to rotate)
            var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.localScale = new Vector3(7, 1.8f, .1f);
            cube.transform.position   = itemPositions[i];
            cube.GetComponent <Renderer>().enabled = false;

            // Add the menu object script to the collider and assign values to the variables
            var menuScript = cube.AddComponent <MenuObject>();
            menuScript.highlight   = highlight;
            menuScript.rotateSpeed = rotateSpeed;
            menuScript.menuObject  = menuObject.transform;
        }
    }
Esempio n. 19
0
    public void BossKotodama2(string str1, Vector3 pos1, float bulletnum, float Angle)
    {
        //enemytext = FlyingText.GetObjects(str1, pos1, Quaternion.identity);//FlyingTextを生成
        enemytext      = FlyingText.GetObjects(str1, redMaterial, null, 10.0f, 2.0f, 5, pos1, Quaternion.identity);//FlyingTextを生成
        enemytext.name = "EnemyText";
        Rigidbody rigidbody = enemytext.AddComponent <Rigidbody>();

        Rigidbody[] rigidbodies = enemytext.GetComponentsInChildren <Rigidbody>();
        enemytext.transform.Rotate(-12, Angle, 0);//PlayerControllerのY.rotateを参照
        foreach (var TextChild in rigidbodies)
        {
            TextChild.useGravity = false;
            TextChild.AddForce(enemytext.transform.forward * bulletnum, ForceMode.Impulse);
            TextChild.tag = "EnemyText";

            //TextChild.gameObject.AddComponent<EnemyflyingText>();
        }
        enemytext.tag = "EnemyText";
        //enemytext.AddComponent<EnemyflyingText>();
        Destroy(enemytext, 10.0f);
    }
Esempio n. 20
0
    IEnumerator ExplodeText()
    {
        acceptInput = false;
        CancelInvoke("BlinkCursor");
        Destroy(textObject);
        FlyingText.addRigidbodies = true;
        var letters = FlyingText.GetObjectsArray(enteredText, new Vector3(-7, 6, 0), Quaternion.identity);

        foreach (var letter in letters)
        {
            letter.GetComponent <Rigidbody>().useGravity = false;
            letter.GetComponent <Rigidbody>().AddTorque(new Vector3(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)) * 10.0f);
            letter.GetComponent <Rigidbody>().AddExplosionForce(390.0f, new Vector3(0, 1, 11), 15.0f);
        }

        yield return(new WaitForSeconds(5));

        foreach (var letter in letters)
        {
            Destroy(letter);
        }
        InitializeText();
    }
Esempio n. 21
0
 public override void Play()
 {
     base.Play();
     FlyingText.CreateFromCharacters(Text, Target, 0);
 }
Esempio n. 22
0
    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            if (dictationRecognizer.Status != SpeechSystemStatus.Running)
            {
                //ディクテーションを開始
                dictationRecognizer.Start();
                //Debug.Log("音声認識開始");

                animVoiceInput.SetBool("MouseHold", true);
            }
        }
        if (dictationRecognizer.Status == SpeechSystemStatus.Running)
        {
            dictationRecognizer.DictationResult += DictationRecognizer_DictationResult;         //DictationRecognizer_DictationResult処理を行う

            dictationRecognizer.DictationHypothesis += DictationRecognizer_DictationHypothesis; //DictationRecognizer_DictationHypothesis処理を行う

            dictationRecognizer.DictationComplete += DictationRecognizer_DictationComplete;     //DictationRecognizer_DictationComplete処理を行う

            dictationRecognizer.DictationError += DictationRecognizer_DictationError;           //DictationRecognizer_DictationError処理を行う

            if (inputText != testText)
            {
                KotodamaPos(inputText);

                textObject      = FlyingText.GetObjects(inputText, CameraPos, Quaternion.identity); //FlyingTextを生成
                textObject.name = inputText;
                textObject.transform.Rotate(CameraAngleX, CameraAngleY + angle, 0);                 //PlayerControllerのY.rotateを参照
                Rigidbody   rigidbody   = textObject.AddComponent <Rigidbody>();
                Rigidbody[] rigidbodies = textObject.GetComponentsInChildren <Rigidbody>();

                foreach (var TextChild in rigidbodies)
                {
                    TextChild.useGravity = false;
                    TextChild.AddForce(textObject.transform.forward * bulletSpeed, ForceMode.Impulse);
                    TextChild.tag = "flyingText";
                }
                Destroy(textObject, 10.0f);

                inputText = testText;
                CriAtomSource atomSrc = gameObject.GetComponent <CriAtomSource>();
                if (atomSrc != null)
                {
                    atomSrc.Play(9);
                }

                /* if (inputText == "スタート" || inputText == "すたーと")
                 * {
                 *
                 *   fade.isFadeOut = true;
                 *   Invoke(nameof(FadeWait), 5.0f);
                 *   Debug.Log("ゲームスタート");
                 * }*/
            }
            inputText = testText;
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (dictationRecognizer.Status != SpeechSystemStatus.Stopped)
            {
                // Debug.Log("音声認識終了");
                dictationRecognizer.Stop();
                animVoiceInput.SetBool("MouseHold", false);
            }
        }

        // イベントにイベントハンドラーを追加
        SceneManager.sceneLoaded += SceneLoaded;
    }
 void OnEnable()
 {
     t = target as FlyingText;
 }
    public override void OnInspectorGUI()
    {
#if UNITY_3_5
        EditorGUIUtility.LookLikeControls(90);
#else
        EditorGUIUtility.labelWidth = 90;
#endif
        showFonts = EditorGUILayout.Foldout(showFonts, "Font settings");
        if (showFonts)
        {
            var hasChanged = false;
            GUILayout.BeginVertical("Box");
            if (GUILayout.Button("+ Add Font"))
            {
                if (t.m_fontData == null)
                {
                    t.m_fontData = new List <FontData>();
                }
                t.m_fontData.Add(new FontData());
                EditorUtility.SetDirty(t);
            }
            if (t.m_fontData != null)
            {
                if (t.m_fontData.Count == 0)
                {
                    EditorGUILayout.HelpBox("You need to add at least one font in order for FlyingText3D to work. Note that TTF fonts must be renamed to end with \"bytes\". You can use the convert .ttf to .bytes utility below to do this.", MessageType.Warning);
                }
                for (int i = 0; i < t.m_fontData.Count; i++)
                {
                    GUILayout.BeginVertical("Box");
                    EditorGUILayout.LabelField("Name in font:", t.m_fontData[i].fontName);
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical();
                    t.m_fontData[i].ttfFile = EditorGUILayout.ObjectField("Font #" + i, t.m_fontData[i].ttfFile, typeof(TextAsset), false) as TextAsset;
                    if (!hasChanged && GUI.changed)
                    {
                        if (t.m_fontData[i].ttfFile != null)
                        {
                            t.m_fontData[i].fontName = TTFFontInfo.GetFontName(t.m_fontData[i].ttfFile.bytes);
                        }
                        hasChanged = true;
                    }
                    GUILayout.EndVertical();
                    if (GUILayout.Button("X", GUILayout.Width(22), GUILayout.Height(16)))
                    {
                        t.m_fontData.RemoveAt(i);
                        EditorUtility.SetDirty(target);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
            }
            GUILayout.EndVertical();
        }
#if UNITY_3_5
        EditorGUIUtility.LookLikeControls(125);
#else
        EditorGUIUtility.labelWidth = 125;
#endif
        showCharacterSettings = EditorGUILayout.Foldout(showCharacterSettings, "Character settings");
        if (showCharacterSettings)
        {
            GUILayout.BeginVertical("Box");
            GUILayout.BeginHorizontal();
            t.m_defaultFont = EditorGUILayout.IntField("Default Font", t.m_defaultFont, GUILayout.Width(148));
            if (t.m_fontData != null && t.m_fontData.Count != 0)
            {
                t.m_defaultFont = Mathf.Clamp(t.m_defaultFont, 0, t.m_fontData.Count - 1);
                GUILayout.Label("(" + t.m_fontData[t.m_defaultFont].fontName + ")");
            }
            else
            {
                t.m_defaultFont = 0;
            }
            GUILayout.EndHorizontal();
            t.m_defaultMaterial     = EditorGUILayout.ObjectField("Default Material", t.m_defaultMaterial, typeof(Material), false) as Material;
            t.m_defaultEdgeMaterial = EditorGUILayout.ObjectField("Default Edge Material", t.m_defaultEdgeMaterial, typeof(Material), false) as Material;
            t.m_useEdgeMaterial     = EditorGUILayout.Toggle("Use Edge Material", t.m_useEdgeMaterial);
            t.m_defaultColor        = EditorGUILayout.ColorField("Default Color", t.m_defaultColor);
            t.m_computeTangents     = EditorGUILayout.Toggle("Compute Tangents", t.m_computeTangents);
            t.m_texturePerLetter    = EditorGUILayout.Toggle("Texture Per Letter", t.m_texturePerLetter);
            t.m_includeBackface     = EditorGUILayout.Toggle("Include Backface", t.m_includeBackface);
            t.m_defaultResolution   = EditorGUILayout.IntField("Default Resolution", t.m_defaultResolution);
            if (t.m_defaultResolution < 1)
            {
                t.m_defaultResolution = 1;
            }
            t.m_defaultSize = EditorGUILayout.FloatField("Default Size", t.m_defaultSize);
            if (t.m_defaultSize < .001f)
            {
                t.m_defaultSize = .001f;
            }
            t.m_defaultDepth = EditorGUILayout.FloatField("Default Depth", t.m_defaultDepth);
            if (t.m_defaultDepth < 0.0f)
            {
                t.m_defaultDepth = 0.0f;
            }
            t.m_smoothingAngle = EditorGUILayout.Slider("Smoothing Angle", t.m_smoothingAngle, 0.0f, 180.0f);
            GUILayout.EndVertical();
        }
        showTextSettings = EditorGUILayout.Foldout(showTextSettings, "Text settings");
        if (showTextSettings)
        {
            GUILayout.BeginVertical("Box");
            t.m_defaultLetterSpacing = EditorGUILayout.FloatField("Default Letter Spacing", t.m_defaultLetterSpacing);
            t.m_defaultLineSpacing   = EditorGUILayout.FloatField("Default Line Spacing", t.m_defaultLineSpacing);
            t.m_defaultLineWidth     = EditorGUILayout.FloatField("Default Line Width", t.m_defaultLineWidth);
            t.m_wordWrap             = EditorGUILayout.Toggle("Word Wrap", t.m_wordWrap);
            t.m_tabStop = EditorGUILayout.FloatField("Tab Stop", t.m_tabStop);
            if (t.m_tabStop < 0.0f)
            {
                t.m_tabStop = 0.0f;
            }
            t.m_defaultJustification = (Justify)EditorGUILayout.EnumPopup("Default Justification", t.m_defaultJustification);
            t.m_verticalLayout       = EditorGUILayout.Toggle("Vertical Layout", t.m_verticalLayout);
            GUILayout.EndVertical();
        }

        showGOsettings = EditorGUILayout.Foldout(showGOsettings, "GameObject settings");
        if (showGOsettings)
        {
            GUILayout.BeginVertical("Box");
            t.m_anchor          = (TextAnchor)EditorGUILayout.EnumPopup("Text Anchor", t.m_anchor);
            t.m_zAnchor         = (ZAnchor)EditorGUILayout.EnumPopup("Z Anchor", t.m_zAnchor);
            t.m_colliderType    = (ColliderType)EditorGUILayout.EnumPopup("Collider Type", t.m_colliderType);
            t.m_addRigidbodies  = EditorGUILayout.Toggle("Add rigidbodies", t.m_addRigidbodies);
            t.m_physicsMaterial = EditorGUILayout.ObjectField("Physics Material", t.m_physicsMaterial, typeof(PhysicMaterial), false) as PhysicMaterial;
            GUILayout.EndVertical();
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
            initialized = false;
        }

        GUILayout.Space(8);
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(2));
        GUILayout.Space(3);

#if UNITY_3_5
        EditorGUIUtility.LookLikeControls(50);
#else
        EditorGUIUtility.labelWidth = 50;
#endif
        GUILayout.Label("Create FlyingText3D object utility", EditorStyles.boldLabel);
        text     = EditorGUILayout.TextField("Text: ", text);
        position = EditorGUILayout.Vector3Field("Location: ", position);
        if (text == "" || !(t.m_fontData != null && t.m_fontData.Count != 0))
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Create"))
        {
            if (!initialized)
            {
                FlyingText.instance.Initialize();
                initialized = true;
            }
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
            Undo.RegisterSceneUndo("Create 3D Text Object");
            var textObject = FlyingText.GetObject(text);
#else
            var textObject = FlyingText.GetObject(text);
            Undo.RegisterCreatedObjectUndo(textObject, "Create 3D Text Object");
#endif
            textObject.transform.position = position;
            var mesh = textObject.GetComponent <MeshFilter>().sharedMesh;
            if (!System.IO.Directory.Exists(Application.dataPath + "/3DTextMeshes"))
            {
                AssetDatabase.CreateFolder("Assets", "3DTextMeshes");
            }
            AssetDatabase.CreateAsset(mesh, AssetDatabase.GenerateUniqueAssetPath("Assets/3DTextMeshes/" + mesh.name + ".asset"));
        }

        GUI.enabled = true;
        GUILayout.Space(8);
        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(2));
        GUILayout.Space(3);

#if UNITY_3_5
        EditorGUIUtility.LookLikeControls(50);
#else
        EditorGUIUtility.labelWidth = 50;
#endif

        GUILayout.Label("Convert .ttf to .bytes utility", EditorStyles.boldLabel);
        ttfFile = EditorGUILayout.ObjectField("TTF File:", ttfFile, typeof(Font), false) as Font;
        if (ttfFile == null)
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Convert"))
        {
            if (!System.IO.Directory.Exists(Application.dataPath + "/ConvertedFonts"))
            {
                AssetDatabase.CreateFolder("Assets", "ConvertedFonts");
            }
            var file = AssetDatabase.GetAssetPath(ttfFile);
            if (file.ToLower().EndsWith(".ttf"))
            {
                var bytes = System.IO.File.ReadAllBytes(file);
                var idx   = file.LastIndexOf("/");
                file = file.Substring(idx + 1, file.Length - idx - 1);
                var name = Application.dataPath + "/ConvertedFonts/" + file.Substring(0, file.Length - 4) + ".bytes";
                System.IO.File.WriteAllBytes(name, bytes);
                AssetDatabase.Refresh();
            }
        }
    }
Esempio n. 25
0
    public void ProcessAction(ActionResult result, Vector2 pos)
    {
        FlyingText rft  = FlyingText.Spawn(pos);
        var        text = result.successGrade.ToString() + "!";

        if (texts.ContainsKey(result.successGrade))
        {
            text = texts[result.successGrade];
        }
        rft.SetText(text);

        var delay = 0.15f;

        if (result.points > 0)
        {
            FlyingText pft = FlyingText.Spawn(pos);
            pft.Delay(delay);
            delay += 0.15f;
            pft.SetText("+" + result.points);
        }

        if (result.successGrade < ActionSuccessGrade.Good)
        {
            comboCounter = 0;
            comboImage.gameObject.SetActive(false);
            comboCounterItem.GetComponent <Animation>().enabled = false;
        }
        else
        {
            comboCounter++;
        }
        comboCounterItem.SetProgress(comboCounter / 3.0f);

        if (comboCounter >= 3)
        {
            comboImage.gameObject.SetActive(true);
            comboCounterItem.GetComponent <Animation>().enabled = true;
            result.points = (int)(result.points * 2f) + (comboCounter - 3) * 20;
            FlyingText ft = FlyingText.Spawn(pos, delay);
            if (comboCounter > 3)
            {
                ft.SetText("COMBO x" + (comboCounter - 2) + "!!");
            }
            else
            {
                ft.SetText("COMBO!");
            }
        }

        var infos = GameObject.FindObjectsOfType <GamePlayer>();

        foreach (var i in infos)
        {
            i.ChangeScore(result.points);
        }
//        if (GamePlayer.Instance != null)
//        {
//             GamePlayer.Instance.DeltaPoints(result.points);
//        }
//
        if (result.successGrade != ActionSuccessGrade.Fail)
        {
            _animations.MySuccessAnimation();
        }
    }
Esempio n. 26
0
    private IEnumerator Create()
    {
        Vector3 position   = Vector3.zero;
        int     r          = 0;
        float   speed      = 0.0f;
        float   time       = 0.0f;
        int     listNumber = wordData.Count;

        while (true)
        {
            position = new Vector3(7.4f, 0.0f, 0.0f);

            // position
            r = random.Next(0, 2);

            switch (r)
            {
            case 0:
                position.y = -3.0f;
                break;

            case 1:
                position.y = -1.0f;
                break;
            }

            // speed
            r = random.Next(0, 2);

            switch (r)
            {
            case 0:
                speed = 3.0f;
                break;

            case 1:
                speed = 5.0f;
                break;

            case 2:
                speed = 2.0f;
                break;
            }

            // Instantiate
            r = random.Next(0, listNumber);

            FlyingText flyingText = Instantiate <FlyingText>(textPrefab, canvas.transform);
            string     word       = wordData[r]["word"].ToString();
            string     kor        = wordData[r]["kor"].ToString();
            string     lang       = wordData[r]["lang"].ToString();

            flyingText.transform.position = new Vector3(position.x, position.y, flyingText.transform.position.z);
            flyingText.speed       = speed;
            flyingText.scoreObject = scoreObject;
            flyingText.Init(word, kor, lang);

            // wait time
            r = random.Next(0, 2);

            switch (r)
            {
            case 0:
                time = 1.0f;
                break;

            case 1:
                time = 1.5f;
                break;

            case 2:
                time = 2.0f;
                break;
            }

            yield return(new WaitForSeconds(time));
        }
    }
Esempio n. 27
0
    void Update()
    {
        //if (!MenuUI.activeSelf)
        //{

        if (Input.GetMouseButton(0))
        {
            if (dictationRecognizer.Status != SpeechSystemStatus.Running)
            {
                //ディクテーションを開始
                dictationRecognizer.Start();
                //Debug.Log("音声認識開始");
                //ホールドアニメーション再生
                animVoiceInput = GameObject.Find("VoiceInput").gameObject.GetComponent <Animator>();
                animVoiceInput.SetBool("MouseHold", true);

                /*if (Time.timeScale==1.0f)
                 * {
                 * Time.timeScale = SlowTime;
                 * }*/
            }
        }
        if (dictationRecognizer.Status == SpeechSystemStatus.Running)
        {
            dictationRecognizer.DictationResult += DictationRecognizer_DictationResult;         //DictationRecognizer_DictationResult処理を行う

            dictationRecognizer.DictationHypothesis += DictationRecognizer_DictationHypothesis; //DictationRecognizer_DictationHypothesis処理を行う

            dictationRecognizer.DictationComplete += DictationRecognizer_DictationComplete;     //DictationRecognizer_DictationComplete処理を行う

            dictationRecognizer.DictationError += DictationRecognizer_DictationError;           //DictationRecognizer_DictationError処理を行う

            if (inputText != testText)
            {
                KotodamaPos(inputText);
                audio.PlayOneShot(ATKClip, 1.0f);
                textObject      = FlyingText.GetObjects(inputText, PlayerPos, Quaternion.identity); //FlyingTextを生成
                textObject.name = inputText;
                textObject.transform.Rotate(CameraAngleX, CameraAngleY + angle, 0);                 //PlayerControllerのY.rotateを参照
                Rigidbody   rigidbody   = textObject.AddComponent <Rigidbody>();
                Rigidbody[] rigidbodies = textObject.GetComponentsInChildren <Rigidbody>();

                foreach (var TextChild in rigidbodies)
                {
                    TextChild.useGravity = false;
                    TextChild.AddForce(textObject.transform.forward * bulletSpeed, ForceMode.Impulse);
                    TextChild.tag = "flyingText";
                }
                //textObject.tag = "flyingText";
                Destroy(textObject, 10.0f);
            }
            inputText = testText;
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (dictationRecognizer.Status != SpeechSystemStatus.Stopped)
            {
                //Debug.Log("音声認識終了");
                dictationRecognizer.Stop();
                animVoiceInput.SetBool("MouseHold", false);

                /*if (Time.timeScale == SlowTime)
                 * {
                 *  Time.timeScale = 1.0f;
                 * }*/
            }
        }
        //}

        // イベントにイベントハンドラーを追加
        SceneManager.sceneLoaded += SceneLoaded;

        if (debugKotodama == true)
        {
            if (Input.GetKeyDown(KeyCode.Q))
            {
                DebugText(DebugText1);
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                DebugText(DebugText2);
            }
            if (Input.GetKeyDown(KeyCode.R))
            {
                DebugText(DebugText3);
            }
        }
    }
Esempio n. 28
0
    // Update is called once per frame
    void Update()
    {
        nowString = WSVoiceRecognition.GetGiveS();

        if (currentString != nowString)
        {
            //取得したテキストからマテリアルを決定
            Material mat = DefaultMat;
            if (Regex.IsMatch(nowString, @"赤"))
            {
                mat = RedMat;
            }
            if (Regex.IsMatch(nowString, @"青"))
            {
                mat = BlueMat;
            }
            if (Regex.IsMatch(nowString, @"黄"))
            {
                mat = YellowMat;
            }
            if (Regex.IsMatch(nowString, @"緑"))
            {
                mat = GreenMat;
            }
            if (Regex.IsMatch(nowString, @"ピンク"))
            {
                mat = PinkMat;
            }
            if (Regex.IsMatch(nowString, @"オレンジ"))
            {
                mat = OrangeMat;
            }
            if (Regex.IsMatch(nowString, @"灰"))
            {
                mat = GrayMat;
            }
            if (Regex.IsMatch(nowString, @"紫"))
            {
                mat = PurpleMat;
            }
            //テキストの生成位置
            Vector3 random = new Vector3(Random.Range(-10f, 10f), Random.Range(-10f, 10f), 0);

            //テキストオブジェクトの生成
            textObject = FlyingText.GetObjects(nowString, mat, mat, 1.0f, 0.25f, 1, random, Quaternion.identity);

            //物理演算の設定(RigidBody)
            var rigidbodies = textObject.GetComponentsInChildren <Rigidbody>();
            foreach (var rb in rigidbodies)
            {
                Vector3 vel = new Vector3(0, 0, 10f);
                rb.velocity   = vel;
                rb.useGravity = false;
            }

            //削除時間の設定
            Destroy(textObject, 4.0f);

            //多重処理防止
            currentString = nowString;
        }
    }
 private void HandleGameTimer(int param)
 {
     theGraphPlot.GraphPlotCanvas.Children.Clear();
     FlyingText.Draw(theGraphPlot.GraphPlotCanvas.Children);
 }
Esempio n. 30
0
 public static void CreateFromCharacters(string text, Vector3 position, float delay)
 {
     FlyingText.CreateFromCharacters(text, position, 1.5f, delay);
 }