// Use this for initialization
    void Start()
    {
        GameObject globalObj = GameObject.Find("Globals");

        globals = globalObj.GetComponent <GlobalVariables>();
        goals   = globalObj.GetComponent <GoalsScript>();
        sound   = GetComponent <AudioSource>();

        //generate goals
        int i = 0;

        foreach (GoalList GOAL in goals.List)
        {
            GameObject obj = (GameObject)Instantiate(goal_temp, new Vector3(0, 0, 0), Quaternion.identity);
            obj.transform.SetParent(wall.transform);
            obj.transform.position = obj.transform.parent.transform.position - new Vector3(0, 120 * i, 0);

            obj.GetComponent <PersonalGoalScript>().img.color  = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), 255);
            obj.GetComponent <PersonalGoalScript>().title.text = GOAL.title;
            obj.GetComponent <PersonalGoalScript>().desc.text  = GOAL.desc;
            obj.GetComponent <PersonalGoalScript>().date.text  = GOAL.date;
            if (GOAL.got >= GOAL.goal)
            {
                obj.GetComponent <PersonalGoalScript>().got.text = GOAL.goal + " / " + GOAL.goal;
            }
            else
            {
                obj.GetComponent <PersonalGoalScript>().got.text = GOAL.got + " / " + GOAL.goal;
            }


            i++;
        }

        //GENERATED LISTS
        foreach (Transform child in transform)
        {
            listCanvas.Add(child);
        }
        foreach (Transform child in listCanvas[0])
        {
            listArray.Add(child);
            wallHeight += 120;
        }

        currentPos = wall.transform.position;
        finalPos   = wallHeight - 100;
    }
示例#2
0
    void Start()
    {
        //get required game objects
        controller = GetComponent <Controller2D> ();
        sound      = GetComponent <AudioSource>();

        GameObject globalObj = GameObject.Find("Globals");

        globals = globalObj.GetComponent <GlobalVariables>();
        goals   = globalObj.GetComponent <GoalsScript>();
        GameObject timerObj = GameObject.Find("Start Timer");

        startTimer = timerObj.GetComponent <StartTimer>();

        //set size of player
        transform.localScale = new Vector3(1, 1, 1);
    }
示例#3
0
    private IEnumerator ButtonClick(int choice)
    {
        sound.PlayOneShot(click, globals.op.option_sound);
        yield return(new WaitForSeconds(click.length));

        if (choice == 1)
        {
            globals.NextLevel = "_S_MENU";
            SceneManager.LoadScene("_Scenes/_S_MENU");
        }
        else if (choice == 9)
        {
            globals.Delete_Player();
            globals.Reset_Player();
        }
        else if (choice == 10)
        {
            GoalsScript goals = globalObj.GetComponent <GoalsScript>();
            goals.Delete_Goals();
            goals.Reset_Goals();
        }
    }