Beispiel #1
0
    private void Interact()
    {
        //First priority, pick up offerings

        if (_offeringsCollider.OfferingsInCollider.Count > 0) //pickup!
        {
            List <Offering> offerings = _offeringsCollider.OfferingsInCollider;

            float    Distance        = Vector2.Distance(playerRB.position, offerings[0].transform.position);
            Offering closestOffering = offerings[0];
            foreach (Offering offering in offerings)
            {
                if (!closestOffering.disappearing) // only pick up offerings which havent been given away to other ghosts
                {
                    if (Vector2.Distance(playerRB.position, offering.transform.position) < Distance)
                    {
                        Distance        = Vector2.Distance(playerRB.position, offering.transform.position);
                        closestOffering = offering;
                    }
                }
            }
            if (!closestOffering.disappearing)
            {
                collectedOfferings.Add(closestOffering);        //add to our internal inventory system
                closestOffering.gameObject.SetActive(false);    //disable the gameobject
                Events.current.PickUpOffering(closestOffering); //set off an event for the UI to listen to
                _pickUpSound.Play();
            }
        }

        // Second Priority: talk to ghosts
        else
        {
            List <GraveGhost> ghosts = _graveGhostsCollider.GhostsInCollider;
            if (ghosts.Count > 0)
            {
                float      Distance     = Vector2.Distance(playerRB.position, ghosts[0].transform.position);
                GraveGhost closestGhost = ghosts[0];
                foreach (GraveGhost ghost in ghosts)
                {
                    if (Vector2.Distance(playerRB.position, ghost.transform.position) < Distance)
                    {
                        Distance     = Vector2.Distance(playerRB.position, ghost.transform.position);
                        closestGhost = ghost;
                    }
                }
                closestGhost.PlayConversation();
            }
        }
    }
Beispiel #2
0
 public void CheckOffQuest(GraveGhost ghost)
 {
     foreach (UIQuest quest in Quests)
     {
         if (ghost.Equals(quest.assignedGhost))
         {
             if (!quest.gameObject.activeSelf)
             {
                 ShowQuest(ghost);
             }
             quest.Crossout.SetActive(true);
             break;
         }
     }
 }
Beispiel #3
0
 public void ShowQuest(GraveGhost ghost)
 {
     foreach (UIQuest quest in Quests)
     {
         if (ghost.Equals(quest.assignedGhost))
         {
             quest.GetComponent <RectTransform>().anchoredPosition = Vector2.zero + new Vector2(0, offset * -30);
             quest.gameObject.SetActive(true);
             QuestScrollMiddle.GetComponent <RectTransform>().sizeDelta         = new Vector2(QuestScrollMiddle.GetComponent <RectTransform>().sizeDelta.x, (offset + 1) * 30);
             QuestScrollBottom.GetComponent <RectTransform>().anchoredPosition += new Vector2(0, -30);
             offset++;
             QuestsShown++;
             break;
         }
     }
 }