示例#1
0
    IEnumerator ShowSaveDialogCoroutine(string pathExtension, EntitySaveData entitySaveData)
    {
        yield return(FileBrowser.WaitForSaveDialog(false, Application.persistentDataPath + Path.AltDirectorySeparatorChar + pathExtension, "Save File", "Save"));

        if (FileBrowser.Success)
        {
            SavaData.Instance.Save(entitySaveData, FileBrowser.Result);
        }
    }
        /// <inheritdoc/>
        public override void Load(SaveData data)
        {
            SaveLoadUtils.BasicLoad(this, data);

            navMeshAgent.Warp(data.pos);
            sensors.ResetVision();

            EntitySaveData entitySaveData = (EntitySaveData)data;

            if (entitySaveData != null)
            {
                hp = entitySaveData.hp;
                if (Dead != entitySaveData.dead)
                {
                    if (entitySaveData.dead)
                    {
                        Kill();
                    }
                    else
                    {
                        Revive();
                    }

                    Dead = entitySaveData.dead;
                }

                switch (entitySaveData.state)
                {
                case AIStateAggresion agr:
                    SwitchState(aggresionState);
                    break;

                case AIStateAttention att:
                    SwitchState(attentionState);
                    break;

                case AIStateCover cvr:
                    SwitchState(coverState);
                    break;

                case AIStateIdle idl:
                    SwitchState(idleState);
                    break;

                case AIStateSleep slp:
                    SwitchState(sleepState);
                    break;
                }
            }
        }
示例#3
0
        ///<inheritdoc/>
        public override void Load(SaveData data)
        {
            SaveLoadUtils.BasicLoad(this, data);

            EntitySaveData entitySaveData = (EntitySaveData)data;

            if (entitySaveData != null)
            {
                hp = entitySaveData.hp;
                if (Dead != entitySaveData.dead)
                {
                    if (entitySaveData.dead)
                    {
                        Kill();
                    }
                    else
                    {
                        Revive();
                    }

                    Dead = entitySaveData.dead;
                }
            }
        }
示例#4
0
 public void ShowSaveDialog(string pathExtension, EntitySaveData entitySaveData)
 {
     StartCoroutine(ShowSaveDialogCoroutine(pathExtension, entitySaveData));
 }
示例#5
0
    public void Save(EntitySaveData entitySaveData, string path)
    {
        string jsonString = JsonUtility.ToJson(entitySaveData);

        File.WriteAllText(path, jsonString);
    }