Exemplo n.º 1
0
    private void OnValidate()
    {
        foreach (StoryEventContainer storyEventContainer in _storyEvents)
        {
            if (storyEventContainer._eventName == "")
            {
                storyEventContainer._eventName = "Default Name";
            }

            if (0 >= storyEventContainer._maxInteractionCount)
            {
                storyEventContainer._maxInteractionCount++;
            }
        }

        if (StoryEventManager.RequiresCollider(_storyEvents))
        {
            _collider = GetComponent <Collider>();
            if (_collider == null)
            {
                if (gameObject.activeSelf)
                {
                    StartCoroutine(FixColiderStatus(true, false));
                }

                return;
            }

            foreach (StoryEventContainer storyEventContainer in _storyEvents)
            {
                if (storyEventContainer._storyEventTriggerType == TriggerType.Interact)
                {
                    if (!GetComponent <Rigidbody>())
                    {
                        Rigidbody rb = gameObject.AddComponent <Rigidbody>();
                    }
                }
            }
        }
        else
        {
            if (_collider != null)
            {
                if (gameObject.activeSelf)
                {
                    StartCoroutine(FixColiderStatus(false));
                }
            }
        }

        if (GetComponent <Rigidbody>() && GetComponent <Collider>())
        {
            //   gameObject.layer = 0;
        }
        else
        {
            //   gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (_audioSource.clip != null)
     {
         if (!_audioSource.isPlaying)
         {
             _audioSource.clip = null;
             StoryEventManager.OnAudioFinished();
         }
     }
 }
Exemplo n.º 3
0
 private void Awake()
 {
     foreach (StoryEventContainer PstoryEvent in _storyEvents)
     {
         if (PstoryEvent._storyEventTriggerType == TriggerType.Awake)
         {
             if (PstoryEvent.CanExecuteStoryEvent())
             {
                 StoryEventManager.QueStoryEvents(PstoryEvent._storyEventsToPlay, PstoryEvent._eventName);
             }
         }
     }
 }
Exemplo n.º 4
0
 private void OnTriggerExit(Collider other)
 {
     foreach (StoryEventContainer PstoryEvent in _storyEvents)
     {
         if (PstoryEvent._storyEventTriggerType == TriggerType.TriggerExit)
         {
             if (PstoryEvent.CanExecuteStoryEvent(other.gameObject))
             {
                 StoryEventManager.QueStoryEvents(PstoryEvent._storyEventsToPlay, PstoryEvent._eventName);
                 return;
             }
         }
     }
 }
Exemplo n.º 5
0
    private void Update()
    {
        #region Movement

        if (Input.GetButtonDown("Jump") && _playerData._canJump)
        {
            _jumpKeyPressed = true;
        }

        _moveInput = _playerData._canMove ? transform.right * Input.GetAxis("Horizontal") + transform.forward * Input.GetAxis("Vertical") : Vector3.zero;
        #endregion

        #region LookAround

        //float mouseLookRotation will be set equal to the x value of the mousemovement multiplied by the sensitivity divined in the gameManager
        _mouseInput.x += Input.GetAxis("Mouse X") * GameManager.MouseVelocity * Time.fixedDeltaTime;
        //float mouseLookUp will be set equal to its old value + the current Y axis of the mouse multiplied by the sensitivity. the result wil be between -80 and 80
        _mouseInput.y = Mathf.Clamp(_mouseInput.y - (Input.GetAxis("Mouse Y") * GameManager.MouseVelocity * Time.fixedDeltaTime), -80, 80);

        #endregion

#if UNITY_EDITOR
        if (Input.GetKeyDown(KeyCode.F1))
        {
            StoryEventManager.FinishQue();
        }
#endif

        if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.Escape))
        {
            SceneManager.LoadScene(0);
        }

        if (Input.GetButton("Crouch") && _playerData._canCrouch)
        {
            ChangeHeight(_playerData._crouchHeight);
            _shouldStopCrouching = false;
        }
        else if (IsCrouching())
        {
            if (CanStopCrouching())
            {
                ChangeHeight(_playerData._normalHeight);
            }
            _shouldStopCrouching = true;
        }

        OnObjectInteraction();
    }
Exemplo n.º 6
0
    public void OnItemInteract(PlayerController owningPlayer)
    {
        Debug.Log("interact");

        foreach (StoryEventContainer PstoryEvent in _storyEvents)
        {
            if (PstoryEvent._storyEventTriggerType == TriggerType.Interact)
            {
                if (PstoryEvent.CanExecuteStoryEvent())
                {
                    StoryEventManager.QueStoryEvents(PstoryEvent._storyEventsToPlay, PstoryEvent._eventName);
                    return;
                }
            }
        }
    }
    void DisplayTriggerPropertys(Rect position, SerializedProperty property, GUIContent label)
    {
        NextLine(25);
        EditorGUI.PrefixLabel(CalculateRect(80, 15), new GUIContent("TriggerType:"));

        List <string> temp            = StoryEventManager.GetTriggerTypes();
        byte          _oldStringIndex = (byte)property.FindPropertyRelative("_interactionType").intValue;

        property.FindPropertyRelative("_interactionType").intValue = EditorGUI.Popup(CalculateRect(150, 0), _oldStringIndex, temp.ToArray());

        NextLine(35);

        EditorGUI.LabelField(CalculateRect(155, 50), new GUIContent("InteractionTriggerCount"));

        NextLine(25);
        EditorGUI.PrefixLabel(CalculateRect(30, 20), new GUIContent("Min:"));

        EditorGUI.PropertyField(CalculateRect(50, 0), property.FindPropertyRelative("_interactionCountBeforePlay"), GUIContent.none);
        EditorGUI.PrefixLabel(CalculateRect(30, 50), new GUIContent("Max:"));
        EditorGUI.PropertyField(CalculateRect(50, 10), property.FindPropertyRelative("_maxInteractionCount"), GUIContent.none);
    }
Exemplo n.º 8
0
 private void Awake()
 {
     Instance = this;
 }