Esempio n. 1
0
    public void LoadDefault(WorldInfo info = null)
    {
        if (info != null)
        {
            playerLocation.position = info.playerPos;
            randX  = info.seeds[0]; randY = info.seeds[1]; randZ = info.seeds[2];
            gRandX = info.seeds[3]; gRandY = info.seeds[4]; gRandZ = info.seeds[5];
        }
        else
        {
            randX  = UnityEngine.Random.Range(-100000f, 100000f);
            randY  = UnityEngine.Random.Range(-100000f, 100000f);
            randZ  = UnityEngine.Random.Range(-100000f, 100000f);
            gRandX = UnityEngine.Random.Range(-100000f, 100000f);
            gRandY = UnityEngine.Random.Range(-100000f, 100000f);
            gRandZ = UnityEngine.Random.Range(-100000f, 100000f);
            ChunkManager.worldInfo =
                new WorldInfo(new float[] { randX, randY, randZ, gRandX, gRandY, gRandZ });
        }
        string path = Application.streamingAssetsPath;

        string[] dirs = Enum.GetNames(NPCType.goblin.GetType());
        foreach (string dir in dirs)
        {
            Chats  chatD = new Chats();
            String dir2  = path + "/chats/" + dir + "/chat";
            bool   brk   = false;
            for (int i = 0; !brk; i++)
            {
                string[] fileData = getData(dir2 + i + ".txt", out brk).Split("\n"[0]);
                if (!brk)
                {
                    chatD.AddChat(fileData);
                }
            }
            npcChats.Add(Path.GetFileName(dir), chatD);
        }
        bool     noth;
        string   data      = getData(path + "/items.json", out noth);
        ItemList listItems = JsonUtility.FromJson <ItemList>(data);

        listItems.weapons.ForEach(w => items.Add(w.name, new IWeapon(w)));
        listItems.armours.ForEach(a => items.Add(a.name, new IArmor(a)));
        listItems.placeAbles.ForEach(p => items.Add(p.name, new IPlaceable(p)));
        listItems.consumables.ForEach(c => items.Add(c.name, new IConsume(c)));
        StartCoroutine(doCheck(pickups, 0f));
        StartCoroutine(doCheck(enemiesL, -5f));
    }