예제 #1
0
        protected override void StartDelayed(InteractionEvent interactionEvent)
        {
            GameObject source     = interactionEvent.Source?.GetComponentInTree <Creature>().gameObject;
            GameObject target     = interactionEvent.Target.GetComponent <Transform>().gameObject;
            Consumable itemInHand = source?.GetComponentInChildren <Hands>().GetItemInHand()?.GetComponent <Consumable>();

            //Debug.Log("source:  " + source.name + " target: " + target?.name + " item: " + itemInHand?.gameObject.name);

            // Item in hand and interacting with origin
            if (target == null)
            {
                itemInHand.ConsumeAction(source);
            }
            // Item not in hand
            Consumable targetedItem = target.GetComponent <Consumable>();

            if (targetedItem)
            {
                targetedItem.ConsumeAction(source);
            }
            // Item in hand and interacting with other player
            if (target.GetComponent <Creature>())
            {
                itemInHand.ConsumeAction(source, target);
            }
        }
예제 #2
0
파일: Consumable.cs 프로젝트: Ryan089/SS3D
        protected override void StartDelayed(InteractionEvent interactionEvent)
        {
            GameObject source     = interactionEvent.Source?.GetComponentInTree <Entity>().gameObject;
            GameObject target     = interactionEvent.Target.GetComponent <Transform>().gameObject;
            Consumable itemInHand = source.GetComponent <Consumable>();

            // Item in hand and interacting with origin
            if (target == null)
            {
                itemInHand.ConsumeAction(source);
            }
            // Item not in hand
            Consumable targetedItem = target.GetComponent <Consumable>();

            if (targetedItem)
            {
                targetedItem.ConsumeAction(source);
            }
            // Item in hand and interacting with other player
            if (target.GetComponent <Entity>())
            {
                itemInHand.ConsumeAction(source, target);
            }
        }