Example #1
0
    void Start()
    {
        _controller = GameObject.FindGameObjectWithTag(SuriAlFuturo.Tag.GameController)
                      .GetComponent <CollectionSystem>();

        Sprite[] icons = Resources.LoadAll <Sprite>("Icons");
        for (int i = 0; i < icons.Length; i++)
        {
            try {
                Collectable.Tag parsedTag =
                    (Collectable.Tag)System.Enum.Parse(typeof(Collectable.Tag),
                                                       icons[i].name);
                _icons[parsedTag] = icons[i];
            } catch {
                Debug.LogWarning(icons[i].name + " has no enumerable on Collectable.Tag :(");
            }
        }

        for (int i = 0; i < Slots.Count; i++)
        {
            Slots[i].Index = i;
        }

        Refresh();
    }
Example #2
0
 public void SetSprite(Sprite sprite, Collectable.Tag tag)
 {
     if (Icon == null)
     {
         Icon = GetComponent <Image>();
     }
     Icon.sprite = sprite;
     _tag        = tag;
 }
Example #3
0
    public void RegisterAsTaken(Collectable.Tag collectable)
    {
        Debug.Log("taken: " + collectable);

        _takenStuff[collectable] = true;
        if (false == Inventory.Contains(collectable))
        {
            Inventory.Add(collectable);
        }
        UIController.Refresh();
    }
Example #4
0
    public bool HasItem(Collectable.Tag item)
    {
        foreach (Collectable.Tag ownedItem in Inventory)
        {
            if (item == ownedItem)
            {
                return(true);
            }
        }

        return(false);
    }
Example #5
0
    private int _IndexOfRequirement(Collectable.Tag requirement)
    {
        for (int i = 0; i < UnmetRequirements.Count; i++)
        {
            if (UnmetRequirements[i].Name == requirement)
            {
                return(i);
            }
        }

        return(-1);
    }
Example #6
0
    // needs refactorization
    public bool TryToTakeRequirement(Collectable.Tag requirement)
    {
        // int i = UnmetRequirements.IndexOf(requirement);
        int i = _IndexOfRequirement(requirement);

        if (i >= 0)
        {
            _receibedDialogueIndex = UnmetRequirements[i].IndexOfDialogue;
            TheTalkable.SetDialogueIndex(_receibedDialogueIndex);
            _controller.RegisterAsGiven(requirement);
            UnmetRequirements.RemoveAt(i);
            TheTalkable.IsForcedToTalk = true;
            return(true);
        }

        return(false);
    }
Example #7
0
 public void RegisterAsGiven(Collectable.Tag collectable)
 {
     _givenStuff[collectable] = true;
     Inventory.Remove(collectable);
     UIController.Refresh();
 }
 public PersistedCollectable(bool isTaken, Collectable.Tag name)
 {
     IsTaken = isTaken;
     Name    = name;
 }
Example #9
0
 public void ShowInventoryLabel(Collectable.Tag tag)
 {
     InventoryLabel.SetActive(true);
     InventoryLabel.GetComponent <Text>().text = _names[tag];
 }