예제 #1
0
    public void AddSM4MapLocation(SM4MapLocation sm4MapLocation)
    {
        var newGO = new GameObject();
        var locationGameObject = Instantiate(newGO, transform);

        Destroy(newGO);
        var location = locationGameObject.AddComponent <SM4MapLocation>();
        var image    = locationGameObject.AddComponent <Image>();

        locationGameObject.AddComponent <Button>();
        locationGameObject.AddComponent <SM4MapInteractable>();

        location.locationVisible     = sm4MapLocation.locationVisible;
        location.locationDisplayName = sm4MapLocation.locationDisplayName;
        location.locationName        = sm4MapLocation.locationName;
        location.path             = sm4MapLocation.path;
        location.keyshortcut      = sm4MapLocation.keyshortcut;
        location.locationPosition = sm4MapLocation.locationPosition;
        location.typeOfLocation   = sm4MapLocation.typeOfLocation;

        location.locationName = sm4MapLocation.locationName;
        location.path         = sm4MapLocation.path;
        location.CreateLocation();

        locationGameObject.name = location.locationName;
        locations.Add(location);
    }
예제 #2
0
    public SM4MapLocation GetLocationFromXml(string locationSubDirectory)
    {
        SM4MapLocation location = new SM4MapLocation();

        location.locationName = Path.GetFileName(locationSubDirectory);
        location.path         = locationSubDirectory;

        var       locationXMLPath = locationSubDirectory + "/Location.xml";
        XDocument doc;

        try
        { doc = XDocument.Load(@locationXMLPath); }
        catch
        { doc = null; }
        XElement xElements = null;

        try
        { xElements = doc.Descendants("Location").First(); }
        catch
        { xElements = null; }
        if (xElements == null)
        {
            ErrorLogger.LogErrorInFile("In " + this.name + "Region was null");
            return(location);
        }

        try { location.locationDisplayName = xElements.Element("Name").FirstAttribute.Value; }
        catch {  }
        try { location.keyshortcut = xElements.Element("Key").FirstAttribute.Value; }
        catch {  }
        try { if (xElements.Element("Type").FirstAttribute.Value == "area")
              {
                  location.typeOfLocation = SM4MapLocation.TypeOfLocation.Area;
              }
              else
              {
                  location.typeOfLocation = SM4MapLocation.TypeOfLocation.House;
              } }
        catch { location.typeOfLocation = SM4MapLocation.TypeOfLocation.Area; }

        try { location.locationPosition = new Vector2(
                  Int32.Parse(xElements.Element("ScreenLocation").FirstAttribute.Value),
                  Int32.Parse(xElements.Element("ScreenLocation").LastAttribute.Value)); }
        catch {  }
        try { location.locationVisible = bool.Parse(xElements.Element("Type").FirstAttribute.Value); }
        catch { location.locationVisible = true; }

        return(location);
    }