public CampaignFile ToProject()
        {
            CampaignFile project = new CampaignFile();

            project.Metadata.Title       = name;
            project.Metadata.Description = description;

            return(project);
        }
        private void ImportNew(object sender, EventArgs e)
        {
            CampaignResource imported = Constants.RESOURCE_DIALOGS[type](null, editor);

            if (!Equals(imported, null))
            {
                CampaignFile project = editor.Document;

                project.Data.Resources.Add(imported);

                //TODO: Fix level sets page unselecting current object after assigning document
                editor.Document = project;

                UpdateDataStore();
            }
        }
Esempio n. 3
0
    /// <summary>
    /// Load a page, called by a campaign file
    /// </summary>
    /// <param name="file">File to load a page for</param>
    public void SwitchPage(CampaignFile file)
    {
        DeletePage();
        Debug.Log("Switching to page: " + file.GetFileName());

        string fullPath = file.GetCampaign().GetCampaignName() + "/" + file.GetFileName() + "." + file.GetExtension();

        fullPath = SerializationManager.CreatePath(fullPath);

        //Get the file extension to determine what file type to display
        switch (file.GetExtension())
        {
        case "sbd":
        {
            pinManager.SetActive(false);
            currrentPage = Instantiate(prefabs[0], viewport.transform);
            StatBlockUIData uiData = (StatBlockUIData)SerializationManager.LoadObject(fullPath);

            currrentPage.GetComponent <StatBlockForm>().BuildPage(uiData);
            currrentPage.GetComponent <StatBlockForm>().fullPath = fullPath;
            currrentPage.GetComponent <StatBlockForm>().campaign = file.GetCampaign().GetCampaignName();
            break;
        }

        case "map":
        {
            pinManager.SetActive(true);
            currrentPage = Instantiate(prefabs[1], viewport.transform);
            SharedImageData uiData = (SharedImageData)SerializationManager.LoadObject(fullPath);
            currrentPage.GetComponent <MapForm>().campaign = file.GetCampaign().GetCampaignName();
            currrentPage.GetComponent <MapForm>().BuildPage(uiData);
            break;
        }

        default:
        {
            Debug.Log(file.GetExtension() + " is not a proper extension!");
            return;
        }
        }

        scrollRect.enabled = true;
        scrollRect.content = currrentPage.GetComponent <RectTransform>();

        SetActiveCampaignView(false);
    }
Esempio n. 4
0
    /// <summary>
    /// Load all files currently in the campaign directory
    /// creating prefabs for each file, modify object heights to properly display files
    /// </summary>
    public void LoadFiles()
    {
        int count = 1;

        DeleteFileTabs();
        foreach (string s in FileManager.instance.GetSavedFilesFromCampaign(campaignName))
        {
            GameObject   gO = Instantiate(campaignFilePrefab, fileHolder.transform);
            CampaignFile cf = gO.GetComponent <CampaignFile>();
            cf.SetFileName(s);
            cf.SetCampaignName(this);
            gO.transform.SetAsFirstSibling();
            count++;
        }
        GetComponent <LayoutElement>().preferredHeight            = 200 + count * 200;
        fileHolder.GetComponent <LayoutElement>().preferredHeight = 200 + count * 200;
    }
Esempio n. 5
0
        public override void Link(GameForm f)
        {
            base.Link(f);
            try
            {
                CampaignFile atre = new CampaignFile();
                atre.ReadFromFile(@".\data\campaigns\ATREIDES.ini");
                Clicked_AtreidesCampaign = () => SelectCampaign(f, atre);
            }
            catch (Exception ex)
            {
                f.Engine.HandleError("Error reading Atreides campaign file", ex);
                spAtreides.Enabled = false;
            }

            try
            {
                CampaignFile hark = new CampaignFile();
                hark.ReadFromFile(@".\data\campaigns\HARKONNEN.ini");
                Clicked_HarkonnenCampaign = () => SelectCampaign(f, hark);
            }
            catch (Exception ex)
            {
                f.Engine.HandleError("Error reading Harkonnen campaign file", ex);
                spHarkonnen.Enabled = false;
            }

            try
            {
                CampaignFile ordo = new CampaignFile();
                ordo.ReadFromFile(@".\data\campaigns\ORDOS.ini");
                Clicked_OrdosCampaign = () => SelectCampaign(f, ordo);
            }
            catch (Exception ex)
            {
                f.Engine.HandleError("Error reading Ordos campaign file", ex);
                spOrdos.Enabled = false;
            }

            Clicked_CustomCampaign = () => SelectCampaign(f, (s) => s.Identifier.Type == MissionType.CUSTOM_CAMPAIGN);
            Clicked_Back           = () => f.Remove(this, TransitionStyle.FADE_BLACK);
        }
        public static CampaignFile CreateProject(ProjectCreateData data)
        {
            try
            {
                DirectoryInfo projectDir   = Directory.CreateDirectory(data.path);
                DirectoryInfo resourcesDir = projectDir.CreateSubdirectory("resources");

                resourcesDir.CreateSubdirectory("levels");
                resourcesDir.CreateSubdirectory("textures");
                //resourcesDir.CreateSubdirectory("audio"); UNUSED FOR NOW

                CampaignFile project = data.ToProject();
                project.Metadata.Guid = Guid.NewGuid().ToString();

                Json.Save(Path.Combine(projectDir.FullName, "project.json"), project, true);

                return(project);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 7
0
 public void SelectCampaign(GameForm f, CampaignFile campaign)
 {
     f.Push(new CampaignMissionSelectionScreen(campaign), TransitionStyle.FADE_BLACK);
 }
        public CampaignMissionSelectionScreen(CampaignFile campaignFile)
        {
            InitializeComponent();
            Dock = DockStyle.Fill;

            _campaignFile = campaignFile;

            string bg   = _campaignFile.Images.Background;
            string mask = _campaignFile.Images.Mask;

            string[] layers = _campaignFile.Images.Layers;

            _samples = new FastBitmap[layers?.Length ?? 0];
            for (int i = 0; i < _samples.Length; i++)
            {
                _samples[i] = new Bitmap(layers[i]).FastLock();
            }
            Bitmap tdata = new Bitmap(mask);

            spBG.BaseImage = new Bitmap(bg);

            /*
             * _samples = new FastBitmap[3];
             * _samples[0] = Properties.Resources.DUNETERRITORY_AT.FastLock();
             * _samples[1] = Properties.Resources.DUNETERRITORY_HK.FastLock();
             * _samples[2] = Properties.Resources.DUNETERRITORY_OD.FastLock();
             * Bitmap tdata = Properties.Resources.DUNETERRITORY;
             */

            _territoryData       = tdata.FastLock();
            _territoryBitmapSize = tdata.Size;
            _colorImage          = new Bitmap(_territoryBitmapSize.Width, _territoryBitmapSize.Height);
            _colorImage.MakeTransparent();

            AnalyseImage();

            SetKeyAction(Keys.Escape, () => { if (spBack.Enabled)
                                              {
                                                  SpBack_Click(null, null);
                                              }
                         }, "Return to previous menu");
            SetKeyAction(Keys.Left, () => { if (spPrevPage.Enabled)
                                            {
                                                SpPrevPage_Click(null, null);
                                            }
                         }, "Previous mission");
            SetKeyAction(Keys.Right, () => { if (spNextPage.Enabled)
                                             {
                                                 SpNextPage_Click(null, null);
                                             }
                         }, "Next mission");
            SetKeyAction(Keys.D1, () => { if (spTerritories.Controls.Count >= 1)
                                          {
                                              (spTerritories.Controls[0] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 1");
            SetKeyAction(Keys.D2, () => { if (spTerritories.Controls.Count >= 2)
                                          {
                                              (spTerritories.Controls[1] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 2");
            SetKeyAction(Keys.D3, () => { if (spTerritories.Controls.Count >= 3)
                                          {
                                              (spTerritories.Controls[2] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 3");
            SetKeyAction(Keys.D4, () => { if (spTerritories.Controls.Count >= 4)
                                          {
                                              (spTerritories.Controls[3] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 4");
            SetKeyAction(Keys.D5, () => { if (spTerritories.Controls.Count >= 5)
                                          {
                                              (spTerritories.Controls[4] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 5");
            SetKeyAction(Keys.D6, () => { if (spTerritories.Controls.Count >= 6)
                                          {
                                              (spTerritories.Controls[5] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 6");
            SetKeyAction(Keys.D7, () => { if (spTerritories.Controls.Count >= 7)
                                          {
                                              (spTerritories.Controls[6] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 7");
            SetKeyAction(Keys.D8, () => { if (spTerritories.Controls.Count >= 8)
                                          {
                                              (spTerritories.Controls[7] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 8");
            SetKeyAction(Keys.D9, () => { if (spTerritories.Controls.Count >= 9)
                                          {
                                              (spTerritories.Controls[8] as SpriteBox)?.DoClick();
                                          }
                         }, "Mission Choice 9");
            SetKeyAction(Keys.R, () => { if (spRefresh.Enabled)
                                         {
                                             SpRefresh_Click(null, null);
                                         }
                         }, "Refresh mission list");
            SetKeyAction(Keys.F5, () => { if (spRefresh.Enabled)
                                          {
                                              SpRefresh_Click(null, null);
                                          }
                         }, "Refresh mission list");
        }