Пример #1
0
    /** SetBehaviorOfObjectsInFront Method
     * @Params : RaycastHit
     * Set the behavior of Objects detected in front of the player.
     * The method tries to get the type of the object (Mechanism, pickable etc...) if it has one and apply its behavior.
     **/
    private void SetBehaviorOfObjectsInFront(RaycastHit hit)
    {
        if (hit.transform.GetComponent <IInterractableEntity>() != null)
        {
            GameObject           objectInFrontOfPlayer = hit.transform.gameObject;
            IInterractableEntity interractable         = hit.transform.GetComponent <IInterractableEntity>();
            interractable.DisplayTextOfInterractable();
            HighlightStatus scriptExisting = objectInFrontOfPlayer.GetComponentInChildren <HighlightStatus>();
            if (scriptExisting == null)
            {
                GameObject obj = (GameObject)Resources.Load("Status/Utils/HighlightStatus", typeof(GameObject));
                Instantiate(obj, objectInFrontOfPlayer.transform.position, objectInFrontOfPlayer.transform.rotation, objectInFrontOfPlayer.transform);
            }
            else
            {
                scriptExisting.ResetStatus();
            }

            if (Input.GetKeyDown(InputsProperties.Activate) && !CursorBehaviour.CursorIsVisible)
            {
                interractable.ActivateInterractable();
            }
        }
    }