Beispiel #1
0
    private void SaveObjects()
    {
        CSceneSafeLoad new_scene_to_save = new CSceneSafeLoad(_scene_name);
        var            objects_to_save   = GameObject.FindGameObjectsWithTag("ToSave");
        var            number_of_objects = objects_to_save.Length;

        for (int i = 0; i < number_of_objects; i++)
        {
            Transform tr     = objects_to_save[i].transform;
            SRVector  coords = new SRVector(tr.position, tr.rotation);

            if (objects_to_save[i].GetComponent <PlayerController>() != null)
            {
                new_scene_to_save.AddPlayer("Player", coords);
            }

            if (objects_to_save[i].GetComponent <CoinController>() != null)
            {
                new_scene_to_save.AddCoin("Coin", coords);
            }

            if (objects_to_save[i].GetComponent <GoalController>() != null)
            {
                new_scene_to_save.AddGoal("Goal", coords);
            }

            if (objects_to_save[i].GetComponent <EnemyController>() != null)
            {
                new_scene_to_save.AddEnemy("Enemy", coords);
            }

            if (objects_to_save[i].GetComponent <PlatformController>() != null)
            {
                new_scene_to_save.AddPlatform("Platform", coords);
            }
        }

        _fm.JsonToFile(new_scene_to_save, _scene_name);
    }