示例#1
0
    // ---------------------------------------------------------------------------- //
    //  送信ボタンを押下した時に呼び出される
    // ---------------------------------------------------------------------------- //
    public void PutMeta()
    {
        if (mInputField.text == "")
        {
            return;
        }

        string mes = mInputField.text.Replace("\n", "");

        NluMetaData data = new NluMetaData();

        data.clientData                    = new ClientData();
        data.clientData.deviceInfo         = new DeviceInfo();
        data.clientData.deviceInfo.playTTS = "on";
        data.clientVer = "0.5.1";
        data.language  = "ja-JP";
        data.voiceText = mes;

        string json = JsonUtility.ToJson(data);

        Speak.Instance().PutMeta(json);

        CancelInvoke("AutoStopTask");
        Interlocked.Increment(ref mDialogCounter);

        LogView(mes);
        mInputField.text = "";
    }
        public ActionResult VolunteerLanguages([Bind(Include = "speakID, lngID, volID")] int?id, int?langSearch)
        {
            var   thisID        = id;
            Speak spks          = new Speak();
            bool  alreadySpeaks = false;

            try
            {
                if (ModelState.IsValid)
                {
                    var lng = db.Languages.OrderBy(q => q.lngName).ToList();
                    ViewBag.langSearch = new SelectList(lng, "lngID", "lngName", langSearch);
                    int lngID = langSearch.GetValueOrDefault();

                    spks.lngID = lngID;
                    spks.volID = id.GetValueOrDefault();

                    alreadySpeaks = db.Speaks.Any(u => u.lngID == lngID && u.volID == id);

                    if (!alreadySpeaks)
                    {
                        db.Speaks.Add(spks);
                        db.SaveChanges();
                    }
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes.Try again, and if the problem persists see your system administrator.");
            }
            var speaks = db.Speaks.Where(sp => sp.volID == id).ToList();

            return(PartialView("_VolunteerLanguages", speaks));
        }
        public ActionResult Result(string word)
        {
            Speak leetSpeak = new Speak();

            leetSpeak.SetSplit(word);
            return(View(leetSpeak));
        }
示例#4
0
        private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
        {
            AppServiceDeferral deferral = args.GetDeferral();
            ValueSet           message  = args.Request.Message;

            if (message == null || !message.ContainsKey("type"))
            {
                return;
            }

            switch (message["type"])
            {
            case "speaking":
                Speak speak = JsonConvert.DeserializeObject <Speak>(message["payload"] as string);
                Messenger.Default.Send(new SpeakMessage(speak));
                break;

            case "audioInData":
                AudioInData?.Invoke(this, message["data"] as float[]);
                break;

            case "audioOutData":
                AudioOutData?.Invoke(this, message["data"] as float[]);
                break;
            }
            deferral.Complete();
        }
示例#5
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(10, 10, 80, 70), "Start"))
     {
         audio = Microphone.Start("Mic in at front panel (black) (Realtek High Definition Audio)", false, 10, 44100);
     }
     if (GUI.Button(new Rect(10, 90, 80, 70), "Stop"))
     {
         SavWav.Save(fileName, audio);
         UploadFile(m_URL);
         //        audio.Play();
     }
     if (GUI.Button(new Rect(10, 170, 80, 70), "Repeat"))
     {
         Speak.qs_no = Speak.qs_no - 1;
         Speak.startSpeaking();
     }
     if (LoadOut)
     {
         //GUI.skin = guiSkin;
         GUI.Box(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 30, 300, 60), LoadOutText);
     }
     GUI.contentColor = Color.black;
     GUI.Label(new Rect(100, 50, 1200, 200), ans);
 }
示例#6
0
        public async Task <CharacterOperation> SendCharacterOperationResult(OperationResult result)
        {
            CharacterOperation operation = new Speak("s3", "3", "Got result: " + result.Result, DialogInstance.DialogButtonsType.Ok);

            operation.ExpectFeedback = false;
            return(operation);
        }
示例#7
0
        public void Insert(IDbConnection cn, Speak speak)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection = cn as SqlConnection;

                StringBuilder sb = new StringBuilder();
                sb.Append("SET NOCOUNT ON;");
                sb.Append("INSERT INTO YZAppNotesSpeak(");
                sb.Append("Account,");
                sb.Append("FileID,");
                sb.Append("Duration,");
                sb.Append("Comments,");
                sb.Append("CreateAt) ");
                sb.Append("VALUES(");
                sb.Append("@Account,");
                sb.Append("@FileID,");
                sb.Append("@Duration,");
                sb.Append("@Comments,");
                sb.Append("@CreateAt);");
                sb.Append("SELECT SCOPE_IDENTITY()");
                cmd.CommandText = sb.ToString();

                cmd.Parameters.Add("@Account", SqlDbType.NVarChar).Value  = this.Convert(speak.Account, false);
                cmd.Parameters.Add("@FileID", SqlDbType.NVarChar).Value   = this.Convert(speak.FileID, false);
                cmd.Parameters.Add("@Duration", SqlDbType.Int).Value      = speak.Duration;
                cmd.Parameters.Add("@Comments", SqlDbType.NVarChar).Value = this.Convert(speak.Comments, true);
                cmd.Parameters.Add("@CreateAt", SqlDbType.DateTime).Value = this.Convert(speak.CreateAt, false);

                speak.ItemID = System.Convert.ToInt32(cmd.ExecuteScalar());
            }
        }
        [TestMethod] //1
        public void SetSplit_SetSplitWithParam_true()
        {
            Speak testSpeak = new Speak();

            testSpeak.SetSplit("Hello");
            Assert.AreEqual(char.Parse("H"), testSpeak.Split[0]);
        }
示例#9
0
        public void Update(IDbConnection cn, Speak speak)
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection = cn as SqlConnection;

                StringBuilder sb = new StringBuilder();
                sb.Append("UPDATE YZAppNotesSpeak SET ");
                sb.Append("Account=@Account,");
                sb.Append("FileID=@FileID,");
                sb.Append("Duration=@Duration,");
                sb.Append("Comments=@Comments,");
                sb.Append("CreateAt=@CreateAt ");
                sb.Append("WHERE ItemID=@ItemID");
                cmd.CommandText = sb.ToString();

                cmd.Parameters.Add("@Account", SqlDbType.NVarChar).Value  = this.Convert(speak.Account, false);
                cmd.Parameters.Add("@FileID", SqlDbType.NVarChar).Value   = this.Convert(speak.FileID, false);
                cmd.Parameters.Add("@Duration", SqlDbType.Int).Value      = speak.Duration;
                cmd.Parameters.Add("@Comments", SqlDbType.NVarChar).Value = this.Convert(speak.Comments, true);
                cmd.Parameters.Add("@CreateAt", SqlDbType.DateTime).Value = this.Convert(speak.CreateAt, false);
                cmd.Parameters.Add("@ItemID", SqlDbType.Int).Value        = speak.ItemID;

                cmd.ExecuteNonQuery();
            }
        }
 void OnApplicationPause(bool pauseStatus)
 {
     Speak.Instance().Stop(OnStop);
     while (Speak.Instance().Poll(true))
     {
     }
 }
示例#11
0
        public async Task <CharacterOperation> SendUserOperation(UserOperation operation)
        {
            CharacterOperation newOperation = new Speak("s4", operation.OperatorId, "Got UserOperation: " + operation.OperationType, DialogInstance.DialogButtonsType.Ok);

            newOperation.ExpectFeedback = false;
            return(newOperation);
        }
        [TestMethod] //5
        public void ReplaceLeet_ReplaceS_Z()
        {
            Speak testSpeak = new Speak();

            testSpeak.SetSplit("s");
            Assert.AreEqual(char.Parse("z"), testSpeak.Split[0]);
        }
 public void Talk(Speak speak)
 {
     for (int i = 0; i < 50; i++)
     {
         speak(i);
     }
 }
示例#14
0
        public void Update(IDbConnection cn, Speak speak)
        {
            using (OracleCommand cmd = new OracleCommand())
            {
                cmd.Connection = cn as OracleConnection;
                cmd.BindByName = true;

                StringBuilder sb = new StringBuilder();
                sb.Append("UPDATE YZAppNotesSpeak SET ");
                sb.Append("Account=:Account,");
                sb.Append("FileID=:FileID,");
                sb.Append("Duration=:Duration,");
                sb.Append("Comments=:Comments,");
                sb.Append("CreateAt=:CreateAt ");
                sb.Append("WHERE ItemID=:ItemID");
                cmd.CommandText = sb.ToString();

                cmd.Parameters.Add(":Account", OracleDbType.NVarchar2).Value  = this.Convert(speak.Account, false);
                cmd.Parameters.Add(":FileID", OracleDbType.NVarchar2).Value   = this.Convert(speak.FileID, false);
                cmd.Parameters.Add(":Duration", OracleDbType.Int32).Value     = speak.Duration;
                cmd.Parameters.Add(":Comments", OracleDbType.NVarchar2).Value = this.Convert(speak.Comments, true);
                cmd.Parameters.Add(":CreateAt", OracleDbType.Date).Value      = this.Convert(speak.CreateAt, false);
                cmd.Parameters.Add(":ItemID", OracleDbType.Int32).Value       = speak.ItemID;

                cmd.ExecuteNonQuery();
            }
        }
 // ---------------------------------------------------------------------------- //
 //
 // SDKを自動停止させるための関数
 //
 // ---------------------------------------------------------------------------- //
 private void AutoStopTask()
 {
     mContext?.Post(__ =>
     {
         Speak.Instance().Stop(OnStop);
     }, null);
 }
 void OnApplicationQuit()
 {
     Speak.Instance().Stop(OnStop);
     while (Speak.Instance().Poll(true))
     {
     }
 }
示例#17
0
        /// <summary>
        /// Gets the step1.
        /// </summary>
        private static byte[] GetStep1()
        {
            var step1 = ApidazeScript.Build()
                        .AddNode(Speak.WithText(
                                     "Our text to speech leverages Google's cloud APIs to offer the best possible solution"))
                        .AddNode(Wait.SetDuration(1))
                        .AddNode(new Speak()
            {
                LangEnum = LangEnum.ENGLISH_AUSTRALIA,
                Voice    = VoiceEnum.MALE_A,
                Text     = "A wide variety of voices and languages are available.Here are just a few",
            }).AddNode(Wait.SetDuration(1))
                        .AddNode(new Speak()
            {
                LangEnum = LangEnum.FRENCH_FRANCE, Text = "Je peux parler français"
            }).AddNode(
                Wait.SetDuration(1)).AddNode(new Speak()
            {
                LangEnum = LangEnum.GERMAN, Text = "Auch deutsch"
            })
                        .AddNode(Wait.SetDuration(1)).AddNode(new Speak()
            {
                LangEnum = LangEnum.JAPANESE,
                Text     = "そして日本人ですら",
            }).AddNode(Wait.SetDuration(1)).AddNode(new Speak()
            {
                Text =
                    "You can see our documentation for a full list of supported languages and voices for them.  We'll take you back to the menu for now.",
            }).AddNode(Wait.SetDuration(2))
                        .ToXml();

            return(Encoding.UTF8.GetBytes(step1));
        }
示例#18
0
        /// <summary>
        /// Gets the intro.
        /// </summary>
        private static byte[] GetIntro()
        {
            var script = ApidazeScript.Build();

            var intro = script.AddNode(Ringback.FromFile(SERVER_URL + PLAYBACK_PATH)).AddNode(Wait.SetDuration(2))
                        .AddNode(new Answer()).AddNode(new Record {
                Name = "example_recording"
            }).AddNode(Wait.SetDuration(2))
                        .AddNode(Playback.FromFile(SERVER_URL + PLAYBACK_PATH))
                        .AddNode(Speak.WithText("This example script will show you some things you can do with our API"))
                        .AddNode(Wait.SetDuration(2)).AddNode(
                new Speak
            {
                DigitTimeoutMillis = TimeSpan.FromSeconds(15).TotalMilliseconds,
                InputTimeoutMillis = TimeSpan.FromSeconds(15).TotalMilliseconds,
                Text  = "Press 1 for an example of text to speech, press 2 to enter an echo line to check voice latency or press 3 to enter a conference.",
                Binds = new List <object>
                {
                    new Bind {
                        Action = SERVER_URL + STEP_1_PATH, Value = "1"
                    },
                    new Bind {
                        Action = SERVER_URL + STEP_2_PATH, Value = "2"
                    },
                    new Bind {
                        Action = SERVER_URL + STEP_3_PATH, Value = "3"
                    },
                },
            })
                        .ToXml();

            return(Encoding.UTF8.GetBytes(intro));
        }
示例#19
0
    public void DisplayNextSentence()
    {
        if (countSentences >= sentences.Count)   // Check if has reach the final speech
        {
            if (countScenes >= cutscene.Scenes.Count - 1)
            {
                EndDialog();
                return;
            }
            else
            {
                countScenes++;
                countSentences = 0;
                StartConversations(cutscene.Scenes[countScenes]);
                return;
            }
        }

        Speak actualSentence = sentences[countSentences];

        // if (actualSentence.image != null)
        //   sceneImageField.sprite = actualSentence.image;

        // Stop the letters animation when the speech is skiped
        StopAllCoroutines();

        // Start Coroutine to write the character speech
        StartCoroutine(TypeSentence(actualSentence.TxtSpeech));

        countSentences++;
    }
        public ProblemManedger(ProblemObservable _probObs, ProblemsExecuteObservable _probExecutObs, SpeechSynthesizer _synthesizer, SettingsClass _settClass)
        {
            _problemAllObs      = _probObs;
            _problemExecutedObs = _probExecutObs;
            _problemForSpeech   = new List <Problem>();

            synthesizer = _synthesizer;
            settClass   = _settClass;

            #region -Timers-
            Interval             = new TimeSpan(0, 0, 1);
            check_timer          = new DispatcherTimer();
            check_timer.Interval = Interval;
            check_timer.Tick    += Check_timer_Tick;
            check_timer.Start();

            pause_timer          = new DispatcherTimer();
            pause_timer.Interval = new TimeSpan(0, 0, 2);
            pause_timer.Tick    += Pause_timer_Tick;

            readText_timer          = new DispatcherTimer();
            readText_timer.Interval = new TimeSpan(0, 30, 10); // должно быть из SettingsClass
            readText_timer.Tick    += ReadText_timer_Tick;
            //readText_timer.Start();
            #endregion

            readList = Speak.LoadText() ?? (new string[0]);
            CheckProblemStart();
        }
示例#21
0
    private void  initStates()
    {
        takeState = Take.Start;
        activateState = Activate.Start;
        deactivateState = Deactivate.Start;
        releaseState = Release.Start;
        tasteState = Taste.Start;
        smellState = Smell.Start;

        /*openDoorState = OpenDoor.Start;
        closeDoorState = CloseDoor.Start;*/
        moveState = Move.Start;
        rotateState = Rotate.Start;
        turnState = Turn.Start;
        commandStatus = CommandStatus.Running;
        headFocusState = HeadFocus.Start;
        headResetState = HeadReset.Start;
        lookForState = LookFor.Start;

        speakState = Speak.Start;

        cancelState = Cancel.Start;
        getSensesState = GetSenses.Start;

        reset = true;           
    }
        [TestMethod] // 7
        public void ReplaceLeet_ReplaceHeLLo_H3110()
        {
            Speak testSpeak = new Speak();

            testSpeak.SetSplit("HeLLo");
            string str = new String(testSpeak.Split);

            Assert.AreEqual("H3110", str);
        }
示例#23
0
        /// <summary>
        /// Gets the step2.
        /// </summary>
        private static byte[] GetStep2()
        {
            var step2 = ApidazeScript.Build()
                        .AddNode(Speak.WithText("You will now be joined to an echo line."))
                        .AddNode(Echo.SetDuration(500))
                        .ToXml();

            return(Encoding.UTF8.GetBytes(step2));
        }
示例#24
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find("Player").transform;
        graph  = GameObject.Find("NavigationGraph").GetComponent <GraphScript>();
        voice  = transform.FindChild("Speech").GetComponent <Speak>();

        transform.FindChild("Cube").renderer.material.mainTexture = Resources.Load("Villager-" + Random.Range(1, 4)) as Texture;

        Say("Exuberant!", "Alive again!", "Why?", "Hello, world!", "Statistical!", "Help", "*hick*", "Hats!", "I'm lost.");
    }
示例#25
0
 void Update()
 {
     try
     {
         Speak.Instance().Poll();
     }
     catch
     {
         Debug.Log("SDK ERROR");
     }
 }
示例#26
0
        static void Main()
        {
            Console.WriteLine("Get Leet Words");
            Console.Write("Enter : ");
            string input = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine(Speak.GetSentence(input));
            Console.WriteLine();
            Main();
        }
示例#27
0
 private void end()
 {
     switch (action)
     {
         case Action.Take:
             takeState = Take.End;
             break;
         case Action.Activate:
             activateState = Activate.End;
             break;
         case Action.Deactivate:
             deactivateState = Deactivate.End;
             break;
         case Action.Release:
             releaseState = Release.End;
             break;
         case Action.Taste:
             tasteState = Taste.End;
             break;
         case Action.Smell:
             smellState = Smell.End;
             break;
         case Action.Move:
             moveState = Move.End;
             break;                
         case Action.Rotate:
             rotateState = Rotate.End;
             break;
         case Action.Turn:
               turnState = Turn.End;
               break;
         case Action.HeadFocus:
             headFocusState = HeadFocus.End;
             break;
         case Action.HeadReset:
             headResetState = HeadReset.End;
             break;
         case Action.LookFor:
             lookForState = LookFor.End;
             break;
         case Action.Speak:
             speakState = Speak.End;
             break;
         case Action.Cancel:
             cancelState = Cancel.End;
             break;
         case Action.GetSenses:
             getSensesState = GetSenses.End;
             break;
         default:
             break; ;
     }   
 }
示例#28
0
        /// <summary>
        /// Gets the step3.
        /// </summary>
        private static byte[] GetStep3()
        {
            var step3 = ApidazeScript.Build()
                        .AddNode(Speak.WithText("You will be entered into a conference call now.  You can initiate more calls to join participants or hangup to leave"))
                        .AddNode(new Conference()
            {
                Name = "SDKTestConference"
            })
                        .ToXml();

            return(Encoding.UTF8.GetBytes(step3));
        }
    // ---------------------------------------------------------------------------- //
    //  SDK初期化処理
    // ---------------------------------------------------------------------------- //
    private void InitializeSpeakSDK()
    {
        Speak.Instance().SetURL("wss://hostname.domain:443/path");
        Speak.Instance().SetDeviceToken("PUT_YOUR_DEVICE_TOKEN");

        // Callback.
        Speak.Instance().SetOnTextOut(OnTextOut);
        Speak.Instance().SetOnMetaOut(OnMetaOut);
        Speak.Instance().SetOnPlayEnd(OnPlayEnd);

        // AudioSource
        Speak.Instance().SetAudioSource(mAudioSource);
    }
        static void Main(string[] args)
        {
            //匿名类型
            var n = new { name = "school", age = 25 };

            Console.WriteLine(n.name);
            Console.WriteLine(n.age);
            //匿名方法
            Speak ss = delegate(string b) { Console.WriteLine("this is the string {0}", b); };

            ss("what do you want?");
            Console.ReadKey();
        }
示例#31
0
        public void Speek()
        {
            var method = new Speak() {
                Text = "Cron 表达式分为7个子表达式",
                Lang = "zh-CN",
                Quality = AsNum.BingTranslate.Api.Methods.Speak.Qualities.Max
            };

            var result = ApiClient.ExecuteWrap(method).Result;
            using (var stm = new MemoryStream(result))
            using (var player = new SoundPlayer(stm)) {
                player.Play();
            }
        }
示例#32
0
    void ShowKingSubtitle()
    {
        if (KingTalkTime == 0)
        {
            KingTalkTime = 1;
        }
        if (LeaderTalkTime == 1)
        {
            LeaderTalkTime = 2;
        }
        if (LeaderTalkTime == 2)
        {
            LeaderTalkTime = 3;
        }

        if (!KingSubtitlePlane.gameObject.active)
        KingSubtitlePlane.gameObject.SetActiveRecursively(true);

        if (KingRestTime >= 0)
        {
            KingRestTime -= Time.deltaTime;
        }

        if (KingRestTime <= 0)
        {
            if (KingSubtitles.Length > KingCurrentSubtitle +1)
            {
                if (KingCurrentSubtitle == 1 && KingTalkTime == 1)
                {
                    KingCurrentSubtitle += 1;
                    KingRestTime = 3f;
                }
                else
                {
                    Debug.Log("a");
                    KingSubtitlePlane.gameObject.SetActiveRecursively(false);
                    curSpeaker = Speak.Leader;
                }

            }
            else
            {
                KingSubtitlePlane.gameObject.SetActiveRecursively(false);
            }
        }

        KingSubtitlePlane.position = new Vector3(0,KingObject.position.y + KingHeight,KingObject.position.z + KingSide);
    }
示例#33
0
    // Use this for initialization
    void Awake()
    {
        player = GameObject.Find("Player").transform;
        graph = GameObject.Find("NavigationGraph").GetComponent<GraphScript>();
        voice = transform.FindChild("Speech").GetComponent<Speak>();

        transform.FindChild("Cube").renderer.material.mainTexture = Resources.Load("Villager-" + Random.Range(1,4)) as Texture;

        float spawnSay = Random.value;

        if(spawnSay > 0.9) voice.Say("Exuberant!");
        else if(spawnSay > 0.8) voice.Say("Alive again!");
        else if(spawnSay > 0.7) voice.Say("Why?");
        else if(spawnSay > 0.6) voice.Say("Hello, world!");
        else if(spawnSay > 0.5) voice.Say("Statistical!");
        else if(spawnSay > 0.4) voice.Say("Help");
        else if(spawnSay > 0.3) voice.Say("*hick*");
        else if(spawnSay > 0.2) voice.Say("Hats!");
        else if(spawnSay > 0.1) voice.Say("I'm lost.");
    }
示例#34
0
    public static void PlayConversation(string id)
    {
        if (xmld == null)
        {
            Init();
        }
        string query = string.Format("//*[@id='{0}']", id);
        XmlElement conv = (XmlElement)xmld.SelectSingleNode(query);

        XmlNodeList nodes = conv.SelectNodes("*");

        Conversation convModel = new Conversation();
        convModel.nodes = new Node[nodes.Count];

        for (int i = 0; i < nodes.Count; ++i)
        {
            XmlNode node = nodes[i];
            string name = node.Name;
            Node nodeModel = null;
            if (name == "dialogue-node")
            {
                DialogNode dialogNodeModel = new DialogNode();

                XmlNodeList dialogSpeaks = node.SelectNodes("*");

                dialogNodeModel.speaks = new Speak[node.SelectNodes("speak-player").Count
                     + node.SelectNodes("speak-char").Count];
                int z = 0;

                for (int j = 0; j < dialogSpeaks.Count; ++j)
                {
                    XmlNode speakNode = dialogSpeaks[j];

                    string speakName = speakNode.Name;

                    if (speakName == "speak-player")
                    {
                        Speak speakModel = new Speak();
                        speakModel.text = speakNode.InnerText;
                        dialogNodeModel.speaks[z] = speakModel;
                        ++z;
                    }
                    else if (speakName == "speak-char")
                    {
                        Speak speakModel = new Speak();
                        speakModel.text = speakNode.InnerText;
                        speakModel.isPhone = true;
                        dialogNodeModel.speaks[z] = speakModel;
                        ++z;
                    }
                    else if (speakName == "condition")
                    {
                        Condition conditionModel = new Condition();

                        XmlNodeList activesList = speakNode.SelectNodes("active");
                        conditionModel.actives = new string[activesList.Count];
                        for (int y = 0; y < activesList.Count; y++)
                        {
                            conditionModel.actives[y] = activesList[y].Attributes["flag"].Value;
                        }

                        XmlNodeList inactivesList = speakNode.SelectNodes("inactive");
                        conditionModel.inactives = new string[inactivesList.Count];
                        for (int y = 0; y < inactivesList.Count; y++)
                        {
                            conditionModel.inactives[y] = inactivesList[y].Attributes["flag"].Value;
                        }

                        dialogNodeModel.speaks[z - 1].condition = conditionModel;
                    }
                    else if (speakName == "child")
                    {
                        dialogNodeModel.nextIndex = Utils.IntParseFast(speakNode.Attributes["nodeindex"].Value);
                    }
                    else if (speakName == "end-conversation")
                    {
                        XmlNode effect = speakNode.SelectSingleNode("effect");
                        if (effect != null)
                        {
                            XmlNodeList effectsList = effect.SelectNodes("*");

                            dialogNodeModel.effects = new EndConvEffect[
                                effectsList.Count - effect.SelectNodes("condition").Count];
                            int m = 0;
                            for (int x = 0; x < effectsList.Count; ++x)
                            {
                                XmlNode effectNode = effectsList[x];

                                string effectNodeName = effectNode.Name;
                                if (effectNodeName == "activate")
                                {
                                    ActivateFlagEffect activateFlageffect = new ActivateFlagEffect();
                                    activateFlageffect.flag = effectNode.Attributes["flag"].Value;
                                    dialogNodeModel.effects[m] = activateFlageffect;
                                    ++m;
                                }
                                else if (effectNodeName == "deactivate")
                                {
                                    DeactivateFlagEffect deactivateFlageffect = new DeactivateFlagEffect();
                                    deactivateFlageffect.flag = effectNode.Attributes["flag"].Value;
                                    dialogNodeModel.effects[m] = deactivateFlageffect;
                                    ++m;
                                }
                                else if (effectNodeName == "increment")
                                {
                                    IncrementFlagEffect eff = new IncrementFlagEffect();
                                    eff.val = Utils.IntParseFast(
                                        effectNode.Attributes["value"].Value);
                                    eff.var = effectNode.Attributes["var"].Value;
                                    dialogNodeModel.effects[m] = eff;
                                    ++m;
                                }
                                else if (effectNodeName == "decrement")
                                {
                                    DecrementFlagEffect eff = new DecrementFlagEffect();
                                    eff.val = Utils.IntParseFast(
                                        effectNode.Attributes["value"].Value);
                                    eff.var = effectNode.Attributes["var"].Value;
                                    dialogNodeModel.effects[m] = eff;
                                    ++m;

                                }
                                else if (effectNodeName == "trigger-conversation")
                                {
                                    TriggerConvEffect eff = new TriggerConvEffect();
                                    eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                    dialogNodeModel.effects[m] = eff;
                                    ++m;
                                }
                                else if (effectNodeName == "trigger-scene")
                                {
                                    TriggerSceneEffect eff = new TriggerSceneEffect();
                                    eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                    dialogNodeModel.effects[m] = eff;
                                    ++m;
                                }
                                else if (effectNodeName == "trigger-cutscene")
                                {
                                    TriggerCutSceneEffect eff = new TriggerCutSceneEffect();
                                    eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                    dialogNodeModel.effects[m] = eff;
                                    ++m;

                                }
                                else if (effectNodeName == "condition")
                                {
                                    Condition conditionModel = new Condition();

                                    XmlNodeList activesList = effectNode.SelectNodes("active");
                                    conditionModel.actives = new string[activesList.Count];
                                    for (int y = 0; y < activesList.Count; y++)
                                    {
                                        conditionModel.actives[y] = activesList[y].Attributes["flag"].Value;
                                    }

                                    XmlNodeList inactivesList = effectNode.SelectNodes("inactive");
                                    conditionModel.inactives = new string[inactivesList.Count];
                                    for (int y = 0; y < inactivesList.Count; y++)
                                    {
                                        conditionModel.inactives[y] = inactivesList[y].Attributes["flag"].Value;
                                    }

                                    dialogNodeModel.effects[m - 1].condition = conditionModel;
                                }
                            }

                        }
                    }
                    else if (speakName == "effect")
                    {
                        XmlNodeList effectsList = speakNode.SelectNodes("*");

                        dialogNodeModel.effects = new EndConvEffect[
                            effectsList.Count - speakNode.SelectNodes("condition").Count];
                        int m = 0;
                        for (int x = 0; x < effectsList.Count; ++x)
                        {
                            XmlNode effectNode = effectsList[x];

                            string effectNodeName = effectNode.Name;
                            if (effectNodeName == "activate")
                            {
                                ActivateFlagEffect activateFlageffect = new ActivateFlagEffect();
                                activateFlageffect.flag = effectNode.Attributes["flag"].Value;
                                dialogNodeModel.effects[m] = activateFlageffect;
                                ++m;
                            }
                            else if (effectNodeName == "deactivate")
                            {
                                DeactivateFlagEffect deactivateFlageffect = new DeactivateFlagEffect();
                                deactivateFlageffect.flag = effectNode.Attributes["flag"].Value;
                                dialogNodeModel.effects[m] = deactivateFlageffect;
                                ++m;
                            }
                            else if (effectNodeName == "increment")
                            {
                                IncrementFlagEffect eff = new IncrementFlagEffect();
                                eff.val = Utils.IntParseFast(
                                    effectNode.Attributes["value"].Value);
                                eff.var = effectNode.Attributes["var"].Value;
                                dialogNodeModel.effects[m] = eff;
                                ++m;
                            }
                            else if (effectNodeName == "decrement")
                            {
                                DecrementFlagEffect eff = new DecrementFlagEffect();
                                eff.val = Utils.IntParseFast(
                                    effectNode.Attributes["value"].Value);
                                eff.var = effectNode.Attributes["var"].Value;
                                dialogNodeModel.effects[m] = eff;
                                ++m;

                            }
                            else if (effectNodeName == "trigger-conversation")
                            {
                                TriggerConvEffect eff = new TriggerConvEffect();
                                eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                dialogNodeModel.effects[m] = eff;
                                ++m;
                            }
                            else if (effectNodeName == "trigger-scene")
                            {
                                TriggerSceneEffect eff = new TriggerSceneEffect();
                                eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                dialogNodeModel.effects[m] = eff;
                                ++m;
                            }
                            else if (effectNodeName == "trigger-cutscene")
                            {
                                TriggerCutSceneEffect eff = new TriggerCutSceneEffect();
                                eff.idTarget = effectNode.Attributes["idTarget"].Value;
                                dialogNodeModel.effects[m] = eff;
                                ++m;

                            }
                            else if (effectNodeName == "condition")
                            {
                                Condition conditionModel = new Condition();

                                XmlNodeList activesList = effectNode.SelectNodes("active");
                                conditionModel.actives = new string[activesList.Count];
                                for (int y = 0; y < activesList.Count; y++)
                                {
                                    conditionModel.actives[y] = activesList[y].Attributes["flag"].Value;
                                }

                                XmlNodeList inactivesList = effectNode.SelectNodes("inactive");
                                conditionModel.inactives = new string[inactivesList.Count];
                                for (int y = 0; y < inactivesList.Count; y++)
                                {
                                    conditionModel.inactives[y] = inactivesList[y].Attributes["flag"].Value;
                                }

                                dialogNodeModel.effects[m - 1].condition = conditionModel;
                            }
                        }

                    }
                }

                nodeModel = dialogNodeModel;
            }
            else if (name == "option-node")
            {
                OptionNode optionNodeModel = new OptionNode();
                XmlAttribute randomAttr = node.Attributes["random"];
                if (randomAttr != null && randomAttr.Value == "yes")
                {
                    optionNodeModel.isRandom = true;
                }
                XmlNodeList optionSpeaks = node.SelectNodes("*");

                optionNodeModel.options = new Option[node.SelectNodes("speak-player").Count];
                int z = 0;

                for (int j = 0; j < optionSpeaks.Count; ++j)
                {
                    XmlNode optionNode = optionSpeaks[j];
                    string optionName = optionNode.Name;
                    if (optionName == "speak-player")
                    {
                        Option speakModel = new Option();
                        speakModel.text = optionNode.InnerText;
                        optionNodeModel.options[z] = speakModel;
                        ++z;
                    }
                    else if (optionName == "condition")
                    {
                        Condition conditionModel = new Condition();

                        XmlNodeList activesList = optionNode.SelectNodes("active");
                        conditionModel.actives = new string[activesList.Count];
                        for (int y = 0; y < activesList.Count; y++)
                        {
                            conditionModel.actives[y] = activesList[y].Attributes["flag"].Value;
                        }

                        XmlNodeList inactivesList = optionNode.SelectNodes("inactive");
                        conditionModel.inactives = new string[inactivesList.Count];
                        for (int y = 0; y < inactivesList.Count; y++)
                        {
                            conditionModel.inactives[y] = inactivesList[y].Attributes["flag"].Value;
                        }

                        optionNodeModel.options[z - 1].condition = conditionModel;
                    }
                    else if (optionName == "child")
                    {
                        optionNodeModel.options[z - 1].nextIndex = Utils.IntParseFast(optionNode.Attributes["nodeindex"].Value);
                    }
                }

                nodeModel = optionNodeModel;
            }

            convModel.nodes[i] = nodeModel;
        }
        convModel.exec();
    }
示例#35
0
    void Start()
    {
        LeaderSubMat.mainTexture = LeaderSubtitles[LeaderCurrentSubtitle];
        LeaderSubtitlePlane.gameObject.SetActiveRecursively(false);

        KingSubMat.mainTexture = KingSubtitles[KingCurrentSubtitle];
        KingSubtitlePlane.gameObject.SetActiveRecursively(false);

        curSpeaker = Speak.None;
    }
示例#36
0
    void Update()
    {
        if (LeaderSubMat.mainTexture != LeaderSubtitles[LeaderCurrentSubtitle])
        {
            LeaderSubMat.mainTexture = LeaderSubtitles[LeaderCurrentSubtitle];
        }
        if (KingSubMat.mainTexture != KingSubtitles[KingCurrentSubtitle])
        {
            KingSubMat.mainTexture = KingSubtitles[KingCurrentSubtitle];
        }

        if (firstRestTime >= 0)
        {
            firstRestTime -= Time.deltaTime;
        }
        else
        {
            if (curSpeaker == Speak.None)
            {
                curSpeaker = Speak.Leader;
            }
        }

        if (curSpeaker == Speak.Leader)
        {
            ShowLeaderSubtitle();
        }
        else if (curSpeaker == Speak.King)
        {
            ShowKingSubtitle();
        }
    }
示例#37
0
    void ShowLeaderSubtitle()
    {
        if ( KingTalkTime == 1)
        {
            KingTalkTime = 2;
        }

        if (!LeaderSubtitlePlane.gameObject.active)
        LeaderSubtitlePlane.gameObject.SetActiveRecursively(true);

        if (LeaderRestTime >= 0)
        {
            LeaderRestTime -= Time.deltaTime;
        }

        if (LeaderRestTime <= 0)
        {
            if (LeaderSubtitles.Length > LeaderCurrentSubtitle +1)
            {
                if (LeaderCurrentSubtitle == 0 && LeaderTalkTime == 1)
                {
                    LeaderCurrentSubtitle += 1;

                    LeaderRestTime = 3f;
                }
                else if (LeaderCurrentSubtitle == 1 && LeaderTalkTime == 1)
                {
                    Debug.Log("S");
                    LeaderSubtitlePlane.gameObject.SetActiveRecursively(false);
                    curSpeaker = Speak.King;
                }

                if (LeaderCurrentSubtitle == 1 && LeaderTalkTime == 2)
                {
                    Debug.Log("Increase");
                    LeaderCurrentSubtitle += 1;

                    LeaderRestTime = 3f;
                }
                else if (LeaderCurrentSubtitle == 3 && LeaderTalkTime ==2)
                {
                    Debug.Log("H");
                    LeaderSubtitlePlane.gameObject.SetActiveRecursively(false);
                    curSpeaker = Speak.King;
                }
            }
            else
            {
                //LeaderSubtitlePlane.gameObject.SetActiveRecursively(false);
            }
        }

        LeaderSubtitlePlane.position = new Vector3(0,LeaderObject.position.y + LeaderHeight,LeaderObject.position.z + LeaderSide);
    }
示例#38
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find("Player").transform;
        graph = GameObject.Find("NavigationGraph").GetComponent<GraphScript>();
        voice = transform.FindChild("Speech").GetComponent<Speak>();

        transform.FindChild("Cube").renderer.material.mainTexture = Resources.Load("Villager-" + Random.Range(1,4)) as Texture;

        Say ("Exuberant!", "Alive again!", "Why?", "Hello, world!", "Statistical!", "Help", "*hick*", "Hats!", "I'm lost.");
    }