コード例 #1
0
ファイル: SaveLoad.cs プロジェクト: Zariay/FiveFoldUI
    public void Load()
    {
        if(File.Exists(Application.persistentDataPath + "/saveFile.dat"))
        {
            BinaryFormatter binary = new BinaryFormatter();
            FileStream fstream = File.Open(Application.persistentDataPath + "/saveFile.dat", FileMode.Open);
            Data data = (Data)binary.Deserialize(fstream);
            fstream.Close();

            StateOfGame = data.StateOfGame;
            HorizontalSpawner = data.HorizontalSpawner;
            VerticalSpawner = data.VerticalSpawner;
            SceneName = data.SceneName;
            Beats[StateOfGame].BeginningPlatform = data.Beats[data.StateOfGame].BeginningPlatform;
            Beats[StateOfGame].CollectableBoost = data.Beats[data.StateOfGame].CollectableBoost;
            Beats[StateOfGame].endlingPlatform = data.Beats[data.StateOfGame].endlingPlatform;
            Beats[StateOfGame].ObstacleInstances = data.Beats[data.StateOfGame].ObstacleInstances;

            InitialPlayerPosX = data.InitialPlayerPosX;
            InitialPlayerPosY = data.InitialPlayerPosY;
            InitialPlayerPosZ = data.InitialPlayerPosZ;

            InitialEvaPosX = data.InitialEvaPosX;
            InitialEvaPosY = data.InitialEvaPosY;
            InitialEvaPosZ = data.InitialEvaPosZ;
        }
    }
コード例 #2
0
    public void Initialize(GameObject[] ObstacleInstances, GameObject BeginningPlatform)
    {
        Instance = this;

        ManagedPlatforms = new List<ObstacleMovement>();

        for (int i = 0; i < NumberOfObstacles; ++i)
        {
            GameObject newObstacle = Instantiate(ObstacleInstances[Random.Range(0, ObstacleInstances.Length)]);
            newObstacle.SetActive(false);
            newObstacle.transform.parent = transform;
            ManagedPlatforms.Add(newObstacle.GetComponent<ObstacleMovement>());
            ManagedPlatforms[i].SetSpeed(Speed);
        }

        IndexToSpawn = 0;
        Playing = true;
        Vector3 Spawn_platform = new Vector3(EvaPosition.position.x, 0.0f, 0.0f);
        ManagedPlatforms[(IndexToSpawn++ % NumberOfObstacles)].Spawn(Spawn_platform);
        CurrentPlatform = 0;

        GameObject beginningObstacle = (GameObject)Instantiate(BeginningPlatform);
        beginningObstacle.transform.parent = transform;
        Vector3 End = beginningObstacle.GetComponent<ObstacleMovement>().GetEndPoint();
        End.x -= Offset;
        Spawn_platform = new Vector3(EvaPosition.position.x - End.x, 0.0f, 0.0f);
        beginningObstacle.GetComponent<ObstacleMovement>().Spawn(Spawn_platform);
    }
コード例 #3
0
    public void Reinitialize(GameObject[] ObstacleInstances)
    {
        Instance = this;
        Vector3 End = ManagedPlatforms[CurrentPlatform % NumberOfObstacles].GetEndPoint();
        End.x -= Offset;

        Destroy();
        ManagedPlatforms = new List<ObstacleMovement>();

        for (int i = 0; i < NumberOfObstacles; ++i)
        {
            GameObject newObstacle = Instantiate(ObstacleInstances[Random.Range(0, ObstacleInstances.Length)]);
            newObstacle.SetActive(false);
            newObstacle.transform.parent = transform;
            ManagedPlatforms.Add(newObstacle.GetComponent<ObstacleMovement>());
            ManagedPlatforms[i].SetSpeed(Speed);
        }
        IndexToSpawn = 0;

        CurrentPlatform = IndexToSpawn;
        Vector3 Spawn_platform = new Vector3(End.x, End.y, 0.0f);
        ManagedPlatforms[((IndexToSpawn++ % NumberOfObstacles))].Spawn(Spawn_platform);
    }
コード例 #4
0
ファイル: SaveLoad.cs プロジェクト: Zariay/FiveFoldUI
    public void Start()
    {
        if (SaveLoadManager == null)
        {
            DontDestroyOnLoad(SaveLoadManager);
            SaveLoadManager = this;
        }
        else if (SaveLoadManager != this)
            Destroy(gameObject);

        Manager = FindObjectOfType<GameManager>();
        Player = FindObjectOfType<PlayerController>();
        Eva = GameObject.FindGameObjectWithTag("Eva");
        PlatformSpawner = FindObjectOfType<SpawnManager>();
        HorizontalSpawner = PlatformSpawner.GetComponent<HorizontalSpawner>();
        VerticalSpawner = PlatformSpawner.GetComponent<VerticalSpawner>();
    }