//-------------------------------------------------------------------------
        // Condition API
        //-------------------------------------------------------------------------
        public override bool IsMet()
        {
            try {
                switch (this.Type)
                {
                case SupportedType.Integer:
                    return(VSave.Get <int>(Folder, Key) == ExpectedInt);

                case SupportedType.Float:
                    return(VSave.Get <float>(Folder, Key) == ExpectedFloat);

                case SupportedType.String:
                    return(VSave.Get <string>(Folder, Key) == ExpectedString);

                case SupportedType.Boolean:
                    return(VSave.Get <bool>(Folder, Key) == ExpectedBool);

                default:
                    return(false);
                }
            } catch (Exception e) {
                Debug.LogWarning(e.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        // Storable API
        //-------------------------------------------------------------------------
        public void Store()
        {
            string folder = StaticFolders.BEHAVIOR;
            string key    = guid.ToString() + Keys.SOLVED;

            VSave.Set(folder, key, solved);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Store the animator's state.
        /// </summary>
        public void Store()
        {
            string key   = guid.ToString() + Keys.PARTICLES_ENABLED;
            bool   value = isEmitting;

            VSave.Set(StaticFolders.ANIMATION, key, value);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Store information about a single animation parameter.
        /// </summary>
        /// <param name="param">The animation parameter to store.</param>
        private void StoreParameter(AnimatorControllerParameter param)
        {
            string  key   = guid.ToString() + "_" + param.name;
            dynamic value = null;

            // Set the value based on the parameter type.
            switch (param.type)
            {
            case AnimatorControllerParameterType.Int: {
                key  += Keys.ANIM_INT;
                value = anim.GetInteger(param.name);
                break;
            }

            case AnimatorControllerParameterType.Bool: {
                key  += Keys.ANIM_BOOL;
                value = anim.GetBool(param.name);
                break;
            }

            case AnimatorControllerParameterType.Float: {
                key  += Keys.ANIM_FLOAT;
                value = anim.GetFloat(param.name);
                break;
            }

            default: return; // Triggers fire one off. They don't need to be stored.
            }

            if (value != null)
            {
                VSave.Set(StaticFolders.ANIMATION, key, value);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Try to load the current dialog from the save file.
        /// </summary>
        private void LoadDialog()
        {
            if (GUID != null)
            {
                string key = GUID.ToString() + Keys.CURRENT_DIALOG;

                if (VSave.Get(StaticFolders.DIALOGS, key, out byte[] bytes))
Exemplo n.º 6
0
        //-------------------------------------------------------------------------
        // Unity API
        //-------------------------------------------------------------------------
        protected virtual void Awake()
        {
            key = string.IsNullOrEmpty(key) ? Name : key;

            if (!string.IsNullOrEmpty(key))
            {
                if (VSave.Get(StaticFolders.PEOPLE, key, out bool collected) && collected)
                {
                    base.OnCollected();
                    DisableComponents();
                }
            }
            else
            {
                Debug.LogWarning("Lost person \"" + name + "\" is missing the name property!");
            }

            behaviours = new List <Behaviour>();
            renderers  = new List <Renderer>();
            foreach (Behaviour behavior in GetComponents <Behaviour>())
            {
                if (behavior != this)
                {
                    behaviours.Add(behavior);
                }
            }

            foreach (Renderer renderer in GetComponents <Renderer>())
            {
                if (renderer != this)
                {
                    renderers.Add(renderer);
                }
            }
        }
Exemplo n.º 7
0
        //-------------------------------------------------------------------------
        // Public Interface
        //-------------------------------------------------------------------------

        /// <summary>
        /// Start playing the game.
        /// </summary>
        public void PlayGame()
        {
            VSave.Reset();
            VSave.CreateSlot("demo");
            VSave.ChooseSlot("demo");
            GameManager.Player?.ClearInventory();
            TransitionManager.MakeTransition(sceneName, spawnName);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Retrieve the active status of a single game object.
        /// </summary>
        /// <param name="guid">the global ID of the game object to load.</param>
        private void RetrieveObject(GuidReference guid)
        {
            string key = guid.ToString() + Keys.ACTIVE;

            if (VSave.Get(StaticFolders.BEHAVIOR, key, out bool value))
            {
                guid.gameObject.SetActive(value);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Store the animator's state.
        /// </summary>
        private void StoreState()
        {
            int hash = curState.fullPathHash;

            string key    = guid.ToString() + Keys.ANIM_STATE;
            string folder = StaticFolders.ANIMATION;

            VSave.Set(folder, key, hash);
        }
Exemplo n.º 10
0
        //-------------------------------------------------------------------------
        // Storable API
        //-------------------------------------------------------------------------

        public void Store()
        {
            string folder = StaticFolders.ANIMATION;
            string key    = guid.ToString() + Keys.POSITION;

            float[] values = new float[] { transform.position.x, transform.position.y, transform.position.z };

            VSave.Set(folder, key, values);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Retrieve whether or not each component on the object is enabled.
 /// </summary>
 public void Retrieve()
 {
     if (VSave.Get(StaticFolders.BEHAVIOR, keys, out List <bool> values))
     {
         for (int i = 0; i < values.Count; i++)
         {
             ComponentsToTrack[i].enabled = values[i];
         }
     }
 }
Exemplo n.º 12
0
        //-------------------------------------------------------------------------
        // Storable API
        //-------------------------------------------------------------------------
        /// <summary>
        /// Store whether or not each component on the object is enabled.
        /// </summary>
        public void Store()
        {
            List <bool> enabledList = new List <bool>();

            foreach (MonoBehaviour comp in ComponentsToTrack)
            {
                enabledList.Add(comp.enabled);
            }

            VSave.Set(StaticFolders.BEHAVIOR, keys, enabledList);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Load the previous animator state.
        /// </summary>
        private void RetrieveState()
        {
            string key    = guid.ToString() + Keys.ANIM_STATE;
            string folder = StaticFolders.ANIMATION;

            var state = anim.GetCurrentAnimatorStateInfo(0);

            if (VSave.Get(folder, key, out int stateHashCode))
            {
                anim.Play(stateHashCode);
            }
        }
Exemplo n.º 14
0
 //-------------------------------------------------------------------------
 // Collectible API
 //-------------------------------------------------------------------------
 public override void OnCollected()
 {
     base.OnCollected();
     if (!string.IsNullOrEmpty(key))
     {
         VSave.Set(StaticFolders.PEOPLE, key, true);
         DisableComponents();
     }
     else
     {
         Debug.LogWarning("Lost person \"" + name + "\" is missing the name property! Collection not saved!");
     }
 }
Exemplo n.º 15
0
        //-------------------------------------------------------------------------
        // Storable API
        //-------------------------------------------------------------------------

        /// <summary>
        /// Retrieve state information.
        /// </summary>
        public void Retrieve()
        {
            string key = guid.ToString() + Keys.PARTICLES_ENABLED;

            if (VSave.Get(StaticFolders.ANIMATION, key, out bool value))
            {
                if (value)
                {
                    particles.Play();
                }
                else
                {
                    particles.Stop();
                }
            }
        }
Exemplo n.º 16
0
        //-------------------------------------------------------------------------
        // Unity API
        //-------------------------------------------------------------------------
        private void Awake()
        {
            GuidComponent guidComponent = gameObject.GetComponent <GuidComponent>();

            if (guidComponent != null)
            {
                guid = guidComponent.GetGuid().ToString();

                if (VSave.Get <bool>(StaticFolders.DESTRUCTIBLE, guid + Keys.KEEP_DESTROYED))
                {
                    Destroy(this.gameObject, Delay);
                }
            }
            else
            {
                Debug.LogWarning("SelfDestructing object \"" + gameObject.name + "\" needs a GuidComponent!");
            }
        }
Exemplo n.º 17
0
        public void Retrieve()
        {
            string folder = StaticFolders.BEHAVIOR;
            string key    = guid.ToString() + Keys.SOLVED;

            if (VSave.Get(folder, key, out bool value))
            {
                solved = value;

                // Resolve the puzzle if it's already been solved.
                if (solved)
                {
                    foreach (PuzzleElement element in Elements)
                    {
                        if (element.Solvable)
                        {
                            element.Solve();
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Load the previous state of an animation parameter
        /// </summary>
        /// <param name="param">The animation parameter to load.</param>
        private void RetrieveParameter(AnimatorControllerParameter param)
        {
            string key    = guid.ToString() + "_" + param.name;
            string folder = StaticFolders.ANIMATION;

            // Set the value based on the parameter type.
            switch (param.type)
            {
            case AnimatorControllerParameterType.Int: {
                key += Keys.ANIM_INT;
                if (VSave.Get(folder, key, out int value))
                {
                    anim.SetInteger(param.name, value);
                }
                break;
            }

            case AnimatorControllerParameterType.Bool: {
                key += Keys.ANIM_BOOL;
                if (VSave.Get(folder, key, out bool value))
                {
                    anim.SetBool(param.name, value);
                }
                break;
            }

            case AnimatorControllerParameterType.Float: {
                key += Keys.ANIM_FLOAT;
                if (VSave.Get(folder, key, out float value))
                {
                    anim.SetFloat(param.name, value);
                }
                break;
            }

            default: return; // Triggers fire one off. They don't need to be stored.
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Quit playing the game.
 /// </summary>
 public void QuitGame()
 {
     VSave.Delete("demo");
     Application.Quit();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Mark this object as permanently destroyed. This means the object won't
 /// respawn when you return to the scene.
 /// </summary>
 public void KeepDestroyed()
 {
     VSave.Set(StaticFolders.DESTRUCTIBLE, guid + Keys.KEEP_DESTROYED, true);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Store the active status of a single game object.
 /// </summary>
 /// <param name="guid">The global ID of the game object to store.</param>
 private void StoreObject(string key)
 {
     VSave.Set(StaticFolders.BEHAVIOR, key, trackedObjects[key]);
 }
Exemplo n.º 22
0
        public void Retrieve()
        {
            string folder = StaticFolders.ANIMATION;
            string key    = guid.ToString() + Keys.POSITION;

            if (VSave.Get(folder, key, out float[] values))
Exemplo n.º 23
0
 //-------------------------------------------------------------------------
 // Storable API
 //-------------------------------------------------------------------------
 public void Store()
 {
     VSave.Set(StaticFolders.DIALOGS, Target.ToString() + Keys.CURRENT_DIALOG, Dialog.ToByteArray());
 }