private void ObjectTakenAction(GameObject obj, PlayerComponent playerComponent, IUsable usable)
    {
        string    typeName = usable.GetType().Name;
        AudioClip clip     = null;

        if (typeName == nameof(BottleComponent))
        {
            clip = bottleSound;
        }
        else if (typeName == nameof(PukeComponent))
        {
            clip = pukeSound;
        }
        else if (typeName == nameof(NPCComponent))
        {
            clip = npcTakeSound;
        }

        if (clip == null)
        {
            return;
        }

        _audioSrc.clip = clip;
        _audioSrc.Play();
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * 100, Color.yellow);

        if (Input.GetMouseButtonDown(RMB))
        {
            Ray ray = PlayerCamera.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out raycastHit, ClickDistance, layerMask))
            {
                if (raycastHit.transform)
                {
                    //Debug.Log(raycastHit.transform.gameObject);
                    IUsable Clickable = raycastHit.transform.GetComponent <IUsable>();
                    //Debug.Log(Clickable);
                    if (Clickable != null)
                    {
                        if (typeof(IInteractionable).IsAssignableFrom(Clickable.GetType()))
                        {
                            //Debug.Log("Interactionable");
                            ((IInteractionable)Clickable).PerformInteraction();
                        }
                        else
                        {
                            //Debug.Log("Usable");
                            Clickable.PerformAction();
                        }
                    }
                }
            }
        }
    }
Beispiel #3
0
    public Stack <IUsable> GetUsables(IUsable type)
    {
        Stack <IUsable> usables = new Stack <IUsable>();


        foreach (SlotScript slot in slots)
        {
            if (!slot.IsEmpty && slot.MyItem.GetType() == type.GetType())
            {
                foreach (Item item in slot.MyItems)
                {
                    usables.Push(item as IUsable);
                }
            }
        }

        foreach (SlotScript slot in slots2)
        {
            if (!slot.IsEmpty && slot.MyItem.GetType() == type.GetType())
            {
                foreach (Item item in slot.MyItems)
                {
                    usables.Push(item as IUsable);
                }
            }
        }

        foreach (SlotScript slot in slots3)
        {
            if (!slot.IsEmpty && slot.MyItem.GetType() == type.GetType())
            {
                foreach (Item item in slot.MyItems)
                {
                    usables.Push(item as IUsable);
                }
            }
        }

        return(usables);
    }
    private void ObjectDroppedAction(GameObject obj, PlayerComponent playerComponent, IUsable usable)
    {
        string    typeName = usable.GetType().Name;
        AudioClip clip     = null;

        if (typeName == nameof(NPCComponent))
        {
            clip = npcDropSound;
        }

        if (clip == null)
        {
            return;
        }

        _audioSrc.clip = clip;
        _audioSrc.Play();
    }
Beispiel #5
0
    public static string GetUseText(IUsable toUse)
    {
        string t = "Взаимодействовать : " + toUse.GetType().Name;

        if (toUse is IDoor)
        {
            t = "Дверь";
        }
        if (toUse is IChest)
        {
            t = "Сундук";
        }
        if (toUse is ILocationTransition)
        {
            t = "Покинуть локацию";
        }
        if (toUse is IItemObject)
        {
            t = IItemAsset.items [((IItemObject)toUse).indentification].name;
        }

        return(t);
    }
 public override string Use(IUsable used)
 {
     return("Leviathan uses " + used.GetType().Name);
 }
Beispiel #7
0
 public override string Use(IUsable used)
 {
     return("Skeleton uses " + used.GetType().Name);
 }
 public override string Use(IUsable used)
 {
     return("Player uses " + used.GetType().Name);
 }
Beispiel #9
0
 public override string Use(IUsable used)
 {
     return("Dracula uses " + used.GetType().Name);
 }