Exemplo n.º 1
0
    public override Dictionary <string, object> Save()
    {
        Dictionary <string, object> dataDictionary = base.Save();

        //Save armour/weapons slots
        if (armourSlot.equippedSlot.InventoryItem != null && armourSlot.equippedSlot.InventoryItem.Item)
        {
            string path = armourSlot.equippedSlot.InventoryItem.Item
                          .AssetPath.Replace("Resources/", "").Replace(".asset", "");
            DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "armourSlot", path);
        }
        if (leftWeaponSlot.equippedSlot.InventoryItem != null && leftWeaponSlot.equippedSlot.InventoryItem.Item)
        {
            string path = leftWeaponSlot.equippedSlot.InventoryItem.Item
                          .AssetPath.Replace("Resources/", "").Replace(".asset", "");
            DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "leftWeapon", path);
        }
        if (rightWeaponSlot.equippedSlot.InventoryItem != null && rightWeaponSlot.equippedSlot.InventoryItem.Item)
        {
            string path = rightWeaponSlot.equippedSlot.InventoryItem.Item
                          .AssetPath.Replace("Resources/", "").Replace(".asset", "");
            DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "rightWeapon", path);
        }

        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);
        return(dataDictionary);
    }
Exemplo n.º 2
0
    public override Dictionary <string, object> Save()
    {
        var dataDictionary = base.Save();

        //save json to file
        var UUID = GetComponent <UUID>()?.ID;

        if (string.IsNullOrWhiteSpace(UUID))
        {
            Debug.LogError("CharacterBase doesn't have an UUID (Can't load data from json)");
            return(dataDictionary);
        }

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "SenseRange", SenseRange);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "AngleOfVision", AngleOfVision);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "WalkDistance", WalkDistance);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "AttackDistance", AttackDistance);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "CurrentPatrolPoint", CurrentPatrolPoint);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "NextPatrolPoint", NextPatrolPoint);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "currentDestination", currentDestination);

        //TODO save transforms and stack of states
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, UUID);
        return(dataDictionary);
    }
Exemplo n.º 3
0
    public virtual Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        //TODO save path of items
        Dictionary <string, int> itemPaths = new Dictionary <string, int>();

        foreach (var inventoryItem in items)
        {
            var item = inventoryItem.InventoryItem?.Item;
            if (item)
            {
                itemPaths.Add(item.AssetPath.Replace("Resources/", "").Replace(".asset", ""), inventoryItem.InventoryItem.Quantity);
            }
        }
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "items", itemPaths);

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
Exemplo n.º 4
0
    public override Dictionary <string, object> Save()
    {
        var dataDictionary = base.Save();

        var UUID = GetComponent <UUID>()?.ID;

        if (string.IsNullOrWhiteSpace(UUID))
        {
            Debug.LogError("CharacterBase doesn't have an UUID (Can't load data from json)");
            return(dataDictionary);
        }

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "velocity", playerVelocity);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "onGround", onGround);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "isCrouching", isCrouching);

        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, UUID);
        return(dataDictionary);
    }
Exemplo n.º 5
0
    public Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "AlertMeter", AlertMeter);

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
    public Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        //save transform
        DataPersitanceHelpers.SaveTransform(ref dataDictionary, transform, "persistantTransform");

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
    public Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "TriggeredPositionOffset", TriggeredPositionOffset);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "targetPosition", targetPosition);

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
Exemplo n.º 8
0
    public Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "TargetPortalIndex", TargetPortalIndex);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "previousTargetPortal", previousTargetPortal);

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
    public Dictionary <string, object> Save()
    {
        //create new dictionary to contain data for characterbase
        Dictionary <string, object> dataDictionary = new Dictionary <string, object>();

        if (!uuid)
        {
            return(dataDictionary);
        }

        //Load currently saved values
        DataPersitanceHelpers.LoadDictionary(ref dataDictionary, uuid.ID);

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "IsInteractable", IsInteractable);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "Toggle", Toggle);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "triggered", triggered);

        //save json to file
        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);

        return(dataDictionary);
    }
Exemplo n.º 10
0
    public override Dictionary <string, object> Save()
    {
        Dictionary <string, object> dataDictionary = base.Save();

        //save left hand
        Dictionary <int, string> leftHandPaths = new Dictionary <int, string>();

        for (int i = 0; i < leftHand.Length; i++)
        {
            EquipSlot slot = leftHand[i];
            if (slot.equippedSlot.InventoryItem != null && slot.equippedSlot.InventoryItem.Item)
            {
                leftHandPaths.Add(i, slot.equippedSlot.InventoryItem.Item
                                  .AssetPath.Replace("Resources/", "").Replace(".asset", ""));
            }
        }

        //save right hand
        Dictionary <int, string> rightHandPaths = new Dictionary <int, string>();

        for (int i = 0; i < rightHand.Length; i++)
        {
            EquipSlot slot = rightHand[i];
            if (slot.equippedSlot.InventoryItem != null && slot.equippedSlot.InventoryItem.Item)
            {
                rightHandPaths.Add(i, slot.equippedSlot.InventoryItem.Item
                                   .AssetPath.Replace("Resources/", "").Replace(".asset", ""));
            }
        }

        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "leftHand", leftHandPaths);
        DataPersitanceHelpers.SaveValueToDictionary(ref dataDictionary, "rightHand", rightHandPaths);

        DataPersitanceHelpers.SaveDictionary(ref dataDictionary, uuid.ID);
        return(dataDictionary);
    }