Example #1
0
    public void Action() // Permet de déterminer l'action à effectuer en fonction du type de l'objet et de son état
    {
        switch (myType)
        {
        case Type.Door:
        {
            doorScript.SelectAndPlayAnimation(myState);
            if (contactSensor != null)
            {
                contactSensor.Switch();
            }
            return;
        }

        case Type.Drawer:
        {
            drawerScript.PlayAnim(this.gameObject.name);
            if (contactSensor != null)
            {
                contactSensor.Switch();
            }
            return;
        }

        case Type.Electronic:
        {
            electronicScript.ActOn();
            return;
        }

        case Type.Light:
        {
            electronicScript.ActOn();
            if (myState == State.Open)
            {
                this.transform.GetChild(0).GetComponent <Light>().enabled = false;
            }
            else if (myState == State.Close)
            {
                this.transform.GetChild(0).GetComponent <Light>().enabled = true;
            }
            return;
        }

        case Type.PickUp:
        {
            if (myState == State.Pick)
            {
//					Debug.Log ("Take");
                this.transform.parent = null;
                rb.useGravity         = true;
                rb.isKinematic        = false;
            }

            else if (myState == State.Drop)
            {
//					Debug.Log ("Release");
                this.transform.parent = characterTransform;
                rb.useGravity         = false;
                rb.isKinematic        = true;
            }

            return;
        }
        }
    }
Example #2
0
    void Update()
    {
        if (Input.GetKeyDown("e"))
        {
            Debug.Log("WalkedObject = " + walkedOverObject);

            if (walkedOverObject != null)
            {
                switch (walkedOverObject.tag)
                {
                case "PickUp":
                {
                    if (isPick)
                    {
                        walkedOverObject.transform.parent = null;
                        AddWalkedOverObject(null, null);
                        rb.useGravity  = true;
                        rb.isKinematic = false;
                        rb             = null;
                        isPick         = false;
                    }

                    else
                    {
                        walkedOverObject.transform.parent = characterTransform;
                        rb             = walkedOverObject.GetComponent <Rigidbody>();
                        rb.useGravity  = false;
                        rb.isKinematic = true;
                        isPick         = true;
                        guiShow        = false;
                    }

                    break;
                }

                case "Door":
                {
                    doorInteraction.PlayAnim();
                    break;
                }

                case "Drawer":
                {
                    drawerInteraction.PlayAnim(walkedOverObject.name);
                    break;
                }

                case "Light":
                {
                    if (walkedOverObject.transform.GetChild(0).GetComponent <Light>().enabled == false)
                    {
                        walkedOverObject.transform.GetChild(0).GetComponent <Light>().enabled = true;
                    }

                    else
                    {
                        walkedOverObject.transform.GetChild(0).GetComponent <Light>().enabled = false;
                    }

                    walkedOverObject.GetComponent <ElectronicDevice>().ActOn();

                    break;
                }

                case "Electronic":
                {
                    walkedOverObject.GetComponent <ElectronicDevice>().ActOn();
                    break;
                }

                case "Test-RFID":
                {
                    walkedOverObject.GetComponent <MovingObjectsRFID>().ChangePosition();
                    break;
                }

                default:
                    break;
                }
            }
        }
    }