MUNICH — The teenager behind the deadly shooting rampage in Munich was a withdrawn loner obsessed with playing “killer” video games, a victim of bullying who suffered from panic attacks set off by contacts with other people, investigators said Sunday, adding that he had planned the attack for a year. Law enforcement officials piecing together a portrait of the 18-year-old shooter said he was seeing a doctor up to last month for treatment of depression and psychiatric problems that began in 2015 with inpatient hospital care and then was followed up with outpatient visits. “He had been planning this crime since last summer,” said Robert Heimberger, Bavaria’s top official, citing a manifesto linked to the shooting found in the gunman’s locked room in the apartment he shared with his parents and brother. Heimberger said he could not reveal details of the document yet because there were “many more terabytes” of information to evaluate, but he described the gunman as a “devoted player” of group Internet “killer games” pitting virtual shooters against each other.