Beispiel #1
0
    public void Init(int slotNumber) //anything in a () is a parameter needs an integer to define
    {
        this.slotNumber = slotNumber;

        icons = new GameObject[Machine.instance.GetNumIcons()];  //gets the total number of icons accessing array directly

        for (int i = 0; i < Machine.instance.GetNumIcons(); i++) //i=index i<machine... no higher than max icons i++= add one to index
        {
            icons[i] = Instantiate(Machine.instance.GetIcons(i).iconPrefab) as GameObject;

            icons[i].transform.position += new Vector3((float)slotNumber, i, 0);  //Slot positioning

            icons[i].transform.parent = this.gameObject.transform;

            IconController iconScript = icons[i].GetComponent <IconController>(); //icons know which slot they belong too
            iconScript.SetSlotRef(this);
        }
    }