Exemple #1
0
    public PlayerInteraction()
    {
        interactableObjectsTags = new List <string>();
        interactableObjectsTags.Add("Carpet");
        interactableObjectsTags.Add("Exit");
        interactableObjectsTags.Add("Toy");

        pickedUpTapis = null;
    }
Exemple #2
0
    private void InteractWithTarget()
    {
        Debug.Log("Interact with target" + target.name);

        if (target.tag.Equals(currentInteractableObject))
        {
            /*
             * Interact with the target object. Get component to know what to do.
             */
            if (currentInteractableObject.Equals("Exit"))
            {
                /*
                 * Interacting with the exit, leaving the level
                 */
                if (hasRetrievedToy)
                {
                    Debug.Log("Par ici la sortie !");
                    endGameManager.Victory(); // Replace SceneManager
                                              //SceneManager.LoadScene(SceneController.instance.nextSceneName);
                }
            }

            if (currentInteractableObject.Equals("Carpet"))
            {
                TapisController tapis = target.GetComponent <TapisController>();
                Debug.Log("Je prends un tapis !");
                tapis.PickUp(this.gameObject);
                isHoldingObject = true;
                pickedUpTapis   = tapis;
            }

            if (currentInteractableObject.Equals("Toy"))
            {
                Debug.Log("On récupère le jouet");
                hasRetrievedToy = true;
                Destroy(target);
            }
        }
        else
        {
            Debug.Log("Mais tu te souviens de trucs louches ma parole. Oublie donc tout ça.");
            target = null;
            currentInteractableObject = "";
        }
    }
Exemple #3
0
 private void TryToDrop()
 {
     if (pickedUpTapis != null)
     {
         Debug.Log("J'ai bien un tapis à poser !");
         if (pickedUpTapis.CanPutDown(this.gameObject.transform.position, GetDirection()))
         {
             Debug.Log("J'ai bien la place de le poser !!");
             pickedUpTapis.PutDown(this.gameObject.transform.position, GetDirection());
             isHoldingObject = false;
             pickedUpTapis   = null;
             target          = null;
             Debug.Log("Posons le tapis.");
         }
         else
         {
             FailToDrop();
         }
     }
 }