// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // /// <summary> /// <para>ファイルリストを取得する。</para> /// <para>ソート済み</para> /// <para>'_' で始まるファイルの除去済み</para> /// </summary> /// <returns>ファイルリスト</returns> public static IEnumerable <string> GetFiles() { IEnumerable <string> files; if (ReleaseMode) { files = File2ResInfo.Keys; } else { files = EnumerableTools.Join(new IEnumerable <string>[] { Directory.GetFiles(DDConsts.ResourceDir_01, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir_01)), Directory.GetFiles(DDConsts.ResourceDir_02, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir_02)), }); // '_' で始まるファイルの除去 // makeDDResourceFile は '_' で始まるファイルを含めない。 files = files.Where(file => Path.GetFileName(file)[0] != '_'); } // ソート // makeDDResourceFile はファイルリストを sortJLinesICase している。 // ここでソートする必要は無いが、戻り値に統一性を持たせるため(毎回ファイルの並びが違うということのないように)ソートしておく。 files = EnumerableTools.Sort(files, StringTools.CompIgnoreCase); return(files); }
protected override void Invoke_02(string command, params string[] arguments) { if (command == ScenarioWords.COMMAND_跳ねて登場) { this.Act.Add(EnumerableTools.Supplier(this.跳ねて登場())); } else { throw new DDError(); } }
public void MakeVideo(WaveData wave, WorkingDir wd, Action <Canvas2> addImage) { int frameNum = DoubleTools.ToInt((wave.Length * 1.0 / wave.WavHz) * AudioPicMP4Props.FPS); foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers) { videoImageMaker.FrameNum = frameNum; videoImageMaker.Wave = wave; videoImageMaker.WD = wd; // ---- videoImageMaker.GetImage = EnumerableTools.Supplier(videoImageMaker.GetImageSequence()); } for (int frame = 0; frame < frameNum; frame++) { Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H); foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers) { videoImageMaker.FrameImg = frameImg; videoImageMaker.Frame = frame; videoImageMaker.Rate = frame * 1.0 / (frameNum - 1); videoImageMaker.InvRate = 1.0 - videoImageMaker.Rate; { Canvas2 currFrameImg = videoImageMaker.GetImage(); if (currFrameImg != null) { PictureUtils.Paste(frameImg, currFrameImg); } } videoImageMaker.FrameImg = null; videoImageMaker.Frame = -1; videoImageMaker.Rate = -1.0; videoImageMaker.InvRate = -1.0; } addImage(frameImg); } foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers) { videoImageMaker.FrameNum = -1; videoImageMaker.Wave = null; videoImageMaker.WD = null; // ---- videoImageMaker.GetImage = null; } }
/// <summary> /// シリアライザ /// 現在の「固有の状態」を再現可能な文字列を返す。 /// </summary> /// <returns></returns> public string Serialize() { return(new AttachString().Untokenize(EnumerableTools.Join(new string[][] { new string[] { this.TypeName, this.InstanceName, this.X.ToString(), this.Y.ToString(), this.Z.ToString(), }, this.Serialize_02(), } ))); }
protected override void Invoke_02(string command, params string[] arguments) { if (command == ScenarioWords.COMMAND_フェードイン) { this.Act.Add(EnumerableTools.Supplier(this.フェードイン())); } else if (command == ScenarioWords.COMMAND_フェードアウト) { this.Act.Add(EnumerableTools.Supplier(this.フェードアウト())); // 削除前にアクションを追加する。 this.RemoveMe(); // 自分自身を削除する。 // memo: // this.Act 内で this.RemoveMe() するやり方は NG ! // プレイヤの読み進める速度によって、どのページで this.RemoveMe() されるか分からない。 // this.RemoveMe() する前にセーブ・ロードしてしまった場合 this.RemoveMe() は実行されず this はそのまま残る。 } else { throw new DDError(); } }
/// <summary> /// Sets the values of all properties of <paramref name="thisObject"/> to the value of the equal property of <paramref name="deserializedObject"/>. /// </summary> /// <remarks> /// This function does not create a deep copy of the property-values. It reassignes only the property-target-objects of <paramref name="thisObject"/>. /// If <paramref name="thisObject"/> is an <see cref="IEnumerable"/> then only the references of the items of the enumeration will be copied, no property-values. /// </remarks> internal void CopyContentOfObject(object thisObject, object deserializedObject) { bool thisIsNull = thisObject == null; bool deserializedObjectIsNull = deserializedObject == null; if (thisIsNull && deserializedObjectIsNull) { return; } if (thisIsNull && !deserializedObjectIsNull) { throw new NullReferenceException(); } if (!thisIsNull && deserializedObjectIsNull) { throw new NullReferenceException(); } if (!thisIsNull && !deserializedObjectIsNull) { Type type = thisObject.GetType(); if (EnumerableTools.TypeIsEnumerable(type)) { foreach (object item in deserializedObject as IEnumerable) { EnumerableTools.AddItemToEnumerable(thisObject, new object[] { item }); } } else { foreach (FieldInfo field in type.GetFields().Where((field) => this.SerializationConfiguration.FieldSelector(field))) { field.SetValue(thisObject, field.GetValue(deserializedObject)); } foreach (PropertyInfo property in type.GetProperties().Where((property) => this.SerializationConfiguration.PropertySelector(property))) { property.SetValue(thisObject, property.GetValue(deserializedObject)); } } } }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // /// <summary> /// <para>ファイルリストを取得する。</para> /// <para>ソート済み</para> /// <para>'_' で始まるファイルの除去済み</para> /// </summary> /// <returns>ファイルリスト</returns> public static IEnumerable <string> GetFiles() { IEnumerable <string> files; if (ReleaseMode) { files = File2ResInfo.Keys; } else { files = Directory.GetFiles(DDConsts.ResourceDir, "*", SearchOption.AllDirectories).Select(file => FileTools.ChangeRoot(file, DDConsts.ResourceDir)); } // '_' で始まるファイルの除去 // makeDDResourceFile はファイルリストを _index として保存するので、どちらの場合でも Where を行わなければならない。 files = files.Where(file => Path.GetFileName(file)[0] != '_'); // ソート // makeDDResourceFile はファイルリストを sortJLinesICase してる。 files = EnumerableTools.Sort(files, StringTools.CompIgnoreCase); return(files); }
public static void 中爆発(double x, double y) { DDGround.EL.Add(EnumerableTools.Supplier(中爆発Seq(x, y))); }
public override bool IsApplicable(Type typeOfObject1, Type typeOfObject2) { return(EnumerableTools.TypeIsTuple(typeOfObject1) && EnumerableTools.TypeIsTuple(typeOfObject2)); }
public override bool DefaultEquals(object item1, object item2) { bool result = this.EqualsTyped(EnumerableTools.ObjectToTuple <object, object>(item1), EnumerableTools.ObjectToTuple <object, object>(item2)); return(result); }
private string ToString(object @object, IDictionary <object, int> visitedObjects, int currentIndentationLevel) { if (@object == null) { return(this.GetIndentation(currentIndentationLevel) + "null"); } Type type = @object.GetType(); if (PrimitiveComparer.TypeIsTreatedAsPrimitive(type)) { return(this.GetIndentation(currentIndentationLevel) + $"(Type: {@object.GetType().Name}, Value: \"{@object.ToString().Replace("\"", "\\\"")}\")"); } if (visitedObjects.ContainsKey(@object)) { return(this.GetIndentation(currentIndentationLevel) + $"[Object {visitedObjects[@object]}]"); } try { int id = this.PropertyEqualsCalculator.GetHashCode(@object); visitedObjects.Add(@object, id); if (EnumerableTools.ObjectIsEnumerable(@object)) { IList <object> objectAsEnumerable = EnumerableTools.ObjectToEnumerable <object>(@object).ToList(); string result = this.GetIndentation(currentIndentationLevel) + "[" + Environment.NewLine; int count = objectAsEnumerable.Count; for (int i = 0; i < count; i++) { object current = objectAsEnumerable[i]; result += this.ToString(current, visitedObjects, currentIndentationLevel + 1); if (i < count - 1) { result = result + "," + Environment.NewLine; } } return(result + Environment.NewLine + this.GetIndentation(currentIndentationLevel) + "]"); } else { List <(string /*Propertyname*/, object)> propertyValues = new(); foreach (FieldInfo field in type.GetFields()) { if (this.FieldSelector(field)) { propertyValues.Add((field.Name, field.GetValue(@object))); } } foreach (PropertyInfo property in type.GetProperties()) { if (this.PropertySelector(property)) { propertyValues.Add((property.Name, property.GetValue(@object))); } } string result = this.GetIndentation(currentIndentationLevel) + $"{{ (ObjectId: {id}, Type: {type.FullName}) "; foreach ((string, object)entry in propertyValues) { result = result + Environment.NewLine + this.GetIndentation(currentIndentationLevel + 1) + entry.Item1 + ": " + Environment.NewLine + this.ToString(entry.Item2, visitedObjects, currentIndentationLevel + 1); } return(result + Environment.NewLine + this.GetIndentation(currentIndentationLevel) + "}"); } } catch { return($"[Error while executing {nameof(ToString)} for object of type {type.FullName}]"); } }
public void Loaded(Tools.D2Point pt) { this.EachFrameSequencer = EnumerableTools.Supplier(this.GetEachFrameSequencer()); }
public Func <bool> GetTask() { return(EnumerableTools.Supplier(this.GetTaskSequence())); }
public void Main01() { FileTools.Delete(W_DIR); FileTools.CreateDir(W_DIR); this.SpData = new SpectrumData(Path.Combine(R_DIR, "Spectrum.csv")); foreach (DDScene scene in DDSceneUtils.Create(20)) { DDCurtain.DrawCurtain(); this.MG_EachFrame(); } Func <bool> backLayer = () => true; Func <bool> foreLayer = EnumerableTools.Supplier(GetLayer01(Path.Combine(SS_DIR, "0006.png"))); double fowLv = 0.0; for (int frmcnt = 0; this.Frame < this.SpData.Rows.Length; frmcnt++) { { Func <bool> nextLayer = null; #if true // 本番用 switch (frmcnt) { case 15: nextLayer = EnumerableTools.Supplier(GetLayer02(Path.Combine(SS_DIR, "0003.png"), 1)); break; case 30: nextLayer = EnumerableTools.Supplier(GetLayer02(Path.Combine(SS_DIR, "0007.png"), -1)); break; case 45: nextLayer = EnumerableTools.Supplier(GetLayer02(Path.Combine(SS_DIR, "0008.png"), 1)); break; case 60: nextLayer = EnumerableTools.Supplier(GetLayer02(Path.Combine(SS_DIR, "0013.png"), -1)); break; case 75: nextLayer = EnumerableTools.Supplier(GetLayer02(Path.Combine(SS_DIR, "0017.png"), 1)); break; case 90: nextLayer = EnumerableTools.Supplier(GetLayer03(Path.Combine(SS_DIR, "0018.png"))); break; case 160: nextLayer = EnumerableTools.Supplier(GetLayer04(Path.Combine(SS_DIR, "0019.png"))); break; } #else // test test test switch (frmcnt) { case 10: nextLayer = EnumerableTools.Supplier(GetLayer04(Path.Combine(SS_DIR, "0019.png"))); break; } #endif if (nextLayer != null) { backLayer = foreLayer; foreLayer = nextLayer; } } backLayer(); foreLayer(); if (this.SpData.Rows.Length - 40 < this.Frame) { DDUtils.Approach(ref fowLv, -1.0, 0.9); DDCurtain.DrawCurtain(fowLv); } this.MG_EachFrame(); } }
public MultiScenario(IEnumerable <IScenario> scenarios) { this.Sequencer = EnumerableTools.Supplier(this.GetSeqnencer(scenarios)); }