Beispiel #1
0
 public void LoadByPathOrName(string pathOrName)
 {
     if (SpriteManager.Instance().SpriteNameIsGood(pathOrName))
     {
         string vesselDir         = System.IO.Path.Combine(UnityEngine.Application.persistentDataPath, "Vessels");
         string buildStringPath   = GameStringsHelper.VesselNameToPath(pathOrName);
         string spriteName        = pathOrName;
         bool   buildStringExists = System.IO.File.Exists(buildStringPath);
         if (buildStringExists)
         {
             string buildString = System.IO.File.ReadAllText(buildStringPath);
             spriteName = buildString.Split(' ')[1];
         }
         Sprite sprite = SpriteManager.Instance().SpriteFromName(spriteName);
         PixelGridManager.Instance().LoadTexture(sprite.texture);
         if (buildStringExists)
         {
             string buildString = System.IO.File.ReadAllText(buildStringPath);
             LoadVesselParts(buildString);
         }
     }
     else
     {
         byte[]    data    = System.IO.File.ReadAllBytes(pathOrName);
         Texture2D texture = new Texture2D(SpriteManager.SPRITE_SIZE, SpriteManager.SPRITE_SIZE);
         texture.LoadImage(data);
         PixelGridManager.Instance().LoadTexture(texture);
     }
 }
    public Vessel BuildVessel(bool requireSource,
                              List <Vessel> sourceVessels,
                              string vesselName,
                              string designation)
    {
        Debug.Log("build vessel: " + vesselName);
        string buildString = vesselNamesToBuildstrings[vesselName];

        return(GameStringsHelper.PerformBuildFromString(requireSource, buildString, designation, sourceVessels));
    }
Beispiel #3
0
    public void LoadVesselParts(string buildString)
    {
        List <VesselPart> parts = GameStringsHelper.PartsListFromBuildString(buildString);

        foreach (VesselPart part in parts)
        {
            PixelGridButton button = PixelGridManager.Instance().ButtonFromRelativePosition(part.position);
            PartPlacementManager.Instance().PlacePart(button, part);
        }
    }
Beispiel #4
0
    public void Save()
    {
        string name = input.text;

        PixelGridManager.Instance().SaveTexture(name);
        string buildstring = "build ";

        buildstring += name + " ";
        buildstring += sizeSlider.value.ToString() + " ";
        buildstring += qualitySlider.value.ToString() + " ";
        foreach (VesselPart part in PartPlacementManager.Instance().GetListOfParts())
        {
            if (part.partType == VesselPartType.Bay)
            {
                buildstring += "-bay ";
            }
            else if (part.partType == VesselPartType.Engine)
            {
                buildstring += "-engine ";
            }
            else if (part.partType == VesselPartType.Launcher)
            {
                buildstring += "-launcher ";
            }
            buildstring += part.size.ToString() + " ";
            buildstring += part.quality1.ToString() + " ";
            buildstring += part.quality2.ToString() + " ";
            Vector2 positionInRelativeForm = PixelGridManager.Instance().GetRelativeForm(part.position);
            buildstring += positionInRelativeForm.x.ToString() + " ";
            buildstring += positionInRelativeForm.y.ToString() + " ";
            buildstring += part.facing.ToString() + " ";
        }

        string vesselDir = GameStringsHelper.VesselDirectory();

        if (!System.IO.Directory.Exists(vesselDir))
        {
            System.IO.Directory.CreateDirectory(vesselDir);
        }
        string path = GameStringsHelper.VesselNameToPath(name);

        if (System.IO.File.Exists(path))
        {
            System.IO.File.Delete(path);
        }
        System.IO.File.WriteAllText(path, buildstring);
    }
    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        vesselNamesToBuildstrings = GameStringsHelper.AllSavedNamesToBuildstrings();
    }
    void Start()
    {
        Dictionary <string, string> namesToBuildstrings = GameStringsHelper.AllSavedNamesToBuildstrings();

        dropdown.AddOptions(new List <string>(namesToBuildstrings.Keys));
    }