コード例 #1
0
    public void UpdateItemCount(GameObject objective)
    {
        ObjectiveInteractable oi = objective.GetComponent <ObjectiveInteractable>();

        if (oi != null)
        {
            tag = oi.name;
        }

        //Checks if the objectives name is the same as the type string
        if (string.Equals(tag, ObjectiveTag))
        {
            OnPickup.Invoke();
            CurrentAmount++;
            Debug.Log(oi.name);
            //Displays message feed
            if (CurrentAmount <= Amount)
            {
                MessageFeedManager.Instance.WriteMessage(string.Format("{0}: {1}/{2}", objective.name, CurrentAmount, Amount));
            }

            QuestLog.Instance.UpdateSelectedQuest();
            QuestLog.Instance.CheckCompletion();

            // if quest is complete
            if (IsComplete)
            {
                CurrentAmount = Amount;
                QuestLog.Instance.UpdateSelectedQuest();
                OnCompletion.Invoke();
            }
        }
    }
コード例 #2
0
        public void HandleStay(Collider2D other)
        {
            if ((1 << other.gameObject.layer & interactableLayer) != 0)
            {
                currentInteractable = other.GetComponentInParent <Interactable>();
                currentInteractable.InRange(player.IsGrounded
          ? InteractableState.Enabled : InteractableState.DisabledVisible);
            }

            if ((1 << other.gameObject.layer & objectiveInteractableLayer) != 0)
            {
                currentObjectiveInteractable = other.GetComponentInParent <ObjectiveInteractable>();
                if (currentObjectiveInteractable.HasInteraction())
                {
                    currentObjectiveInteractable.InRange(player.IsGrounded
            ? InteractableState.Enabled : InteractableState.DisabledVisible);
                }
                else
                {
                    currentObjectiveInteractable.ExitRange();
                }
            }

            if ((1 << other.gameObject.layer & guardAttentionLayer) != 0)
            {
                currentZone = other.GetComponentInChildren <AttentionZone>();
                currentZone.StayAttention(gameObject);
            }

            if ((1 << other.gameObject.layer & lineOfSightLayer) != 0)
            {
                currentLineOfSight = other.GetComponentInChildren <LineOfSight>();
                currentLineOfSight.EnterAttention();
            }

            if ((1 << other.gameObject.layer & lightLayer) != 0)
            {
                playerLitManager.IsLit = true;
            }

            if ((1 << other.gameObject.layer & eventSequenceLayer) != 0)
            {
                var eventSequence = other.GetComponentInParent <EventSequence>();
                StartCoroutine(eventSequence.ExecuteSequence());
            }

            if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0)
            {
                var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>();
                conditionalDisplay.UpdateCondition();
            }
        }
コード例 #3
0
        public void HandleExit(Collider2D other)
        {
            if (currentInteractable != null && (1 << other.gameObject.layer & interactableLayer) != 0)
            {
                other.GetComponentInParent <ObjectiveInteractable>().ExitRange();
                currentInteractable = null;
            }

            if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0)
            {
                var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>();
                conditionalDisplay.Hide();
            }
        }
コード例 #4
0
 public void StartDialogue(TextAsset[] text,
                           DialogueType type,
                           Transform parent,
                           ObjectiveInteractable currentInteractable = null,
                           Action onComplete = null)
 {
     if (queuedDialogue)
     {
         return;
     }
     runner.SourceText               = text;
     uiBehaviour.BubbleParent        = parent;
     uiBehaviour.CurrentInteractable = currentInteractable;
     uiBehaviour.OnDialogueComplete  = onComplete + EnableInput;
     StartCoroutine(QueueDialogue());
 }
コード例 #5
0
        public void HandleExit(Collider2D other)
        {
            if ((1 << other.gameObject.layer & interactableLayer) != 0)
            {
                //Assumes you can only intersect one interactable at a time.
                other.GetComponentInParent <Interactable>().ExitRange();
                currentInteractable = null;
            }

            if ((1 << other.gameObject.layer & objectiveInteractableLayer) != 0)
            {
                //Assumes you can only intersect one interactable at a time.
                other.GetComponentInParent <ObjectiveInteractable>().ExitRange();
                currentObjectiveInteractable = null;
            }

            if ((1 << other.gameObject.layer & vantageLayer) != 0)
            {
                vantagePointManager.ResetVantage();
            }

            if ((1 << other.gameObject.layer & guardAttentionLayer) != 0)
            {
                currentZone = null;
            }

            if ((1 << other.gameObject.layer & lightLayer) != 0)
            {
                playerLitManager.IsLit = false;
            }

            if ((1 << other.gameObject.layer & guardAttentionLayer) != 0)
            {
                currentZone = other.GetComponentInChildren <AttentionZone>();
                currentZone.ExitAttention(gameObject);
            }

            if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0)
            {
                var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>();
                conditionalDisplay.Hide();
            }
        }
コード例 #6
0
        private void UpdateCurrentInteractable(Collider2D other)
        {
            ObjectiveInteractable interactable = other.GetComponentInParent <ObjectiveInteractable>();

            if (!interactable.HasInteraction())
            {
                interactable.ExitRange();
                currentInteractable = null;
                return;
            }

            currentInteractable = interactable;
            if (currentInteractable != null && !player.IsGrounded)
            {
                currentInteractable.InRange(InteractableState.DisabledVisible);
                return;
            }

            currentInteractable.InRange(InteractableState.Enabled);
        }
コード例 #7
0
    public override void Act()
    {
        if (target == null)
        {
            return;
        }

        Debug.Log("Interact action called.");
        ObjectiveInteractable objective = target.GetComponent <ObjectiveInteractable>();
        {
            if (objective != null && !objective.isCollected)
            {
                if (onInteractObjective != null)
                {
                    if (objective.enabled)
                    {
                        objective.isCollected = true;
                        onInteractObjective.Invoke(objective.gameObject);
                    }
                }
            }
        }
    }
コード例 #8
0
 public void RegisterInteractable(ObjectiveInteractable interactable)
 {
     interactables.Add(interactable);
 }
コード例 #9
0
        public void HandleEnter(Collider2D other)
        {
            if ((1 << other.gameObject.layer & interactableLayer) != 0)
            {
                currentInteractable = other.GetComponentInParent <Interactable>();
                currentInteractable.InRange(player.IsGrounded
          ? InteractableState.Enabled : InteractableState.DisabledVisible);
            }

            if ((1 << other.gameObject.layer & objectiveInteractableLayer) != 0)
            {
                currentObjectiveInteractable = other.GetComponentInParent <ObjectiveInteractable>();
                if (currentObjectiveInteractable.HasInteraction())
                {
                    currentObjectiveInteractable.InRange(player.IsGrounded
            ? InteractableState.Enabled : InteractableState.DisabledVisible);
                }
                else
                {
                    currentObjectiveInteractable.ExitRange();
                }
            }

            if ((1 << other.gameObject.layer & eventSequenceLayer) != 0)
            {
                var eventSequence = other.GetComponentInParent <EventSequence>();
                StartCoroutine(eventSequence.ExecuteSequence());
            }

            if ((1 << other.gameObject.layer & oneWayTriggerLayer) != 0)
            {
                var oneWayPlatform = other.GetComponentInParent <OneWayPlatform>();
                oneWayPlatform.IntersectTrigger();
            }

            if ((1 << other.gameObject.layer & guardAttentionLayer) != 0)
            {
                currentZone = other.GetComponentInChildren <AttentionZone>();
                currentZone.EnterAttention(gameObject);
            }

            if ((1 << other.gameObject.layer & lineOfSightLayer) != 0)
            {
                currentLineOfSight = other.GetComponentInChildren <LineOfSight>();
                currentLineOfSight.EnterAttention();
            }

            if ((1 << other.gameObject.layer & vantageLayer) != 0)
            {
                var vantage = other.GetComponentInChildren <VantagePoint>();
                vantage.ShowIndicator();
                vantagePointManager.RegisterCurrentVantage(vantage);
            }

            if ((1 << other.gameObject.layer & lightLayer) != 0)
            {
                playerLitManager.IsLit = true;
            }

            if ((1 << other.gameObject.layer & checkpointLayer) != 0)
            {
                var checkpoint = other.GetComponentInParent <Checkpoint>();
                checkpoint.UpdateLastCheckpoint();
            }

            if ((1 << other.gameObject.layer & conditionalDisplayLayer) != 0)
            {
                var conditionalDisplay = other.GetComponentInParent <ConditionalDisplay>();
                conditionalDisplay.Show();
            }
        }