Beispiel #1
0
    public IItem take(Enums.TakeType takeAction)
    {
        if (OnCooldown + Delay > Time.realtimeSinceStartup)
        {
            return(null);
        }
        GameObject selectedZone = null;

        //Debug.Log("Take:" + takeAction);
        switch (takeAction)
        {
        case Enums.TakeType.Oben:
            selectedZone = oben;
            break;

        case Enums.TakeType.Mitte:
            selectedZone = mitte;
            break;

        case Enums.TakeType.Unten:
            selectedZone = unten;
            break;
        }
        RaycastHit2D hit = Physics2D.BoxCast(selectedZone.transform.position, new Vector2(0.9f, 1f / 3f), 0, Vector2.zero, 0f, mask);

        if (hit.collider != null)
        {
            OnCooldown = Time.realtimeSinceStartup;
            IItem item = hit.collider.gameObject.GetComponent <Regalfach>().GrabItem();
            return(item);
        }
        return(null);
    }
Beispiel #2
0
 private void makeDecision()
 {
     Enums.TakeType takeDecision = (Enums.TakeType)Random.Range(1, (int)Enums.TakeType.COUNT);
     holdItem = takeControl.take(takeDecision);
     if (holdItem != null)
     {
         //20% Chance etwas zu essen. Ansonsten essen.
         if (Random.Range(0, 6) == 0)
         {
             anim.SetTrigger(animId_tGrabItem);
             eat(holdItem);
         }
         else
         {
             anim.SetTrigger(animId_tThrowItem);
             finishedPuttingIntoCart();
         }
         audio.PlayOneShot(m_AudioTakeItem);
     }
 }