Exemplo n.º 1
0
    public void LoadMyData()
    {
        //load separate file "actors.xml" and read the values
        var actorCollection = ActorContainer.Load(path);

        //set the dynamic digital values to the values in the file
        foreach (Actor actor in actorCollection.actors)
        {
            //set Values
            actorInformation.setName(actor.name);
            actorInformation.setGender(actor.gender);
            actorInformation.setID(actor.id);
            actorInformation.setScore(actor.score);


            tmp_actor.name   = actorInformation.getName();
            tmp_actor.gender = actorInformation.getGender();
            tmp_actor.id     = actorInformation.getID();
            tmp_actor.score  = actorInformation.getScore();
        }

        Debug.Log("Geladene ID: " + tmp_actor.id);
        Debug.Log("Geladener Name: " + tmp_actor.name);
        Debug.Log("Geladener Gender: " + tmp_actor.gender);
        Debug.Log("Geladener Score: " + tmp_actor.score);
    }
Exemplo n.º 2
0
    void Start()
    {
        firstLogin = false;
        if (Application.loadedLevel == 18)
        {
        }
        else
        {
            if (!System.IO.File.Exists(path))
            {
                System.IO.File.Create(path).Dispose();

                Actor tmp = new Actor();
                tmp.id     = 000;
                tmp.name   = "reserved";
                tmp.gender = 0;

                ActorContainer actorCollection = new ActorContainer();
                actorCollection.actors.Add(tmp);
                actorCollection.Save(path);
            }

            UpdateSize();
            if (size == 0)
            {
                Actor tmp = new Actor();
                tmp.id        = 000;
                tmp.name      = "reserved";
                tmp.gender    = 0;
                all_actors[0] = tmp;
            }
        }
    }
Exemplo n.º 3
0
    public void SaveMyData()
    {
        if (weight_text != null)
        {
            tmp_weight = float.Parse(weight_text.GetComponent <Text>().text);
        }

        //increase size +1 entry
        size = size + 1;

        //save all values in tmp_actor
        all_actors[size] = setActorValuesToSave();

        //create and add values to List that will be saved in separate file "actors.xml"
        ActorContainer actorCollection = new ActorContainer();

        //actorCollection.actors.Add(all_actors[size]);
        foreach (Actor loop_actor in all_actors)
        {
            actorCollection.actors.Add(loop_actor);
        }

        actorCollection.Save(path);
        Debug.Log("new Entry was successfull saved!");
        userCreated = true;
    }
Exemplo n.º 4
0
    private static void SaveActors(string path, ActorContainer actors)
    {
        try
        {
            string json = JsonUtility.ToJson(actors);
            Debug.Log("json " + json);
            StreamWriter sw = File.CreateText(path);
            sw.Close();

            File.WriteAllText(path, json);

            //밑은 AR을 위한 것

            foreach (ActorData data in actors.actors)
            {
                data.pos.x *= 0.01f;
                data.pos.y  = 0;
                data.pos.z *= 0.01f;
            }

            string scenename = SceneManager.GetActiveScene().name;
            string title     = Strings.title; //title 받아오기

            path = System.IO.Path.Combine(Application.persistentDataPath, scenename + title + "aractors.json");

            json = JsonUtility.ToJson(actors);

            sw = File.CreateText(path);
            sw.Close();

            File.WriteAllText(path, json);
        }
        catch { }
    }
Exemplo n.º 5
0
        internal ActorSystem(string name, ActorsConfiguration?config)
        {
            Config = config ?? ActorsConfiguration.CreateDefault();

            Name        = ActorPath.Sanitize(name);
            Location    = new ActorPath($"{ActorPath.ProtocolName}://{Name}/");
            Actors      = new Dictionary <ActorPath, ActorContainer>();
            CancelToken = new CancellationTokenSource();
            Scheduler   = new Scheduler();

            Scheduler.AssignSystem(this);

            Root = new RootSupervisor(this);
            Root.Populate(this, ActorReferences.Nobody, Location);
            var rootcontainer = new ActorContainer(new ActorSchematic(() => new RootSupervisor(this)), Location.Name, Root);

            Actors.Add(Location, rootcontainer);
            Root.CallOnCreate();

            Log = new ActorLogger(Root);

            Lost = new LostLetters(this);
            Lost.Populate(this, new LocalActorReference(this, Root.Path), new ActorPath(Location.Path, "lost-letters"));
            var lostcontainer = new ActorContainer(new ActorSchematic(() => new LostLetters(this)), "lost-letters", Lost);

            Actors.Add(Lost.Path, lostcontainer);
            Lost.CallOnCreate();

            if (!Config.ManuallyStartScheduler)
            {
                Scheduler.Start();
            }

            SystemCount++;
        }
Exemplo n.º 6
0
        public void InformActorDestruction(ActorContainer container)
        {
            lock (QueueLock)
            {
                if (Queue.Contains(container))
                {
                    BeginSessionPersistence(System.Lost);
                    Task.Run(() =>
                    {
                        Thread.CurrentThread.Name = System.Lost.Path.Path;
                        foreach (var token in container.Dump())
                        {
                            if (CancelToken.IsCancellationRequested)
                            {
                                break;
                            }

                            var lost_letter = new LostLetter(token.Sender, token.Receiver, token.Data);
                            System.Lost.ProcessMessage(token.Sender, token.Data, CancelToken.Token);
                        }
                    },
                             CancelToken.Token)
                    .ContinueWith(_ =>
                    {
                        EndSessionPersistence(System.Lost);
                    });

                    Queue.Remove(container);
                }
            }
        }
Exemplo n.º 7
0
    public void loadProfil(string name)
    {
        //load separate file "actors.xml" and read the values
        var actorCollection = ActorContainer.Load(path);

        //set the dynamic digital values to the values in the file
        foreach (Actor actor in actorCollection.actors)
        {
            if (name.Equals(actor.name))
            {
                //set Values
                actorInformation.setName(actor.name);
                actorInformation.setGender(actor.gender);
                actorInformation.setID(actor.id);
                actorInformation.setScore(actor.score);


                tmp_actor.name   = actorInformation.getName();
                tmp_actor.gender = actorInformation.getGender();
                tmp_actor.id     = actorInformation.getID();
                tmp_actor.score  = actorInformation.getScore();
            }
        }

        Debug.Log("Geladene ID: " + tmp_actor.id);
        Debug.Log("Geladener Name: " + tmp_actor.name);
        Debug.Log("Geladener Gender: " + tmp_actor.gender);
        Debug.Log("Geladener Score: " + tmp_actor.score);

        login = true;
        //SimpleTest.previousWeight = 0.0f;
        firstLogin = true;
    }
Exemplo n.º 8
0
    public static void Save(string path, ActorContainer actors)
    {
        OnBeforeSave();

        SaveActors(path, actors);

        ClearActorList();
    }
Exemplo n.º 9
0
    private static void  SaveActors(string path, ActorContainer actors)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(ActorContainer));

        FileStream stream = new FileStream(path, FileMode.Create);

        serializer.Serialize(stream, actors);

        stream.Close();
    }
Exemplo n.º 10
0
    private static void SaveActors(string path, ActorContainer actors)
    {
        string json = JsonUtility.ToJson(actors);

        StreamWriter sw = File.CreateText(path);

        sw.Close();

        File.WriteAllText(path, json);
    }
    public static void Load(string path)
    {
        actorContainer = LoadActors(path);

        foreach (ActorData data in actorContainer.actors)
        {
            EnemyMovement.Generate(data, EnemyMovement.enemyPath, data.name,
                                   data.pos, Quaternion.identity);
        }
        ClearActorList();
    }
Exemplo n.º 12
0
    public static void Load(string path)
    {
        actorContainer = LoadActors(path);

        foreach (ActorData data in actorContainer.actors)
        {
            GameController.CreateActor(data, GameController.playerPath, new Vector3(0, 0, 0), Quaternion.identity);
        }
        OnLoaded();

        ClearActorList();
    }
Exemplo n.º 13
0
    private static ActorContainer LoadActors(string path)
    {
        XmlSerializer serializer = new XmlSerializer(typeof(ActorContainer));

        FileStream stream = new FileStream(path, FileMode.Open);

        ActorContainer actors = serializer.Deserialize(stream) as ActorContainer;

        stream.Close();

        return(actors);
    }
Exemplo n.º 14
0
    private static void SaveActors(string path, ActorContainer actors)
    {
        File.WriteAllText(path, "");

        XmlSerializer serializer = new XmlSerializer(typeof(ActorContainer));

        FileStream stream = new FileStream(path, FileMode.Truncate);

        serializer.Serialize(stream, actors);



        stream.Dispose();
    }
Exemplo n.º 15
0
        public void Enqueue(ActorContainer container, ActorQueueToken token)
        {
            if (Sleeping)
            {
                Spinup();
            }

            container.Enqueue(token);

            lock (QueueLock)
            {
                Queue.Add(container);
            }
        }
Exemplo n.º 16
0
    public static void Load(string path)
    {
        if (System.IO.File.Exists(path) == true)
        {
            actorContainer = LoadActors(path);

            foreach (ActorData data in actorContainer.actors)
            {
                GameController.CreateActor(data, GameController.PlayerPath,
                                           new Vector3(data.PosX, data.PosY, data.PosZ), Quaternion.identity);
            }

            OnLoaded();
        }
    }
Exemplo n.º 17
0
    public void updateScore(string input)
    {
        //load separate file "actors.xml" and read the values
        var actorCollection = ActorContainer.Load(path);

        //set the dynamic digital values to the values in the file
        foreach (Actor actor in actorCollection.actors)
        {
            if (actor.name.Equals(input))
            {
                actor.score = actorInformation.getScore();
            }
        }
        actorCollection.Save(path);
    }
Exemplo n.º 18
0
    public static void Save(string path, ActorContainer actors)
    {
        try
        {
            OnBeforeSave();
        }
        catch (System.Exception e)
        {
            Debug.Log("No Furniture!");
        }
        //ClearSave(path);

        SaveActors(path, actors);

        ClearActorList();
    }
Exemplo n.º 19
0
 public static void ARLoad(string path)
 {
     actorContainer = LoadActors(path);
     foreach (ActorData data in actorContainer.actors)
     {
         GameController.ARCreateActor(data, data.path + "ar", data.pos, data.rot);
     }
     try
     {
         OnLoaded();
     }
     catch (System.Exception e)
     {
         Debug.Log("No Furniture!");
     }
     ClearActorList();
 }
Exemplo n.º 20
0
    public static void Load(string path)
    {
        actorContainer = LoadActors(path);

        foreach (ActorData data in actorContainer.actors)
        {
            if (data.ObjectName == "GreenAndy")
            {
                GameController.CreateActor(data, GameController.playerPath, data.pos, data.rotation);
            }

            if (data.ObjectName == "YellowAndy")
            {
                GameController.CreateActor(data, GameController.playerPath2, data.pos, data.rotation);
            }
        }

        OnLoaded();

        ClearActorList();
    }
Exemplo n.º 21
0
    public void UpdateSize()
    {
        //load separate file "actors.xml" and read the values
        var actorCollection = ActorContainer.Load(path);

        //update current size of all_actor array
        size = actorCollection.actors.Count;

        int i = 0;

        foreach (Actor actor in actorCollection.actors)
        {
            //set Values
            actorInformation.setName(actor.name);
            actorInformation.setGender(actor.gender);
            actorInformation.setID(actor.id);
            actorInformation.setScore(actor.score);

            Actor tmp = new Actor();
            tmp.name   = actorInformation.getName();
            tmp.id     = actorInformation.getID();
            tmp.gender = actorInformation.getGender();
            tmp.score  = actorInformation.getScore();

            all_actors[i] = tmp;
            if (Application.loadedLevelName == "LoadProfile" && i > 0)
            {
                Button test = Instantiate(profil);
                profil.name           = tmp.name;
                test.transform.parent = my_canvas.transform;
                test.image.rectTransform.localScale = new Vector3(1, 1, 1);
                test.image.rectTransform.sizeDelta  = new Vector2(150, 75);
                if (i > 4)
                {
                    test.image.rectTransform.localPosition = new Vector3(-250 + 170, 150 - ((i - 1 - 4) * 85), 0);
                    if (tmp.gender == 1)
                    {
                        test.image.color = kindOfBlue;
                    }
                    else if (tmp.gender == 2)
                    {
                        test.image.color = kindOfRed;
                    }
                }
                else
                {
                    test.image.rectTransform.localPosition = new Vector3(-250, 150 - ((i - 1) * 85), 0);
                    if (tmp.gender == 1)
                    {
                        test.image.color = kindOfBlue;
                    }
                    else if (tmp.gender == 2)
                    {
                        test.image.color = kindOfRed;
                    }
                }



                test.GetComponentInChildren <Text>().text = tmp.name;
            }
            i++;
        }
        //need to be decreased cause will be increased in the next save step
        if (i > 0)
        {
            size--;
        }
    }