예제 #1
0
        public void RegistNewSetter(SakuraCore.SPropertyData property)
        {
            ISPropertyInterface newset;

            switch (property.PropType)
            {
            case "bool":
            {
                newset = new BoolSwitch() as ISPropertyInterface; break;
            }

            case "float":
            {
                newset = new FloatSet() as ISPropertyInterface; break;
            }

            case "const SVector&":
            case "SVector":
            case "structSakuraMath::SVector":
            {
                newset = new SVectorSet() as ISPropertyInterface; break;
            }

            case "const std::string&":
            case "std::string":
            case "string":
            case "std:string":
            {
                newset = new StringSet() as ISPropertyInterface; break;
            }

            default:
            {
                // Containers
                if (SakuraCore.PropIsContainer(property))
                {
                    RegistContainer(property);
                    return;
                }
                else
                {
                    //
                    newset = RegistSubMember(property);
                    break;
                }
            }
            }
            newset.Initialize(property);
            PropertySetters.Add(newset);
            DetailsDock.Children.Add(newset as UserControl);
            (newset as UserControl).SetValue(DockPanel.DockProperty, Dock.Top);
        }
예제 #2
0
        public void updateProperties(GameTime gameTime, IDictionary <string, object> properties, double duration, ETransition transition)
        {
            double startTime = gameTime.TotalGameTime.TotalSeconds;
            double endTime   = startTime + duration;

            foreach (KeyValuePair <string, object> item in properties)
            {
                string name = item.Key;

                IProperty property = null;

                System.Reflection.PropertyInfo proInfo = obj.GetType().GetProperty(name);

                if (proInfo != null)
                {
                    property = new PropertyProperty()
                    {
                        property = proInfo
                    };
                }


                if (property == null)
                {
                    System.Reflection.FieldInfo fieldInfo = obj.GetType().GetField(name);

                    if (fieldInfo != null)
                    {
                        property = new FieldProperty()
                        {
                            field = fieldInfo
                        };
                    }
                }

                if (property == null)
                {
                    continue;
                }

                Type           proType   = property.getType();
                IChangeSet     changeSet = null;
                TransitionCall transCall = EaseUtils.easeLinear;


                switch (transition)
                {
                case ETransition.EaseInElastic:
                    transCall = EaseUtils.easeInElastic;
                    break;

                case ETransition.EaseOutElastic:
                    transCall = EaseUtils.easeOutElastic;
                    break;

                case ETransition.EaseInOutElastic:
                    transCall = EaseUtils.easeInOutElastic;
                    break;

                case ETransition.EaseInCubic:
                    transCall = EaseUtils.easeInCubic;
                    break;

                case ETransition.EaseOutCubic:
                    transCall = EaseUtils.easeOutCubic;
                    break;

                case ETransition.Linear:
                    transCall = EaseUtils.easeLinear;
                    break;
                }

                if (proType == typeof(float))
                {
                    float beginValue  = (float)(property.getValue(obj, null));
                    float gotoValue   = float.Parse(item.Value.ToString());
                    float changeValue = gotoValue - beginValue;

                    FloatSet floatSet = new FloatSet(transCall)
                    {
                        name        = name,
                        beginValue  = beginValue,
                        changeValue = changeValue,
                        startTime   = startTime,
                        endTime     = endTime,
                        duration    = duration,
                        property    = property,
                    };
                    changeSet = floatSet;
                }
                else if (proType == typeof(int))
                {
                    int beginValue  = (int)(property.getValue(obj, null));
                    int gotoValue   = int.Parse(item.Value.ToString());
                    int changeValue = gotoValue - beginValue;

                    changeSet = new IntSet(transCall)
                    {
                        name        = name,
                        beginValue  = beginValue,
                        changeValue = changeValue,
                        startTime   = startTime,
                        endTime     = endTime,
                        duration    = duration,
                        property    = property,
                    };
                }

                if (changeSet != null)
                {
                    if (!_names.Contains(name))
                    {
                        _names.Add(name);
                    }

                    _changeSets[name] = changeSet;
                }
            }
        }