Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        start = new GameObject();
        MenuFloatingDisplay startDisp = start.AddComponent <MenuFloatingDisplay>();

        startDisp.setDisplay("Start Game");
        BoxCollider startCol = start.gameObject.AddComponent <BoxCollider>();

        startCol.size = new Vector3(4, 1, 1);

        exit = new GameObject();
        MenuFloatingDisplay exitDisp = exit.AddComponent <MenuFloatingDisplay>();

        exitDisp.setDisplay("Exit Game");
        BoxCollider exitCol = exit.gameObject.AddComponent <BoxCollider>();

        exit.transform.position = 2f * -Vector3.up;
        exitCol.size            = new Vector3(4, 1, 1);

        music = gameObject.GetComponent <AudioClip>();
        music = Resources.Load <AudioClip>("bensound-epic");
        AudioSource musicSource = gameObject.GetComponent <AudioSource>();

        musicSource       = gameObject.AddComponent <AudioSource>();
        musicSource.clip  = music;
        musicSource.pitch = .5f;
        musicSource.loop  = true;
        musicSource.Play(0);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            MenuFloatingDisplay fd = hit.collider.gameObject.GetComponent <MenuFloatingDisplay>();
            if (fd)
            {
                fd.setColour(2);
            }
        }

        Debug.DrawRay(Camera.main.ScreenPointToRay(Input.mousePosition).origin, Camera.main.ScreenPointToRay(Input.mousePosition).direction * 100);
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.transform.gameObject == start)
                {
                    SceneManager.LoadScene("PlayerControllerTest", LoadSceneMode.Single);
                }
                else if (hit.transform.gameObject == exit)
                {
                    Application.Quit();
                }
            }
        }

        Camera.main.transform.LookAt(this.transform.position);
        Camera.main.transform.Translate(Vector3.right * Time.deltaTime);
    }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        start = new GameObject();
        MenuFloatingDisplay startDisp = start.AddComponent <MenuFloatingDisplay>();

        startDisp.setDisplay("Start Game");
        BoxCollider startCol = start.gameObject.AddComponent <BoxCollider>();

        startCol.size = new Vector3(4, 1, 1);

        exit = new GameObject();
        MenuFloatingDisplay exitDisp = exit.AddComponent <MenuFloatingDisplay>();

        exitDisp.setDisplay("Exit Game");
        BoxCollider exitCol = exit.gameObject.AddComponent <BoxCollider>();

        exit.transform.position = 2f * -Vector3.up;
        exitCol.size            = new Vector3(4, 1, 1);
    }