コード例 #1
0
        public override void SetVariable <T>(string variableName, T value, bool includeLeading = true)
        {
            Yarn.Value yarnValue = new Yarn.Value(value);

            if (includeLeading)
            {
                variableName = AddLeading(variableName);
            }

            VariableStorage.SetValue(variableName, yarnValue);
        }
コード例 #2
0
        /// Erase all variables and reset to default values
        public override void ResetToDefaults()
        {
            Clear();

            // For each default variable that's been defined, parse the
            // string that the user typed in in Unity and store the
            // variable
            foreach (var variable in defaultVariables)
            {
                object value;

                switch (variable.type)
                {
                case Yarn.Value.Type.Number:
                    float f = 0.0f;
                    float.TryParse(variable.value, out f);
                    value = f;
                    break;

                case Yarn.Value.Type.String:
                    value = variable.value;
                    break;

                case Yarn.Value.Type.Bool:
                    bool b = false;
                    bool.TryParse(variable.value, out b);
                    value = b;
                    break;

                case Yarn.Value.Type.Variable:
                    // We don't support assigning default variables from
                    // other variables yet
                    Debug.LogErrorFormat("Can't set variable {0} to {1}: You can't " +
                                         "set a default variable to be another variable, because it " +
                                         "may not have been initialised yet.", variable.name, variable.value);
                    continue;

                case Yarn.Value.Type.Null:
                    value = null;
                    break;

                default:
                    throw new System.ArgumentOutOfRangeException();
                }

                var v = new Yarn.Value(value);

                SetValue("$" + variable.name, v);
            }
        }
コード例 #3
0
        // Use this for initialization
        void Start()
        {
            //Use scene changer's singleton reference instead of slow gameobject.find
            dialogue   = SceneChanger.instance.transform.GetChild(0).gameObject;
            meshes     = gameObject.GetComponentsInChildren <SkinnedMeshRenderer>();
            moreMeshes = gameObject.GetComponentsInChildren <MeshRenderer>();
            spriteRend = gameObject.GetComponentInChildren <SpriteRenderer>();

            Yarn.Value biStage = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$biStage");
            int        stage   = (int)biStage.AsNumber; //avoid comparison of floating point numbers by casting to int

            if (stage == 0)
            {
                //hide avery and kim on blossom island
                if (gameObject.name != "Spot" && gameObject.name != "Hinty")
                {
                    Yarn.Value forestComplete = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$foundDog");
                    bool       temp           = forestComplete.AsBool;

                    if (!temp)
                    {
                        setMesh(false, false);
                    }
                }
                else
                {
                    setMesh(false, true);
                }
            }
            else
            {
                if (!startActive && gameObject.name != "Avery")
                {
                    if ((stage > 3 && gameObject.name == "Maison") || (stage == 10 && gameObject.name == "Eden"))
                    {
                        setMesh(true, false);
                    }
                    else
                    {
                        setMesh(false, true);
                    }
                }
            }

            originalPosition = gameObject.transform;
        }
コード例 #4
0
ファイル: Game.cs プロジェクト: Freezer-Games/Frozen-Out
        IEnumerator LoadLevel(int level, SaveData data)
        {
            AsyncOperation async = SceneManager.LoadSceneAsync(level, LoadSceneMode.Single);

            // While the asynchronous operation to load the new scene is not yet complete, continue waiting until it's done.
            while (!async.isDone)
            {
                yield return(null);
            }
            Time.timeScale = 1;
            Vector3 newposplayer    = new Vector3(data.positionplayer[0], data.positionplayer[1], data.positionplayer[2]);
            Vector3 newposcamera    = new Vector3(data.positioncamera[0], data.positioncamera[1], data.positioncamera[2]);
            Vector3 newauxposcamera = new Vector3(data.positionauxcamera[0], data.positionauxcamera[1], data.positionauxcamera[2]);

            GameObject.Find("Player").GetComponent <MoverAlCargar>().mover(newposplayer);
            GameObject.Find("Player").GetComponent <MoverAlCargar>().rotar(data.rotationplayer);
            GameObject.Find("MainCamera").GetComponent <MoverAlCargar>().mover(newposcamera);

            //cargar informacion de dialogos ya realizados
            for (int i = 0; i < data.YarnValues.Count; i++)
            {
                FindObjectOfType <YarnVariableStorage>().ResetToDefaults();
                Yarn.Value yarnValue = new Yarn.Value(data.YarnValues[i]);
                Debug.Log(data.YarnKeys[i]);
                Debug.Log(yarnValue);
                FindObjectOfType <YarnVariableStorage>().SetValue(data.YarnKeys[i], yarnValue);
            }

            //cargar posiciones de cada objeto que se haya movido
            for (int i = 0; i < data.nombres.Count; i++)
            {
                Vector3 newpos     = new Vector3(data.positions[i * 3], data.positions[i * 3 + 1], data.positions[i * 3 + 2]);
                float[] rotaciones = new float[4];
                rotaciones[0] = data.rotations[i * 4];
                rotaciones[1] = data.rotations[i * 4 + 1];
                rotaciones[2] = data.rotations[i * 4 + 2];
                rotaciones[3] = data.rotations[i * 4 + 3];
                GameObject.Find(data.nombres[i]).GetComponent <MoverAlCargar>().mover(newpos);
                GameObject.Find(data.nombres[i]).GetComponent <MoverAlCargar>().rotar(rotaciones);
                if (GameObject.Find(data.nombres[i]).GetComponent <Patrulla>() != null)
                {
                    GameObject.Find(data.nombres[i]).GetComponent <Patrulla>().SiguientePunto = data.nextpos[i];
                }
            }
        }
コード例 #5
0
ファイル: NPC.cs プロジェクト: Mostopha/Jazz-on-the-A-Train
        // Use this for initialization
        public override void OnActivate()
        {
            if (string.IsNullOrEmpty(talkToNode))
            {
                Debug.Log(characterName + " has nothing to say.");
            }
            else
            {
                Debug.Log("Beginning conversation with " + characterName + " at node " + talkToNode);
                // Kick off the dialogue at this node.
                FindObjectOfType <DialogueRunner>().StartDialogue(talkToNode);

                Yarn.Value v = new Yarn.Value(true);
                FindObjectOfType <ExampleVariableStorage>().SetValue("$happy", v);
                Yarn.Value b = FindObjectOfType <ExampleVariableStorage>().GetValue("$happy");
                Debug.Log(b.type);
                if (b.type == Yarn.Value.Type.Bool)
                {
                    bool boolean = b.AsBool;
                    Debug.Log(boolean);
                }
            }
        }
コード例 #6
0
 /// Set a variable's value
 public override void SetValue(string variableName, Yarn.Value value)
 {
     // Copy this value into our list
     variables[variableName] = new Yarn.Value(value);
 }
コード例 #7
0
 public YarnKeyValue(string _key, Yarn.Value _value)
 {
     m_key   = _key;
     m_value = _value;
 }
コード例 #8
0
 // Set a variable's value
 public override void SetValue(string variableName, Yarn.Value value)
 {
     // Copy this value into our list
     variables[variableName] = new Yarn.Value(value);
 }
コード例 #9
0
ファイル: Dialogue.cs プロジェクト: modyari/YarnSpinner
        /// <inheritdoc/>
        public virtual void SetValue(string variableName, bool boolValue)
        {
            Value val = new Yarn.Value(boolValue);

            SetValue(variableName, val);
        }
コード例 #10
0
 public override void SetValue(string variableName, Yarn.Value value)
 {
     variables[variableName] = new Yarn.Value(value);
 }
コード例 #11
0
    // Erase all variables and reset to default values
    public override void ResetToDefaults()
    {
        Clear ();

        // For each default variable that's been defined, parse the string
        // that the user typed in in Unity and store the variable
        foreach (var variable in defaultVariables) {

            object value;

            switch (variable.type) {
            case Yarn.Value.Type.Number:
                float f = 0.0f;

                float.TryParse(variable.value, out f);

                value = f;

                break;

            case Yarn.Value.Type.String:

                value = variable.value;

                break;
            case Yarn.Value.Type.Bool:

                bool b = false;

                bool.TryParse(variable.value, out b);

                value = b;

                break;
            case Yarn.Value.Type.Variable:

                // We don't support assigning default variables from other variables
                // yet
                Debug.LogErrorFormat("Can't set variable {0} to {1}: You can't " +
                    "set a default variable to be another variable, because it " +
                    "may not have been initialised yet.", variable.name, variable.value);
                continue;

            case Yarn.Value.Type.Null:

                value = null;

                break;
            default:
                throw new System.ArgumentOutOfRangeException ();
            }

            var v = new Yarn.Value(value);

            SetValue ("$" + variable.name, v);
        }
    }
コード例 #12
0
 public override float GetNumberVariable(string variableName, bool includeLeading = true)
 {
     Yarn.Value yarnValue = GetObjectValue(variableName, includeLeading);
     return(yarnValue.AsNumber);
 }
コード例 #13
0
 public void Add(string _key, Yarn.Value _value)
 {
     variables.Add(_key, _value);
 }
コード例 #14
0
        public virtual void SetValue(string variableName, float floatValue)
        {
            Value value = new Yarn.Value(floatValue);

            this.SetValue(variableName, value);
        }
コード例 #15
0
        public override void SetValue(string variableName, bool boolValue)
        {
            Value boolVal = new Yarn.Value(boolValue);

            variables[variableName] = boolVal;
        }
コード例 #16
0
        public override void SetValue(string variableName, float floatValue)
        {
            Value fltVal = new Yarn.Value(floatValue);

            variables[variableName] = fltVal;
        }
コード例 #17
0
        public override void SetValue(string variableName, string stringValue)
        {
            Value strVal = new Yarn.Value(stringValue);

            variables[variableName] = strVal;
        }
コード例 #18
0
        // Update is called once per frame
        void Update()
        {
            //Turn on/off barrier when moving
            if (barrier)
            {
                barrier.enabled = !IsMoving();
            }

            //Look rotation
            if (ForceLookAtTarget)
            {
                var v         = ForceLookAtTarget.transform.position - transform.position;
                var rot       = Quaternion.LookRotation(v.normalized);
                var targetRot = Quaternion.Euler(0, rot.eulerAngles.y, 0);
                transform.rotation = Quaternion.Lerp(targetRot, transform.rotation, 0.1f);

                if (Vector3.Dot(v, transform.forward) > 0.9f)
                {
                    ForceLookAtTarget = null;                                                           //If we're looking at our target, stop following
                }
            }

            if (IsMoving())
            {
                //Animator stuff
                if (GetComponent <ThirdPersonUserControl>())
                {
                    myAnim.SetFloat("Forward", agent.velocity.sqrMagnitude);
                }
                if (myAnim)
                {
                    myAnim.SetFloat("Walking", agent.velocity.sqrMagnitude);
                }


                if (Vector3.Distance(transform.position, agent.destination) < destinationRange)
                {
                    if (gameObject.name == "Kim" && target.GetComponent <OW_Character>().Name == "Charlie")
                    {
                        string startNode = gameObject.GetComponent <OW_NPC>().StartNode;
                        //dialogue.GetComponent<DialogueRunner>().StartDialogue(startNode);
                    }



                    if (shouldDestroy)
                    {
                        Destroy(gameObject, 1);
                        Debug.Log("Destroying " + gameObject.name);
                    }

                    if (gameObject.name == "Luca")
                    {
                        if (target.gameObject.name == "PointA")
                        {
                            movetopoint("TownHallExt", "no");
                        }
                        else if (target.gameObject.name == "TownHallExt")
                        {
                            Yarn.Value biStage = dialogue.GetComponent <ExampleVariableStorage>().GetValue("$biStage");
                            int        stage   = (int)biStage.AsNumber;
                            if (stage == 10)
                            {
                                GetComponent <ActivateCharacter>().setMesh(false, true);
                                stopMoving();
                            }
                        }
                    }
                    else
                    {
                        print(gameObject.name + " at destination");
                        stopMoving();
                    }
                }
            }
        }
コード例 #19
0
        public virtual void SetValue(string variableName, string boolValue)
        {
            Value value = new Yarn.Value(boolValue);

            this.SetValue(variableName, value);
        }
コード例 #20
0
 public override string GetStringVariable(string variableName, bool includeLeading = true)
 {
     Yarn.Value yarnValue = GetObjectValue(variableName, includeLeading);
     return(yarnValue.AsString);
 }