Example #1
0
    // Use this for initialization
    void Start()
    {
        askPanel = transform.FindChild("slot").GetComponent <AskPanel>();
        askPanel.initPanel();

        audio = GetComponent <AudioSource>();

        //Calculus the distance between switches
        SpriteRenderer sr_aux = switchPrefab.GetComponent <SpriteRenderer>();

        distance = (sr_aux.sprite.rect.width * switchPrefab.transform.localScale.y / sr_aux.sprite.pixelsPerUnit) * 1.3f;

        switches    = new SwitchMachine[5];
        switches[0] = (Instantiate(switchPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <SwitchMachine>();
        switches[1] = (Instantiate(switchPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <SwitchMachine>();
        switches[2] = (Instantiate(switchPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <SwitchMachine>();
        switches[3] = (Instantiate(switchPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <SwitchMachine>();
        switches[4] = (Instantiate(switchPrefab, Vector3.zero, Quaternion.identity) as GameObject).GetComponent <SwitchMachine>();

        foreach (SwitchMachine sm in switches)
        {
            sm.transform.parent        = this.transform;
            sm.transform.localPosition = Vector3.zero;
            sm.gameObject.SetActive(false);
        }

        initSwitches();
    }
Example #2
0
 public void newAsk()
 {
     askPanel.initPanel();
     initSwitches();
 }