Ejemplo n.º 1
0
    ///<summary>
    ///Loops through all the interactables in the room, then their internal Interaction components.
    ///The keywords are kind of hard coded into this one, but it shouldn't be a problem.
    ///</summary>
    void PrepareObjects(Room currentRoom)
    {
        for (int i = 0; i < currentRoom.interactableObjectsInRoom.Length; i++)
        {
            string descriptionNotInInventory = interactableItems.GetObjects(currentRoom, i);
            if (descriptionNotInInventory != null)
            {
                interactionDescriptionsInRoom.Add(descriptionNotInInventory);
            }

            InteractableObjects interactableInRoom = currentRoom.interactableObjectsInRoom[i];

            for (int j = 0; j < interactableInRoom.interactions.Length; j++)
            {
                Interaction interaction = interactableInRoom.interactions[j];
                if (interaction.inputAction.keyWord == "examine")
                {
                    interactableItems.examineDictionary.Add(interactableInRoom.noun, interaction.textResponse);
                }

                if (interaction.inputAction.keyWord == "take")
                {
                    interactableItems.takeDictionary.Add(interactableInRoom.noun, interaction.textResponse);
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void PrepareObjectsToTakeOrExamine(GameArea currentArea)
    {
        for (int i = 0; i < currentArea.interactableObjectsInArea.Length; i++)
        {
            string descriptionNotInInventory = interactableItems.GetObjectsNotInInventory(currentArea, i);

            if (descriptionNotInInventory != null)
            {
                areaInteractionDescription.Add(descriptionNotInInventory);
            }

            InteractableObjects interactableInArea = currentArea.interactableObjectsInArea[i];

            for (int j = 0; j < interactableInArea.interactions.Length; j++)
            {
                Interaction interaction = interactableInArea.interactions[j];
                if (interaction.inputAction.keyWord == "examine")
                {
                    interactableItems.examineDictionary.Add(interactableInArea.noun, interaction.textResponse);
                }

                if (interaction.inputAction.keyWord == "take")
                {
                    interactableItems.takeDictionary.Add(interactableInArea.noun, interaction.textResponse);
                }
            }
        }
    }
Ejemplo n.º 3
0
    IEnumerator CheckLookObject()
    {
        while (_currentObject != null)
        {
            RaycastHit hit;
            Ray        ray = new Ray(transform.position, transform.forward);

            //Assign object as current object
            if (Physics.Raycast(ray, out hit, 1000))
            {
                if (hit.collider.gameObject.tag == "Cocktail")
                {
                    Debug.Log("glass of" + hit.collider.gameObject.GetComponent <InteractableObjects>().GetDrinkType());
                    _lookingAtGlassCup      = true;
                    _currentLookingGlassCup = hit.collider.gameObject.GetComponent <InteractableObjects>();

                    if (IsHoldingObject())
                    {
                        _src2 = _currentLookingGlassCup.GetDrinkType();
                    }
                }
                else
                {
                    _lookingAtGlassCup = false;
                }
            }
            else
            {
                //                debugText.text = "Not looking at glass cup";
                _lookingAtGlassCup = false;
            }
            //Check at preferred frame interval
            yield return(new WaitForSeconds(frameInterval * Time.deltaTime));
        }
    }
Ejemplo n.º 4
0
    public void AddActionResponsesToDictionary()
    {
        for (int i = 0; i < nounsInInventory.Count; i++)
        {
            string noun = nounsInInventory[i];
            InteractableObjects interactableObjectInInventory = GetObjectsFromUsableList(noun);
            if (interactableObjectInInventory == null)
            {
                continue;
            }

            for (int j = 0; j < interactableObjectInInventory.interactions.Length; j++)
            {
                Interaction interaction = interactableObjectInInventory.interactions[j];

                if (interaction.actionResponse == null)
                {
                    continue;
                }

                if (!useDictionary.ContainsKey(noun))
                {
                    useDictionary.Add(noun, interaction.actionResponse);
                }
            }
        }
    }
Ejemplo n.º 5
0
    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "Object")
        {
            InteractableObjects objectInRadius = other.GetComponent <InteractableObjects>();

            _objectList.Remove(objectInRadius);
        }
    }
Ejemplo n.º 6
0
    public void AddObjects(InteractableObjects stuff)
    {
        _objectList.Add(stuff);
        _objectList[_amountOfObjects].transform.position = orbitSpots[_amountOfObjects].transform.position;
        orbitSpots[_amountOfObjects].GetComponentInChildren <ParticleSystem>().Emit(10);
        _objectList[_amountOfObjects].transform.parent = orbitSpots[_amountOfObjects].transform;

        _amountOfObjects++;
    }
Ejemplo n.º 7
0
 void OnTriggerEnter2D(Collider2D other)  // store info about object that player collided with
 {
     if (other.CompareTag("interObject")) // if we walk into interactable object
     {
         Debug.Log(other.name);           // testing
         currentInterObj       = other.gameObject;
         currentInterObjScript = currentInterObj.GetComponent <InteractableObjects> ();
     }
 }
Ejemplo n.º 8
0
    ///<summary>
    ///Gets objects not currently in the inventory.
    ///</summary>
    public string GetObjects(Room currentRoom, int i)
    {
        InteractableObjects InteractableInRoom = currentRoom.interactableObjectsInRoom[i];

        if (!nounsInInventory.Contains(InteractableInRoom.noun))
        {
            nounsInRoom.Add(InteractableInRoom.noun);
            return(InteractableInRoom.description);
        }
        return(null);
    }
Ejemplo n.º 9
0
    public string GetObjectsNotInInventory(GameArea currentArea, int i)
    {
        InteractableObjects interactableInArea = currentArea.interactableObjectsInArea[i];

        if (!nounsInInventory.Contains(interactableInArea.noun))
        {
            nounsInArea.Add(interactableInArea.noun);
            return(interactableInArea.description);
        }

        return(null);
    }
Ejemplo n.º 10
0
    private void OnTriggerStay(Collider other)
    {
        if (other.tag == "Object")
        {
            InteractableObjects objectInRadius = other.GetComponent <InteractableObjects>();

            if (objectInRadius != null)
            {
                objectInRadius.Suck(transform);
            }
        }
    }
Ejemplo n.º 11
0
    void SetDestination()
    {
        List <InteractableObjects> iObjects = handler.GetList().ToList();

        if (target != null)
        {
            iObjects.RemoveAll(t => t == target);
        }

        int selected = Random.Range(0, iObjects.Count);

        target = iObjects[selected];
    }
Ejemplo n.º 12
0
    public void OnYesButtonClicked()
    {
        GameObject          other_obj = Lieutenant.GetComponent <CharacterController>().GetOtherObject();
        InteractableObjects obj_inter = other_obj.GetComponent <InteractableObjects>();

        if (other_obj.GetComponent <Item>())
        {
            GameObject.Find("Slots").GetComponent <Inventory>().AddItem(other_obj.name);
        }
        else if (other_obj && !reported_list.Contains(other_obj))
        {
            AddHungerVal(obj_inter.hungerImpact);
            AddInmateVal(obj_inter.inmateImpact);
            AddWatcherVal(obj_inter.watcherImpact);
            AddPersonalVal(obj_inter);
            tbm.tasks[task_count].show = true;
            tbm.tasks[task_count].task.GetComponentInChildren <Text>().text    = other_obj.name;
            tbm.subTasks[task_count].task.GetComponentInChildren <Text>().text = obj_inter.recordContent;
            tbm.UpdateTaskBoard();
            task_count++;
            //	task_list.text += "\n" + task_count + ". " + other_obj.GetComponent<InteractableObjects>().recordContent;
            reported_list.Add(other_obj);
            inter.objs.Add(obj_inter.name);
            inter.objs.Add(obj_inter.context);
            inter.objs.Add(obj_inter.inmateImpact.ToString());
            inter.objs.Add(obj_inter.watcherImpact.ToString());
            inter.objs.Add(obj_inter.hungerImpact.ToString());
            inter.per_prefs.Add(obj_inter.name);
            inter.per_prefs.Add(obj_inter.personal_pref.ToString());
            if (obj_inter.name == "Peter")
            {
                peterFound = true;
            }
            if (obj_inter.name == "James")
            {
                jamesFound = true;
            }
            if (obj_inter.name == "Chair")
            {
                chairFound = true;
            }
            if (obj_inter.name == "Skull")
            {
                skullFound = true;
            }
        }
        Lieutenant.GetComponent <CharacterController>().SetMoveEnable(true);
        inter_box.SetActive(false);
    }
Ejemplo n.º 13
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Object")
        {
            InteractableObjects objectInRadius = other.GetComponent <InteractableObjects>();

            if (objectInRadius != null)
            {
                objectInRadius.Suck(transform);
                if (!_objectList.Contains(objectInRadius))
                {
                    // _objectList.Add(objectInRadius);
                }
            }
        }
    }
Ejemplo n.º 14
0
    void CheckObjectID(InteractableObjects interactableObject)
    {
        string ID = interactableObject.ID;

        if (ID == "PC")
        {
            if (InputManager.GetKeyDown("Interact"))
            {
                gameManager.BehindPc();
            }

            if (!gameManager.IsPlayerBehindPc())
            {
                HighlightObject(interactableObject);
            }
        }

        if (ID == "CoffeeCan")
        {
            if (gameManager.coffeeDone)
            {
                HighlightObject(interactableObject);
                if (InputManager.GetKeyDown("Interact"))
                {
                    gameManager.ResetCoffeeMachine();
                    gameManager.AddEnergy(40);
                    gameManager.coffeeDone = false;
                }
            }
        }

        if (ID == "CoffeeMachine")
        {
            if (!gameManager.makinCoffee)
            {
                HighlightObject(interactableObject);
            }

            if (InputManager.GetKeyDown("Interact"))
            {
                gameManager.makinCoffee = true;
            }
        }
    }
Ejemplo n.º 15
0
    public void GrabObject()
    {
        // If you don't have anything
        if (_currentObject == null)
        {
            RaycastHit hit;
            Ray        ray = new Ray(transform.position, transform.forward);

            int touchableDistance = 1000;

            //Assign object as current object
            if (Physics.Raycast(ray, out hit, touchableDistance))
            {
                //Check if object is interactable
                if (hit.collider.gameObject.GetComponent <InteractableObjects>() != null && hit.collider.gameObject.tag != "Cocktail")
                {
                    _currentObject = hit.collider.gameObject;
                    _currentObject.transform.rotation = Quaternion.identity;
                    _currentRB = _currentObject.GetComponent <Rigidbody>();
                    _currentRB.detectCollisions = false;
                    _currentRB.useGravity       = false;
                    _interactableObject         = _currentObject.GetComponent <InteractableObjects>();
                    MoveObjectTowardsPlayer();
                    StartCoroutine("CheckLookObject");
                    ///////////////////////////////////////////////
                    if (_temp = _currentObject.GetComponent <InteractableObjects>())
                    {
                        if (_src1 != DRINK_TYPE.EMPTY)
                        {
                            _src1            = _temp.GetDrinkType();
                            _alcoholContent1 = _temp.GetAlcoholContent();
                        }
                    }

                    /////////////////////////////////////////////////
                }
            }
        }
        else
        {
        }
    }
Ejemplo n.º 16
0
 private void Awake()
 {
     interactableObject = GetComponent <InteractableObjects>();
 }
Ejemplo n.º 17
0
 void HighlightObject(InteractableObjects interactableObject)
 {
     interactableObject.isHighlighted = true;
 }
Ejemplo n.º 18
0
 public void AddPersonalVal(InteractableObjects io)
 {
     io.personal_pref += io.personalImpact;
 }
Ejemplo n.º 19
0
    public void PourCurrentDrink()
    {
        // Animetion
        rotateArmToDrink(ARM_MOTION.DRINKING, true);

        InteractableObjects currentObject = _currentObject.gameObject.GetComponent <InteractableObjects>();

        //Only can pour drinks
        if (currentObject.GetObjectType() == OBJECT_TYPE.DRINKS)
        {
            // Current I have thing.
            DRINK_TYPE src1 = currentObject.GetDrinkType();
            // Current I look thing.
            DRINK_TYPE src2 = _currentLookingGlassCup.GetDrinkType();

            switch (_currentLookingGlassCup.GetGlassState())
            {
            case GLASS_STATE.EMPTY:

                //Sound
                AudioSource.PlayClipAtPoint(pourSound, transform.position);

                // If I look cup is empty, I just pour.
                _currentLookingGlassCup.SetDrinkType(src1);

                _currentLookingGlassCup.AddAlcoholContent(src1);

                _currentLookingGlassCup.SetGlassState(GLASS_STATE.HALF);

                Debug.Log("Glass is " + currentObject.GetDrinkType());
                Debug.Log("Glass is " + currentObject.GetGlassState());
                Debug.Log("This AC is " + currentObject.GetAlcoholContent());
                Debug.Log("POURING");
                break;

            case GLASS_STATE.HALF:

                //Sound
                AudioSource.PlayClipAtPoint(pourSound, transform.position);

                // I pour the same thing
                if (src1 == src2)
                {
                    _currentLookingGlassCup.SetDrinkType(src1);
                    _currentLookingGlassCup.AddAlcoholContent(src1);
                }


                // I pour the waste. or  I pour any thing to the waste.
                if (src1 == DRINK_TYPE.WASTE || src2 == DRINK_TYPE.WASTE)
                {
                    _currentLookingGlassCup.SetDrinkType(DRINK_TYPE.WASTE);
                    _currentLookingGlassCup.AddAlcoholContent(src1);
                }


                // I investigate combination when I pour any drink to other drink.
                foreach (ChartData data in _cd)
                {
                    if (data._src1 == src1)
                    {
                        if (data._src2 == src2)
                        {
                            _currentLookingGlassCup.SetDrinkType(data._compost);
                            _currentLookingGlassCup.AddAlcoholContent(src1);
                        }
                    }

                    if (data._src1 == src2)
                    {
                        if (data._src2 == src1)
                        {
                            _currentLookingGlassCup.SetDrinkType(data._compost);
                            _currentLookingGlassCup.AddAlcoholContent(src1);
                        }
                    }
                }

                _currentLookingGlassCup.SetGlassState(GLASS_STATE.FULL);
                Debug.Log("Glass is " + _currentLookingGlassCup.GetDrinkType());
                Debug.Log("Glass is " + _currentLookingGlassCup.GetGlassState());
                Debug.Log("This AC is " + currentObject.GetAlcoholContent());

                Debug.Log("POURING");
                break;

            case GLASS_STATE.FULL:
                // Do nothing
                break;

            default:
                // This combination wasn't in chart data.
                _currentLookingGlassCup.SetDrinkType(DRINK_TYPE.WASTE);
                break;
            }
        }
    }
Ejemplo n.º 20
0
 public void AddInteractableObject()
 {
     Model.InteractableObject newIO = new Model.InteractableObject();
     newIO.Name = NewIOName;
     InteractableObjects.Add(newIO);
 }