Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (character is IMovable) // if the character implements the Imovable interface it can move using the axes called Vertical and Horizontal
        {
            IMovable moveable = character as IMovable;
            moveable.MoveForward(Input.GetAxis("Vertical"));
            moveable.MoveRight(Input.GetAxis("Horizontal"));
        }
        if (character is IJumpable) // if the character implements the Ijumpable interface, it can jump
        {
            IJumpable jumpable = character as IJumpable;

            if (Input.GetButtonDown("Jump"))
            {
                jumpable.Jump();
            }
        }
    }