コード例 #1
0
        private void bImport_Click(object sender, EventArgs e)
        {
            GameData.Item          file;
            OgreSceneImporter.Node tag;
            GameData gameDatum = this.nav.ou.gameData;

            foreach (TreeNode node in this.tree.Nodes)
            {
                if (!node.Checked)
                {
                    continue;
                }
                if (((OgreSceneImporter.Node)node.Tag).target == null)
                {
                    switch (this.getNodeType((OgreSceneImporter.Node)node.Tag))
                    {
                    case OgreSceneImporter.NodeType.PART:
                    {
                        OgreSceneImporter.Entity entity = node.Tag as OgreSceneImporter.Entity;
                        file = gameDatum.createItem(itemType.BUILDING_PART);
                        file["phs or mesh"] = new GameData.File(string.Concat(this.Path, entity.mesh));
                        int?nullable  = null;
                        int?nullable1 = nullable;
                        nullable = null;
                        int?nullable2 = nullable;
                        nullable = null;
                        this.Item.addReference("parts", file, nullable1, nullable2, nullable);
                        break;
                    }

                    case OgreSceneImporter.NodeType.LIGHT:
                    {
                        OgreSceneImporter.Light light = node.Tag as OgreSceneImporter.Light;
                        file               = gameDatum.createItem(itemType.LIGHT);
                        file["diffuse"]    = light.diffuse;
                        file["specular"]   = light.specular;
                        file["radius"]     = light.radius;
                        file["brightness"] = light.power;
                        file["inner"]      = (float)Math.Round((double)(light.inner * 180f) / 3.14159265358979, 2);
                        file["outer"]      = (float)Math.Round((double)(light.outer * 180f) / 3.14159265358979, 2);
                        file["falloff"]    = light.falloff;
                        file["type"]       = light.mode;
                        file["landscape"]  = light.shadows;
                        file["buildings"]  = light.shadows;
                        file["characters"] = light.shadows;
                        this.Item.addInstance(light.name, file, light.x, light.y, light.z, light.qx, light.qy, light.qz, light.qw);
                        break;
                    }

                    case OgreSceneImporter.NodeType.EFFECT:
                    {
                        tag  = node.Tag as OgreSceneImporter.Node;
                        file = gameDatum.createItem(itemType.EFFECT);
                        this.Item.addInstance(tag.name, file.stringID, tag.x, tag.y, tag.z, tag.qx, tag.qy, tag.qz, tag.qw);
                        break;
                    }

                    case OgreSceneImporter.NodeType.NODE:
                    {
                        tag = node.Tag as OgreSceneImporter.Node;
                        this.Item.addInstance(tag.name, "", tag.x, tag.y, tag.z, tag.qx, tag.qy, tag.qz, tag.qw);
                        break;
                    }
                    }
                }
                else
                {
                    tag = node.Tag as OgreSceneImporter.Node;
                    this.Item.addInstance(tag.name, tag.target, tag.x, tag.y, tag.z, tag.qx, tag.qy, tag.qz, tag.qw);
                }
                this.nav.HasChanges = true;
            }
            base.Close();
        }
コード例 #2
0
        private void bOk_Click(object sender, EventArgs e)
        {
            object defaultValue = this.getDefaultValue(this.fieldName.Text);
            object str          = null;

            if (defaultValue == null)
            {
                MessageBox.Show("无效字段名称");
                return;
            }
            if (defaultValue is bool)
            {
                str = this.enumValue.SelectedItem.ToString() == "True";
            }
            else if (defaultValue is int)
            {
                str = int.Parse(this.fieldValue.Text);
            }
            else if (defaultValue is float)
            {
                str = float.Parse(this.fieldValue.Text);
            }
            else if (defaultValue is string)
            {
                str = this.fieldValue.Text;
            }
            else if (defaultValue is GameData.File)
            {
                str = new GameData.File(this.fieldValue.Text);
            }
            else if (defaultValue.GetType().IsEnum)
            {
                str = this.enumValue.SelectedItem;
            }
            else if (defaultValue is GameData.TripleInt)
            {
                str = this.parseReferences(this.getDesc(this.fieldName.Text), this.fieldValue.Text);
            }
            if (str == null)
            {
                return;
            }
            if (!(defaultValue is GameData.TripleInt))
            {
                this.nav.HasChanges = true;
                foreach (GameData.Item item in this.items)
                {
                    item[this.fieldName.Text] = str;
                    this.nav.refreshItemWindow(item);
                    this.nav.refreshState(item);
                }
                base.Close();
                return;
            }
            foreach (GameData.Item item1 in this.items)
            {
                foreach (KeyValuePair <GameData.Item, GameData.TripleInt> keyValuePair in str as List <KeyValuePair <GameData.Item, GameData.TripleInt> > )
                {
                    if (!item1.hasReferenceTo(this.fieldName.Text, keyValuePair.Key.stringID))
                    {
                        item1.addReference(this.fieldName.Text, keyValuePair.Key, new int?(keyValuePair.Value.v0), new int?(keyValuePair.Value.v1), new int?(keyValuePair.Value.v2));
                    }
                    else
                    {
                        item1.setReferenceValue(this.fieldName.Text, keyValuePair.Key.stringID, keyValuePair.Value);
                    }
                    this.nav.HasChanges = true;
                    this.nav.refreshItemWindow(item1);
                    this.nav.refreshState(item1);
                }
            }
            base.Close();
        }