コード例 #1
0
        private void AdjustObjLogicalDir(LogicObj obj, int nDir)
        {
            if (m_parentFrm.htObjLogicDirIndices.ContainsKey(obj.tyPe) && m_parentFrm.htObjLogicRotationIndices.ContainsKey(obj.tyPe))
            {
                int dirIndex = Convert.ToInt32(m_parentFrm.htObjLogicDirIndices[obj.tyPe]);
                int oldDir   = Convert.ToInt32(obj.values[dirIndex]);
                int newDir   = nDir;
                obj.values[dirIndex]         = newDir.ToString();
                obj.fields_changed[dirIndex] = true;

                int   rotationIndex = Convert.ToInt32(m_parentFrm.htObjLogicRotationIndices[obj.tyPe]);
                float x = 0.0f, y = 0.0f, z = 0.0f, w = 1.0f;
                Program.Engine.QuaternionRotationByNDir(ref x, ref y, ref z, ref w, nDir);
                double xx = x, yy = y, zz = z, ww = w;
                xx = Math.Round(xx, 6);
                yy = Math.Round(yy, 6);
                zz = Math.Round(zz, 6);
                ww = Math.Round(ww, 6);
                string newRotation = string.Format("{0},{1},{2},{3}", xx, yy, zz, ww);
                obj.values[rotationIndex] = newRotation;

                obj.ForcePreviewChange(true, rotationIndex);
                obj.ForceInhandChange(true);
                this.m_parentFrm.ForceMapChanged();
                this.m_parentFrm.Pg.Refresh();
            }
        }
コード例 #2
0
        private void AdjustObjLogicalPos(LogicObj obj, PointF pfClientRateAdjust)
        {
            if (m_parentFrm.htObjScenePosIndices.ContainsKey(obj.tyPe))
            {
                double x = 0.0, y = 0.0;
                float  height = 0.0f;
                // 场景pos
                if (m_parentFrm.htObjScenePosIndices[obj.tyPe] != null)
                {
                    int      posIndex  = Convert.ToInt32(m_parentFrm.htObjScenePosIndices[obj.tyPe]);
                    string   vPosition = obj.values[posIndex];
                    string[] fields    = vPosition.Split(new char[] { ',' });
                    x      = Convert.ToDouble(fields[0]);
                    y      = Convert.ToDouble(fields[2]);
                    x     += pfClientRateAdjust.X * m_parentFrm.curMapLogicWidthTotal * m_panel1.scale;
                    y     -= pfClientRateAdjust.Y * m_parentFrm.curMapLogicHeightTotal * m_panel1.scale;
                    x      = Math.Round(x, 2);
                    y      = Math.Round(y, 2);
                    height = 0.0f;
                    Program.Engine.GetHeight((int)m_parentFrm.htScenePtr[m_parentFrm.m_curMapName], (float)x, (float)y, out height);
                    vPosition            = string.Format("{0},{1},{2}", x, height, y);
                    obj.values[posIndex] = vPosition;
                    obj.ForcePreviewChange(true, posIndex);
                }

                // 逻辑xyz
                if (m_parentFrm.htObjLogicNXIndices[obj.tyPe] != null)
                {
                    float logic_x_start = (float)(Convert.ToDouble((m_parentFrm.maps[m_parentFrm.m_curMapName] as LO_Map).MAIN.values[11]));
                    float logic_z_start = (float)(Convert.ToDouble((m_parentFrm.maps[m_parentFrm.m_curMapName] as LO_Map).MAIN.values[12]));
                    int   lX = 0, lY = 0, lZ = 0;
                    Helper.SceneToLogical(ref lX, ref lY, ref lZ, (float)x, height, (float)y, 0.0f, logic_x_start, logic_z_start);
                    int nXIndex = Convert.ToInt32(m_parentFrm.htObjLogicNXIndices[obj.tyPe]);
                    obj.values[nXIndex]     = lX.ToString();
                    obj.values[nXIndex + 1] = lY.ToString();
                    obj.values[nXIndex + 2] = lZ.ToString();

                    obj.ForcePreviewChange(true, nXIndex);
                    obj.ForcePreviewChange(true, nXIndex + 1);
                    obj.ForcePreviewChange(true, nXIndex + 2);
                }

                obj.ForceInhandChange(true);
                this.m_parentFrm.ForceMapChanged();
                this.m_parentFrm.Pg.Refresh();
            }
        }
コード例 #3
0
ファイル: SaveData.cs プロジェクト: uvbs/FullSource
        private void SaveOneLogicObj(LogicObj lobj, string strFileName, ref int affectedObjCount)
        {
            affectedObjCount++;

            string iniBlock       = string.Empty;
            string iniFieldPrefix = string.Empty;
            int    inDex          = lobj.inDex;
            int    parentindex    = lobj.parentindex;

            switch (lobj.tyPe)
            {
            case "MAIN":
                iniBlock = "MAIN";
                break;

            case "NPC":
                iniBlock = "NPC" + inDex.ToString();
                break;

            case "Doodad":
                iniBlock = "Doodad" + inDex.ToString();
                break;

            case "NPCRefreshPointSet":
                iniBlock = "NPCRefreshPointSet" + inDex.ToString();
                break;

            case "NPCRefreshPoint":
                iniBlock       = "NPCRefreshPointSet" + parentindex.ToString();
                iniFieldPrefix = "Point" + inDex.ToString();
                break;

            case "NPCRefreshNPC":
                iniBlock       = "NPCRefreshPointSet" + parentindex.ToString();
                iniFieldPrefix = "NPC" + inDex.ToString();
                break;

            case "DoodadRefreshPointSet":
                iniBlock = "DoodadRefreshPointSet" + inDex.ToString();
                break;

            case "DoodadRefreshPoint":
                iniBlock       = "DoodadRefreshPointSet" + parentindex.ToString();
                iniFieldPrefix = "Point" + inDex.ToString();
                break;

            case "DoodadRefreshDoodad":
                iniBlock       = "DoodadRefreshPointSet" + parentindex.ToString();
                iniFieldPrefix = "Doodad" + inDex.ToString();
                break;

            case "AIGroup":
                iniBlock = "AIGroup" + inDex.ToString();
                break;

            case "AIGroupNPC":
                iniBlock       = "AIGroup" + parentindex.ToString();
                iniFieldPrefix = "NPC" + inDex.ToString();
                break;

            case "WayPointSet":
                iniBlock = "WayPointSet" + inDex.ToString();
                break;

            case "WayPoint":
                iniBlock       = "WayPointSet" + parentindex.ToString();
                iniFieldPrefix = "Point" + inDex.ToString();
                break;

            case "LogicalPoly":
                iniBlock = "LogicalPoly" + inDex.ToString();
                break;

            case "LogicalPolyVertex":
                iniBlock       = "LogicalPoly" + parentindex.ToString();
                iniFieldPrefix = "Vertex" + inDex.ToString();
                break;
            }

            StringBuilder sb = new StringBuilder(255);

            for (int i = 0; i < lobj.fields.Length; i++)
            {
                Helper.WriteIniFile(iniBlock, iniFieldPrefix + lobj.fields[i], lobj.values[i], strFileName);
            }

            lobj.ForceInhandChange(false);
            lobj.ForcePreviewChange(false);
        }
コード例 #4
0
ファイル: SaveData.cs プロジェクト: viticm/pap2
        private void SaveOneLogicObj(LogicObj lobj, string strFileName, ref int affectedObjCount)
        {
            affectedObjCount++;

            string iniBlock = string.Empty;
            string iniFieldPrefix = string.Empty;
            int inDex = lobj.inDex;
            int parentindex = lobj.parentindex;

            switch (lobj.tyPe)
            {
                case "MAIN":
                    iniBlock = "MAIN";
                    break;

                case "NPC":
                    iniBlock = "NPC" + inDex.ToString();
                    break;
                case "Doodad":
                    iniBlock = "Doodad" + inDex.ToString();
                    break;

                case "NPCRefreshPointSet":
                    iniBlock = "NPCRefreshPointSet" + inDex.ToString();
                    break;
                case "NPCRefreshPoint":
                    iniBlock = "NPCRefreshPointSet" + parentindex.ToString();
                    iniFieldPrefix = "Point" + inDex.ToString();
                    break;
                case "NPCRefreshNPC":
                    iniBlock = "NPCRefreshPointSet" + parentindex.ToString();
                    iniFieldPrefix = "NPC" + inDex.ToString();
                    break;

                case "DoodadRefreshPointSet":
                    iniBlock = "DoodadRefreshPointSet" + inDex.ToString();
                    break;
                case "DoodadRefreshPoint":
                    iniBlock = "DoodadRefreshPointSet" + parentindex.ToString();
                    iniFieldPrefix = "Point" + inDex.ToString();
                    break;
                case "DoodadRefreshDoodad":
                    iniBlock = "DoodadRefreshPointSet" + parentindex.ToString();
                    iniFieldPrefix = "Doodad" + inDex.ToString();
                    break;

                case "AIGroup":
                    iniBlock = "AIGroup" + inDex.ToString();
                    break;
                case "AIGroupNPC":
                    iniBlock = "AIGroup" + parentindex.ToString();
                    iniFieldPrefix = "NPC" + inDex.ToString();
                    break;

                case "WayPointSet":
                    iniBlock = "WayPointSet" + inDex.ToString();
                    break;
                case "WayPoint":
                    iniBlock = "WayPointSet" + parentindex.ToString();
                    iniFieldPrefix = "Point" + inDex.ToString();
                    break;

                case "LogicalPoly":
                    iniBlock = "LogicalPoly" + inDex.ToString();
                    break;
                case "LogicalPolyVertex":
                    iniBlock = "LogicalPoly" + parentindex.ToString();
                    iniFieldPrefix = "Vertex" + inDex.ToString();
                    break;
            }

            StringBuilder sb = new StringBuilder(255);
            for (int i = 0; i < lobj.fields.Length; i++)
            {
                Helper.WriteIniFile(iniBlock, iniFieldPrefix + lobj.fields[i], lobj.values[i], strFileName);
            }

            lobj.ForceInhandChange(false);
            lobj.ForcePreviewChange(false);
        }
コード例 #5
0
ファイル: Preview.cs プロジェクト: viticm/pap2
        private void AdjustObjLogicalDir(LogicObj obj, int nDir)
        {
            if (m_parentFrm.htObjLogicDirIndices.ContainsKey(obj.tyPe) && m_parentFrm.htObjLogicRotationIndices.ContainsKey(obj.tyPe))
            {
                int dirIndex = Convert.ToInt32(m_parentFrm.htObjLogicDirIndices[obj.tyPe]);
                int oldDir = Convert.ToInt32(obj.values[dirIndex]);
                int newDir = nDir;
                obj.values[dirIndex] = newDir.ToString();
                obj.fields_changed[dirIndex] = true;

                int rotationIndex = Convert.ToInt32(m_parentFrm.htObjLogicRotationIndices[obj.tyPe]);
                float x = 0.0f, y = 0.0f, z = 0.0f, w = 1.0f;
                Program.Engine.QuaternionRotationByNDir(ref x, ref y, ref z, ref w, nDir);
                double xx = x, yy = y, zz = z, ww = w;
                xx = Math.Round(xx, 6);
                yy = Math.Round(yy, 6);
                zz = Math.Round(zz, 6);
                ww = Math.Round(ww, 6);
                string newRotation = string.Format("{0},{1},{2},{3}", xx, yy, zz, ww);
                obj.values[rotationIndex] = newRotation;

                obj.ForcePreviewChange(true, rotationIndex);
                obj.ForceInhandChange(true);
                this.m_parentFrm.ForceMapChanged();
                this.m_parentFrm.Pg.Refresh();
            }
        }
コード例 #6
0
ファイル: Preview.cs プロジェクト: viticm/pap2
        private void AdjustObjLogicalPos(LogicObj obj, PointF pfClientRateAdjust)
        {
            if (m_parentFrm.htObjScenePosIndices.ContainsKey(obj.tyPe))
            {
                double x = 0.0, y = 0.0;
                float height = 0.0f;
                // 场景pos
                if (m_parentFrm.htObjScenePosIndices[obj.tyPe] != null)
                {
                    int posIndex = Convert.ToInt32(m_parentFrm.htObjScenePosIndices[obj.tyPe]);
                    string vPosition = obj.values[posIndex];
                    string[] fields = vPosition.Split(new char[] { ',' });
                    x = Convert.ToDouble(fields[0]);
                    y = Convert.ToDouble(fields[2]);
                    x += pfClientRateAdjust.X * m_parentFrm.curMapLogicWidthTotal * m_panel1.scale;
                    y -= pfClientRateAdjust.Y * m_parentFrm.curMapLogicHeightTotal * m_panel1.scale;
                    x = Math.Round(x, 2);
                    y = Math.Round(y, 2);
                    height = 0.0f;
                    Program.Engine.GetHeight((int)m_parentFrm.htScenePtr[m_parentFrm.m_curMapName], (float)x, (float)y, out height);
                    vPosition = string.Format("{0},{1},{2}", x, height, y);
                    obj.values[posIndex] = vPosition;
                    obj.ForcePreviewChange(true, posIndex);
                }
                
                // 逻辑xyz
                if (m_parentFrm.htObjLogicNXIndices[obj.tyPe] != null)
                {
                    float logic_x_start = (float)(Convert.ToDouble((m_parentFrm.maps[m_parentFrm.m_curMapName] as LO_Map).MAIN.values[11]));
                    float logic_z_start = (float)(Convert.ToDouble((m_parentFrm.maps[m_parentFrm.m_curMapName] as LO_Map).MAIN.values[12]));
                    int lX = 0, lY = 0, lZ = 0;
                    Helper.SceneToLogical(ref lX, ref lY, ref lZ, (float)x, height, (float)y, 0.0f, logic_x_start, logic_z_start);
                    int nXIndex = Convert.ToInt32(m_parentFrm.htObjLogicNXIndices[obj.tyPe]);
                    obj.values[nXIndex] = lX.ToString();
                    obj.values[nXIndex + 1] = lY.ToString();
                    obj.values[nXIndex + 2] = lZ.ToString();

                    obj.ForcePreviewChange(true, nXIndex);
                    obj.ForcePreviewChange(true, nXIndex + 1);
                    obj.ForcePreviewChange(true, nXIndex + 2);
                }

                obj.ForceInhandChange(true);
                this.m_parentFrm.ForceMapChanged();
                this.m_parentFrm.Pg.Refresh();
            }
        }