Example #1
0
    // Use this for initialization
    void Start()
    {
        select_scene();

        GameObject   newLineGen = Instantiate(lineGerneratorPrefab);
        LineRenderer lRend      = newLineGen.GetComponent <LineRenderer>();

        lRend.positionCount = pos.Length;
        int index = 0;
        // for data bus
        List <string> nameList  = new List <string>();
        List <int>    valueList = new List <int>();

        for (int i = 0; i < pos.GetLength(0); i++)
        {
            GameObject   newLineGen_2 = Instantiate(lineGerneratorPrefab);
            LineRenderer lRend_2      = newLineGen_2.GetComponent <LineRenderer>();
            lRend_2.positionCount = pos.GetLength(1);

            for (int j = 0; j < pos.GetLength(1); j++)
            {
                // new number cube location diff from offset
                Vector3 vec = new Vector3(width * (float)pos[i, j], -height * i / pos.GetLength(0), (float)dis[i, j]);
                // final position after add all adjustment.
                Vector3 newPos = eyePosition.position + vec + offset;

                // generate number object
                GameObject projectile = Instantiate(spawnee, newPos, eyePosition.rotation);
                rotation_degree((float)pos[i, j]);
                projectile.transform.rotation = Quaternion.Euler(0, (float)rot_degree, 180);
                //projectile.transform.rotation = Quaternion.Euler(0, (float)rot[i,j], 180);
                //projectile.transform.rotation = Quaternion.Euler(0, 0, 180);

                // apply texture
                int texture_index = Random.Range(0, 10);
                projectile.GetComponent <Renderer>().material.mainTexture = textures[texture_index];

                // add canvas to be number parent
                string name = index.ToString() + 'a' + texture_index.ToString();
                projectile.name = name;

                // store object id and value to Databus
                nameList.Add(name);

                if (currentScene == 1)
                {
                    lRend.SetPosition(index, newPos);
                }
                if (currentScene == 2)
                {
                    lRend_2.SetPosition(index, newPos);
                }

                index++;
            }
        }

        gameDatabus = GameDataBus.FindObjectsOfType <GameDataBus>()[0];
        gameDatabus.InitializedData(nameList, valueList);
    }
Example #2
0
 void Awake()
 {
     gameDatabus = GameDataBus.FindObjectsOfType <GameDataBus>()[0];
 }