Esempio n. 1
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 /// <returns>true</returns>
 /// <c>false</c>
 override public bool DoMove()
 {
     if (showing)
     {
         if (!done && !dialog.Visible)
         {
             enemy.MovementComplete();
             dialog.HideDialog();
             done = true;
         }
     }
     else if (!done)
     {
         dialog.ShowDialog();
         showing = true;
     }
     return(true);
 }
Esempio n. 2
0
        /// <summary>
        /// Character leaves the trigger.
        /// </summary>
        /// <param name="character">Character. NOTE: This can be null if triggered by something that is not a character.</param>
        virtual protected bool LeaveTrigger(Character character)
        {
            if (enabled && ExitConditionsMet(character))
            {
                if (autoLeaveRoutine != null)
                {
                    StopCoroutine(autoLeaveRoutine);
                    autoLeaveRoutine = null;
                }
                OnTriggerExited(character);
                for (int i = 0; i < receivers.Length; i++)
                {
                    if (receivers[i] != null)
                    {
                        // TODO Should only be one implementation of these
                        switch (receivers[i].leaveAction)
                        {
                        case TriggerActionType.SEND_MESSAGE:
                            receivers[i].receiver.SendMessage("EnterTrigger", SendMessageOptions.DontRequireReceiver);
                            break;

                        case TriggerActionType.ACTIVATE_PLATFORM:
                            receivers[i].platform.Activate(character);
                            break;

                        case TriggerActionType.DEACTIVATE_PLATFORM:
                            receivers[i].platform.Deactivate(character);
                            break;

                        case TriggerActionType.ACTIVATE_GAMEOBJECT:
                            receivers[i].receiver.SetActive(true);
                            break;

                        case TriggerActionType.DEACTIVATE_GAMEOBJECT:
                            receivers[i].receiver.SetActive(false);
                            break;

                        case TriggerActionType.CHANGE_CAMERA_ZONE:
                            PlatformCamera.DefaultCamera.ChangeZone(receivers[i].cameraZone);
                            break;

                        case TriggerActionType.SWITCH_SPRITE:
                            SpriteRenderer spriteRenderer = receivers[i].receiver.GetComponentInChildren <SpriteRenderer>();
                            if (spriteRenderer != null)
                            {
                                spriteRenderer.sprite = receivers[i].newSprite;
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to switch sprite but no SpriteRenderer was found");
                            }
                            break;

                        case TriggerActionType.SHOW_DIALOG:
                            UIDialog dialog = receivers[i].receiver.GetComponentInChildren <UIDialog>();
                            if (dialog != null)
                            {
                                dialog.ShowDialog(transform);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to show dialog but no UIDialog was found.");
                            }
                            break;

                        case TriggerActionType.HIDE_DIALOG:
                            UIDialog dialogToHide = receivers[i].receiver.GetComponentInChildren <UIDialog>();
                            if (dialogToHide != null)
                            {
                                dialogToHide.HideDialog();
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to show dialog but no UIDialog was found.");
                            }
                            break;

                        case TriggerActionType.OPEN_DOOR:
                            Door doorToOpen = receivers[i].receiver.GetComponent <Door>();
                            if (doorToOpen != null)
                            {
                                doorToOpen.Open(character);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to open door but no Door was found.");
                            }
                            break;

                        case TriggerActionType.CLOSE_DOOR:
                            Door doorToClose = receivers[i].receiver.GetComponent <Door>();
                            if (doorToClose != null)
                            {
                                doorToClose.Close(character);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to close door but no Door was found.");
                            }
                            break;

                        case TriggerActionType.ACTIVATE_SPAWN_POINT:
                            RespawnPoint point = receivers[i].receiver.GetComponentInChildren <RespawnPoint>();
                            if (point != null)
                            {
                                point.SetActive();
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to activate respawn point but no RespawnPoint was found");
                            }
                            break;

                        case TriggerActionType.FORWARD:
                            receivers[i].combiner.LeftTrigger(this, character);
                            break;
                        }
                    }
                }
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        /// Character entered proximity.
        /// </summary>
        /// <param name="character">Character. NOTE: This can be null if triggered by something that is not a character.</param>
        virtual protected void EnterTrigger(Character character)
        {
            if (enabled && ConditionsMet(character))
            {
                OnTriggerEntered(character);
                for (int i = 0; i < receivers.Length; i++)
                {
                    if (receivers[i] != null)
                    {
                        switch (receivers[i].enterAction)
                        {
                        case TriggerActionType.SEND_MESSAGE:
                            receivers[i].receiver.SendMessage("EnterTrigger", SendMessageOptions.DontRequireReceiver);
                            break;

                        case TriggerActionType.ACTIVATE_PLATFORM:
                            receivers[i].platform.Activated = true;
                            break;

                        case TriggerActionType.DEACTIVATE_PLATFORM:
                            receivers[i].platform.Activated = false;
                            break;

                        case TriggerActionType.ACTIVATE_GAMEOBJECT:
                            receivers[i].receiver.SetActive(true);
                            break;

                        case TriggerActionType.DEACTIVATE_GAMEOBJECT:
                            receivers[i].receiver.SetActive(false);
                            break;

                        case TriggerActionType.CHANGE_CAMERA_ZONE:
                            PlatformCamera.DefaultCamera.ChangeZone(receivers[i].cameraZone);
                            break;

                        case TriggerActionType.SWITCH_SPRITE:
                            // TODO This should not be done here
                            SpriteRenderer spriteRenderer = receivers[i].receiver.GetComponentInChildren <SpriteRenderer>();
                            if (spriteRenderer != null)
                            {
                                spriteRenderer.sprite = receivers[i].newSprite;
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to switch sprite but no SpriteRenderer was found");
                            }
                            break;

                        case TriggerActionType.SHOW_DIALOG:
                            UIDialog dialog = receivers[i].receiver.GetComponentInChildren <UIDialog>();
                            if (dialog != null)
                            {
                                dialog.ShowDialog(transform);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to show dialog but no UIDialog was found.");
                            }
                            break;

                        case TriggerActionType.HIDE_DIALOG:
                            UIDialog dialogToHide = receivers[i].receiver.GetComponentInChildren <UIDialog>();
                            if (dialogToHide != null)
                            {
                                dialogToHide.HideDialog();
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to show dialog but no UIDialog was found.");
                            }
                            break;

                        case TriggerActionType.OPEN_DOOR:
                            Door doorToOpen = receivers[i].receiver.GetComponent <Door>();
                            if (doorToOpen != null)
                            {
                                doorToOpen.Open(character);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to open door but no Door was found.");
                            }
                            break;

                        case TriggerActionType.CLOSE_DOOR:
                            Door doorToClose = receivers[i].receiver.GetComponent <Door>();
                            if (doorToClose != null)
                            {
                                doorToClose.Close(character);
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to close door but no Door was found.");
                            }
                            break;

                        case TriggerActionType.ACTIVATE_SPAWN_POINT:
                            RespawnPoint point = receivers[i].receiver.GetComponentInChildren <RespawnPoint>();
                            if (point != null)
                            {
                                point.SetActive();
                            }
                            else
                            {
                                Debug.LogError("Trigger tried to activate respawn point but no RespawnPoint was found");
                            }
                            break;
                        }
                    }
                }

                if (autoLeaveTime > 0)
                {
                    if (!oneShot || autoLeaveRoutine == null)
                    {
                        autoLeaveRoutine = DoLeaveAfterDelay(character, autoLeaveTime);
                        StartCoroutine(autoLeaveRoutine);
                    }
                }
                else
                {
                    if (oneShot)
                    {
                        enabled = false;
                    }
                }
            }
        }