Ejemplo n.º 1
0
    private void ApplyGame(Game game)
    {
        GameObject stalker_prefab = (GameObject)Resources.Load("Prefabs/Stalker");

        StalkerBehaviour[] stalkers = StalkerBehaviour.FindObjectsOfType <StalkerBehaviour> ();
        for (int i = 0; i < stalkers.Length; i++)
        {
            Destroy(stalkers[i].gameObject);
        }
        for (int g = 0; g < game.groups.Length; g++)
        {
            for (int s = 0; s < game.groups[g].stalkers.Length; s++)
            {
                Instantiate(stalker_prefab).GetComponent <StalkerBehaviour>().to_save_data = game.groups[g].stalkers[s];
            }
        }
        for (int i = 0; i < game.items.Length; i++)
        {
            GameObject pref = (GameObject)Resources.Load("ItemsObjects/Item_" + game.items[i].id);
            Instantiate(pref, game.items[i].position, Quaternion.identity);
        }
    }
Ejemplo n.º 2
0
    private Game CreateFromGame()
    {
        Game g = new Game();

        g.groups = new GroupClass[2];

        for (int i = 0; i < g.groups.Length; i++)
        {
            g.groups[i] = new GroupClass();

            g.groups[i].group = (ToSaveData.Group)i;
            List <ToSaveData>  tsd      = new List <ToSaveData>();
            StalkerBehaviour[] stalkers = StalkerBehaviour.FindObjectsOfType <StalkerBehaviour> ();
            for (int s = 0; s < stalkers.Length; s++)
            {
                if (stalkers[s].to_save_data.group == g.groups[i].group)
                {
                    tsd.Add(stalkers[s].to_save_data);
                }
            }
            g.groups[i].stalkers = tsd.ToArray();
        }

        ItemObject[] items = FindObjectsOfType <ItemObject> ();

        List <ItemSavable> savs = new List <ItemSavable> ();

        for (int i = 0; i < items.Length; i++)
        {
            savs.Add(items[i].sav);
        }

        g.items = savs.ToArray();

        return(g);
    }