/// <summary>
    /// Closes the door.
    /// </summary>
    public void CloseDoor(float DoorTravelTime)
    {
        if (state() == true)
        {
            if (!DoorBusy)
            {
                if (isPortcullis() == false)
                {
                    if (ObjectInteraction.PlaySoundEffects)
                    {
                        objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_DOOR_MOVE];
                        objInt().aud.Play();
                    }
                    StartCoroutine(RotateDoor(this.transform, Vector3.up * doordir() * CloseRotation, DoorTravelTime));
                }
                else
                {
                    if (ObjectInteraction.PlaySoundEffects)
                    {
                        objInt().aud.clip = GameWorldController.instance.getMus().SoundEffects[MusicController.SOUND_EFFECT_PORTCULLIS];
                        objInt().aud.Play();
                    }
                    StartCoroutine(RaiseDoor(this.transform, new Vector3(0f, -1.1f, 0f), DoorTravelTime));
                }
                objInt().item_id    -= 8;
                objInt().zpos       -= 24;
                objInt().flags       = 0;
                objInt().enchantment = 0;
                //state=false;

                if (objInt().link != 0)
                {                                                       //If it's link is to something that is not a lock then it is likely to be a trigger
                    if
                    (
                        (ObjectLoader.GetItemTypeAt(objInt().link) != ObjectInteraction.LOCK)
                        &&
                        (ObjectLoader.GetItemTypeAt(objInt().link) != ObjectInteraction.AN_OPEN_TRIGGER)
                    )
                    {
                        trigger_base tb = ObjectLoader.getObjectIntAt(objInt().link).GetComponent <trigger_base>();
                        if (tb != null)
                        {
                            tb.Activate(this.gameObject);
                        }
                    }
                    else
                    {                                                            //The object is linked to a lock. The next of the lock is the use trigger to use here
                        ObjectInteraction LockObj = ObjectLoader.getObjectIntAt(objInt().link);
                        if (LockObj != null)
                        {
                            int next = LockObj.next;

                            while (next != 0)
                            {
                                ObjectInteraction TriggerObject = ObjectLoader.getObjectIntAt(next);

                                if (TriggerObject != null)
                                {
                                    next = 0;
                                    trigger_base tb = TriggerObject.GetComponent <trigger_base>();
                                    if (tb != null)
                                    {
                                        if (tb.objInt().GetItemType() != ObjectInteraction.AN_OPEN_TRIGGER)
                                        {
                                            tb.Activate(this.gameObject);
                                        }
                                        next = tb.objInt().next;
                                    }
                                }
                                else
                                {
                                    next = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Opens the door.
    /// </summary>
    public void OpenDoor(float DoorTravelTime)
    {
        if (state() == false)
        {
            if (!DoorBusy)
            {
                if (isPortcullis() == false)
                {
                    if (ObjectInteraction.PlaySoundEffects)
                    {
                        objInt().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_DOOR_MOVE];
                        objInt().aud.Play();
                    }
                    StartCoroutine(RotateDoor(this.transform, Vector3.up * doordirection() * OpenRotation, DoorTravelTime));
                }
                else
                {
                    if (ObjectInteraction.PlaySoundEffects)
                    {
                        objInt().aud.clip = MusicController.instance.SoundEffects[MusicController.SOUND_EFFECT_PORTCULLIS];
                        objInt().aud.Play();
                    }
                    StartCoroutine(RaiseDoor(this.transform, new Vector3(0f, 1.1f, 0f), DoorTravelTime));
                }
                owner       = 0;
                item_id    += 8;
                zpos       += 24;
                enchantment = 1;
                if (isPortcullis())
                {
                    //flags=12;
                    flags = 4;
                    NavMeshObstacle nmo = this.GetComponent <NavMeshObstacle>();
                    if (nmo != null)
                    {
                        nmo.enabled = !state();
                    }
                }
                else
                {
                    //flags=13;
                    flags = 5;
                }

                //state=true;
                if (link != 0)
                {                               //If it's link is to something that is not a lock then it is likely to be a trigger
                    if (
                        (
                            (ObjectLoader.GetItemTypeAt(link) != ObjectInteraction.LOCK)
                            &&
                            (ObjectLoader.GetItemTypeAt(link) != ObjectInteraction.A_CLOSE_TRIGGER)
                        )
                        )
                    {
                        trigger_base tb = ObjectLoader.getObjectIntAt(link).GetComponent <trigger_base>();
                        if (tb != null)
                        {
                            tb.Activate(this.gameObject);
                        }
                    }
                    else
                    {                            //The object is linked to a lock. The next of the lock is the use trigger to use here
                        ObjectInteraction LockObj = ObjectLoader.getObjectIntAt(link);
                        if (LockObj != null)
                        {
                            int next = LockObj.next;

                            while (next != 0)
                            {
                                ObjectInteraction TriggerObject = ObjectLoader.getObjectIntAt(next);
                                if (TriggerObject != null)
                                {
                                    next = 0;
                                    trigger_base tb = TriggerObject.GetComponent <trigger_base>();
                                    if (tb != null)
                                    {
                                        if
                                        (
                                            (tb.objInt().GetItemType() != ObjectInteraction.A_CLOSE_TRIGGER)
                                            &&
                                            (tb.objInt().GetItemType() != ObjectInteraction.AN_UNLOCK_TRIGGER)
                                        )
                                        {
                                            tb.Activate(this.gameObject);
                                        }
                                        next = tb.next;
                                    }
                                }
                                else
                                {
                                    next = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
    }