示例#1
0
    //! Actions for when the State starts.
    // Set the Camera inside the state to be Active, overlaying the Main Camera used at InGameState,
    // close all dialogs that might be enabled.
    public override void OnStartRun()
    {
        //Opens inventory TODO: is it still going to be always open?
        GameObject.Find("InventoryManager").GetComponent <InventoryManager> ().changeList(0);
        cameraState.gameObject.SetActive(true);
        cameraState.depth = 2;

        Debug.Log("Starting LIA state");
        //Set active the interaction canvas accordingly to the type of step
        switch (progressController.StepType)
        {
        case TypeOfStep.CompoundClass:
            checkCompoundClassCanvas.SetActive(true);
            checkCompoundClassCanvas.GetComponentInChildren <ToggleGroup>().SetAllTogglesOff();
            break;

        case TypeOfStep.WhatCompound:
            whatCompoundAnswer.text = "";
            GameObject.Find("GameController").GetComponent <HUDController> ().LockKeys(true);
            checkWhatCompoundCanvas.SetActive(true);
            break;

        case TypeOfStep.MolarityCheck:
            molarityAnswer.text = "";
            GameObject.Find("GameController").GetComponent <HUDController> ().LockKeys(true);
            checkMolarityValueCanvas.SetActive(true);
            break;

        case TypeOfStep.GlasswareCheck:
            checkGlasswareCanvas.SetActive(true);
            break;
        }
        HudText.SetText("");
    }
示例#2
0
    public void UpdateHudText(Transform target, int value, HudTextEnum type)
    {
        HudText hud = ObjectPooling.Instance.GetObject <HudText>
                          (Manage.Instance.Resources.GetObj(ResourcesEnum.UIPrefab, "HudText"), HudTextParent);

        hud.Reset(target, value, type);
    }
        /// <summary>
        ///		From ICommandable. Executes when it's timer event goes off.
        ///		This does NOT respawn the player.
        /// </summary>
        public void ExecuteCommand()
        {
            // Lose a life
            GameSessionData.Active.DecrementLives();

            // Player will now disappear
            this.Context.MarkForDeletion();

            // Prepare the "Get Ready" text, but only in 2-player mode
            // And only if not Game Over
            if (SceneManager.Self.TotalNumberOfPlayers == SceneManager.NumberOfPlayers.Two &&
                GameSessionData.Active.Lives > 0)
            {
                string newText = " ";

                if (SceneManager.Self.ActiveSceneName == Scene.Name.GamePlayerOne)
                {
                    newText = "GET READY - PLAYER 2";
                }
                else if (SceneManager.Self.ActiveSceneName == Scene.Name.GamePlayerTwo)
                {
                    newText = "GET READY - PLAYER 1";
                }

                // Create the HUD text
                HudText getReady = new HudText(205.0f, 70.0f, newText, Azul.AZUL_FONTS.Consolas24pt, Colors.Green);
                SceneManager.Self.ActiveScene.HudDisplay.AddDisposableHudText(getReady);
            }

            this.timedEvent = null;
        }
示例#4
0
    // Update is called once per frame
    //! Processing precision errors.
    void Update()
    {
        if (allowShowFloat)
        {
            if (Time.time - timeToUpdateValueAcc > timeToUpdateValue)
            {
                string errorStringForm = "0";
                if (errorPrecision > 0)
                {
                    errorStringForm = "0.";
                    for (int i = 0; i < errorPrecision; i++)
                    {
                        errorStringForm += "0";
                    }
                }
                textResult.text      = applyErrorInFloat(resultFloat).ToString(errorStringForm);
                timeToUpdateValueAcc = Time.time;
            }
        }

        if (allowShowTexture)
        {
            if (rendererResult != null)
            {
                rendererResult.material.mainTexture = resultTexture;
            }
            allowShowTexture = false;
        }

        if (Time.time - timeToShowPrintTextAcc > timeToShowPrintText)
        {
            timeToShowPrintTextAcc = Mathf.Infinity;
            HudText.EraseText();
        }
    }
示例#5
0
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player")
        {
            if (Input.GetKeyDown(keyToUse) && allowChangeScene)
            {
                HudText.EraseText();

                this.transform.localScale = inventoryScale;

                this.GetComponent <Collider>().isTrigger = false;
                BoxCollider col = this.GetComponent <Collider>() as BoxCollider;
                col.size   = inventoryColliderSize;
                col.center = inventoryColliderPosition;


                this.transform.parent = inventory.gameObject.transform;
                DontDestroyOnLoad(this.gameObject);

                if (!isSolid)
                {
                    inventory.AddReagentLiquid(reagent);
                    reagent.inInventory = true;
                }
                else
                {
                    inventory.AddReagentSolid(reagentSolid);
                }
            }
        }
    }
    //! Actions for when the State starts.

    /*! Set the Camera inside the state to be Active, overlaying the Main Camera used at InGameState,
     * close all dialogs that might be enabled. */
    public override void OnStartRun()
    {
        cameraState.gameObject.SetActive(true);
        cameraState.depth = 2;
        HudText.SetText("");
        GetComponentInParent <WorkBench>().OnStartRun();
    }
示例#7
0
 //! The collider other has stopped touching the trigger.
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "Player" && allowGetData)
     {
         HudText.EraseText();
     }
 }
 //! Collider other has stopped touching the trigger.
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "Player")
     {
         allowChangeScene = false;
         HudText.EraseText();
     }
 }
 //! Does the interaction.
 /*! Fades the camera and starts the equipment state. */
 public override void Interact()
 {
     callInteract = true;
     HudText.SetText("");
     GetComponent <BoxCollider>().enabled = false;
     Debug.Log("here start interact");
     Interacting = true;
 }
示例#10
0
    //! Actions for when the State starts.

    /*! Set the Camera inside the state to be Active, overlaying the Main Camera used at InGameState,
     * close all dialogs that might be enabled. */
    public override void OnStartRun()
    {
        //cameraState.enabled = true;
        //cameraState.GetComponent<AudioListener> ().enabled = true;
        //cameraState.depth = 2;
        HudText.SetText("");
        returnPosition();
    }
示例#11
0
    //! Is called when the collider other enters the trigger.

    /*! This message is sent to the trigger collider and the rigidbody
     * that the trigger collider belongs to, and the rigidbody that touches the trigger.*/
    void OnTriggerEnter(Collider other)
    {
        Debug.Log(other.name);
        if (other.name == "Player" && allowGetData)
        {
            HudText.SetText("Aperte " + keyToUse.ToString() + " para pegar as folhas da impressora.");
        }
    }
示例#12
0
    //! Actions for when the State starts.

    /*! Set the Camera inside the state to be Active, overlaying the Main Camera used at InGameState,
     * does the animation to open the cupboard left door and enable the UI Canvas. */
    public override void OnStartRun()
    {
        //GameObject.Find ("Journal").GetComponent<JournalController> ().checkJournalItem (0);
        cameraState.gameObject.SetActive(true);
        HudText.SetText("");
        leftDoor.Open();
        canvasUI.GetComponent <Canvas>().enabled = true;

        //UIScrollList.transform.parent.GetComponent<ScrollRect>().verticalScrollbar.value = 1;
    }
    //! Actions for when the State starts.

    /*! Set the Camera inside the state to be Active, overlaying the Main Camera used at InGameState,
     * does the animation to open the cupboard left door and enable the UI Canvas. */
    public override void OnStartRun()
    {
        cameraState.gameObject.SetActive(true);
        HudText.SetText("");

        leftDoor.Open();
        canvasUI.GetComponent <Canvas>().enabled = true;

        //UIScrollList.transform.parent.GetComponent<ScrollRect>().verticalScrollbar.value = 1;
    }
 //! Message for interaction with the machine.
 /*! Is sent to the trigger collider and the rigidbody that the trigger collider belongs to, and to the rigidbody that touches the trigger.*/
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         allowChangeScene = true;
         if (string.IsNullOrEmpty(machineName))
         {
             HudText.SetText("Aperte " + keyToUse.ToString() + " para usar o aparelho.");
         }
         else
         {
             HudText.SetText("Aperte " + keyToUse.ToString() + " para usar " + machineName + ".");
         }
     }
 }
示例#15
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         allowChangeScene = true;
         if (isSolid)
         {
             HudText.SetText("Aperte " + keyToUse.ToString() + " para pegar " + solidName + ".");
         }
         else
         {
             HudText.SetText("Aperte " + keyToUse.ToString() + " para pegar " + objectName + ".");
         }
     }
 }
        //
        // Methods
        //

        public void ExecuteCommand()
        {
            // Not Game Over yet
            if (GameSessionData.Active.Lives > 0)
            {
                // Make the aliens move again
                AlienCoordinator aliens = GameObjectManager.Active.Find(GameObject.Name.AlienCoordinator, SceneManager.Self.ActiveScene.AlienCoordinatorId) as AlienCoordinator;
                Debug.Assert(aliens != null, "The AlienCoordinator could not be found upon respawning the Player!");
                aliens.StartMovingAgain();

                // Respawn player
                GameScene scene = SceneManager.Self.ActiveScene as GameScene;
                Debug.Assert(scene != null, "Trying to respawn a player in a non-GameScene!");
                PlayerFactory factory = new PlayerFactory(scene);
                factory.CreatePlayer();

                // Go to the next scene. See OnLoadNextScene() in P1Scene and P2Scene
                SceneManager.Self.ActiveScene.TransitionToNextScene();
            }
            // Game Over
            else
            {
                // Create a new Game Over text for the HUD
                HudText gameOverText = new HudText(HudDisplayer.LabelGameOverX, HudDisplayer.LabelGameOverY, "GAME OVER", Azul.AZUL_FONTS.Consolas36pt, Colors.Red);
                SceneManager.Self.ActiveScene.HudDisplay.AddHudText(gameOverText);

                // Test for new highscore
                bool isNewHighscore = SceneManager.Self.DetermineNewHighscore(GameSessionData.Active.Score);
                if (isNewHighscore)
                {
                    HudText highScoreLabel = new HudText(HudDisplayer.LabelGameOverX + 27.0f, HudDisplayer.LabelGameOverY + 70.0f, "NEW HIGHSCORE", Azul.AZUL_FONTS.Consolas12pt, Colors.White);
                    SceneManager.Self.ActiveScene.HudDisplay.AddHudText(highScoreLabel);
                }

                // Create a GameOver delay. Which will go to the next scene.
                GameOverDelayEvent gameOver = new GameOverDelayEvent();
            }

            // This thing is done
            this.timedEvent = null;
        }
    //! Set positons (player) and rotation (camera).
    /*! Is sent to the trigger and the collider that touches the trigger.*/
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player")
        {
            if (Input.GetKeyDown(keyToUse))
            {
                HudText.EraseText();

                PlayerPrefs.SetFloat("PlayerPosX", other.transform.position.x);
                PlayerPrefs.SetFloat("PlayerPosy", other.transform.position.y);
                PlayerPrefs.SetFloat("PlayerPosZ", other.transform.position.z);
                PlayerPrefs.SetFloat("RotationCameraX", Camera.main.transform.localEulerAngles.x);
                PlayerPrefs.SetFloat("RotationCameraY", Camera.main.transform.localEulerAngles.y);
                PlayerPrefs.SetFloat("RotationCameraZ", Camera.main.transform.localEulerAngles.z);
                PlayerPrefs.Save();
                Application.LoadLevel(sceneToGo);

                InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
            }
        }
    }
示例#18
0
    //! Is called almost all the frames for every collider other that is touching the trigger.
    /*! This message is sent to the trigger and the collider that touches the the trigger. */
    void OnTriggerStay(Collider other)
    {
        if (other.tag == "Player" && allowGetData)
        {
            if (Input.GetKeyDown(keyToUse))
            {
                HudText.EraseText();
                allowGetData = false;

                //! Add the chart in inventory
                foreach (Texture2D item in pressSheets)
                {
                    Chart graph = Instantiate(chartPrefab) as Chart;
                    graph.transform.parent = inventory.transform;
                    graph.SetChart(item);
                    graph.gameObject.layer = 10;
                    inventory.AddChart(graph);
                }

                pressSheets.Clear();
            }
        }
    }
    //! Does the interaction.
    /*! Fades the camera and starts the equipment state. */
    public override void Interact()
    {
        callInteract = true;
        HudText.SetText("");
        GetComponent <BoxCollider>().enabled = false;
        //arrumar a posição do player
        player.transform.position = newPosition;

        //Ativar o Timed Input do botão Action
        ActionButton.GetComponent <TimedInputObject>().enabled = true;
        phMeterButton.GetComponent <CanvasGroup>().alpha       = 1f;
        canvasLigarMedir.GetComponent <CanvasGroup>().alpha    = 0.5f;
        map.GetComponent <TimedInputObject>().enabled          = false;
        exit.GetComponent <TimedInputObject>().enabled         = false;
        exit.GetComponent <CanvasGroup>().alpha = 0f;
        gameControler.GetComponent <HUDController>().mapBlocked = true;
        dicaLocomotionCanvas.GetComponent <CanvasGroup>().alpha = 0f;
        dicaLocomotionCanvas.enabled = false;
        DisplayY.GetComponent <CanvasGroup>().alpha = 0f;
        setinha.gameObject.SetActive(true);
        LigarButton.enabled = true;
        MedirButton.enabled = true;
        Interacting         = true;
    }
示例#20
0
    //! Uses of reagent liquid in all machines.
    public void Use(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }

        switch (myType)
        {
        case MACHINES.PHMETER:
        {
            resultFloat      = realReagent.PH;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            resultFloat      = realReagent.Conductibility - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            resultTexture    = realReagent.uvSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            resultTexture    = realReagent.irSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_FLAME:
        {
            resultTexture = Resources.Load <Texture2D>("specter/grafico_sem_fitting");
            //resultTexture = realReagent.flameSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.POLARIMETER:
        {
            resultFloat      = realReagent.Polarizability;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.HPLC:
        {
            resultTexture    = realReagent.hplc;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.REFRATOMETER:
        {
            resultFloat      = realReagent.Refratometer;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            resultFloat      = realReagent.Turbidity - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;
        }

        InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;

        //!Prints the chart
        if (allowShowTexture)
        {
            resultTexture = ChartGenerator.GenerateWithTextureConectingDots(resultTexture, concentration, 0.8f);
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);

            HudText.SetText("O grafico foi Impresso!");
            timeToShowPrintTextAcc = Time.time;
        }

        if (allowShowFloat)
        {
            resultFloat *= concentration;
        }
    }
示例#21
0
    //! Setup of reagent liquid in all machines.
    public void Setup(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }


        allowShowFloat   = false;
        allowShowTexture = false;

        bool showFloat = false;

        switch (myType)
        {
        default:
        {
            setupFloat       = 0f;
            setupTexture     = null;
            allowShowFloat   = false;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            setupFloat = realReagent.Conductibility;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            setupTexture     = realReagent.uvSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            setupTexture     = realReagent.irSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            setupFloat = realReagent.Turbidity;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;
        }

        if (showFloat)
        {
            resultFloat *= concentration;

            string errorStringForm = "0";
            if (errorPrecision > 0)
            {
                errorStringForm = "0.";
                for (int i = 0; i < errorPrecision; i++)
                {
                    errorStringForm += "0";
                }
            }

            textResult.text = applyErrorInFloat(resultFloat).ToString(errorStringForm);
        }

        if (allowShowTexture)
        {
            setupTexture = ChartGenerator.GenerateWithTextureConectingDots(setupTexture, concentration, 0.8f);
            HudText.SetText("O grafico foi Impresso!");
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);
            timeToShowPrintTextAcc = Time.time;
        }
    }
示例#22
0
 private void Start()
 {
     score = FindObjectOfType <HudText>();
 }
示例#23
0
    // Use this for initialization
    //! Returns the component of type TextObject.
    void Start()
    {
        instance = this;

        textObject = instance.gameObject.GetComponent <Text> ();
    }
示例#24
0
    void Update()
    {
        if (inInteraction)
        {
            motor.movement.velocity = Vector3.zero;
            transform.position      = lastPosition;
            currentDelay           += Time.deltaTime;
            if (currentDelay > delayInteract)
            {
                currentDelay  = 0;
                inInteraction = false;
            }
            return;
        }

        // Get the input vector from kayboard or analog stick
        Vector3 directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

        if (directionVector != Vector3.zero)
        {
            // Get the length of the directon vector and then normalize it
            // Dividing by the length is cheaper than normalizing when we already have the length anyway
            float directionLength = directionVector.magnitude;
            directionVector = directionVector / directionLength;

            // Make sure the length is no bigger than 1
            directionLength = Mathf.Min(1.0f, directionLength);

            // Make the input vector more sensitive towards the extremes and less sensitive in the middle
            // This makes it easier to control slow speeds when using analog sticks
            directionLength = directionLength * directionLength;

            // Multiply the normalized direction vector by the modified length
            directionVector = directionVector * directionLength;
        }

        // Apply the direction to the CharacterMotor
        if (!keysLocked)
        {
            motor.inputMoveDirection = transform.rotation * directionVector;
            //motor.inputJump = Input.GetButton ("Jump");
        }

        // Implements Raycast to get which object is being Hit and how to interact with it.
        Ray        cameraRay = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, Mathf.Infinity));
        RaycastHit hitInfo;


        if (Physics.Raycast(cameraRay, out hitInfo, Mathf.Infinity))
        {
            bool nameReset = false;
            if (hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ())
            {
                if (hitInfo.collider.gameObject.Equals(lastHit.collider.gameObject))
                {
                    nameReset = true;
                    hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ().SetTrigger(true);
                    HudText.SetText(hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ().equipName);
                    if (hitInfo.distance > 3)
                    {
                        hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ().setCanvasAlpha(1f);
                    }
                    else
                    {
                        hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ().setCanvasAlpha(0.5f * hitInfo.distance - 0.5f);
                    }
                }
                else
                if (lastHit.collider.GetComponent <AccessEquipmentBehaviour> () != null)
                {
                    lastHit.collider.GetComponent <AccessEquipmentBehaviour> ().SetTrigger(false);
                }
            }
            else if (lastHit.collider.GetComponent <AccessEquipmentBehaviour> () != null)
            {
                lastHit.collider.GetComponent <AccessEquipmentBehaviour> ().SetTrigger(false);
            }
            if (hitInfo.collider.GetComponent <InteractObjectBase> () && hitInfo.distance <= distanceToInteract)
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    hitInfo.collider.GetComponent <InteractObjectBase> ().Interact();
                    if (!hitInfo.collider.GetComponent <AccessEquipmentBehaviour> ())
                    {
                        gameObject.GetComponent <PlayerAnimation> ().PlayInteractAnimation();
                    }
                    inInteraction = true;
                    lastPosition  = transform.position;
                }
                HudText.SetText(interactText);
            }
            else
            {
                if (!nameReset)
                {
                    HudText.EraseText();
                }
            }
            //show information about the object

            lastHit = hitInfo;
        }


        //State Machine for the different uses of input
        //HUD components:

        /*if (Input.GetKeyDown (KeyCode.Escape)) {
         *      hudController.menu.Pause ();
         * }
         * if(Input.GetKeyDown(hudController.journalKey)&&!hudController.lockKey){
         *      hudController.CallTabletTrigger();
         * }
         * if ((Input.GetKeyDown (hudController.inventoryKey))&&!hudController.lockKey) {
         *      hudController.CallInventoryTrigger();
         * }
         * if((Input.GetKeyDown(hudController.mapKey))&&!hudController.lockKey){
         *      hudController.CallMapTrigger();
         * }
         *
         * //End of states
         * if (gameController.GetCurrentState () == gameController.gameStates [0]) {
         *
         * }*/
    }