예제 #1
0
    /*
     * Activates only the components corresponding to the desired
     * treatment type, PAY or WAIT
     */
    public void activatePanel(TreatmentObtainType panelType)
    {
        if (panelType == TreatmentObtainType.PAY)
        {
            treatmentDay = true;
            justPay      = true;
            payPedestal.SetActive(true);
            payPill.SetActive(true);
            payPanel.SetActive(true);
            treatmentInformationPanel.SetActive(true);

            // Track the pay bottle's position
            payPill.transform.position = new Vector3(payBottleInitXPosition, payBottleInitYPosition, payBottleInitZPosition);
            payBottlePositionA         = payPill.transform.position;
            Debug.Log("Pay bottle instantiated at pos: " + payBottlePositionA.x.ToString() + "," + payBottlePositionA.y.ToString() + "," + payBottlePositionA.z.ToString());
        }

        else if (panelType == TreatmentObtainType.WAIT)
        {
            treatmentDay = true;
            justWait     = true;
            waitPedestal.SetActive(true);
            waitPill.SetActive(true);
            waitPanel.SetActive(true);
            treatmentInformationPanel.SetActive(true);

            // Track the wait bottle's position
            waitPill.transform.position = new Vector3(waitBottleInitXPosition, waitBottleInitYPosition, waitBottleInitZPosition);
            waitBottlePositionA         = waitPill.transform.position;
            Debug.Log("Wait bottle instantiated at pos: " + waitBottlePositionA.x.ToString() + "," + waitBottlePositionA.y.ToString() + "," + waitBottlePositionA.z.ToString());
        }
    }
예제 #2
0
    /*
     * Attempt to make a transaction - validate that the participant
     * can afford it, and then call out as necessary to apply changes
     * to the environment to reflect the transaction.
     */
    private bool attemptObtain(TreatmentObtainType t)
    {
        float effectiveWaitTime = -1.0f;     // Seconds
        float effectiveCost     = -1.0f;     // Lab dollars
        bool  transactionValid  = false;

        SimManager.GameState currentSimState = simManagerComponent.currentState();

        if (t == TreatmentObtainType.PAY)
        {
            effectiveCost    = simManagerComponent.getCurrentTreatmentCost();
            transactionValid = (
                currentSimState == SimManager.GameState.RUNNING &&
                simManagerComponent.getCurrentScore() > effectiveCost
                );
        }

        else if (t == TreatmentObtainType.WAIT)
        {
            effectiveWaitTime = simManagerComponent.getCurrentTreatmentWaitTime();
            transactionValid  = currentSimState == SimManager.GameState.RUNNING;
        }


        // Only apply changes to the environment if the transaction was approved
        if (transactionValid)
        {
            if (t != TreatmentObtainType.WAIT)
            {
                disablePanels();
            }
            simManagerComponent.determinePostTreatmentActions(t, effectiveCost, effectiveWaitTime);
        }

        else
        {
            // Play a quick error sound to make them realize it didn't work
            audioManagerComponent.playSound(AudioManager.SoundType.ERROR);

            Debug.Log("Invalid treatment obtain attempt. Resetting " + t.ToString() + " bottle position.");

            if (t == TreatmentObtainType.PAY)
            {
                // Detach the pill from the hand holding it
                Valve.VR.InteractionSystem.Hand handHoldingPill = simManagerComponent.getHandScriptHoldingObj(payPill);
                if (handHoldingPill != null)
                {
                    handHoldingPill.DetachObject(payPill);
                }

                // Then, reset its position
                payPill.transform.position = new Vector3(
                    payBottleInitXPosition,
                    payBottleInitYPosition,
                    payBottleInitZPosition
                    ); payPill.transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);

                payBottlePositionA = payPill.transform.position;
            }

            else if (t == TreatmentObtainType.WAIT)
            {
                // Detach the pill from the hand holding it
                Valve.VR.InteractionSystem.Hand handHoldingPill = simManagerComponent.getHandScriptHoldingObj(waitPill);
                if (handHoldingPill != null)
                {
                    handHoldingPill.DetachObject(waitPill);
                }

                // Then, reset its position
                waitPill.transform.position = new Vector3(
                    waitBottleInitXPosition,
                    waitBottleInitYPosition,
                    waitBottleInitZPosition
                    ); waitPill.transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);

                waitBottlePositionA = waitPill.transform.position;
            }

            else
            {
                Debug.Log("Unrecognized bottle type. Not resetting position.");
            }
        }

        return(transactionValid);
    }