Ejemplo n.º 1
0
    public void AddShadowsIntoTheBorrle(int shadowsBottleId, int newShadowId)
    {
        ShadowBorrleData shadowBorrleData = SaveSystem.LoadShadowBorrleData(shadowsBottleId);
        bool             resultOfAdding   = shadowBorrleData.AddShadow(newShadowId);

        if (resultOfAdding)
        {
            Debug.Log("Тень была сохранена");
            SaveSystem.SaveShadowBorrleData(shadowsBottleId, shadowBorrleData.listOfShadows);
        }
    }
Ejemplo n.º 2
0
    public void AddShadow(int shadowId)
    {
        ShadowBorrleData shadowBorrleData = SaveSystem.LoadShadowBorrleData(items[currentSelectedItemIndex].id);

        if (shadowBorrleData.AddShadow(shadowId))
        {
            Debug.Log($"Тень была добавлена в флягу с id {items[currentSelectedItemIndex].id}");
            SaveSystem.SaveShadowBorrleData(items[currentSelectedItemIndex].id, shadowBorrleData.listOfShadows);
        }
        else
        {
            Debug.Log($"Фляга с id {items[currentSelectedItemIndex].id} заполнена");
        }
    }
Ejemplo n.º 3
0
    public static void SaveShadowBorrleData(int shadowsBottleId, int[] listOfShadows, bool setNullShadows = false)
    {
        BinaryFormatter binaryFormatter   = new BinaryFormatter();
        int             currentSessionNum = LoadSession().GetActiveSessionNum();

        if (!Directory.Exists(Application.persistentDataPath + "/saves" + $"/Session_{currentSessionNum}"))
        {
            Directory.CreateDirectory(Application.persistentDataPath + "/saves" + $"/Session_{currentSessionNum}");
        }
        string path = Application.persistentDataPath + "/saves/" + $"/Session_{currentSessionNum}/" +
                      $"shadowsBottle_{shadowsBottleId}" + ".save";

        FileStream stream = new FileStream(path, FileMode.Create);

        ShadowBorrleData data = new ShadowBorrleData(listOfShadows, setNullShadows);

        binaryFormatter.Serialize(stream, data);

        stream.Close();
    }
Ejemplo n.º 4
0
    public static ShadowBorrleData LoadShadowBorrleData(int shadowsBottleId)
    {
        int    currentSessionNum = LoadSession().GetActiveSessionNum();
        string path = Application.persistentDataPath + "/saves/" + $"/Session_{currentSessionNum}/" +
                      $"shadowsBottle_{shadowsBottleId}" + ".save";

        if (File.Exists(path))
        {
            BinaryFormatter  binaryFormatter  = new BinaryFormatter();
            FileStream       stream           = new FileStream(path, FileMode.Open);
            ShadowBorrleData shadowBorrleData = binaryFormatter.Deserialize(stream) as ShadowBorrleData;

            stream.Close();

            return(shadowBorrleData);
        }
        else
        {
            SaveShadowBorrleData(shadowsBottleId, new int[3], setNullShadows: true);
            return(new ShadowBorrleData(new int[3]));
        }
    }
Ejemplo n.º 5
0
 public void ActivateAbility()
 {
     if (wasActivated || currentSelectedItemIndex == -1)
     {
         return;
     }
     if (items[currentSelectedItemIndex].itemType == ItemType.Artifact)
     {
         Vector2      playerPosition = gameObject.transform.position;
         ArtifactData artifactData   = listsOfItmes.GetArtifactData(items[currentSelectedItemIndex].id);
         artifactData.Activate(playerPosition, windPushRadius, enemiesLayer, pushForce);
         ShadowBorrleData shadowBorrleData = SaveSystem.LoadShadowBorrleData(items[currentSelectedItemIndex].id);
         if (shadowBorrleData.HasShadows())
         {
             artifactData.Activate(gameObject.transform, listOfAllShadows.GetShadow(shadowBorrleData.GetShadowId()),
                                   GetComponentInChildren <PatrolPoint>());
             SaveSystem.SaveShadowBorrleData(items[currentSelectedItemIndex].id, shadowBorrleData.listOfShadows);
         }
         else
         {
             Debug.Log("Фляга пуста");
         }
     }
 }