public void ShowSecondaryActionType()
    {
        if (!facade.GrabConfiguration.SecondaryAction)
        {
            if (GUILayout.Button("Generate Secondary Action"))
            {
                SwitchSecondaryAction();
            }
        }
        else
        {
            if (interactibleObject.GetComponent <ClimbableObject>())
            {
                return;
            }

            MyEditorTools.BeginHorizontal();

            var secondaryType = (InteractibleObject.SecondaryTypes)EditorGUILayout.EnumPopup("SecondaryAction", interactibleObject.secondaryAction);

            if (interactibleObject.secondaryAction != secondaryType)
            {
                Undo.RecordObject(interactibleObject, "Changed Secondary Type");
                interactibleObject.secondaryAction = secondaryType;
                SwitchSecondaryAction();
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
            }


            MyEditorTools.ShowRefrenceButton(facade.GrabConfiguration.SecondaryAction.gameObject);


            MyEditorTools.EndHorizontal();
        }
    }
Esempio n. 2
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();
            }
        }
    }