/// <summary> /// オブジェクトがレイヤーに登録されたときに実行されるイベントを追加する。 /// </summary> /// <exception cref="ArgumentNullException"></exception> public static void AddOnAddedEvent(this asd.Object2D obj, Action action) { if (action == null) { throw new ArgumentNullException("action"); } obj.GetObject2DComponent().OnAddedEvent += _ => action(); }
protected override void OnUpdating() { if(Time % 2 == 0) { var temp = obj; obj = new asd.TextureObject2D(); layer.AddObject(obj); obj.AddComponent(new VanishingComponent(temp, 3), "v"); } }
protected override void OnStart() { var scene = new asd.Scene(); layer = new asd.Layer2D(); obj = new asd.TextureObject2D(); asd.Engine.ChangeScene(scene); scene.AddLayer(layer); layer.AddObject(obj); }
protected override void OnUpdating() { if (Time % 2 == 0) { var temp = obj; obj = new asd.TextureObject2D(); layer.AddObject(obj); obj.AddComponent(new VanishingComponent(temp, 3), "v"); } }
private static Object2DComponent <asd.Object2D> GetObject2DComponent(this asd.Object2D obj) { var component = (Object2DComponent <asd.Object2D>)obj.GetComponent(ComponentName); if (component == null) { component = new Object2DComponent <asd.Object2D>(ComponentName); component.Attach(obj); } return(component); }
/// <summary> /// コルーチンを管理するクラスを取得する。 /// </summary> public static CoroutineManager CoroutineManager(this asd.Object2D obj) { var component = (CoroutineComponent)obj.GetComponent(CoroutineComponentName); if (component == null) { component = new CoroutineComponent(); obj.AddComponent(component, CoroutineComponentName); } return(component.Coroutine); }
/// <summary> /// Object2Dコレクションの変更 /// </summary> /// <param name="layer">Object2Dをもつレイヤー</param> /// <param name="object2D">Object2D</param> /// <param name="isAdd">加えたか</param> public static void ChangeObject2D(asd.Layer2D layer, asd.Object2D object2D, bool isAdd) { if (!Enable) { return; } if (isAction) { isAction = false; return; } UndoStack.Push(new Object2DChangedCommand(layer, object2D, isAdd)); RedoStack.Clear(); OnUpdateData(); }
//衝突判定 public void ColligeWith(asd.Object2D obj) { if (obj == null) { return; } if (obj is Wall) { if (ShapeOfCollige.GetIsCollidedWith(((Wall)obj).ShapeOfCollige)) { HP = 0; } } else if (obj is Cloud) { if (ShapeOfCollige.GetIsCollidedWith(((Cloud)obj).ShapeOfCollige)) { HP += -1; } } else if (obj is Rain) { if (ShapeOfCollige.GetIsCollidedWith(((Rain)obj).ShapeOfCollige)) { HP += -1; obj.Dispose(); } } else if (obj is Healer) { if (ShapeOfCollige.GetIsCollidedWith(((Healer)obj).ShapeOfCollige)) { HP += 10; obj.Dispose(); } } else if (obj is Wind) { if (ShapeOfCollige.GetIsCollidedWith(((Wind)obj).ShapeOfCollige)) { WindCount += 20; obj.Dispose(); } } }
public bool NeedToDelete(asd.Object2D o) { if (o is Obstacle_Fever) { if (o.IsAlive && isFever == false) { return(true); } } else if (o is StraightObstacles) { if (o.IsAlive && isFever == true) { return(true); } } return(false); }
protected override void OnUpdated() { //-----playerやられたらgameover if (!isSceneChangeing && !player.IsAlive) { asd.Engine.ChangeSceneWithTransition(new GameOverScene(score), new asd.TransitionFade(1.0f, 1.0f)); isSceneChangeing = true; } else { count++; // countを上げる。 //-----Fevermodeの時に仕様をごっそり変える。 if (isFever) { FeverMode(); } else { NormalMode(); } //-----スコア表示 score = asd.MathHelper.Clamp(score, 999999999, 0); scoreWindow.point.Text = score.ToString("D9"); // scoreWindow.point.Text = String.Format("{0:D9}",score); //---先輩にいろいろ書き方を教わったよ!--- // scoreWindow.point.Text = $"{score:D9}"; } foreach (var obj in layer.Objects) { if (NeedToDelete(obj)) { emptyObj = obj; } } if (emptyObj != null) { emptyObj.Dispose(); } }
public Object2DChangedCommand(asd.Layer2D layer, asd.Object2D object2D, bool isAdd) { Layer = layer; Object2D = object2D; IsAdd = isAdd; }
public VanishingComponent(asd.Object2D vanishedObject, int etime) { this.vanishedObject = vanishedObject; this.etime = etime; }