Beispiel #1
0
        protected override void OnInitialize(ModuleConfiguration configuration)
        {
            BrainConfig brainConfig = configuration as BrainConfig;

            AwarenessRadius = brainConfig.AwarenessRadius;

            Awareness = new BrainAwareness(this);
            Triggers  = new BrainTriggers();

            ActiveBrain = BrainScriptSelector.InstantiateScript(brainConfig.SelectedBrainScript);
            ActiveBrain.SetComponent(this);

            CreateSpeechBubble();
        }
Beispiel #2
0
    void Update()
    {
        print(canInteract);
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        if (Input.GetMouseButtonDown(0))
        {
            if (canInteract == true)
            {
                //Checks if player clicks on interactable objects

                int layer_mask       = LayerMask.GetMask("Interactable");
                int destructableMask = LayerMask.GetMask("Destructable");
                int brainMask        = LayerMask.GetMask("Brain");
                if (Physics.Raycast(ray, out hitInfo, 1000, layer_mask))
                {
                    var rig = hitInfo.collider;
                    if (rig.CompareTag("Interactable"))
                    {
                        canvasToggle = rig.GetComponent <ToggleObjectCanvas>();
                        canvasToggle.ToggleCanvas();
                        playerScript.LockJoystick();

                        objectAudio.clip   = journalOpening;
                        objectAudio.volume = 0.542f;
                        objectAudio.Play();

                        UI.currentAnimator = rig.GetComponent <Animator>();

                        markingCanvasScript = rig.GetComponentInChildren <RemoveMarking>();
                        /*markingCanvasScript.DestroyMarking();*/
                    }

                    if (pUController.interactableHintInteger == 1)
                    {
                        pUController.CloseInteractableHint();
                        playerScript.UnlockJoystick();
                    }
                }

                if (Physics.Raycast(ray, out hitInfo, 1000, destructableMask))
                {
                    var rig = hitInfo.collider;
                    destructableScript = rig.GetComponent <Destructable>();
                    destructableScript.Break();
                }

                if (Physics.Raycast(ray, out hitInfo, 1000, brainMask))
                {
                    var rig = hitInfo.collider;
                    brainScript = rig.GetComponent <BrainScript>();
                    brainScript.BrainHit();
                }
            }
            int tutorialMask = LayerMask.GetMask("Tutorial");
            if (Physics.Raycast(ray, out hitInfo, 1000, tutorialMask))
            {
                var rig = hitInfo.collider;
                if (rig.CompareTag("Interactable"))
                {
                    canvasToggle = rig.GetComponent <ToggleObjectCanvas>();
                    canvasToggle.ToggleCanvas();
                    playerScript.LockJoystick();

                    objectAudio.clip   = journalOpening;
                    objectAudio.volume = 0.42f;
                    objectAudio.Play();

                    UI.currentAnimator = rig.GetComponent <Animator>();

                    markingCanvasScript = rig.GetComponentInChildren <RemoveMarking>();
                    /*markingCanvasScript.DestroyMarking();*/
                }
                if (rig.CompareTag("Wood"))
                {
                    rig.gameObject.GetComponent <Destructable>().Break();
                    pUController.CloseDestructableHint();
                    pUController.destructableHintInteger = 0;
                    playerScript.UnlockJoystick();
                }

                if (pUController.interactableHintInteger == 1)
                {
                    pUController.CloseInteractableHint();
                    playerScript.UnlockJoystick();
                }
            }
        }
    }