Exemple #1
0
        public bool LoadParticleSystem(string filename)
        {
            /*
             * // make sure we have it checked out
             * if ((File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
             * {
             * string str = String.Format("File : {0} is read only!\nYou are not allowed to load!\nMake sure you checked the file out of Perforce!", filename);
             * MessageBox.Show(str, "Read Only File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             * return false;
             * }
             */

            SetTabName(filename);
            XmlSerializer s  = new XmlSerializer(typeof(ParticleEffect), new Type[] {});
            Stream        st = File.OpenRead(filename);

            mEffect = (ParticleEffect)s.Deserialize(st);
            st.Close();
            mEffect.postDeserialization();
            ResourcePathInfo pathInfo = new ResourcePathInfo(filename);

            mEffect.Name = pathInfo.RelativePath;

            //- strip out the art directory.   ResourcePathInfo should do this for you
            if (mArtDir.Length > 0)
            {
                mEffect.Name = mEffect.Name.Substring(mArtDir.Length);
            }

            bindData(0);
            refreshTreeView(true);
            return(true);
        }
Exemple #2
0
        public bool WriteParticleSystem(string filename)
        {
            //-- if the file exists make sure we have it checked out
            if (File.Exists(filename) && ((File.GetAttributes(filename) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly))
            {
                string str = String.Format("File: {0} is read only!\nYou are not allowed to save!\nMake sure you checked the file out of Perforce!", filename);
                MessageBox.Show(str, "Read Only File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            mEffect.preSerialization();

            if (!Path.HasExtension(filename))
            {
                filename = String.Format("{0}.pfx", filename);
            }

            ResourcePathInfo pathInfo = new ResourcePathInfo(filename);

            XmlSerializer s  = new XmlSerializer(typeof(ParticleEffect), new Type[] { });
            Stream        st = File.Create(filename);

            s.Serialize(st, mEffect);
            st.Close();
            mEffect.postDeserialization();

            XMBProcessor.CreateXMB(filename, false);

            return(true);
        }
Exemple #3
0
        //-- Add Stage
        private void button1_Click(object sender, EventArgs e)
        {
            if (!bInitialized)
            {
                return;
            }

            OpenFileDialog d = new OpenFileDialog();

            d.InitialDirectory = CoreGlobals.getSaveLoadPaths().mParticleEffectDirectory;
            d.Filter           = "TGA Texture (*.tga)|*.tga";
            if (d.ShowDialog() == DialogResult.OK)
            {
                EditorCore.CoreGlobals.getSaveLoadPaths().mParticleEffectDirectory = Path.GetDirectoryName(d.FileName);

                TextureStage newTexture = new TextureStage();

                String           filePath = d.FileName;
                ResourcePathInfo pathInfo = new ResourcePathInfo(d.FileName);

                newTexture.file = pathInfo.RelativePath;

                //-- strip out the stupid art directory -
                //-- ResourcePathInfo should cooler and do this for you
                if (mArtFolder.Length > 0)
                {
                    newTexture.file = newTexture.file.Substring(mArtFolder.Length);
                }

                newTexture.weight = 1.0f;
                data.Textures.Add(newTexture);

                refreshListBox(false);
                getModifiedData();

                //-- select the new item
                int selectedItem = listView1.Items.Count - 1;
                if (selectedItem < 0)
                {
                    selectedItem = 0;
                }
                selectItem(selectedItem);
            }
        }
Exemple #4
0
    /// <summary>
    /// 初始化默认配置
    /// </summary>
    public void InitDefaultInfo()
    {
        TerrainMakerDefine.DefaultTerrainInfo defaultTerrainInfo = m_Root.Define.CurrentDefaultTerrainInfo;

        m_ResourcePathInfo   = defaultTerrainInfo.ResourcePathInfo.Clone() as ResourcePathInfo;
        m_GameObjectPathInfo = defaultTerrainInfo.GameObjectPathInfo.Clone() as GameObjectPathInfo;
        m_BuildingInfo       = defaultTerrainInfo.BuildingInfo.Clone() as BuildingInfo;
        m_GamePlayInfo       = defaultTerrainInfo.GamePlayInfo.Clone() as GamePlayInfo;
        m_TweenInfo          = defaultTerrainInfo.TweenInfo.Clone() as TweenInfo;
        m_ColorInfo          = defaultTerrainInfo.ColorInfo.Clone() as ColorInfo;
        m_SceneArtInfo       = defaultTerrainInfo.SceneArtInfo.Clone() as SceneArtInfo;

        LogHelper.Trace?.Log("TerrainMakerTool", "InitDefaultInfo.",
                             LogHelper.Object2String(m_ResourcePathInfo),
                             LogHelper.Object2String(m_GameObjectPathInfo),
                             LogHelper.Object2String(m_BuildingInfo),
                             LogHelper.Object2String(m_GamePlayInfo),
                             LogHelper.Object2String(m_TweenInfo),
                             LogHelper.Object2String(m_ColorInfo),
                             LogHelper.Object2String(m_SceneArtInfo)
                             );
    }
Exemple #5
0
    /// <summary>
    /// 创建默认配置
    /// </summary>
    private void __CreateDefaultTerrainInfo()
    {
        //资源路径
        if (m_CurrentDefaultTerrainInfo.ResourcePathInfo == null)
        {
            ResourcePathInfo resourcePathInfo = new ResourcePathInfo();

            resourcePathInfo.TerrainPath      = "Prefab/Terrain";
            resourcePathInfo.TerrainPiecePath = "Prefab/TerrainPiece";

            m_CurrentDefaultTerrainInfo.ResourcePathInfo = resourcePathInfo;
        }

        if (m_CurrentDefaultTerrainInfo.GameObjectPathInfo == null)
        {
            GameObjectPathInfo gameObjectPathInfo = new GameObjectPathInfo();

            gameObjectPathInfo.PieceMaterialPath = "Cube";
            gameObjectPathInfo.SideRootPath      = "Side";
            gameObjectPathInfo.SideMaterialPath  = "Tag";
            gameObjectPathInfo.DownPath          = "Down";
            gameObjectPathInfo.UpPath            = "Up";
            gameObjectPathInfo.BuildingRootPath  = "Building";

            m_CurrentDefaultTerrainInfo.GameObjectPathInfo = gameObjectPathInfo;
        }


        //建筑
        if (m_CurrentDefaultTerrainInfo.BuildingInfo == null)
        {
            BuildingInfo buildingInfo = new BuildingInfo();
            //地块大小
            buildingInfo.TerrainSize   = new Vector3();
            buildingInfo.TerrainSize.x = 4;
            buildingInfo.TerrainSize.y = 1;
            buildingInfo.TerrainSize.z = 4;

            //间隔
            buildingInfo.IntervalSize   = new Vector3();
            buildingInfo.IntervalSize.x = 1;
            buildingInfo.IntervalSize.y = 1.6f;
            buildingInfo.IntervalSize.z = 1;

            //地块方向块偏移值 (从中心点到边缘的方向)
            buildingInfo.SideShiftingValue = 0.35f;

            m_CurrentDefaultTerrainInfo.BuildingInfo = buildingInfo;
        }

        //玩法
        if (m_CurrentDefaultTerrainInfo.GamePlayInfo == null)
        {
            GamePlayInfo gamePlayInfo = new GamePlayInfo();

            gamePlayInfo.BirthLogicPosition  = Vector3.zero;
            gamePlayInfo.HasEndLogicPosition = false;
            gamePlayInfo.EndLoigcPosition    = Vector3.zero;

            m_CurrentDefaultTerrainInfo.GamePlayInfo = gamePlayInfo;
        }

        //动画
        if (m_CurrentDefaultTerrainInfo.TweenInfo == null)
        {
            TweenInfo tweenInfo = new TweenInfo();

            tweenInfo.Originate = 8;
            tweenInfo.MoveSpeed = 1.8f;

            m_CurrentDefaultTerrainInfo.TweenInfo = tweenInfo;
        }

        //颜色
        if (m_CurrentDefaultTerrainInfo.ColorInfo == null)
        {
            ColorInfo colorInfo = new ColorInfo();

            colorInfo.Floor_Current = new Color(1, 1, 1, 1);
            colorInfo.Floor_Other   = new Color(0.8f, 0.8f, 0.8f, 0.29f);

            colorInfo.Piece_Current      = new Color(1, 1, 1, 1);
            colorInfo.Piece_ArriveAround = new Color(0.75f, 0.78f, 0.79f, 1);
            colorInfo.Piece_Other        = new Color(0.75f, 0.78f, 0.79f, 1);
            colorInfo.Piece_End          = new Color(0.82f, 0.3f, 0.3f, 1);

            colorInfo.Side_Current = new Color(0.36f, 0.33f, 0.3f, 1);
            colorInfo.Side_Other   = new Color(0.37f, 0.38f, 0.35f, 1);

            m_CurrentDefaultTerrainInfo.ColorInfo = colorInfo;
        }

        //场景表现
        if (m_CurrentDefaultTerrainInfo.SceneArtInfo == null)
        {
            SceneArtInfo sceneArtInfo = new SceneArtInfo();

            //首层3200 到3000可以容纳40层,应该是满足扩展的。
            sceneArtInfo.FirstFloorShaderLayer = 3200;

            //每个层预留5个shader层级单位
            //  0 = 扩展层
            // -1 = player
            // -2 = building
            // -3 = pieceSide
            // -4 = piece
            sceneArtInfo.FloorShaderLayerInterval = 5;

            m_CurrentDefaultTerrainInfo.SceneArtInfo = sceneArtInfo;
        }
    }
Exemple #6
0
        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            string filter;

            filter        = mFilterName + " (*" + mFilterExtension + ")|*" + mFilterExtension;
            d.Filter      = filter;
            d.FilterIndex = 0;

            d.InitialDirectory = CoreGlobals.getSaveLoadPaths().mGameDirectory;

            if ((mFileName != null) && (mFileName.Length > 0))
            {
                if (mReferenceFolder.Length > 0)
                {
                    d.InitialDirectory += "\\" + mReferenceFolder;
                }

                d.InitialDirectory += "\\" + mFileName;

                if (!Path.HasExtension(d.InitialDirectory))
                {
                    // Add extension
                    d.InitialDirectory += mFilterExtension;
                }
            }
            else
            {
                // Use last browse folder if it matches the startup folder
                if ((sLastBrowseDirectory != null) && (sLastBrowseDirectory.Length > 0))
                {
                    if (mStartFolder.Length > 0)
                    {
                        if (sLastBrowseDirectory.IndexOf(mStartFolder) != -1)
                        {
                            d.InitialDirectory += "\\" + sLastBrowseDirectory;
                        }
                        else
                        {
                            d.InitialDirectory += "\\" + mStartFolder;
                        }
                    }
                    else
                    {
                        d.InitialDirectory += "\\" + sLastBrowseDirectory;
                    }
                }
                else
                {
                    if (mStartFolder.Length > 0)
                    {
                        d.InitialDirectory += "\\" + mStartFolder;
                    }
                }
            }

            if (d.ShowDialog() == DialogResult.OK)
            {
                ResourcePathInfo relativePathName = new ResourcePathInfo(d.FileName);

                if (relativePathName.IsRelativePath)
                {
                    string relativeFileName = relativePathName.RelativePath;

                    // Remove ReferenceFolder if non-empty
                    if (mStartFolder.Length > 0)
                    {
                        relativeFileName = relativeFileName.Substring(mReferenceFolder.Length + 1);
                    }

                    // Remove extension
                    relativeFileName = relativeFileName.Remove(relativeFileName.Length - 4);

                    FileName = relativeFileName;

                    // Remember last directory we were in.
                    sLastBrowseDirectory = relativePathName.RelativePath;

                    // call event
                    EventArgs args = new EventArgs();
                    if (ValueChanged != null)
                    {
                        ValueChanged(this, args);
                    }
                }
                else
                {
                    if (MessageBox.Show("File is not under the correct folder.  Nothing changed.", "Warning", MessageBoxButtons.OK) != DialogResult.OK)
                    {
                        return;
                    }
                }
            }
        }