当前位置: 首页>>代码示例>>C#>>正文


C# NamedObjectSave.SetPropertyValue方法代码示例

本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.SetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.SetPropertyValue方法的具体用法?C# NamedObjectSave.SetPropertyValue怎么用?C# NamedObjectSave.SetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlatRedBall.Glue.SaveClasses.NamedObjectSave的用法示例。


在下文中一共展示了NamedObjectSave.SetPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRelativeAbsoluteConversion

        public void TestRelativeAbsoluteConversion()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.UpdateCustomProperties();
            nos.InstanceName = "SpriteObject";
            nos.SetPropertyValue("ScaleX", 2.0f);
            nos.SetPropertyValue("X", 4.0f);
            nos.SetPropertyValue("RotationZ", 4.0f);
            nos.SetPropertyValue("RotationZVelocity", 4.0f);

            mEntitySave.NamedObjects.Add(nos);

            CustomVariable customVariable = new CustomVariable();
            customVariable.SourceObject = nos.InstanceName;
            customVariable.SourceObjectProperty = "ScaleY";
            customVariable.DefaultValue = 8.0f;

            mEntitySave.CustomVariables.Add(customVariable);

            ElementRuntime elementRuntime = new ElementRuntime(mEntitySave, null, null, null, null);

            Sprite sprite = elementRuntime.ContainedElements[0].DirectObjectReference as Sprite;
            sprite.ForceUpdateDependencies();

            if (elementRuntime.X != 0)
            {
                throw new Exception("NOS variables are being applied to the container instead of just to the NOS");
            }

            if (sprite.X != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting X on objects even though they're attached");
            }

            if (sprite.RotationZ != 4.0f)
            {
                throw new Exception("Absolute values should get set when setting RotationZ on objects even though they're attached");
            }
            if (sprite.RelativeRotationZVelocity != 4.0f)
            {
                throw new Exception("Setting RotationZVelocity should set RelativeRotationZVelocity");
            }
            if (sprite.ScaleX != 2.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
            if (sprite.ScaleY != 8.0f)
            {
                throw new Exception("Scale values aren't properly showing up on Sprites");
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:53,代码来源:NamedObjectSaveTests.cs

示例2: CreateNosFor

        private NamedObjectSave CreateNosFor(InstanceSave instance, IElement container)
        {

            NamedObjectSave nos = new NamedObjectSave();

            string name = instance.Name;

            // See if this name is already used by RFS's
            var allRfss = container.GetAllReferencedFileSavesRecursively();
            while (allRfss.Any(item => item.GetInstanceName() == name) || container.ReferencedFiles.Any(item => item.Name == name))
            {
                name = name + instance.BaseType;
            }

            nos.InstanceName = name;
            RecursiveVariableFinder rvf = new RecursiveVariableFinder(instance, instance.ParentContainer);
            if (instance.BaseType == "Sprite")
            {
                nos.SourceType = SourceType.FlatRedBallType;
                nos.SourceClassType = "Sprite";

                float width = rvf.GetValue<float>("Width");
                float height = rvf.GetValue<float>("Height");

                if (width == 0 && height == 0)
                {
                    nos.SetPropertyValue("TextureScale", 1.0f);
                }
                else
                {
                    // Eventually handle width/height
                    nos.SetPropertyValue("Width", width);
                    nos.SetPropertyValue("Height", height);
                }

                SetPositionValuesOn(nos, instance);

                string texture = rvf.GetValue<string>("SourceFile");

                string fileInstanceName = FileManager.RemoveExtension(FileManager.RemovePath(texture));

                var added = nos.SetPropertyValue("Texture", fileInstanceName);
                added.Type = "Texture2D";
            }
            return nos;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:46,代码来源:GumInstanceToGlueNamedObjectSave.cs

示例3: AdjustCircle

        private void AdjustCircle(NamedObjectSave nos, IElement element)
        {
            if (Is2D(element))
            {

                nos.SetPropertyValue("Radius", 16f);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:8,代码来源:NewNamedObjectPlugin.cs

示例4: AdjustSpriteFrame

        private void AdjustSpriteFrame(NamedObjectSave nos, IElement element)
        {

            if (Is2D(element))
            {

                nos.SetPropertyValue("PixelSize", .5f);

            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:10,代码来源:NewNamedObjectPlugin.cs

示例5: CreateScreenSave

        private void CreateScreenSave()
        {
            mScreenSave = new ScreenSave();
            mScreenSave.Name = "ScreenSaveInVariableSettingTest";
            ObjectFinder.Self.GlueProject.Screens.Add(mScreenSave);

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.SourceClassType = mEntitySave.Name;
            nos.UpdateCustomProperties();
            nos.InstanceName = "TestObject1";
            nos.SetPropertyValue("X", 150);

            mScreenSave.NamedObjects.Add(nos);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:15,代码来源:VariableSetting.cs

示例6: ReactToFontSet

        private void ReactToFontSet(NamedObjectSave namedObjectSave, object oldValue)
        {
            string value = namedObjectSave.GetCustomVariable("Font").Value as string;

            if (!string.IsNullOrEmpty(value))
            {
                IElement element = EditorLogic.CurrentElement;

                ReferencedFileSave referencedFileSave = element.GetReferencedFileSaveByInstanceNameRecursively(value);


                if (referencedFileSave != null)
                {
                    string file = referencedFileSave.GetRelativePath();
                    file = ProjectManager.MakeAbsolute(file, true);

                    string contents = FileManager.FromFileText(file);

                    int size =
                        StringFunctions.GetIntAfter(
                        "size=", contents);

                    float lineHeightInPixels =
                        StringFunctions.GetIntAfter(
                        "lineHeight=", contents);

                    lineHeightInPixels /= 2.0f;

                    namedObjectSave.SetPropertyValue("Scale", (float)lineHeightInPixels);
                    namedObjectSave.SetPropertyValue("Spacing", (float)lineHeightInPixels);
                    namedObjectSave.SetPropertyValue("NewLineDistance", (float)(lineHeightInPixels * 1.5f));

                }
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:35,代码来源:NamedObjectSetVariableLogic.cs

示例7: SetVariableOn

        public static void SetVariableOn(NamedObjectSave nos, string memberName, Type memberType, object value)
        {

            if (memberType != null &&
                value is string &&
                memberType != typeof(Microsoft.Xna.Framework.Color) &&
                !CustomVariableExtensionMethods.GetIsFile(memberType) // If it's a file, we just want to set the string value and have the underlying system do the loading                            
                )
            {
                bool isCsv = NamedObjectPropertyGridDisplayer.GetIfIsCsv(nos, memberName);
                bool shouldConvertValue = !isCsv &&
                    memberType != typeof(object) &&
                    // variable could be an object
                    memberType != typeof(PositionedObject);
                // If the MemberType is object, then it's something we can't convert to - it's likely a state
                if (shouldConvertValue)
                {
                    value = PropertyValuePair.ConvertStringToType((string)value, memberType);
                }
            }

            nos.SetPropertyValue(memberName, value);
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:23,代码来源:NamedObjectPropertyGridDisplayer.cs

示例8: CreateNamedObjectWithSetVariable

        private void CreateNamedObjectWithSetVariable()
        {
            mNamedObjectWithSetVariable = new NamedObjectSave();
            mNamedObjectWithSetVariable.InstanceName = "SpriteObject";
            // This will be complicated because it requires FRB to be instantiated!
            //mNamedObjectWithSetVariable.SourceType = SourceType.File;
            //mNamedObjectWithSetVariable.SourceFile = "Entities/StateTestEntity/SceneFile.scnx";
            //mNamedObjectWithSetVariable.SourceName = "Untextured (Sprite)";

            mNamedObjectWithSetVariable.SourceType = SourceType.FlatRedBallType;
            mNamedObjectWithSetVariable.SourceClassType = "Sprite";

            mNamedObjectWithSetVariable.UpdateCustomProperties();
            mNamedObjectWithSetVariable.SetPropertyValue("Y", 10.0f);

            mEntitySave.NamedObjects.Add(mNamedObjectWithSetVariable);
            
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:18,代码来源:StateTests.cs

示例9: TestSetPropertyValue

        public void TestSetPropertyValue()
        {
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("Texture", "redball");

            if (nos.InstructionSaves.Count == 0)
            {
                throw new Exception("There should be a Texture instruction save");
            }

            if (nos.InstructionSaves.First(instruction => instruction.Member == "Texture").Type != "Texture2D")
            {
                throw new Exception("The instruction should be of type Texture2D, but it's not");
            }

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:20,代码来源:NamedObjectSaveTests.cs

示例10: CreateContainerElementRuntime

        void CreateContainerElementRuntime()
        {

            EntitySave containerEntitySave = new EntitySave { Name = "ContainerVariableSetting" };
            ObjectFinder.Self.GlueProject.Entities.Add(containerEntitySave);
            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.Entity;
            nos.InstanceName = mEntitySave.Name + "Instance";
            nos.SourceClassType = mEntitySave.Name;
            containerEntitySave.NamedObjects.Add(nos);

            nos.UpdateCustomProperties();
            nos.SetPropertyValue("CurrentStateSaveCategoryState", "SecondState");

            mContainedElementRuntime = new ElementRuntime(containerEntitySave, null, null, null, null);

            // This thing is attached - we need to check its relativeX
            //if (mContainedElementRuntime.ContainedElements[0].X != -10.0f)
            if (mContainedElementRuntime.ContainedElements[0].RelativeX != -10.0f)
            {
                throw new Exception("Categorized states on contained NamedObjectSave Elements aren't setting values properly");
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:23,代码来源:VariableSetting.cs

示例11: ReactToAnimationChainSet

        private void ReactToAnimationChainSet(NamedObjectSave namedObjectSave, object oldValue)
        {
            AvailableAnimationChainsStringConverter aacsc = new AvailableAnimationChainsStringConverter(
                GlueState.Self.CurrentElement, namedObjectSave);

            var customVariable = namedObjectSave.GetCustomVariable("CurrentChainName");

            string currentChain = null;

            if (customVariable != null)
            {
                currentChain = customVariable.Value as string;
            }

            if (!aacsc.AvailableChains.Contains(currentChain))
            {
                if (aacsc.AvailableChains.Length == 0)
                {
                    namedObjectSave.SetPropertyValue("CurrentChainName", null);

                }
                else
                {
                    namedObjectSave.SetPropertyValue("CurrentChainName", aacsc.AvailableChains[0]);
                }
            }
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:27,代码来源:NamedObjectSetVariableLogic.cs

示例12: CreateElementRuntime

        void CreateElementRuntime(string name)
        {
            var entitySave = new EntitySave {Name = name};

            ObjectFinder.Self.GlueProject.Entities.Add(entitySave);

            #region Create CustomVariables
            var xVariable = new CustomVariable
                                {
                                    Name = "X", 
                                    Type = "float", 
                                    DefaultValue = 3.0f
                                };
            entitySave.CustomVariables.Add(xVariable);

            var yVariable = new CustomVariable
                                {
                                    Name = "Y", 
                                    Type = "float", 
                                    DefaultValue = 4.0f
                                };
            entitySave.CustomVariables.Add(yVariable);


            var customVariable = new CustomVariable
                                {
                                    Name = "SomeNewVar",
                                    Type = "double",
                                    DefaultValue = 3.333
                                };
            entitySave.CustomVariables.Add(customVariable);

            var csvTypeVAriable = new CustomVariable
                                {
                                    Name = "CsvTypeVariable",
                                    Type = "CsvType.csv",
                                    DefaultValue = null

                                };
            entitySave.CustomVariables.Add(csvTypeVAriable);

            var csvTypeVariable2 = new CustomVariable
                                {
                                    Name = "EnemyInfoVariable",
                                    Type = "EnemyInfo.csv",
                                    DefaultValue = "Imp"

                                };
            entitySave.CustomVariables.Add(csvTypeVariable2);

            var scaleXVariable = new CustomVariable
            {
                Name = "ScaleX",
                Type = "float",
                DefaultValue = 10.0f
            };
            entitySave.CustomVariables.Add(scaleXVariable);


            #endregion

            #region Create the NamedObjectsSave

            NamedObjectSave nos = new NamedObjectSave();
            nos.SourceType = SourceType.FlatRedBallType;
            nos.SourceClassType = "Sprite";
            nos.InstanceName = "SpriteObject";
            nos.UpdateCustomProperties();
            nos.SetPropertyValue("ScaleX", 3.0f);
            entitySave.NamedObjects.Add(nos);


            #endregion

            #region Create the ReferencedFileSaves

            ReferencedFileSave rfs = new ReferencedFileSave();
            rfs.Name = "Content/Entities/ReferencedFileSaveTestsBaseEntity/SceneFile.scnx";
            entitySave.ReferencedFiles.Add(rfs);

            rfs = new ReferencedFileSave();
            rfs.Name = "Content/EnemyInfo.csv";
            rfs.CreatesDictionary = true;

            entitySave.ReferencedFiles.Add(rfs);


            #endregion

            mElementRuntime = new ElementRuntime(entitySave, null, null, null, null)
                                  {
                                      X = (float) xVariable.DefaultValue, 
                                      Y = (float) yVariable.DefaultValue
                                  };


            #region Create the uncategorized states

            var leftX = new InstructionSave
            {
//.........这里部分代码省略.........
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:ExpressionParserTests.cs

示例13: CreateParentElementRuntime

        void CreateParentElementRuntime()
        {
            EntitySave containerEntity = new EntitySave();
            ObjectFinder.Self.GlueProject.Entities.Add(containerEntity);

            containerEntity.Name = "ContainerEntity";

            NamedObjectSave first = new NamedObjectSave();
            first.SourceType = SourceType.Entity;
            first.SourceClassType = "ExpressionParserTestEntity";
            first.InstanceName = "FirstObject";
            first.UpdateCustomProperties();
            first.SetPropertyValue("CsvTypeVariable", "CsvValue1");

            containerEntity.NamedObjects.Add(first);

            mParentElementRuntime = new ElementRuntime(
                containerEntity, null, null, null, null);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:19,代码来源:ExpressionParserTests.cs

示例14: AdjustSprite

        private void AdjustSprite(NamedObjectSave nos, IElement element)
        {
            if (Is2D(element))
            {
                nos.SetPropertyValue("TextureScale", 1.0f);


            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:9,代码来源:NewNamedObjectPlugin.cs

示例15: AdjustAxisAlignedRectangle

 private void AdjustAxisAlignedRectangle(NamedObjectSave nos, IElement element)
 {
     if (Is2D(element))
     {
         nos.SetPropertyValue("Width", 32f);
         nos.SetPropertyValue("Height", 32f);
     }
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:8,代码来源:NewNamedObjectPlugin.cs


注:本文中的FlatRedBall.Glue.SaveClasses.NamedObjectSave.SetPropertyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。