예제 #1
0
        private void loadRegionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckChanges())
            {
                return;
            }

            WLDFileController wldc = FileDatabase.Instance.GetWLD();

            FableMod.WLD.WLDFile wld = wldc.WLD;

            FormRegionSelect form = new FormRegionSelect();

            for (int i = 0; i < wld.RegionCount; ++i)
            {
                form.listBoxRegions.Items.Add(
                    wld.GetRegion(i).RegionName);
            }

            if (form.ShowDialog() != DialogResult.OK)
            {
                // Cancel!
                return;
            }

            form.Dispose();

            Reset();

            FableMod.WLD.Region region = wld.GetRegion(
                form.listBoxRegions.Items[
                    form.listBoxRegions.SelectedIndex].ToString());

            LoadRegion(region);
        }
예제 #2
0
        private void myView_ThingCreated(
            float x, float y, float z,
            float nx, float ny, float nz)
        {
            ThingMap selectedMap = null;

            for (int i = 0; i < myMaps.Count; ++i)
            {
                if (myMaps[i].IsOver(x, y, z))
                {
                    selectedMap = myMaps[i];
                    break;
                }
            }

            if (selectedMap == null)
            {
                FormMain.Instance.ErrorMessage("Click over a map, please.");
                return;
            }

            if (myCreateMode == CreateMode.SelectTeleporterDst)
            {
                float dstx = x - myTeleporterMap.X;
                float dsty = y - myTeleporterMap.Y;

                CTCBlock block =
                    myTeleporter.get_CTCs("CTCPhysicsStandard");

                if (MessageBox.Show(
                        "Create a two-way teleporter?",
                        "ChocolateBox",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing myOriginal = myCreatedThing;

                    if (SetupForTeleporter())
                    {
                        selectedMap.AddThing(
                            myController,
                            myCreatedThing,
                            "NULL",
                            x, y, z,
                            nx, ny, nz);

                        CTCBlock blockSrc =
                            myOriginal.get_CTCs("CTCPhysicsStandard");

                        CTCBlock blockDst =
                            myTeleporter.get_CTCs("CTCPhysicsStandard");

                        blockDst.get_Variables("PositionX").Value =
                            (myTeleporterMap.X +
                             (float)blockSrc.get_Variables("PositionX").Value) -
                            selectedMap.X;

                        blockDst.get_Variables("PositionY").Value =
                            (myTeleporterMap.Y +
                             (float)blockSrc.get_Variables("PositionY").Value) -
                            selectedMap.Y;

                        blockDst.get_Variables("PositionZ").Value =
                            ((float)blockSrc.get_Variables(
                                 "PositionZ").Value) + 0.5f;

                        selectedMap.AddThing(
                            myController,
                            myTeleporter,
                            "NULL");

                        // So we spawn over the thing.
                        z += 0.5f;
                    }
                }
                else if (MessageBox.Show(
                             "Create a teleportation platform?\r\n" +
                             "This object is a visual que only.",
                             "ChocolateBox",
                             MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    FableMod.TNG.Thing platform =
                        new FableMod.TNG.Thing("Object");

                    platform.Create(
                        FileDatabase.Instance.TNGDefinitions,
                        "OBJECT_GUILD_PEDESTAL_TELEPORT_01");

                    platform.UID    = FableMod.TNG.UIDManager.Generate();
                    platform.Player = 4;

                    selectedMap.AddThing(
                        myController,
                        platform,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    // So we spawn over the thing.
                    z += 0.5f;
                }

                // Set the jump coordinates.
                block.get_Variables("PositionX").Value = dstx;
                block.get_Variables("PositionY").Value = dsty;
                block.get_Variables("PositionZ").Value = z;

                FormMain.Instance.InfoMessage(string.Format(
                                                  "Teleporter created from map \"{0}\" to map \"{1}\".",
                                                  myTeleporterMap.Name,
                                                  selectedMap.Name));

                myCreateMode = CreateMode.None;
                myView.Mode  = EditorMode.Normal;

                //Close();

                return;
            }
            else if (myCreateMode == CreateMode.SelectTeleporterSrc)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);

                    selectedMap.AddThing(
                        myController,
                        myTeleporter,
                        "NULL");
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                    return;
                }

                WLDFileController wldc =
                    FileDatabase.Instance.GetWLD();
                FableMod.WLD.WLDFile wld = wldc.WLD;

                FormRegionSelect form = new FormRegionSelect();

                form.Text = "Select Destination Region";

                for (int i = 0; i < wld.RegionCount; ++i)
                {
                    form.listBoxRegions.Items.Add(
                        wld.GetRegion(i).RegionName);
                }

                if (form.ShowDialog() == DialogResult.OK)
                {
                    FableMod.WLD.Region region = wld.GetRegion(
                        form.listBoxRegions.Items[
                            form.listBoxRegions.SelectedIndex].
                        ToString());

                    if (region.RegionName != myRegion)
                    {
                        FormEditor formEditor = new FormEditor(
                            region,
                            myCreatedThing,
                            myTeleporter,
                            selectedMap);

                        FormMain.Instance.AddMDI(formEditor);
                    }
                    else
                    {
                        // Use this window.
                        SelectTeleporterDestination(
                            myCreatedThing, myTeleporter, selectedMap);

                        return;
                    }
                }
                else
                {
                    myController.RemoveThing(myCreatedThing);
                    myController.RemoveThing(myTeleporter);
                }

                form.Dispose();

                myCreatedThing = null;

                // Reset variable.
                myTeleporter = null;
            }
            else if (myCreateMode == CreateMode.CreateNew)
            {
                try
                {
                    selectedMap.AddThing(
                        myController,
                        myCreatedThing,
                        "NULL",
                        x, y, z,
                        nx, ny, nz);
                }
                catch (Exception ex)
                {
                    FormMain.Instance.ErrorMessage(ex.Message);
                }

                myCreatedThing = null;
            }
            else if (myCreateMode == CreateMode.Import)
            {
                for (int i = 0; i < myImports.Count; ++i)
                {
                    FableMod.TNG.Thing thing = myImports[i];

                    selectedMap.AddThing(
                        myController, thing, "NULL");
                }
            }

            myImports.Clear();
            myCreateMode = CreateMode.None;
            myView.Mode  = EditorMode.Normal;
        }