Example #1
0
    void Act(GameObject animal)
    {
        switch (input)
        {
        case InputType.LMB:
        {
            ISpeak speak = animal.GetComponent <ISpeak>();
            if (speak != null)
            {
                speak.Speak();
                speakCount++;
            }
            break;
        }

        case InputType.RMB:
        {
            IWalk walk = animal.GetComponent <IWalk>();
            if (walk != null)
            {
                walk.Walk();
                walkCount++;
            }
            break;
        }

        case InputType.Space:
        {
            ISwim swim = animal.GetComponent <ISwim>();
            if (swim != null)
            {
                swim.Swim();
                swimCount++;
            }
            break;
        }

        case InputType.I:
        {
            IID id = animal.GetComponent <IID>();

            if (id != null)
            {
                id.Identify();
            }

            break;
        }

        default: break;
        }
    }