Esempio n. 1
0
 public void OnSelectStart(InteractibleObject interaction)
 {
     if (currentAudio != null)
     {
         speakerSource.PlayOneShot(currentAudio.PressAudio);
     }
 }
Esempio n. 2
0
    public void Throw(InteractibleObject carriedGO)
    {
        if (carriedGO != null)
        {
            if (container == Container.TRASH)
            {
                choresProgres.ChoreCompleted(typeOfObject);
                carriedGO.IdleToDestroyed();
                SoundManager.instance.PlayCorrectThrow();
            }
            else if (carriedGO.container == container)
            {
                choresProgres.ChoreCompleted(typeOfObject);
                levelManager.BonusTime();
                carriedGO.IdleToDestroyed();
                SoundManager.instance.PlayCorrectThrow();
            }
            else
            {
                SoundManager.instance.PlayIncorrectThrow();
                StartCoroutine(wrongConainerFeedback());
            }

            if (throwParticle != null)
            {
                throwParticle.Play();
            }
        }
    }
Esempio n. 3
0
 public void OnSelectEnd(InteractibleObject interaction)
 {
     if (currentAudio != null)
     {
         speakerSource.PlayOneShot(currentAudio.ReleaseAudio);
     }
 }
    public override void Act(InteractibleObject @from)
    {
        dialogueSource = FindObjectOfType <DialogueManager>();
        float toWait = 1.5f + afterThis.toPlay.length;

        dialogueSource.PlayDialogueAfter(toWait, narration);
    }
Esempio n. 5
0
    public void TriggerAction(InteractibleObject carriedGO)
    {
        if (doingSomething)
        {
            return;
        }

        switch (typeOfObject)
        {
        case TypeOfObject.MOVABLE:
            IdleToAttached();
            break;

        case TypeOfObject.DESTROYABLE:
            IdleToDestroyed();
            break;

        case TypeOfObject.REPARABLE:
            IdleToRepaired();
            break;

        case TypeOfObject.CONTAINER:
            Throw(carriedGO);
            break;
        }

        if (repairParticles != null)
        {
            repairParticles.Play();
        }
    }
Esempio n. 6
0
        public RaycastHit SphereCastFromHead(float radius)
        {
            Transform  head = HeadTransform;
            RaycastHit hitInfo;
            Ray        gazeRay = new Ray(head.position, head.forward);

            if (Physics.SphereCast(gazeRay, radius, out hitInfo))
            {
                Transform hitTransform = hitInfo.collider.transform;

                // Traverse up parent path until interactible object found
                while (hitTransform != null)
                {
                    InteractibleObject interactableComponent = hitTransform.GetComponent <InteractibleObject>();

                    if (interactableComponent != null)
                    {
                        return(hitInfo);
                    }

                    hitTransform = hitTransform.parent;
                }
            }

            return(hitInfo);
        }
Esempio n. 7
0
    IEnumerator Sequence(InteractibleObject f, Item toRemove, bool removeObject, List <Spawnable> spawning, AudioClip toPlay, Sprite newPlayerSprite)
    {
        FadeIn();
        yield return(new WaitForSeconds(fadeTime + 0.1f));

        if (removeObject)
        {
            Destroy(f.gameObject);
        }
        if (toRemove != null)
        {
            inventory.DeleteItem(toRemove);
        }
        foreach (var spawnable in spawning)
        {
            Transform spawned = Instantiate(spawnable.toSpawn, spawnable.spawnLocation, quaternion.identity);
        }

        if (newPlayerSprite != null)
        {
            ClickToMoveController player = FindObjectOfType <ClickToMoveController>();
            player.GetComponentInChildren <SpriteRenderer>().sprite = newPlayerSprite;
        }
        source.PlayOneShot(toPlay);
        yield return(new WaitForSeconds(toPlay.length + 0.1f));

        FadeOut();
    }
Esempio n. 8
0
    private void OnEnable()
    {
        if (transform.GetChild(0).GetComponent <DirectionalDriveFacade>())
        {
            dirDriveFacade = transform.GetChild(0).gameObject.GetComponent <DirectionalDriveFacade>();
        }
        else if (transform.GetChild(0).GetComponent <RotationalDriveFacade>())
        {
            rotDriveFacade = transform.GetChild(0).gameObject.GetComponent <RotationalDriveFacade>();
        }
        else
        {
            //Debug.LogError("No Drive a 0 child");
            return;
        }

        interactibleObject = GetComponentInChildren <InteractibleObject>();
        valueEventsParent  = transform.GetChild(transform.childCount - 1);
        CheckValueEvents();

        if (valueEvents == null)
        {
            valueEvents = new List <ValueEvent>();
        }
    }
Esempio n. 9
0
 public override void Act(InteractibleObject from)
 {
     cover = FindObjectOfType <BlackCover>();
     if (from == null)
     {
         removeInteractedObject = false;
     }
     cover.StartSequence(from, itemToRemove, removeInteractedObject, objectsToSpawn, toPlay, newPlayerSprite);
 }
Esempio n. 10
0
 public bool SetCarriedGO(InteractibleObject go)
 {
     if (carriedGO != null && go != null)
     {
         return(false);
     }
     carriedGO = go;
     return(true);
 }
Esempio n. 11
0
    private void OnTriggerEnter(Collider other)
    {
        InteractibleObject interact = other.GetComponent <InteractibleObject>();

        if (interact != null && interact.type != InteractibleObject.InteractType.FusePoint)
        {
            interact.Interact(other.transform.position);
        }
    }
Esempio n. 12
0
    void OnTriggerStay2D(Collider2D other)
    {
        InteractibleObject interactible = null;

        if (InteractibleObject.TryGetInteractible(other.gameObject, out interactible))
        {
            objectsInRange[other] = interactible;
        }
    }
        /// <summary>
        /// Does the transform contain a valid filter. No filter is a valid filter.
        /// </summary>
        /// <param name="transform"> The transform that will be tested for a valid filter. </param>
        /// <returns></returns>
        public bool ContainsValidFilter(Transform transform)
        {
            InteractibleObject interactibleObject = transform.GetComponent <InteractibleObject>();

            if (interactibleObject != null)
            {
                return(FilterTags.ValidTags.Contains(interactibleObject.FilterTag.Tag));
            }
            return(true);
        }
Esempio n. 14
0
    private void OnTriggerStay(Collider other)
    {
        InteractibleObject interact = other.GetComponent <InteractibleObject>();

        if (interact != null && (
                interact.type == InteractibleObject.InteractType.DangerZone ||
                interact.type == InteractibleObject.InteractType.Death))

        {
            interact.Interact(other.transform.position);
        }
    }
Esempio n. 15
0
    private void OnParticleCollision(GameObject col)
    {
        if (col.CompareTag("Player"))
        {
            MovementController movementController = col.GetComponent <MovementController>();
            Rigidbody          playerRigidbody    = col.GetComponent <Rigidbody>();
            if (!movementController.DamageCoolDownActivated)
            {
                movementController.DamageCoolDownActivated = true;

                // damage player
                InteractibleObject interactibleObject = GetComponent <InteractibleObject>();
                if (interactibleObject != null && interactibleObject.type == InteractibleObject.InteractType.Damage)
                {
                    interactibleObject.Interact(transform.position);
                }
            }

            if (movementController.IsFuseMoving)
            {
                return;
            }

            // bump player back
            if (ParticlesOnCollision != null)
            {
                Vector3 position = movementController.transform.position;
                position.y = 0.5f;
                Instantiate(ParticlesOnCollision, position, Quaternion.identity);
                AudioEvent.SendAudioEvent(AudioEvent.AudioEventType.HurtPlayer, _audioEvents, gameObject);
            }

            if (movementController.IsMoving)
            {
                Vector3 targetPos = movementController.transform.position -
                                    movementController.transform.forward * movementController.DamageBounceValue;
                targetPos.y = 0;
                StartCoroutine(movementController.MoveBackRoutine(targetPos, MovementController.MoveDuration));
            }
            else
            {
                _particleSystem.GetCollisionEvents(col, _collisionEvents);
                Vector3 collisionForce = _collisionEvents[0].velocity;
                collisionForce.y = 0;
                playerRigidbody.AddForce(collisionForce * WaterForce);
            }
        }
    }
    public override void Act(InteractibleObject @from)
    {
        Inventory mainInv = GlobalStats.instance.PlayerInventory;

        Debug.Log(mainInv.ItemSlots.Count);

        foreach (var item in toRemove)
        {
            mainInv.DeleteItem(item);
        }

        foreach (var item in toAdd)
        {
            mainInv.AddItem(item);
        }
    }
    private void OnSceneGUI()
    {
        interactibleObject = (InteractibleObject)target;

        if (interactibleObject.secondaryAction == InteractibleObject.SecondaryTypes.FollowDirection)
        {
            Handles.color = Color.red;
            Handles.DrawLine(interactibleObject.transform.position, interactibleObject.transform.position + interactibleObject.transform.forward);
        }

        //var tempEditor = CreateEditor(interactibleObject);

        //tempEditor.OnInspectorGUI();
        //SceneView.RepaintAll();
        //tempEditor.serializedObject.ApplyModifiedProperties();
    }
 public void UpdateOnHoverEnd(InteractibleObject caller) // Called during HoverStay() and HoverEnd() events by InteractionBehavior script
 {
     foreach (Finger finger in leftHandFingers)
     {
         if (finger.nearObjects.Contains(caller))
         {
             finger.nearObjects.Remove(caller);
         }
     }
     foreach (Finger finger in rightHandFingers)
     {
         if (finger.nearObjects.Contains(caller))
         {
             finger.nearObjects.Remove(caller);
         }
     }
 }
Esempio n. 19
0
    private void CheckRayCollision(float height, float width)
    {
        RaycastHit hit;

        if (Physics.Raycast(new Vector3(transform.position.x + width, height, transform.position.z), transform.forward, out hit,
                            Vector3.Distance(transform.position, TargetPosition)))
        {
            InteractibleObject interactableObj = hit.transform.gameObject.GetComponent <InteractibleObject>();
            if (interactableObj == null)
            {
                return;
            }
            interactableObj.Interact(hit.point);
            if ((IsDashing && interactableObj.IsBreakable) ||
                interactableObj.type == InteractibleObject.InteractType.BurnableProp)
            {
                CheckCollision();
            }
        }
    }
Esempio n. 20
0
File: Watcher.cs Progetto: tsi25/Zen
    public void Update()
    {
        if(rotationController != null) transform.rotation = rotationController.transform.rotation;
        RaycastHit[] hits = Physics.RaycastAll(transform.position, transform.forward, Mathf.Infinity);

        //run through all the hits
        for(int i = 0; i < hits.Length; i++)
        {
            //is thehit in  interactive layer
            if(hits[i].collider.gameObject.layer == INTERACTIVE_LAYER_ID)
            {
                InteractibleObject io = hits[i].collider.gameObject.GetComponent<InteractibleObject>();
                //does the hit actually have an interactible object?
                if (io != null)
                {
                    //we found a new object!
                    CurrentInteractibleObject = io;
                    return;
                }
            }
        }

        CurrentInteractibleObject = null;
    }
    public override void OnInspectorGUI()
    {
        interactibleObject = (InteractibleObject)target;

        if (interactibleObject.facade)
        {
            serializedObject.Update();

            facade           = interactibleObject.facade;
            serializedFacade = new SerializedObject(facade);

            if (facade != null)
            {
                ShowProperties();
            }
            else
            {
                GUILayout.Label("NO INTERACIBLE OBJECT");
            }

            serializedFacade.ApplyModifiedProperties();
            serializedObject.ApplyModifiedProperties();
        }
    }
Esempio n. 22
0
    // Update is called once per frame
    void Update()
    {
        Vector3 movement = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

        animator.SetFloat("speed", movement.magnitude);
        playerMovement.SetMovement(movement);
        if (carriedGO != null)
        {
            animator.SetBool("carryObject", true);
        }
        else
        {
            animator.SetBool("carryObject", false);
        }
        if (Input.GetButtonDown("Interaction"))
        {
            if (objectInFocus != null)
            {
                InteractibleObject interactedObject = objectInFocus.GetComponent <InteractibleObject>();
                if (interactedObject != null)
                {
                    interactedObject.TriggerAction(carriedGO);
                    objectInFocus.GetComponent <InteractibleObject>().SwitchHighlight(false);
                    objectInFocus = null;
                }
                else if (carriedGO != null)
                {
                    carriedGO.Place();
                }
            }
            else if (carriedGO != null)
            {
                carriedGO.Place();
            }
        }
    }
Esempio n. 23
0
 public void StartSequence(InteractibleObject f, Item toRemove, bool removeObject, List <Spawnable> toSpawn, AudioClip tp, Sprite newPlayerSprite)
 {
     StartCoroutine(Sequence(f, toRemove, removeObject, toSpawn, tp, newPlayerSprite));
 }
Esempio n. 24
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            List <string> validTags = new List <string>();
            List <string> layerTags = new List <string>();

            layerTags.Add(FilterTag.DefaultTag);

            // Find all focus layers in scene
            InteractibleObject[] interactibleObjects = FilterTagDrawer.GetAllInteractibleObjects();

            // Get all layer tags from interactible objects
            for (int i = 0; i < interactibleObjects.Length; ++i)
            {
                InteractibleObject interactibleObject = interactibleObjects[i];
                if (interactibleObject != null && interactibleObject.FilterTag != null)
                {
                    string tag = interactibleObject.FilterTag.Tag;

                    if (!string.IsNullOrEmpty(tag) && !layerTags.Contains(tag))
                    {
                        layerTags.Add(tag);
                    }


                    // Get all layer tags from other components on interactible objects
                    Component[] accompanyingComponents = interactibleObject.GetComponents <Component>();
                    for (int j = 0; j < accompanyingComponents.Length; j++)
                    {
                        if (accompanyingComponents[j] == interactibleObject)
                        {
                            continue;
                        }

                        foreach (FieldInfo field in accompanyingComponents[j].GetType().GetFields())
                        {
                            if (field.IsPublic && field.FieldType == typeof(FilterTag))
                            {
                                FilterTag fieldFilterTag = (FilterTag)field.GetValue(accompanyingComponents[j]);
                                if (fieldFilterTag != null && !string.IsNullOrEmpty(fieldFilterTag.Tag))
                                {
                                    layerTags.Add(fieldFilterTag.Tag);
                                }
                            }
                        }
                    }
                }
            }

            // Sort alphabetically
            layerTags.Sort();

            EditorGUI.BeginProperty(position, label, property);
            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            // Label
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            // Get the valid tags property
            SerializedProperty currentValidTagsProperty = property.FindPropertyRelative("ValidTags");

            // Add the current tags to the list
            for (int i = 0; i < currentValidTagsProperty.arraySize; ++i)
            {
                validTags.Add(currentValidTagsProperty.GetArrayElementAtIndex(i).stringValue);
            }

            // Get the current selected mask from the tags
            int mask = 0;

            for (int i = 0; i < layerTags.Count; ++i)
            {
                if (validTags.Contains(layerTags[i]))
                {
                    mask |= 1 << i;
                }
            }

            // Draw the mask feild
            Rect rect = new Rect(position.x, position.y, 150, 18);

            mask = EditorGUI.MaskField(rect, mask, layerTags.ToArray());

            // Get the new valid tags - the mask has changed
            validTags.Clear();
            for (int i = 0; i < layerTags.Count; ++i)
            {
                if ((mask & 1 << i) != 0)
                {
                    validTags.Add(layerTags[i]);
                }
            }

            // Set the tags
            currentValidTagsProperty.ClearArray();
            currentValidTagsProperty.arraySize = validTags.Count;

            for (int i = 0; i < currentValidTagsProperty.arraySize; ++i)
            {
                currentValidTagsProperty.GetArrayElementAtIndex(i).stringValue = validTags[i];
            }

            EditorGUI.indentLevel = indent;
            EditorGUI.EndProperty();
        }
Esempio n. 25
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            List <string> layerTags = new List <string>();

            layerTags.Add(FilterTag.DefaultTag);

            // Find all focus layers in scene
            InteractibleObject[] interactibleObjects = GetAllInteractibleObjects();

            // Get all layer tags
            for (int i = 0; i < interactibleObjects.Length; ++i)
            {
                InteractibleObject interactibleObject = interactibleObjects[i];
                if (interactibleObject != null && interactibleObject.FilterTag != null)
                {
                    string tag = interactibleObject.FilterTag.Tag;

                    if (!string.IsNullOrEmpty(tag) && !layerTags.Contains(tag))
                    {
                        layerTags.Add(tag);
                    }

                    // Get all layer tags from other components on interactible objects
                    Component[] accompanyingComponents = interactibleObject.GetComponents <Component>();
                    for (int j = 0; j < accompanyingComponents.Length; j++)
                    {
                        if (accompanyingComponents[j] == interactibleObject)
                        {
                            continue;
                        }

                        foreach (FieldInfo field in accompanyingComponents[j].GetType().GetFields())
                        {
                            if (field.IsPublic && field.FieldType == typeof(FilterTag))
                            {
                                FilterTag fieldFilterTag = (FilterTag)field.GetValue(accompanyingComponents[j]);
                                if (fieldFilterTag != null && !string.IsNullOrEmpty(fieldFilterTag.Tag))
                                {
                                    layerTags.Add(fieldFilterTag.Tag);
                                }
                            }
                        }
                    }
                }
            }

            // Sort alphabetically
            layerTags.Sort();

            EditorGUI.BeginProperty(position, label, property);

            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            // Label
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            // Current layer tag
            SerializedProperty currentLayerProperty = property.FindPropertyRelative("Tag");
            int tagIndex = layerTags.IndexOf(currentLayerProperty.stringValue);

            // Draw popup with all current tags in scene
            Rect rect = new Rect(position.x, position.y, 150, 18);

            tagIndex = EditorGUI.Popup(rect, tagIndex, layerTags.ToArray());

            // Set tag value
            if (tagIndex >= 0 && tagIndex < layerTags.Count)
            {
                currentLayerProperty.stringValue = layerTags.ElementAt(tagIndex);
            }
            else
            {
                currentLayerProperty.stringValue = FilterTag.DefaultTag;
            }

            // Draw tag
            rect = new Rect(position.x, position.y + 20, 150, 17);
            currentLayerProperty.stringValue = EditorGUI.TextField(rect, currentLayerProperty.stringValue);

            EditorGUI.indentLevel = indent;
            EditorGUI.EndProperty();
        }
Esempio n. 26
0
 public abstract void Act(InteractibleObject from);
 public override void Act(InteractibleObject from)
 {
     TaskManager.instance.CompleteTask(toComplete);
 }
Esempio n. 28
0
 public void OnHoverEnd(InteractibleObject interaction)
 {
     currentAudio = null;
 }
Esempio n. 29
0
 public static bool TryGetInteractible(GameObject obj, out InteractibleObject outInteractible)
 {
     return(interactibles.TryGetValue(obj, out outInteractible));
 }
Esempio n. 30
0
    // Update is called once per frame
    void Update()
    {
        hitObject = null;

        RaycastHit hit;

        Cm.setNormalCursor();

        InteractibleObject interacObj = null;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), out hit, range, 1 << 8)) // Raycast sur la layer des
        {
            hitObject  = hit.collider.gameObject;                                                                                       // on recupere l'objet vise
            interacObj = hitObject.GetComponent <InteractibleObject> ();                                                                // on recupere sa composante InteractibleObject

            if (handsFull &&
                (interacObj.type == InteractibleType.SettingPiece ||
                 interacObj.type == InteractibleType.NPC) &&
                !interacObj.GetComponent <ConvolutionObject> ().HasFragment()) // si on a un fragment et qu'on clique sur un batiment ou un NPC qui n'en a pas
            {
                Cm.setFragmentCursor();                                        // on met le fragment correspondant
            }
            else if
            (!handsFull &&
             ((interacObj.type == InteractibleType.Fragment &&
               (interacObj.transform.parent == null || interacObj.transform.parent.name != "inHandPosition")) ||
              (interacObj.type == InteractibleType.SettingPiece)))                         // Si on a les mains vides et qu'on vise un fragment ou un batiment
            {
                Cm.setInteractibleCursor();
            }
        }

        //Bouton action
        if (Input.GetButtonDown("Action"))
        {
            if (Cm.cursorT == CursorType.interactible)                       // si on a rien en main et qu'on vise un objet rammassable

            {
                print("try PickUpObject");
                PickUpObject(interacObj.OnTouch());
            }
            else if (Cm.cursorT == CursorType.fragment)                       // si on a un objet en main et qu'on vise un NPC
            // ou un batiment vide
            {
                ConvolutionObject convolObj = interacObj.GetComponent <ConvolutionObject> ();

                //ajout de l'objet en main a l'objet vise
                print("ajout de l'objet en main a l'objet vise");
                // WwiseAudioManager.instance.PlayFiniteEvent("linker_morceau", this.gameObject);
                Fragment fragment = inHandObject.GetComponent <Fragment> ();
                AddingFragment();
                convolObj.OnAddingFragment(fragment);
                fragment.gameObject.SetActive(false);
            }
            else if (handsFull)                         // sinon, si on a juste un objet en main et qu'on ne vise pas un NPC

            //on laisse tomber l'objet en main
            {
                DropInHandObject();
            }
            else
            {
                Cm.setFailCursor();
            }
        }
    }