示例#1
0
 void Start()
 {
     snake_trans          = GetComponent <Transform> ();
     snake_trans.position = new Vector3(0.0f, 0.0f, 0.0f);
     scoreCtr             = GameObject.Find("/Canvas/ScoreValue").GetComponent <ScoreCtr> ();
     userInterCtr         = GameObject.Find("/Canvas/UIController").GetComponent <UICtr> ();
     soundCtr             = GameObject.Find("/Scene/Sound").GetComponent <SceneSoundCtr> ();
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        Button btnRestart = btn1.GetComponent <Button> ();
        Button btnExit    = btn2.GetComponent <Button> ();

        snkCtr   = GameObject.Find("/Player/Snake").GetComponent <SnakeController> ();
        scoreCtr = GameObject.Find("/Canvas/ScoreValue").GetComponent <ScoreCtr> ();
        soundCtr = GameObject.Find("/Scene/Sound").GetComponent <SceneSoundCtr> ();
        sceneCtr = GameObject.Find("/Scene/SceneController").GetComponent <SceneCtr> ();

        btnRestart.onClick.AddListener(RestartTask);
        btnExit.onClick.AddListener(ExitTask);

        Debug.Log(score.name);
        score.SetActive(false);
    }
示例#3
0
    public bool playing = true;           //Vraible para ejecutar el sonido durante el tiempo de juego solo una vez,
    //es reiniciada a true cuando se presiona el boton de restart

    public void Start()
    {
        //snake = GameObject.Find ("/Player/Snake").GetComponent<SnakeController> ();		//Encontrar la ubicacion del objeto que contiene el componente
        activeFood = new List <GameObject>();                   //Inicializar la lista de objetos

        //Lo siguiente genera genera una copia del prefab(GameObject) food declarado al inicio, y lo muestra en una posicion aleatoria
        //en la pantalla
        Vector3    RandomSpawn = new Vector3(Random.Range(-6, 6), Random.Range(-4, 4), 0.0f);         //Vector aleatorio x,y,z; Random.range() genera un numero aleatorio entre los dos numeros pasados como parametros
        GameObject fo1;

        fo1 = Instantiate(food) as GameObject;
        //Instantiate (fo1, RandomSpawn, Quaternion.identity);
        fo1.transform.SetParent(transform);             //Asigna al componente transform los mismos valores del transform del elemento que lo contiene
        fo1.transform.position = RandomSpawn;           //Los valores del vector3 position perteniciente al transform del objeto se establecen igual al vector aleatorio generado anteriormente
        activeFood.Add(fo1);                            //Agrega el objeto generado a la lista de objetos

        origen = new Vector3(0.0f, 0.0f, 0.0f);

        scoreCtr = GameObject.Find("/Canvas/ScoreValue").GetComponent <ScoreCtr> ();
        soundCtr = GameObject.Find("/Scene/Sound").GetComponent <SceneSoundCtr> ();
    }
示例#4
0
 void Start()
 {
     pointerPivot = gameObject.GetComponentInChildren <Transform>();
     rb           = gameObject.GetComponent <Rigidbody>();
     scrCtr       = score.GetComponent <>();
 }