예제 #1
0
    protected void SetItem(PickupableItem newItem)
    {
        _item = newItem;

        Icon.sprite = newItem.Icon;
        DisplayIcon();
    }
예제 #2
0
    public virtual void ClearSlot()
    {
        _item = null;

        Icon.sprite  = null;
        Icon.enabled = false;
    }
예제 #3
0
    //Called when a trigger enters this collider
    void OnTriggerEnter(Collider other)
    {
        if (inputLocked)
        {
            return;
        }

        Debug.Log(other.gameObject.name);

        //if the collider was from a pickupable
        if (other.gameObject.CompareTag("Pickuppable"))
        {
            //get the item script
            PickupableItem item = other.GetComponent <PickupableItem>();
            //if the script is not null
            if (item != null)
            {
                inventory.AddItem(item);

                if (PickupUI.activeSelf == false)
                {
                    PickupUI.SetActive(true);
                }
            }
        }
    }
예제 #4
0
    public void SpawnItem()
    {
        if(spawnedItem == null) {
            spawnedItem = (PickupableItem)Instantiate(itemToSpawn, transform.position, Quaternion.identity);
        }

        if(!spawnedItem.gameObject.activeSelf) {
            spawnedItem.gameObject.SetActive(true);
            spawnedItem.Reset();
        }
    }
예제 #5
0
    /// <summary>
    /// removes a given item to the near items list
    /// </summary>
    /// <param name="item"></param>
    public bool RemoveItem(PickupableItem item)
    {
        bool emptyList = false;

        if (nearItems.Contains(item))
        {
            //remove the item from the near items list
            nearItems.Remove(item);

            if (nearItems.Count == 0)
            {
                emptyList = true;
            }
        }

        return(emptyList);
    }
예제 #6
0
    public void SetItem(PickupableItem newItem, int stackCount)
    {
        base.SetItem(newItem);

        if (newItem is ConsumableItem consumable &&
            consumable.StackLimit != 1)
        {
            StackCountText.text = stackCount.ToString();

            if (stackCount == consumable.StackLimit)
            {
                StackCountText.color = Color.green;
            }
            else
            {
                StackCountText.color = Color.white;
            }

            StackCountText.enabled = true;
        }
예제 #7
0
 //Called when a trigger exits this collider
 private void OnTriggerExit(Collider other)
 {
     if (inputLocked)
     {
         return;
     }
     //if the collider was from a pickupable
     if (other.gameObject.CompareTag("Pickuppable"))
     {
         //get the item script
         PickupableItem item = other.GetComponent <PickupableItem>();
         //if the script is not null and this item is in the near items list
         if (item != null)
         {
             if (inventory.RemoveItem(item) && PickupUI.activeSelf == true)
             {
                 PickupUI.SetActive(false);
             }
         }
     }
 }
예제 #8
0
    public void DoDrop()
    {
        Debug.Log("Do drop!");
        var parent = transform.parent.gameObject.transform;

        for (var itemNum = 0; itemNum < droppedItems.Count; itemNum++)
        {
            var rnd = Random.Range(0f, 1f);
            if (rnd < dropChances[itemNum])
            {
                var drop = Instantiate(droppedItems[itemNum], parent);
                DoDropSingleItem(drop);
            }
        }

        if (dropRandomInventoryItem)
        {
            Debug.Log("drop inventory item");
            var inventory = parent.GetComponent <Room>().roomNode.manager.player.GetComponent <InventoryComponent>();
            if (inventory.itemsLeftToSpawn.Count == 0)
            {
                Debug.LogWarning("could not drop any item! nothing left!");
            }
            else
            {
                int rnd      = Random.Range(0, inventory.itemsLeftToSpawn.Count);
                var itemType = inventory.itemsLeftToSpawn[rnd];
                Debug.Log("go for" + itemType);
                inventory.itemsLeftToSpawn.RemoveAt(rnd);
                var drop = Instantiate(randomInventoryItemPrefab, parent);
                // todo: add a texture.
                PickupableItem pickup = drop.GetComponent <PickupableItem>();
                drop.GetComponent <SpriteRenderer>().sprite = inventory.allItemSprites[(int)itemType];
                pickup.givesItem = true;
                pickup.itemType  = itemType;
                DoDropSingleItem(drop);
            }
        }
    }
예제 #9
0
        //this might be used to load "story" from file in the future, right now it's a mess
        private void Initialize()
        {
            //## MANUAL ##
            //PART I
            //1. LOCATIONS
            //location schema: Location(name, description)
            //connecting two locations: ConnectLocations(loc1, loc2)
            //2. ITEMS
            //item schema: PickupableItem(name, description, location/creature)
            //3. NPC (or creature)
            //npc schema: Npc(name, greeting, location)
            //adding attack reactions: person.ReactionList.Addmany(string, string, string, ...)
            //4 OBJECTIVE
            //objective schema: Objectiove(name, description, ObjectiveType.type)
            //PART II
            //1. add your locations, items, npcs and objectives to lists (locations, creatures, items, objectives)
            //2. remember to set _startingLocation
            //## END MANUAL ##

            //LOCATIONS

            //roads
            var junction    = new Location("junction", "junction where north street, south street and east street cross");
            var northStreet = new Location("north street", "calm, wide street");
            var southStreet = new Location("south street", "calm, wide street");
            var eastStreet  = new Location("east street", "quiet, narrow street");

            //grocery shop
            var groceryShop           = new Location("grocery shop", "big grocery shop with shelves full of fruit and vegetables");
            var groceryShopBackOffice = new Location("back office", "small back office with some boxes");

            //playground
            var playground = new Location("playground", "abandoned children playground");

            //villa
            var houseHall       = new Location("house entrance", "house hall with some hangers and a big mirror on the wall");
            var houseGarage     = new Location("garage", "empty garage with intensive petrol smell");
            var houseLivingRoom = new Location("living room", "living room with coffe table, sofa and tv hanged on the wall");
            var houseKitchen    = new Location("kitchen", "old style kitchen with wooden furniture");
            var houseToilet     = new Location("toilet", "small toilet with tiny bathhub");
            var houseBackyard   = new Location("backyard", "huge, neglected garden, full of ferns and apple trees");
            var houseAlcove     = new Location("alcove", "wooden alcove with gardening tools");

            //CONNECTIONS
            ConnectLocations(junction, northStreet);
            ConnectLocations(junction, southStreet);
            ConnectLocations(junction, eastStreet);

            ConnectLocations(groceryShop, groceryShopBackOffice);

            ConnectLocations(houseHall, houseGarage);
            ConnectLocations(houseHall, houseLivingRoom);
            ConnectLocations(houseHall, houseBackyard);
            ConnectLocations(houseLivingRoom, houseKitchen);
            ConnectLocations(houseLivingRoom, houseToilet);
            ConnectLocations(houseBackyard, houseAlcove);

            ConnectLocations(northStreet, groceryShop);
            ConnectLocations(eastStreet, groceryShop);
            ConnectLocations(eastStreet, playground);
            ConnectLocations(eastStreet, houseHall);
            ConnectLocations(southStreet, houseBackyard);

            _startingLocation = junction;

            //ITEMS

            var item1  = new PickupableItem("wallet", "leather wallet, almost empty", northStreet);
            var item2  = new PickupableItem("keys", "couple of keys on a keychain", northStreet);
            var item3  = new PickupableItem("foil bag", "transparent, yellow foil bag", junction);
            var item4  = new PickupableItem("stub", "cigarette stub", southStreet);
            var item5  = new PickupableItem("apple", "fresh, green apple", groceryShop);
            var item6  = new PickupableItem("banana", "slightly brown banana", groceryShop);
            var item7  = new PickupableItem("tomato", "blood-red tomato", groceryShop);
            var item8  = new PickupableItem("lime", "fresh lime", groceryShop);
            var item9  = new PickupableItem("doll", "very old, destroyed doll", playground);
            var item10 = new PickupableItem("coat", "slightly worn, brown leather coat", houseHall);
            var item11 = new Weapon("umbrella", "a yellow umbrella with steel tip", houseHall, 2);
            var item12 = new PickupableItem("sneakers", "sport sneakers", houseHall);
            var item13 = new PickupableItem("bowl", "ceramic bowl", houseLivingRoom);
            var item14 = new PickupableItem("newspaper", "black and white newspaper", houseLivingRoom);
            var item15 = new PickupableItem("watch", "expensive silver watch", houseLivingRoom);
            var item16 = new PickupableItem("book", "thick adventure book with blue cover", houseLivingRoom);
            var item17 = new Weapon("butcher knife", "a big, heavy butcher knife", houseKitchen, 25);
            var item18 = new PickupableItem("milk", "carton of milk", houseKitchen);
            var item19 = new PickupableItem("toilet paper", "a roll of toilet paper", houseToilet);
            var item20 = new PickupableItem("toothbrush", "used, blue toothbrush");
            var item21 = new PickupableItem("stone", "tiny, gray stone", houseBackyard);
            var item22 = new PickupableItem("empty bottle", "empty irish beer bottle", houseBackyard);
            var item23 = new Weapon("baseball bat", "wooden bat used in baseball", houseBackyard, 12);
            var item24 = new PickupableItem("wooden plank", "long, sharp wooden plank", houseAlcove);
            var item25 = new Weapon("long broom", "long, old broom", houseAlcove, 3);
            var item26 = new Weapon("small broom", "short, brown broom", houseAlcove, 2);
            var item27 = new Weapon("wrench", "steel wrench", houseGarage, 4);

            //NPCS

            var shopkeeper = new Npc("Shopkeeper", "Welcome in my store! Sorry but I'm busy right now.", groceryShop);

            shopkeeper.ReactionList.AddMany("What the hell?", "Stop it!", "What are you doing?", "Stop hitting me!");

            var dave = new Npc("Dave", "Hello! What do you need?", eastStreet);

            dave.ReactionList.AddMany("Ugh!", "Argh...", "Ouch!", "That hurts!");

            var cutthroat = new Npc("Cutthroat", "Go away. Now.", southStreet);

            var hooker = new Npc("Hooker", "Oh hello. I can't talk with at the moment, come back later.", southStreet);

            hooker.ReactionList.AddMany("Please stop!", "Don't kill me!", "Why?");

            var janitor = new Npc("Janitor", "I am a janitor. I'm busy.", houseAlcove);

            janitor.ReactionList.AddMany("Ouch, that hurts!", "Please, stop it.", "Why are you doing that?");

            var john = new Npc("John", "Give me a rest, I'm tired.", houseBackyard);

            john.ReactionList.AddMany("Stop it now!", "Dude...", "Argh!");

            var stranger = new Npc("Stranger", "...", playground);

            var groceryClient = new Npc("Client", "I'm talking with right now, please wait.", groceryShop);

            //OBJECTIVES
            var getKnife      = new Objective("get butcher knife", "search the area for butcher knife", ObjectiveType.Have);
            var killCutthroat = new Objective("kill Cutthroat", "find and kill Cutthroat", ObjectiveType.Kill);


            // ## LISTS ##

            _locations.AddMany(
                northStreet,
                junction,
                southStreet,
                eastStreet,
                groceryShop,
                groceryShopBackOffice,
                playground,
                houseHall,
                houseGarage,
                houseLivingRoom,
                houseKitchen,
                houseToilet,
                houseBackyard,
                houseAlcove
                );

            _creatures.AddMany(
                shopkeeper,
                dave,
                john,
                cutthroat,
                hooker,
                janitor,
                stranger,
                groceryClient
                );

            _items.AddMany(
                item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11,
                item12, item13, item14, item15, item16, item17, item18, item19, item20, item21,
                item22, item23, item24, item25, item26, item27
                );

            _objectives.AddMany(
                getKnife,
                killCutthroat
                );
        }
예제 #10
0
 public PickUpActivity(PickupableItem item)
 {
     _Item = item;
 }
예제 #11
0
 /// <summary>
 /// adds a given item to the near items list
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(PickupableItem item)
 {
     //add the item to the near items list
     nearItems.Add(item);
 }
예제 #12
0
 public ItemStack(PickupableItem item, int count)
 {
     Item  = item;
     Count = count;
 }
 public ItemPickedUpEventArgs(PickupableItem pickupableItem)
 {
     PickupableItem = pickupableItem;
 }