Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            if (t.phase == TouchPhase.Began)
            {
                if (Object1.HitTest(t.position, Camera.main))
                {
                    ButtonPresssed = true;
                    currentLine1++;
                }
            }
        }
        if (currentLine1 == 7)
        {
            Object1.GetComponent <GUITexture>().enabled = false;
            Object2.GetComponent <GUITexture>().enabled = true;
            Object3.GetComponent <GUITexture>().enabled = false;
        }
        if (currentLine1 == 9)
        {
            Object1.GetComponent <GUITexture>().enabled = false;
            Object2.GetComponent <GUITexture>().enabled = false;
            Object3.GetComponent <GUITexture>().enabled = true;
        }
    }
Ejemplo n.º 2
0
    private void OnTheGUI()
    {
        if (m_Button1.HitTest(Input.mousePosition))
        {
            m_Button1.GetComponent <ChangeTextureHover>().ChangeToHoverTexture();
        }
        else
        {
            m_Button1.GetComponent <ChangeTextureHover>().ChangeBack();
        }
        if (m_Button2.HitTest(Input.mousePosition))
        {
            m_Button2.GetComponent <ChangeTextureHover>().ChangeToHoverTexture();
        }
        else
        {
            m_Button2.GetComponent <ChangeTextureHover>().ChangeBack();
        }

        if (m_Button1.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            EndMenu();
            RasmusGameSave.SaveLevel();
            Application.LoadLevel(m_Scene);
        }
        if (m_Button2.HitTest(Input.mousePosition) && Input.GetMouseButtonDown(0))
        {
            EndMenu();
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Inicializa este control
    /// </summary>
    /// <param name="_textoObjetivo">Texto del objetivo</param>
    /// <param name="_conseguido">Indica si se ha conseguido o no este objetivo</param>
    public void Inicializar(string _textoObjetivo, bool _conseguido)
    {
        GetReferencias();

        m_conseguido = _conseguido;

        m_textoObjetivo.text = _textoObjetivo;

        PintarComoConseguido(_conseguido);

        // al pulsar sobre el control => desplegarlo
        m_btnConseguido.action = (_name) => {
            Desplegar();
        };

        // obtener las coordenadas de los elementos cuando estan plegados
        m_pixelOffsetTexto          = m_textoObjetivo.pixelOffset;
        m_pixelInsetFondoDesplegado = m_imgFondo.pixelInset;
        m_pixelInsetIconoDesplegado = m_icono.pixelInset;

        // plegar los elementos
        m_desplegado = false;
        m_textoObjetivo.pixelOffset = new Vector2(m_pixelOffsetTexto.x + OFFSET_X, m_pixelOffsetTexto.y);
        m_imgFondo.GetComponent <GUITexture>().pixelInset      = new Rect(m_pixelInsetFondoDesplegado.xMin + OFFSET_X, m_pixelInsetFondoDesplegado.yMin, m_pixelInsetFondoDesplegado.width, m_pixelInsetFondoDesplegado.height);
        m_icono.GetComponent <GUITexture>().pixelInset         = new Rect(m_pixelInsetIconoDesplegado.xMin + OFFSET_X, m_pixelInsetIconoDesplegado.yMin, m_pixelInsetIconoDesplegado.width, m_pixelInsetIconoDesplegado.height);
        m_btnConseguido.GetComponent <GUITexture>().pixelInset = m_icono.GetComponent <GUITexture>().pixelInset;
    }
Ejemplo n.º 4
0
 void Start()
 {
     resumeButton.GetComponent <GUIText>().enabled = false;
     menuButton.GetComponent <GUIText>().enabled   = false;
     quitButton.GetComponent <GUIText>().enabled   = false;
     darken.GetComponent <GUITexture>().enabled    = false;
 }
Ejemplo n.º 5
0
 void doPause()
 {
     if (isPaused == false)
     {
         isPaused       = true;
         Time.timeScale = 0;
         //darkenScreen.guiTexture.enabled = true;
         darkenScreen.GetComponent <GUITexture>().enabled = true;
         //pausedText.guiText.enabled = true;
         pausedText.GetComponent <GUIText>().enabled = true;
         resumeGraphics.SetActive(true);
         menuGraphics.SetActive(true);
     }
     else
     {
         isPaused       = false;
         Time.timeScale = 1;
         //darkenScreen.guiTexture.enabled = false;
         darkenScreen.GetComponent <GUITexture>().enabled = false;
         //pausedText.guiText.enabled = false;
         pausedText.GetComponent <GUIText>().enabled = false;
         resumeGraphics.SetActive(false);
         menuGraphics.SetActive(false);
     }
 }
Ejemplo n.º 6
0
    void FadeToWhite()
    {
        if (startFade)
        {
            if (whiteBackground == null)
            {
                whiteBackground = (GUITexture)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().whiteBackground);
                whiteBackground.name = "WhiteBackground";

                whiteBackground.gameObject.AddComponent("ResizeGUITexture");
                (whiteBackground.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = whiteBackground.guiTexture;
                (whiteBackground.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();
                SceneManager.Instance.scene.DestroySomeInterfaceElements();
            }

            if (whiteBackground.color.a < 0.5f)
                whiteBackground.color = new Color(
                    whiteBackground.color.r,
                    whiteBackground.color.g,
                    whiteBackground.color.b,
                    whiteBackground.color.a + fadeConst * Time.deltaTime);
            else
            {
                Destroy(whiteBackground);
                whiteBackground = null;
                SceneManager.Instance.scene.CloseScene();
                SceneManager.Instance.ChangeLevelCampaignMode(level);
            }
        }
    }
Ejemplo n.º 7
0
    public override void Start()
    {
        //-PLAYERAIRPLANE-------------------------------------------------------------------------//
        playerAirplane = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().PlayerAirplane);
        playerAirplane.name = "PlayerAirplane";

        // Setamos a o aviao como alvo da camera
        SmoothFollow.Instance.target = playerAirplane.transform;

        //-SET------------------------------------------------------------------------------------//
        Set = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Set);
        Set.name = "Set";

        //-LIGHT----------------------------------------------------------------------------------//
        Light = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Light);
        Light.name = "Light";

        //-INTERFACE-IN-GAME----------------------------------------------------------------------//
        interfaceInGame = (GUITexture)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().interfaceInGame);
        interfaceInGame.name = "InterfaceInGame";

        interfaceInGame.gameObject.AddComponent("ResizeGUITexture");
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = interfaceInGame.guiTexture;
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        (interfaceInGame.GetComponent("AirSpeedIndicator") as AirSpeedIndicator).playerAirplane = (this.playerAirplane.GetComponent("PlayerAirplane") as PlayerAirplane);
    }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pauseGame = !pauseGame;

            if (pauseGame == true)
            {
                Time.timeScale = 0;
                pauseGame      = true;
                GameObject.Find("Player").GetComponent <MoveController>().enabled = false;
                showGUI = true;
            }
        }

        if (pauseGame == false)
        {
            Time.timeScale = 1;
            pauseGame      = false;
            GameObject.Find("Player").GetComponent <MoveController>().enabled = true;
            showGUI = false;
        }

        if (showGUI == true)
        {
            telaPause.GetComponent <GUITexture>().enabled    = true;
            telaPause.GetComponent <GUITexture>().pixelInset = new Rect(Screen.width / 2 - telaPause.GetComponent <GUITexture>().pixelInset.width / 2, Screen.height / 2 - telaPause.GetComponent <GUITexture>().pixelInset.height / 2, -50, -50);
        }
        else
        {
            telaPause.GetComponent <GUITexture>().enabled = false;
        }
    }
Ejemplo n.º 9
0
        //Game play GUI on
        void GameGUIOn()
        {
            for (int i = 0; i < gameGUI.Length; i++)
            {
                gameGUI[i].GetComponent <GUIText>().enabled = true;
            }

            //Activate player avatar texture
            playerAvatar.GetComponent <GUITexture>().enabled = true;
        }
Ejemplo n.º 10
0
    //function enabling cooldowns
    void Cooldowns()
    {
        //check if cooldown1 should be active
        if (cooldown1 > 0)
        {
            cooldown1 = cooldown1 - 1 * Time.deltaTime;

            //sets back to zero
            if (cooldown1 < 0)
            {
                cooldown1 = 0;
                leftTrigger.GetComponent <FadeManager>().activeState = false;
            }
        }

        //check if cooldown2 should be active
        if (cooldown2 > 0)
        {
            cooldown2 = cooldown2 - 1 * Time.deltaTime;

            //sets back to zero
            if (cooldown2 < 0)
            {
                cooldown2 = 0;
                leftBumper.GetComponent <FadeManager>().activeState = false;
            }
        }

        //check if cooldown3 should be active
        if (cooldown3 > 0)
        {
            cooldown3 = cooldown3 - 1 * Time.deltaTime;

            //sets back to zero
            if (cooldown3 < 0)
            {
                cooldown3 = 0;
                rightBumper.GetComponent <FadeManager>().activeState = false;
            }
        }

        //check if cooldown4 should be active
        if (cooldown4 > 0)
        {
            cooldown4 = cooldown4 - 1 * Time.deltaTime;

            //sets back to zero
            if (cooldown4 < 0)
            {
                cooldown4 = 0;
                rightTrigger.GetComponent <FadeManager>().activeState = false;
            }
        }
    }
 /// <summary>
 /// 开始按钮 猫爪效果
 /// </summary>
 void BeginBtnEffect()
 {
     if (_BeginBtn.GetComponent <GUITexture>().texture != _BeginBtn_1)
     {
         _BeginBtn.GetComponent <GUITexture>().texture = _BeginBtn_1;
     }
     else
     {
         _BeginBtn.GetComponent <GUITexture>().texture = _BeginBtn_2;
     }
 }
Ejemplo n.º 12
0
    public void ActivateGameOver()
    {
        if (!gameOver)
        {
            GameOverNotification.GetComponent <Animation>().Play("GameOver");
            GameOverNotification.GetComponent <Animation>().PlayQueued("Brethe", QueueMode.CompleteOthers);
            //GameOverNotification.animation.Play("Brethe");
        }


        gameOver = true;
    }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        isPaused = pauseButtonObject.GetComponent <pauseButton>().isPaused;

        // Grow the alert bar (do not show when the game is paused)
        if (bearAlertLevel > 0 && bearAwake == false && isPaused == false)
        {
            // Decrease the alert level over time
            bearAlertLevel = bearAlertLevel - (Time.deltaTime * 50);
            alertBarFilling.GetComponent <GUITexture>().enabled = true;
            alertBarFull.GetComponent <GUITexture>().enabled    = false;
            alertBarFilling.GetComponent <GUITexture>().transform.localScale = new Vector3(bearAlertLevel * 0.005f, 0.04f, 1);
        }

        // The bear is not aware at all
        else if (bearAwake == false && isPaused == false)
        {
            alertBarFilling.GetComponent <GUITexture>().transform.localScale = new Vector3(0, 0.04f, 1);
            alertBarFilling.GetComponent <GUITexture>().enabled = false;
            alertBarFull.GetComponent <GUITexture>().enabled    = false;
        }

        // The bear is coming
        else if (bearAwake == true && isPaused == false)
        {
            alertBarFull.GetComponent <GUITexture>().enabled = true;
        }

        if (throwNetPrompt.GetComponent <Renderer>().enabled == true && throwNetPrompt.transform.position != new Vector3(0, 0, 0))
        {
            rightButton.GetComponent <GUITexture>().texture = rightButtonInactive;
            leftButton.GetComponent <GUITexture>().texture  = leftButtonInactive;
        }

        // Used to indicate to the user that no buttons can be pressed until the bear respawns after a net was thrown
        if (throwNetPrompt.GetComponent <throwNetScript>().bearReadyAndUp == true)
        {
            if (currentButton == "right" && leftButton.GetComponent <GUITexture>().texture == leftButtonInactive && throwNetPrompt.GetComponent <Renderer>().enabled == false && throwNetPrompt.GetComponent <throwNetScript>().bearReadyAndUp == true)
            {
                leftButton.GetComponent <GUITexture>().texture = leftButtonActive;
            }
            else if (currentButton == "left" && rightButton.GetComponent <GUITexture>().texture == rightButtonInactive && throwNetPrompt.GetComponent <Renderer>().enabled == false && throwNetPrompt.GetComponent <throwNetScript>().bearReadyAndUp == true)
            {
                rightButton.GetComponent <GUITexture>().texture = rightButtonActive;
            }
        }

        //bearAlertDisplay.text = "Level: " + bearAlertLevel.ToString ();
    }
Ejemplo n.º 14
0
    void Start()
    {
        for (int i = 0; i < 100; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                tile.GetComponent <MapTile>().x    = j;
                tile.GetComponent <MapTile>().y    = i;
                tile.GetComponent <MapTile>().size = mapSize;

                GameObject clone;
                clone = Instantiate(tile, new Vector3(mapX, mapY, 0.0f), new Quaternion()) as GameObject;
            }
        }
    }
Ejemplo n.º 15
0
    void HandleJoystickVisuals(Touch t)
    {
        if (!DebugVisuals)
        {
            return;
        }

        //Set the position of the screen in percentage of the screen size for unity format.
        unitTouchPosition.x = t.position.x / screen.width;
        unitTouchPosition.y = t.position.y / screen.height;

        //Temp storage for the new position.
        Vector3 joystickImagePosition = Vector3.zero;

        joystickImagePosition.Set(unitTouchPosition.x, unitTouchPosition.y, 0.0f);

        //Tranfering the temp position to the transform.
        analogStick.transform.position = joystickImagePosition;



        //Display the joystick image.
        joypad.GetComponent <GUITexture>().enabled = true;
        analogStick.enabled = true;
    }
Ejemplo n.º 16
0
    void OnGUI()
    {
        if (ButtonPresssed)
        {
            if (currentLine10 < talkLines10.Length)
            {
                GUI.Label(new Rect(Screen.width * xLabel, Screen.height * yLabel, (Screen.width * 0.75f), (Screen.height * 0.2f)),
                          "" + talkLines10[currentLine10] + "\n");
                //r
                if (currentLine10 == 3 && currentLine10 < talkLines10.Length)
                {
                    Object2.GetComponent <GUITexture>().enabled = false;                   //r



                    Object1.GetComponent <GUITexture>().enabled = true;
                }
            }
            else if (currentLine10 == 8)
            {
                Application.LoadLevel(levelToLoad);
                Destroy(GameObject.FindWithTag("MainCamera"));
            }
        }
    }
Ejemplo n.º 17
0
    public void receiveClickEvent(float x, float y, bool mouseInputMode = false)
    {
        for (int i = 0; i < GUIList.Length; ++i)
        {
            GUITexture gui = GUIList[i];

            if (gui.enabled == false || gui.gameObject.activeInHierarchy == false)
            {
                continue;
            }

            Vector3 screenPoint = new Vector3(x, y, gui.transform.position.z);

            if (false == mouseInputMode)
            {
                screenPoint = Camera.main.ViewportToScreenPoint(screenPoint);
            }

            if (gui.HitTest(screenPoint))
            {
                GUIEvent guiEvent = gui.GetComponent <GUIEvent>();

                if (guiEvent != null)
                {
                    guiEvent.onClickEvent(x, y);

                    if (clickAudio)
                    {
                        AudioSource.PlayClipAtPoint(clickAudio, transform.position, 1.0f);
                    }
                }
            }
        }
    }
Ejemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        WebCamTexture camtexture = new WebCamTexture();

        //Get the list of devices available
        WebCamDevice[] devices = WebCamTexture.devices;
        //conside the input orientation parameters - activate if necessary
        //flipx = flipHorizontal ? -1 : 1;
        //flipy = flipVertical ? -1 : 1;
        //flip logic of guitexture
        ARBackgroundTexture.transform.localScale = new Vector3(flipx, flipy, 1);
        //If devices found
        if (devices.Length > 0)
        {
            print("StorylineARSystem:: Inside Start:: device name: " + devices[0].name);
            //assign the first available device to camera texture - can include hard code camera name
            camtexture.deviceName = devices[0].name;
        }
        ARBackgroundTexture.texture = camtexture;
        ARBackgroundTexture.GetComponent <GUITexture>().enabled = true;
        camtexture.Play();
        //when hand wave to skip the story
        GameObject ardisplaystoryline = GameObject.Find("StorylineDialog");

        ardisplaystoryline.GetComponent <StorylineDialog>().changeARstoryline += delegate(object sender, string state) {
            switch (state)
            {
            case "Start": camtexture.Play();
                break;

            case "Stop": camtexture.Stop();
                break;
            }
        };
    }
Ejemplo n.º 19
0
    public void addCombo()
    {
        int currentCombo    = _gameData.combo;
        int currentMaxCombo = _gameData.maxCombo;

        currentCombo++;
        textCombo.enabled    = true;
        textureCombo.enabled = true;

        GUIScaleAction actionFromTexture = textureCombo.GetComponent <GUIScaleAction> ();

        actionFromTexture.from = 1.5f + (currentCombo * 0.2f);
        GUIScaleAction actionFromText = textCombo.GetComponent <GUIScaleAction> ();

        actionFromText.from = 1.5f + (currentCombo * 0.2f);

        GameAction.invoke(textureCombo.gameObject);
        GameAction.invoke(textCombo.gameObject);

        textCombo.text = currentCombo.ToString();

        if (currentCombo > currentMaxCombo)
        {
            currentMaxCombo = currentCombo;
        }

        _gameData.combo    = currentCombo;
        _gameData.maxCombo = currentMaxCombo;
    }
Ejemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        if (m_GUITexture.enabled == true && (Input.GetButtonDown("Fire2") || Input.GetKeyUp(KeyCode.Escape)) && m_Active == true)
        {
            m_GUITexture.enabled = false;
            Camera.main.transform.parent.GetComponent <FirstPersonController> ().UnLockPlayerMovement();
            Camera.main.GetComponent <FirstPersonCamera> ().UnLockCamera();
            m_GUITexture.GetComponent <GUITexturePos> ().ScaleBackOriginal();
            m_Active = false;

            if (GetComponent <SuperTrigger>())
            {
                GetComponent <SuperTrigger>().ActivateTrigger();
            }
        }
    }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        camtexture = new WebCamTexture();
        //Get the list of devices available
        WebCamDevice[] devices = WebCamTexture.devices;
        //conside the input orientation parameters - activate if necessary
        //flipx = flipHorizontal ? -1 : 1;
        //flipy = flipVertical ? -1 : 1;
        //flip logic of guitexture
        ARBackgroundTexture.transform.localScale = new Vector3(flipx, flipy, 1);
        //If devices found
        if (devices.Length > 0)
        {
            print("ARDisplay:: Inside Start:: device name: " + devices[0].name);
            //assign the first available device to camera texture - can include hard code camera name
            camtexture.deviceName = devices[0].name;
        }
        ARBackgroundTexture.texture = camtexture;
        ARBackgroundTexture.GetComponent <GUITexture>().enabled = true;
        camtexture.Play();

        GameObject arDisplayChangeGame01 = GameObject.Find("MainMenu");

        arDisplayChangeGame01.GetComponent <MainMenu>().changeARGame01 += delegate(object sender, string state) {
            switch (state)
            {
            case "Start": camtexture.Play();
                break;

            case "Stop": camtexture.Stop();
                break;
            }
        };

        GameObject arDisplayChangeGame02 = GameObject.Find("QuitGame");

        arDisplayChangeGame02.GetComponent <QuitGame>().changeARGame02 += delegate(object sender, string state) {
            switch (state)
            {
            case "Start": camtexture.Play();
                break;

            case "Stop": camtexture.Stop();
                break;
            }
        };

        GameObject arDisplayChangeGame03 = GameObject.Find("RestartLevel");

        arDisplayChangeGame03.GetComponent <Restart>().changeARGame03 += delegate(object sender, string state) {
            switch (state)
            {
            case "Start": camtexture.Play();
                break;

            case "Stop": camtexture.Stop();
                break;
            }
        };
    }
    // This function is called externally from playerStatus.js (Dead function).
    // Also is called too from AiScript.js (Dead function).
    // Its a Knockout.
    public IEnumerator KO(string loser)
    {
        if (!gameFinished)
        {
            // Play the Texture animation thats show "KnockOut" message.
            //knock_out.animation.Play();
            knock_out.GetComponent <Animation>().Play();
            //Debug.Log("KO!");

            // Stop the clock.
            CancelInvoke("Clock");
            // Finish the game.
            gameFinished = true;
            // Play Applause audioclip
            audio.PlayOneShot(ApplauseAudio);
            // Wait 3 seconds.
            yield return(new WaitForSeconds(6f));

            // Set the winner.
            if (loser == "player")
            {
                winner = "PC AI";
            }
            if (loser == "enemy")
            {
                winner = "Player";
            }

            // End the Game by KnockOut.
            EndGame("knockOut");
        }
    }
Ejemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     background = background.GetComponent <GUITexture> ();
     text       = text.GetComponent <GUIText> ();
     loadingBar = loadingBar.GetComponent <GUITexture> ();
     InvokeRepeating("Loading", 0, 0.3f);
     StartCoroutine(LoadingScreen(2));
 }
Ejemplo n.º 24
0
    private void OnTouchStart(Touch touch)
    {
        if (!cover.GetComponent <GUITexture>().HitTest(touch.position))
        {
            return;
        }

        PushKnob(touch);
    }
Ejemplo n.º 25
0
    public void receiveMoveEvent(float x, float y, bool mouseInputMode = false)
    {
        for (int i = 0; i < GUIList.Length; ++i)
        {
            GUITexture gui = GUIList[i];

            if (gui.enabled == false || gui.gameObject.activeInHierarchy == false)
            {
                continue;
            }

            Vector3 screenPoint = new Vector3(x, y, gui.transform.position.z);

            if (false == mouseInputMode)
            {
                screenPoint = Camera.main.ViewportToScreenPoint(screenPoint);
            }

            GUIEvent guiEvent = gui.GetComponent <GUIEvent>();

            if (guiEvent == null)
            {
                return;
            }

            if (gui.HitTest(screenPoint))
            {
                if (guiEvent.Charge >= 1.0f)
                {
                    return;
                }

                guiEvent.Charge += (Time.deltaTime / chargeTime);

                guiEvent.ChargeTexture      = chargeTexture;
                guiEvent.ChargeTextureColor = chargeTextureColor;

                if (guiEvent.Charge > 1.0f)
                {
                    guiEvent.Charge = 1.0f;
                    guiEvent.onClickEvent(x, y);
                    if (clickAudio)
                    {
                        AudioSource.PlayClipAtPoint(clickAudio, transform.position, 1.0f);
                    }
                }
                guiEvent.onMoveEvent(x, y);
            }
            else
            {
                guiEvent.Charge = 0.0f;
            }
        }
    }
Ejemplo n.º 26
0
    void Start()
    {
        WebCamOutTexture.transform.localPosition = new Vector3(ScreenPropotion.x, ScreenPropotion.y, 0.0f);
        Vector2 tempVec2 = new Vector2(Screen.width * ScreenPropotion.width, Screen.height * ScreenPropotion.height);

        WebCamOutTexture.pixelInset = new Rect(-tempVec2.x * 0.5f, -tempVec2.y * 0.5f, tempVec2.x, tempVec2.y);

        QR = new QRCodeReader();
        Application.RequestUserAuthorization(UserAuthorization.WebCam);
        for (int cameraIndex = 0; cameraIndex < WebCamTexture.devices.Length; ++cameraIndex)
        {
            if (isFrontCamera)
            {
                if (WebCamTexture.devices[cameraIndex].isFrontFacing)
                {
                    camTexture = new WebCamTexture(WebCamTexture.devices[cameraIndex].name);
                    // Here we flip the GuiTexture by applying a localScale transformation
                    // works only in Landscape mode
                    WebCamOutTexture.transform.localScale = new Vector3(-ScreenPropotion.width * 2.0f, -ScreenPropotion.height * 2.0f, 1);
                }
            }
            else
            {
                if (!WebCamTexture.devices[cameraIndex].isFrontFacing)
                {
                    camTexture = new WebCamTexture(WebCamTexture.devices[cameraIndex].name);
                    // Here we flip the GuiTexture by applying a localScale transformation
                    // works only in Landscape mode
                    //WebCamOutTexture.transform.localScale = new Vector3(-1,-1,1);
                }
            }
        }
        OnEnable();

        WebCamOutTexture.texture = camTexture;

        Renderer renderer = GetComponent <Renderer>();

        renderer.material.mainTexture = camTexture;
        baseRotation = transform.rotation;
        camTexture.Play();

        if (camTexture != null)
        {
            c = new Color32[camTexture.width * camTexture.height];
        }
        else
        {
            WebCamOutTexture.GetComponent <GUITexture>().texture = nullTexture2D;
        }

        qrThread = new Thread(DecodeQR);
        qrThread.Start();
    }
Ejemplo n.º 27
0
    // Update is called once per frame
    void Update()
    {
        if (m_GUITexture.enabled == true && m_Active == true)
        {
            if (Input.GetButtonDown("Fire2") || Input.GetKeyUp(KeyCode.Escape))
            {
                m_GUITexture.enabled = false;
                Camera.main.transform.parent.GetComponent <FirstPersonController> ().UnLockPlayerMovement();
                Camera.main.GetComponent <FirstPersonCamera> ().UnLockCamera();
                Camera.main.gameObject.GetComponent <RasmusRaycast> ().m_HoldingAnObject = false;
                Camera.main.gameObject.GetComponent <RasmusRaycast> ().HoldObject        = null;
                m_GUITexture.GetComponent <GUITexturePos> ().ScaleBackOriginal();

                m_Active = false;

                if (GetComponent <SuperTrigger>())
                {
                    GetComponent <SuperTrigger>().ActivateTrigger();
                }
            }
            else if (Input.GetButtonDown(m_Right))
            {
                if (m_Page < m_Textures.Length - 1)
                {
                    m_Page++;
                    SwitchPage();
                }
                SetArrows();
            }
            else if (Input.GetButtonDown(m_Left))
            {
                if (m_Page > 0)
                {
                    m_Page--;
                    SwitchPage();
                }
                SetArrows();
            }
        }
    }
Ejemplo n.º 28
0
    public override void Start()
    {
        //-BACKGROUND-----------------------------------------------------------------------------//

        background = (GUITexture)Instantiate(AssetManager.Instance.GetMenuAssets().rankingBackground);
        background.name = "RankingBackground";

        background.gameObject.AddComponent("ResizeGUITexture");
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = background.guiTexture;
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-MENU-BUTTON----------------------------------------------------------------------------//

        menuButton = (GUITexture)Instantiate(AssetManager.Instance.GetMenuAssets().menuButton);
        menuButton.name = "MenuButton";

        menuButton.gameObject.AddComponent("ResizeGUITexture");
        (menuButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = menuButton.guiTexture;
        (menuButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //----------------------------------------------------------------------------------------//
    }
Ejemplo n.º 29
0
    public override void Start()
    {
        //-BACKGROUND-----------------------------------------------------------------------------//

        background = (GUITexture)Instantiate(AssetManager.Instance.GetOpeningAssets().background);
        background.name = "OpeningBackground";

        background.gameObject.AddComponent("ResizeGUITexture");
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = background.guiTexture;
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-PRESS-SPACE-BUTTON---------------------------------------------------------------------//

        pressSpaceButton = (GUITexture)Instantiate(AssetManager.Instance.GetOpeningAssets().pressSpaceButton);
        pressSpaceButton.name = "PressSpaceButton";

        pressSpaceButton.gameObject.AddComponent("ResizeGUITexture");
        (pressSpaceButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = pressSpaceButton.guiTexture;
        (pressSpaceButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //----------------------------------------------------------------------------------------//
    }
Ejemplo n.º 30
0
    protected void Initialize()
    {
        //Store the original position for later use.
        OriginalPosition = transform.position;
        OriginalScale    = transform.localScale;

        //dragallouance = guiTexture.pixelInset.width * 2;

        //If we have a hit texture hide it.
        if (HitTexture)
        {
            HitTexture.GetComponent <GUITexture>().enabled = false;
        }
    }
Ejemplo n.º 31
0
    public void DisplayFruit(int index, float time)
    {
        //Set the texture according to the index.
        currentFruit.texture = FruitList[index];

        //Set the values for on.
        timer          = DisplayTime;
        currentColor.a = 1.0f;
        nf++;

        fruitstamps.Add(time);

        //Play the animation.
        currentFruit.GetComponent <Animation>().Play();
    }
Ejemplo n.º 32
0
    void Awake()
    {
        // The scale factor as a fraction of the screen resolution.
        float guiTexScreenResScaleFactor = Screen.height * guiTexScaleFactor;

        jTransClampValue *= guiTexScreenResScaleFactor;

        guiTex           = gameObject.GetComponent <GUITexture>();
        guiTexWidth      = (int)(gameObject.GetComponent <GUITexture>().pixelInset.width *guiTexScreenResScaleFactor);
        guiTexHalfWidth  = guiTexWidth / 2;
        guiTexHeight     = (int)(gameObject.GetComponent <GUITexture>().pixelInset.height *guiTexScreenResScaleFactor);
        guiTexHalfHeight = guiTexHeight / 2;

        fixedJoystickTextWidth      = (int)(fixedJoystickTex.GetComponent <GUITexture>().pixelInset.width *guiTexScreenResScaleFactor);
        fixedJoystickTextHalfWidth  = fixedJoystickTextWidth / 2;
        fixedJoystickTextHeight     = (int)(fixedJoystickTex.GetComponent <GUITexture>().pixelInset.height *guiTexScreenResScaleFactor);
        fixedJoystickTextHalfHeight = fixedJoystickTextHeight / 2;

        // Cache the color to change later only the alpha component.
        fadeControlColor       = guiTex.color;
        fadeControlColor.a     = 0.0f;
        guiTex.color           = fadeControlColor;
        fixedJoystickTex.color = fadeControlColor;
    }
Ejemplo n.º 33
0
    private void Update()
    {
        if (!currentPlayer)
        {
            foreach (Touch touch in Input.touches)
            {
                if (touch.phase == TouchPhase.Stationary && RespawnButton.HitTest(touch.position))
                {
                    RespawnButton.GetComponent <GUITexture>().enabled = true;
                }
            }

            {
                SpawnPlayer(checkpoint);
            }
        }
    }
Ejemplo n.º 34
0
 void OnMouseUp()
 {
     //this.guiTexture.enabled = true;
     this.GetComponent <GUITexture>().texture = normalTexture;
     this.GetComponent <GUITexture>().enabled = false;
     pauseImage.enabled        = false;
     quitButton.enabled        = false;
     pauseButtonObject.enabled = true;
     bearAlertIcon.enabled     = true;
     leftFoot.enabled          = true;
     rightFoot.enabled         = true;
     alertBar.enabled          = true;
     alertBarFilling.enabled   = true;
     alertBarFull.enabled      = true;
     Time.timeScale            = 1.0f;
     pauseButtonObject.GetComponent <pauseButton>().isPaused = false;
 }
Ejemplo n.º 35
0
    //-----------------------------------------------------
    void Start()
    {
        // -- GUITexture du logo (ratio fixe) --
        string logoPath = (usefullData._edition == usefullData.OSedition.Lite? m_logoExpressPath: m_logoFullPath);
        Texture logoTex = (Texture2D) Resources.Load(logoPath, typeof(Texture2D));
        if(logoTex == null)
            Debug.LogError(DEBUGTAG+logoPath+" "+PC.MISSING_RES);

        if(transform.childCount > 0)
        {
            mLogoGUItex = transform.GetChild(0).transform.GetComponent<GUITexture>();
            mLogoGUItex.GetComponent<GUITexture>().texture = logoTex;
        }

           /* if(mLogoGUItex == null || mLogoGUItex.guiTexture.texture == null)
        {
            Debug.LogError(DEBUGTAG+"Logo GUItexture not found or texture not assigned."); this.enabled = false;
        }*/

        // -- Texture de fond pendant montage --
           /* if(mMontageBgTex == null)
            { Debug.LogError(DEBUGTAG+"Texture not found... Deactivating script."); this.enabled = false;}*/

        // -- Textures loading & menu : chargement selon la résolution de l'écran --
        mLoadingBgTex     = null;
        mMenuBgTex        = null;

        string    bgFormat = ChooseBestBgRatio(UnityEngine.Screen.width, UnityEngine.Screen.height);
        Object[]  bgObj    = Resources.LoadAll("gui/backgrounds/"+bgFormat, typeof(Texture));
        Texture   curTex;
        for(int i=0; i<bgObj.Length; i++)
        {
            curTex = (Texture) bgObj[i];
            //Debug.Log(DEBUGTAG+" found splash : "+curTex.name);
            if(curTex.name.Contains(mLoadingBgFilename))
                mLoadingBgTex = curTex;

            if(curTex.name.Contains(mMainmenuBgFilename))
                mMenuBgTex = curTex;

        //            else if(PC.DEBUG && DEBUG)
        //                Debug.LogWarning(DEBUGTAG+"Found unknown splash texture : "+curTex.name);
        }

        // -- Erreurs si images non trouvées --
           /* if(mLoadingBgTex == null)
        {
            Debug.LogError(DEBUGTAG+"Splash not found : "+mLoadingBgFilename+" for format \""+bgFormat+"\"");
            mLoadingBgTex = (Texture) Resources.Load("gui/backgrounds/"+sBgMissingFilename, typeof(Texture));
        }
        if(mMenuBgTex   == null)
        {
            Debug.LogError(DEBUGTAG+"Splash not found : "+mMainmenuBgFilename+" for format \""+bgFormat+"\"");
            mMenuBgTex = (Texture) Resources.Load("gui/backgrounds/"+sBgMissingFilename, typeof(Texture));
        }*/

        // -- Configuration initiale --

        SetLoadingMode();
    }
Ejemplo n.º 36
0
    public virtual void CallIntroduction()
    {
        if (firstTimeIntroduction)
        {
            timer += Time.deltaTime;

            if (timer >= 3)
            {
                SceneManager.Instance.paused = true;

                CampaignAndSurviveModeAssets csma = AssetManager.Instance.GetCampaignAndSurviveModeAssets();

                //-RESTART-BUTTON-------------------------------------------------------------------------//

                restartButton = (GUITexture)Instantiate(csma.restartButton);
                restartButton.name = "RestartButton";

                restartButton.gameObject.AddComponent("ResizeGUITexture");
                (restartButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = restartButton.guiTexture;
                (restartButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

                //-CONTINUE-BUTTON------------------------------------------------------------------------//

                continueButton = (GUITexture)Instantiate(csma.continueButton);
                continueButton.name = "ContinueButton";

                continueButton.gameObject.AddComponent("ResizeGUITexture");
                (continueButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = continueButton.guiTexture;
                (continueButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

                //-MENU-IN-GAME-BUTTON--------------------------------------------------------------------//

                menuInGameButton = (GUITexture)Instantiate(csma.menuInGameButton);
                menuInGameButton.name = "MenuInGameButton";

                menuInGameButton.gameObject.AddComponent("ResizeGUITexture");
                (menuInGameButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = menuInGameButton.guiTexture;
                (menuInGameButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

                //-INTRODUCTION-CHAPTER-01----------------------------------------------------------------//
                introduction = (GUITexture)Instantiate(introductionPrefab);
                introduction.name = "Introduction";

                introduction.gameObject.AddComponent("ResizeGUITexture");
                (introduction.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = introduction.guiTexture;
                (introduction.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

                firstTimeIntroduction = false;
            }
        }
    }
Ejemplo n.º 37
0
    public override void Start()
    {
        MenuAssets ma = AssetManager.Instance.GetMenuAssets();

        //-BACKGROUND-----------------------------------------------------------------------------//

        background = (GUITexture)Instantiate(ma.menuBackground);
        background.name = "MenuBackground";

        background.gameObject.AddComponent("ResizeGUITexture");
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = background.guiTexture;
        (background.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-CAMPAIGN-BUTTON------------------------------------------------------------------------//

        campaignButton = (GUITexture)Instantiate(ma.campaignButton);
        campaignButton.name = "CampaignButton";

        campaignButton.gameObject.AddComponent("ResizeGUITexture");
        (campaignButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = campaignButton.guiTexture;
        (campaignButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-SURVIVE-BUTTON-------------------------------------------------------------------------//

        surviveButton = (GUITexture)Instantiate(ma.surviveButton);
        surviveButton.name = "SurviveButton";

        surviveButton.gameObject.AddComponent("ResizeGUITexture");
        (surviveButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = surviveButton.guiTexture;
        (surviveButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-CREDITS-BUTTON-------------------------------------------------------------------------//

        creditsButton = (GUITexture)Instantiate(ma.creditsButton);
        creditsButton.name = "CreditsButton";

        creditsButton.gameObject.AddComponent("ResizeGUITexture");
        (creditsButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = creditsButton.guiTexture;
        (creditsButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-RANKING-BUTTON-------------------------------------------------------------------------//

        rankingButton = (GUITexture)Instantiate(ma.rankingButton);
        rankingButton.name = "RankingButton";

        rankingButton.gameObject.AddComponent("ResizeGUITexture");
        (rankingButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = rankingButton.guiTexture;
        (rankingButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-INSTRUCTIONS-BUTTON--------------------------------------------------------------------//

        instructionsButton = (GUITexture)Instantiate(ma.instructionsButton);
        instructionsButton.name = "InstructionsButton";

        instructionsButton.gameObject.AddComponent("ResizeGUITexture");
        (instructionsButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = instructionsButton.guiTexture;
        (instructionsButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //-QUIT-BUTTON----------------------------------------------------------------------------//

        quitButton = (GUITexture)Instantiate(ma.quitButton);
        quitButton.name = "QuitButton";

        quitButton.gameObject.AddComponent("ResizeGUITexture");
        (quitButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = quitButton.guiTexture;
        (quitButton.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        //----------------------------------------------------------------------------------------//

        ma = null;
    }
Ejemplo n.º 38
0
    // Called when an invetory held under the mouse cursor is dropped
    // Returns true if successful
    public bool AttemptItemPutDown(GUITexture item)
    {
        int inventorySlot = InventorySlotUnderPoint(
            new Vector2(Input.mousePosition.x, Input.mousePosition.y));
        int equipmentSlot = EquipmentSlotUnderPoint(
            new Vector2(Input.mousePosition.x, Input.mousePosition.y));

        // add item to inventory
        if(inventorySlot != -1)
        {
            // SWAP if necessary
            if(_items[inventorySlot] != null)
            {
                _items[inventorySlot].GetComponent<ItemTextureControls>().InventorySlot = -1;
                _items[inventorySlot].GetComponent<ItemTextureControls>().PickedUp = true;
                ItemPickedUpInventory(inventorySlot);
            }
            else
            {
                _itemPickedUp = null;
            }

            // Place item in inventory
            _items[inventorySlot] = item;
            item.transform.parent = _inventorySlots[inventorySlot].transform;
            item.transform.localPosition = new Vector3(0,0,2);
            item.pixelInset =
            new Rect(_inventorySlots[inventorySlot].pixelInset.xMin,
                    _inventorySlots[inventorySlot].pixelInset.yMin,
                    _inventorySlots[inventorySlot].pixelInset.width,
                    _inventorySlots[inventorySlot].pixelInset.height);
            item.GetComponent<ItemTextureControls>().InventorySlot = inventorySlot;
        }
        // place in equipment
        else if(equipmentSlot != -1)
        {
            // wrong equipment slot clicked; do nothing
            if(! EquipmentSlotCheckItemCompatability(equipmentSlot,
                item.GetComponent<ItemData>().itemClass))
            {
                return false;
            }

            // SWAP if necessary
            if(_equippedItems[equipmentSlot] != null)
            {
                _equippedItems[equipmentSlot].GetComponent<ItemTextureControls>().EquipmentSlot = -1;
                _equippedItems[equipmentSlot].GetComponent<ItemTextureControls>().PickedUp = true;
                ItemPickedUpEquipment(equipmentSlot);
            }
            else
            {
                _itemPickedUp = null;
            }

            // Place item in equipment
            _equippedItems[equipmentSlot] = item;
            item.transform.parent = _equippedSlots[equipmentSlot].transform;
            item.transform.localPosition = new Vector3(0,0,2);
            item.pixelInset =
            new Rect(_equippedSlots[equipmentSlot].pixelInset.xMin,
                    _equippedSlots[equipmentSlot].pixelInset.yMin,
                    _equippedSlots[equipmentSlot].pixelInset.width,
                    _equippedSlots[equipmentSlot].pixelInset.height);
            item.GetComponent<ItemTextureControls>().EquipmentSlot = equipmentSlot;

            if(equipmentSlot == 4 || equipmentSlot == 5)
            {
                UpdateHandheldItemSprites();
            }
        }
        // drop item
        else
        {
            OTSprite newpickup = OT.CreateObject("pickup").GetComponent<OTSprite>();

            newpickup.position =
                    self.position - new Vector2(10,0);
            newpickup.gameObject.AddComponent<ItemData>();
            newpickup.GetComponent<ItemData>().SetValues(item.GetComponent<ItemData>());
            newpickup.frameName = newpickup.GetComponent<ItemData>().itemType.ToString();

            _itemPickedUp = null;

            Destroy(item.gameObject);
        }

        RecalcStats();
        return true;
    }
Ejemplo n.º 39
0
    public override void Start()
    {
        //-PLAYERAIRPLANE-------------------------------------------------------------------------//
        playerAirplane = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().PlayerAirplane);
        playerAirplane.name = "PlayerAirplane";

        // Setamos a o aviao como alvo da camera
        SmoothFollow.Instance.target = playerAirplane.transform;

        //-ENEMYAIRPLANE--------------------------------------------------------------------------//

        enemyAirplane = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().EnemyAirplane);
        enemyAirplane.name = "EnemyAirplane";
        (enemyAirplane.GetComponent("EnemyAirplane") as EnemyAirplane).targetAirplane = playerAirplane.transform;

        //-ENEMYAIRPLANE--------------------------------------------------------------------------//

        enemyAirplane2 = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().EnemyAirplane);
        enemyAirplane2.transform.position = new Vector3(Random.Range(0,100), enemyAirplane2.transform.position.y, enemyAirplane2.transform.position.z);
        enemyAirplane2.name = "EnemyAirplane";
        (enemyAirplane2.GetComponent("EnemyAirplane") as EnemyAirplane).targetAirplane = playerAirplane.transform;

        //-ENEMYAIRPLANE--------------------------------------------------------------------------//

        enemyAirplane3 = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().EnemyAirplane);
        enemyAirplane3.transform.position = new Vector3(enemyAirplane3.transform.position.x, enemyAirplane3.transform.position.y , Random.Range(0,100));
        enemyAirplane3.name = "EnemyAirplane";
        (enemyAirplane3.GetComponent("EnemyAirplane") as EnemyAirplane).targetAirplane = playerAirplane.transform;

        //-SET------------------------------------------------------------------------------------//
        Set = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Set);
        Set.name = "Set";

        //-LIGHT----------------------------------------------------------------------------------//
        Light = (GameObject)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().Light);
        Light.name = "Light";

        //-INTERFACE-IN-GAME----------------------------------------------------------------------//
        interfaceInGame = (GUITexture)Instantiate(AssetManager.Instance.GetCampaignAndSurviveModeAssets().interfaceInGame);
        interfaceInGame.name = "InterfaceInGame";

        interfaceInGame.gameObject.AddComponent("ResizeGUITexture");
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).image = interfaceInGame.guiTexture;
        (interfaceInGame.GetComponent("ResizeGUITexture") as ResizeGUITexture).StartResize();

        (interfaceInGame.GetComponent("AirSpeedIndicator") as AirSpeedIndicator).playerAirplane = (this.playerAirplane.GetComponent("PlayerAirplane") as PlayerAirplane);

        base.Start();
    }