Пример #1
0
    public TroutData(AITrout fish)
    {
        Vector3 fishPos = fish.transform.position;

        position = new float[]
        {
            fishPos.x, fishPos.y, fishPos.z
        };
    }
Пример #2
0
    void LoadFish()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + FISH_SUB + SceneManager.GetActiveScene().buildIndex;
        string          countPath = Application.persistentDataPath + FISH_COUNT_SUB + SceneManager.GetActiveScene().buildIndex;
        int             fishCount = 0;

        if (File.Exists(countPath))
        {
            FileStream countStream = new FileStream(countPath, FileMode.Open);

            fishCount = (int)formatter.Deserialize(countStream);
            countStream.Close();
        }
        else
        {
            Debug.LogError("Path not found in " + countPath);
        }

        for (int i = 0; i < fishCount; i++)
        {
            if (File.Exists(path + i))
            {
                FileStream stream = new FileStream(path + i, FileMode.Open);
                TroutData  data   = formatter.Deserialize(stream) as TroutData;

                stream.Close();

                Vector3 position = new Vector3(data.position[0], data.position[1], data.position[2]);

                AITrout fish = Instantiate(fishPrefab, position, Quaternion.identity);
            }
            else
            {
                Debug.LogError("Path not found in " + path + i);
            }
        }
    }