internal static ObjectTransport CreateNewObjectTransportUDPclient()
        {
            var udpClient      = new NetworkChannel.UDP.UDPClientChannel();
            var jsonSerializer = new JSONserializer();

            return(new ObjectTransport(udpClient, jsonSerializer));
        }
Beispiel #2
0
    void Start()
    {
        JSONserializer json = new JSONserializer();

        locations = json.LoadLocations(PlayerInfo.currentPlanet.locations, PlayerInfo.currentPlanet.name);
        float planetScale = PlayerInfo.currentPlanet.planetScale; //Size of the planet

        planetMesh.transform.localScale = new Vector3(planetScale, planetScale, planetScale);
        planetMesh.material.SetTexture("_MainTex", PlayerInfo.currentPlanet.texture); //chnages the texture of the planet
        itemLibrary itL = new itemLibrary();

        itL.CreateLibraryFile();    //Temporary test, creates the JSON file of all the available items in the game

        foreach (Location location in locations)
        {
            GameObject gObject   = Instantiate(locationIcon);
            Vector3    planetPos = planetMesh.transform.position;
            gObject.transform.position = planetPos + location.position * planetScale * 0.5f;
            gObject.transform.parent   = planetMesh.transform;
            gObject.GetComponent <LocationIcon>().location = location;

            gObject.transform.rotation = Quaternion.LookRotation(-location.position);
        }
        float f = Random.Range(0.0f, 360.0f);

        planetMesh.transform.Rotate(Vector3.up, f);
        planetLight.transform.Rotate(Vector3.up, -f);
    }
Beispiel #3
0
    public void setupSystem()
    {
        JSONserializer json = new JSONserializer();

        planets = json.LoadAllPlanets();
        if (PlayerInfo.currentPlanet == null && planets.Count > 0)
        {
            PlayerInfo.currentPlanet = planets[0];
        }
        foreach (GameObject gObject in planetObjects)
        {
            Destroy(gObject);
        }
        planetObjects = new List <GameObject>();
        foreach (Planet planet in planets)
        {
            planet.texture = textures[planet.textureInt];
            GameObject gObject = Instantiate(tempPlanetObject.gameObject);
            gObject.transform.position = planet.boardPosition;
            gObject.GetComponent <PlanetLocationIcon>().planet = planet;
            planetObjects.Add(gObject);
        }

        QuestManager.RefreshQuestList();
    }
Beispiel #4
0
    public void DeleteAllPlanets()
    {
        JSONserializer json = new JSONserializer();

        json.DeleteFolder(Application.persistentDataPath + "/Planets/Generated");
        json.DeleteFolder(Application.persistentDataPath + "/Locations");
        json.DeleteFolder(Application.persistentDataPath + "/Quests");
        json.DeleteFolder(Application.persistentDataPath + "/Data");
    }
Beispiel #5
0
    public void GenerateNewInventory(int amount)
    {
        itemLibrary    itL     = new itemLibrary();
        JSONserializer json    = new JSONserializer();
        List <Item>    itemLib = json.LoadItemLibrary(); //The list of all available items in the game, this should be moved somewhere where it won't be reloaded repeatedly

        int libraryLength = itemLib.Count;

        for (int i = 0; i < amount; i++)
        {
            int index = Random.Range(0, libraryLength);
            AddItem(itemLib[index]);
        }
    }
Beispiel #6
0
    public static Quest GenerateRandomQuest()
    {
        Quest        quest    = new Quest();
        questItemReq itemReqs = new questItemReq(true);

        quest.questGoals.Add(itemReqs);

        quest.questID                    = nextQuestID;
        quest.questDescription           = QuestDescription(itemReqs, quest);
        quest.characterQuestIntroduction = quest.questDescription; //This should be changed
        //Debug.Log(quest.questID);
        NextQuestID -= 1;                                          //Iterate to make sure that the same quest ID isn't reused

        JSONserializer json = new JSONserializer();

        json.SaveFile(quest);
        return(quest);
    }
Beispiel #7
0
    public static void LoadQuest(int id)
    {
        if (quests == null)
        {
            JSONserializer json = new JSONserializer();
            quests = json.loadQuests();
        }
        string   location = Application.persistentDataPath + "/Data/GameData.txt";
        string   s        = File.ReadAllText(location);
        GameData data     = JsonUtility.FromJson <GameData>(s);

        nextQuestID = data.questID;
        //foreach (Quest quest in quests)
        //{
        //    Debug.Log(quest.questID);
        //}
        Debug.Log(nextQuestID);
    }
Beispiel #8
0
    public void CreateNew(List <Texture2D> textures, Vector2 potision)
    {
        float  vertical     = Camera.main.orthographicSize;
        float  horizontal   = vertical * Screen.width / Screen.height;
        int    textureIndex = Random.Range(0, textures.Count);
        Planet planet       = new Planet()
        {
            name          = TempLibrary.randomPlanetNames[Random.Range(0, TempLibrary.randomPlanetNames.Count)], //name = Random.Range(0, 9999).ToString(),
            boardPosition = potision,
            textureInt    = textureIndex,
            planetScale   = Random.Range(4.0f, 10.0f)
        };

        planet.majorityPopString = TempLibrary.randomRaces[Random.Range(0, TempLibrary.randomRaces.Count)];
        int randomSize = Random.Range(1, 4);

        //print(randomSize);
        planet.minorityPopsString = "the " + TempLibrary.randomRaces[Random.Range(0, TempLibrary.randomPlanetNames.Count)];
        for (int i = 1; i < randomSize; i++)
        {
            planet.minorityPopsString += ", the " + TempLibrary.randomRaces[Random.Range(0, TempLibrary.randomPlanetNames.Count)];
        }
        planet.minorityPopsString += " and the " + TempLibrary.randomRaces[Random.Range(0, TempLibrary.randomPlanetNames.Count)];

        JSONserializer json          = new JSONserializer();
        int            locationCount = Random.Range(2, 5);

        for (int i = 0; i < locationCount; i++)
        {
            Location location = new Location();
            location.position = Random.onUnitSphere;
            location.GenerateNewLocation();
            location.planetName = planet.name;
            planet.locations.Add(location.name.ToString());
            json.SaveLocation(location);
        }

        Debug.Log(json.SaveFile(planet)); //Saves planet as a file which returns a string
    }
        public static ObjectTransport CreateNewObjectTransport(INetworkChannel channel)
        {
            var jsonSerializer = new JSONserializer();

            return(new ObjectTransport(channel, jsonSerializer));
        }
Beispiel #10
0
    public static void RefreshQuestList()
    {
        JSONserializer json = new JSONserializer();

        quests = json.loadQuests();
    }