Exemplo n.º 1
0
    void IndicateFocus(object sender, EventArgs e)
    {
        world.RespondAndUpdate(string.Empty);         // clear dialogue box

        focusObj = ((SelectionEventArgs)e).Content as GameObject;
        Debug.Log(string.Format("Focused on {0}, world @ {1} screen @ {2}", focusObj.name,
                                Helper.VectorToParsable(focusObj.transform.position),
                                Helper.VectorToParsable(Camera.main.WorldToScreenPoint(focusObj.transform.position))));

        focusCircle.enabled            = true;
        focusCircle.transform.position = new Vector3(focusObj.transform.position.x,
                                                     Helper.GetObjectWorldSize(focusObj).max.y,
                                                     focusObj.transform.position.z);
        //Debug.Log(Helper.VectorToParsable(focusCircle.transform.position));
        focusTimeoutTimer.Interval = focusTimeoutTime;
        focusTimeoutTimer.Enabled  = true;
        spriteAnimator.enabled     = true;
        spriteAnimator.Play("circle_anim_test", 0, 0);
    }
Exemplo n.º 2
0
    void ConsumeData(object sender, EventArgs e)
    {
        if (((RestEventArgs)e).Content is string)
        {
            if ((((RestEventArgs)e).Content.ToString() != string.Empty) &&
                (((RestEventArgs)e).Content.ToString() != lastReceivedData))
            {
                Debug.Log(((RestEventArgs)e).Content);
                CommanderStatus dict = JsonUtility.FromJson <CommanderStatus>(((RestEventArgs)e).Content.ToString());
                if (dict != null)
                {
//					Debug.Log(string.Format("input: \"{0}\", question: \"{1}\", utter: \"{2}\"",dict.input,dict.question,dict.utter));
                    lastReceivedData = ((RestEventArgs)e).Content.ToString();

                    if (dict.input != string.Empty)
                    {
                        ((InputController)(GameObject.Find("IOController").GetComponent("InputController")))
                        .inputString = dict.input.Trim();
                        ((InputController)(GameObject.Find("IOController").GetComponent("InputController")))
                        .MessageReceived(dict.input.Trim());
                    }
                    else if (dict.question != string.Empty)
                    {
                        if (Regex.IsMatch(dict.question, @"The .+ block\?"))
                        {
                            string     color        = dict.question.Split()[1];
                            MethodInfo methodToCall = preds.GetType().GetMethod(color.ToUpper());
                            object     obj          = methodToCall.Invoke(preds, new object[] { world.availableObjs.ToArray() });
                            if (obj != null)
                            {
                                world.ReachFor(GameObject.Find(obj as string));
                            }

                            world.RespondAndUpdate(dict.question);
                        }
                        else if (Regex.IsMatch(dict.question, @".*<.+; .+; .+>\?"))
                        {
                            string coord = Regex.Match(dict.question, @"<.+; .+; .+>").Value;
                            world.RespondAndUpdate(Regex.Replace(dict.question, @"<.+; .+; .+>", "here"));
                            world.ReachFor(GlobalHelper.ParsableToVector(coord));
                        }
                        else
                        {
                            world.RespondAndUpdate(dict.question);
                        }
                    }
                    else if (dict.utter != string.Empty)
                    {
                        world.RespondAndUpdate(dict.utter);
                    }
                    else if (dict.hide != string.Empty)
                    {
                        GameObject obj = GameObject.Find(dict.hide);
                        if (obj != null)
                        {
                            preds.DISABLE(new object[] { obj });
                        }
                    }
                    else if (dict.show != string.Empty)
                    {
                        for (int i = 0; i < objSelector.disabledObjects.Count; i++)
                        {
                            if (objSelector.disabledObjects[i].name == dict.show)
                            {
                                preds.ENABLE(new object[] { objSelector.disabledObjects[i] });
                            }
                        }
                    }
                    else if (dict.anim != string.Empty)
                    {
                        world.MoveToPerform();
                        world.gestureController.PerformGesture(dict.anim);
                    }
                }
            }
        }
    }