コード例 #1
0
    // generate a new institution
    public static Institution GeneratorInstitution(Person owner, String type, Plot location)
    {
//            string type = GetRandomType();
        Institution newInstitution;

        switch (type)
        {
        case "ConstructionCompany":
            newInstitution = new ConstructionCompany(owner, location, type);
            break;

        case "School":
            newInstitution = new School(owner, location, type);
            break;

        case "Hospital":
            newInstitution = new Hospital(owner, location, type);
            break;

        case "LawFirm":
            newInstitution = new LawFirm(owner, location, type);
            break;

        case "ApartmentComplex":
            newInstitution = new ApartmentComplex(owner, location, type);
            break;

        default:
            newInstitution = new Institution(owner, location, type);
            break;
        }

        if (newInstitution.getType().Equals("ConstructionCompany"))
        {
            constructionCompanyList.Add(newInstitution as ConstructionCompany);
        }

        institutionList.Add(newInstitution);

        if (InstitutionDictionary.ContainsKey(type))
        {
            List <Institution> tempList = InstitutionDictionary[type];
            tempList.Add(newInstitution);
        }
        else
        {
            InstitutionDictionary[type] = new List <Institution> {
                newInstitution
            };
        }

        Logger.Log("Institution", type, owner.name, "(" + location.x_pos + "," + location.y_pos + ")");

        return(newInstitution);
    }