Beispiel #1
0
    public void Interact(InputContoller _inputcontoller)
    {
        if (interactibles.Count != 0)
        {
            interactibles.Last().GetComponent <IInteractible>().Interact(_inputcontoller);
        }

        //if (_interactible != null)
        //_interactible.Interact(_inputcontoller);
    }
 public void Interact(InputContoller stateManager)
 {
     if (ItemInside != null && hasPickedUpItem == false)
     {
         DialogueDisplayer.Instance.DisplayMessage($"You've found a {ItemInside.objectName}!");
         hasPickedUpItem = true;
         Inventory.instance.AddItemToInventory(ItemInside.id);
         return;
     }
     GetComponent <DialogueTrigger>().StartDialogue(ObjectID);
 }
    private void StartWorking(InputContoller inputController)
    {
        //  Remove Used Item from inventory
        Inventory.instance.RemoveItem(Inventory.instance.GetCurrentItemIndex());

        //Loading bar appears and make it be filled with time
        LoadingBar.Instance.UISlider.gameObject.SetActive(true);
        LoadingBar.Instance.StartLoading(timeConsumes);

        //Transition player to a busy state
        inputController.SetState(new PlayerBusyState(inputController, timeConsumes));

        //Start the sound
        if (AssociatedSound != null)
        {
            GetComponent <AudioSource>().clip = AssociatedSound;
            GetComponent <AudioSource>().Play();
        }

        //Start a timer at the end of which invoke a delegate and potentially give an item to a player
        StartCoroutine(AfterTaskEvents());
    }
    public void Interact(InputContoller inputController)
    {
        // If there is more than 1 item in inventory
        if (Inventory.instance.GetInventoryLength() > 0 && hasFinishedTask == false && ItemForInteraction != null)
        {
            // If current item is the item needed for interaction then...
            try
            {
                Item currentItem = Inventory.instance.GetItemFromInventory(Inventory.instance.GetCurrentItemIndex()) ?? null;
                // If current item is the item needed for interaction then...
                if (currentItem != null && (int)currentItem.id == (int)ItemForInteraction.id)
                {
                    StartWorking(inputController);
                    hasFinishedTask = true;
                }
                else
                {
                    dialogueTrigger.StartDialogue(ObjectID);
                }
            }
            // If there are any problems with code above, juse fire a dialogue
            catch (Exception)
            {
                dialogueTrigger.StartDialogue(ObjectID);
                throw;
            }
        }

        else
        {
            if (ItemForInteraction == null)
            {
                StartWorking(inputController); return;
            }
            dialogueTrigger.StartDialogue(ObjectID);
        }
    }
 public PlayerBusyState(InputContoller _inputcontoller, float time) : base(_inputcontoller)
 {
     _busyTime = time;
 }
Beispiel #6
0
 public PlayerNoControlState(InputContoller sm) : base(sm)
 {
 }
Beispiel #7
0
 public State(InputContoller sm)
 {
     _inputcontoller = sm;
 }
Beispiel #8
0
 public PlayerNormalState(InputContoller _inputcontoller) : base(_inputcontoller)
 {
 }