Example #1
0
    void SummonAll()
    {
        ImportDat sr = dat;

        while (!sr.EndOfStream)
        {
            string line = sr.ReadLine();
            if (line [0] == '/' || line.Length < 1)
            {
                continue;
            }
            string[]   parts = line.Split(';');
            GameObject go    = new GameObject(parts [0], typeof(SpriteRenderer), typeof(CircleCollider2D), typeof(Rigidbody2D));
            go.transform.position = new Vector2(float.Parse(parts [6]), float.Parse(parts [7]));
            go.GetComponent <Rigidbody2D> ().bodyType     = RigidbodyType2D.Dynamic;
            go.GetComponent <Rigidbody2D> ().mass         = float.Parse(parts [2]);
            go.GetComponent <Rigidbody2D> ().drag         = float.Parse(parts [3]);
            go.GetComponent <Rigidbody2D> ().angularDrag  = float.Parse(parts [4]);
            go.GetComponent <Rigidbody2D> ().gravityScale = 0f;
            go.GetComponent <CircleCollider2D> ().radius  = float.Parse(parts [5]);
            Sprite sprite = world.CharacterSprites [int.Parse(parts [1])];
            Debug.Log("Loaded new Sprite called: " + sprite.name);
            go.GetComponent <SpriteRenderer> ().sprite = sprite;
            world.AddNewCharacter(go);
        }
    }