Beispiel #1
0
        /// <summary>
        /// クローンメソッド
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var ess = new EffectStateStructure(false);

            Array.Copy(data, ess.data, ess.data.Length);
            ess.BlendMode = BlendMode;
            return(ess);
        }
Beispiel #2
0
        private static BaseEffect ReadXMLEffect(XmlReader reader, ReadResourceCallBack callback, string dir)
        {
            var effect = new BaseEffect();
            EffectStateStructure lastess = null;
            var set = new EffectStateRatioSet();

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "Effect":
                        effect.Filename = Path.Combine(dir, reader.GetAttribute("FilePath"));
                        callback(effect.Filename);
                        break;

                    case "State":
                        var       ess = new EffectStateStructure();
                        BlendMode blendMode;
                        if (!Enum.TryParse <BlendMode>(reader.GetAttribute("Blend"), out blendMode))
                        {
                            blendMode = BlendMode.None;
                        }
                        ess.BlendMode = blendMode;
                        ess.X         = float.Parse(reader.GetAttribute("X"), CultureInfo.InvariantCulture);
                        ess.Y         = float.Parse(reader.GetAttribute("Y"), CultureInfo.InvariantCulture);
                        ess.Alpha     = float.Parse(reader.GetAttribute("Alpha"), CultureInfo.InvariantCulture);
                        ess.Rotation  = float.Parse(reader.GetAttribute("Rotation"), CultureInfo.InvariantCulture);
                        ess.ScaleX    = float.Parse(reader.GetAttribute("ScaleX"), CultureInfo.InvariantCulture);
                        ess.ScaleY    = float.Parse(reader.GetAttribute("ScaleY"), CultureInfo.InvariantCulture);
                        if (lastess != null)
                        {
                            set.StartState = lastess;
                            set.EndState   = ess;
                            effect.Sets.Add(set.StartFrame, set);
                            set = new EffectStateRatioSet();
                        }
                        lastess = ess;
                        break;

                    case "RatioMakers":
                        set.StartFrame = int.Parse(reader.GetAttribute("StartFrame"), CultureInfo.InvariantCulture);
                        set.EndFrame   = int.Parse(reader.GetAttribute("EndFrame"), CultureInfo.InvariantCulture);
                        ReadXMLRatioMakers(reader.ReadSubtree(), set);
                        break;

                    case "BezierPositions":
                        ReadXMLBezierPositions(reader.ReadSubtree(), set);
                        break;
                    }
                }
            }
            effect.CheckFrameLength();
            reader.Close();
            return(effect);
        }
Beispiel #3
0
        /// <summary>
        /// 途中の状態を得る
        /// </summary>
        /// <param name="ratio">比</param>
        /// <param name="state">状態</param>
        /// <returns></returns>
        public EffectStateStructure GetMixedState(float ratio, EffectStateStructure state)
        {
            var ret = new EffectStateStructure(false)
            {
                BlendMode = BlendMode
            };

            foreach (RatioType type in Utility.RatioTypeArray)
            {
                ret[type] = GetDivision(data[(int)type], state[type], ratio);
            }
            return(ret);
        }
Beispiel #4
0
 private void WriteState(EffectStateStructure state, XmlWriter writer)
 {
     writer.WriteStartElement("State");
     foreach (RatioType type in Utility.RatioTypeArray)
     {
         writer.WriteStartAttribute(type.ToString());
         writer.WriteString(state[type].ToString(CultureInfo.InvariantCulture));
         writer.WriteEndAttribute();
     }
     writer.WriteStartAttribute("Blend");
     writer.WriteString(state.BlendMode.ToString());
     writer.WriteEndAttribute();
     writer.WriteEndElement();
 }
Beispiel #5
0
 /// <summary>
 /// 更新する
 /// </summary>
 /// <param name="parentframe">親のフレーム</param>
 /// <param name="parentfps">親のFPS</param>
 /// <param name="parentstate">親の状態</param>
 public void Update(float parentframe, float parentfps, EffectStateStructure parentstate)
 {
     if (!InnerUpdate(parentframe, parentstate))
     {
         return;
     }
     foreach (IEffect effect in Effects)
     {
         if (effect.Effects.Count == 0)
         {
             effect.Update(currentframe * effect.FPS / parentfps, CurrentState);
         }
         else
         {
             effect.Update(currentframe * effect.FPS / parentfps, FPS, CurrentState);
         }
     }
 }
Beispiel #6
0
        private bool InnerUpdate(float parentframe, EffectStateStructure parentState)
        {
            currentframe = parentframe - StartFrame;
            if (currentframe > FrameLength || currentframe < 0)
            {
                return(false);
            }
            EffectStateRatioSet set = Sets.Values[BinaryFinder.FindNearest(Sets.Keys, ref parentframe)];

            CurrentState = set.StartState.GetMixedState(set.GetRatios(parentframe), set.EndState);
            if (set.IsBezierPosition)
            {
                var bratio = set.GetRatio(RatioType.BezierPosition, parentframe);
                set.BAnalyzer.GetPoint(BezierCaliculator.BezierAnalyzer.MaxRatio * (1 - bratio), out PointF outp, out PointF outdir);
                CurrentState.X = outp.X;
                CurrentState.Y = outp.Y;
            }
            CurrentState.Compose(parentState);
            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// クローンメソッド
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var ret = new EffectManager
            {
                FPS          = FPS,
                StartFrame   = StartFrame,
                currentFrame = currentFrame,
                FrameLength  = FrameLength
            };

            if (CurrentState != null)
            {
                ret.CurrentState = (EffectStateStructure)CurrentState.Clone();
            }
            ret.state = state;
            foreach (IEffect effect in Effects)
            {
                ret.Effects.Add((IEffect)effect.Clone());
            }
            EffectStateStructure effectState = null;

            foreach (KeyValuePair <int, EffectStateRatioSet> set in Sets)
            {
                if (!ret.Sets.ContainsKey(set.Key))
                {
                    var newset = (EffectStateRatioSet)set.Value.CloneExceptState();
                    if (effectState != null)
                    {
                        newset.StartState = effectState;
                    }
                    else
                    {
                        newset.StartState = (EffectStateStructure)set.Value.StartState.Clone();
                    }
                    newset.EndState = (EffectStateStructure)set.Value.EndState.Clone();
                    effectState     = newset.EndState;
                    ret.Sets.Add(set.Key, newset);
                }
            }
            return(ret);
        }
Beispiel #8
0
        /// <summary>
        /// 合成します。
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public void Compose(EffectStateStructure parent)
        {
            var matrix = GetMatrix();

            if (parent.ComposedMatrices != null)
            {
                ComposedMatrices = new Matrix[parent.ComposedMatrices.Length + 1];
                Array.Copy(parent.ComposedMatrices, ComposedMatrices, parent.ComposedMatrices.Length);
            }
            else
            {
                ComposedMatrices = new Matrix[1];
            }
            ComposedMatrices[ComposedMatrices.Length - 1] = matrix;
            ComposedAlpha     = Alpha = Alpha * parent.Alpha;
            ComposedBlendMode = parent.BlendMode;
            if (BlendMode != BlendMode.None)
            {
                ComposedBlendMode = BlendMode;
            }
        }
Beispiel #9
0
        /// <summary>
        /// クローンメソッド
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var ret = new BaseEffect
            {
                FPS          = FPS,
                StartFrame   = StartFrame,
                currentframe = currentframe,
                FrameLength  = FrameLength,
                Filename     = Filename
            };

            if (CurrentState != null)
            {
                ret.CurrentState = (EffectStateStructure)CurrentState.Clone();
            }
            foreach (IEffect effect in Effects)
            {
                ret.Effects.Add((IEffect)effect.Clone());
            }
            EffectStateStructure state = null;

            foreach (KeyValuePair <int, EffectStateRatioSet> set in Sets)
            {
                var newset = (EffectStateRatioSet)set.Value.CloneExceptState();
                if (state != null)
                {
                    newset.StartState = state;
                }
                else
                {
                    newset.StartState = (EffectStateStructure)set.Value.StartState.Clone();
                }
                newset.EndState = (EffectStateStructure)set.Value.EndState.Clone();
                state           = newset.EndState;
                ret.Sets.Add(set.Key, newset);
            }
            return(ret);
        }
Beispiel #10
0
 /// <summary>
 /// 更新する
 /// </summary>
 /// <param name="parentFrame">親のフレーム</param>
 /// <param name="parentState">親の状態</param>
 public void Update(float parentFrame, EffectStateStructure parentState)
 {
     currentFrame = parentFrame;
     InnerUpdate();
 }