public override void Kill() { var e = new PreEventArgs(); EntityLiving.PreKill?.Invoke(this, e); if (e.IsCanceled) { return; } IsDying = true; DyingTick = DyingMax; if (IsDying) { SetKilledAnime(); } if (IsCrushed) { SetCrushedAnime(); } if (!IsCrushed && !IsFall) { DESound.Play(KilledSound); } Velocity = Vector.Zero; }
public static IEnumerator Execute() { if ((CurrentScript == null) && (EventScriptQueue.Count > 0)) { CurrentScript = EventScriptQueue.Dequeue(); } if ((CurrentScript != null) && (CurrentScript.Current != null)) { var args = CurrentScript.Current.Args; switch (CurrentScript.Current.Name) { case "bgm": if (args == null) { Core.I.BgmPlay(); } else { Core.I.BgmPlay(args[0]); } break; case "bgmstop": int time; if (args == null) { Core.I.BgmStop(); } else if (int.TryParse(args[0], out time)) { Core.I.BgmStop(time); } break; case "se": int id; if (int.TryParse(args[0], out id)) { DESound.Play(id); } else { Sounds snd; if (Enum.TryParse(args[0], out snd)) { DESound.Play(snd); } } break; case "mesbox": BalloonIsShowing = true; goto case "messtart"; case "messtart": if (args == null) { MesPos = UpDown.Down; } else { switch (args[0]) { case "up": MesPos = UpDown.Up; break; case "down": MesPos = UpDown.Down; break; } } MessageIsShowing = true; break; case "mes": var mes = args[0]; var tick = 2; if (args.Length >= 2) { tick = int.Parse(args[1]); } // DFKeyboard.Z = false; // DFKeyboard.Z.IsKeyDown = false; foreach (var c in mes) { MesBuffer += c; DESound.Play(Sounds.Speaking); for (var i = 0; i < tick / (DFKeyboard.ShiftLeft ? 2 : 1); i++) { yield return(null); } } IsWaitingResponse = true; while (!DFKeyboard.Z.IsKeyDown) { yield return(null); } DESound.Play(Sounds.Selected); yield return(null); IsWaitingResponse = false; MesBuffer = ""; break; case "mescont": mes = args[0]; tick = 1; if (args.Length >= 2) { tick = int.Parse(args[1]); } foreach (var c in mes) { MesBuffer += c; DESound.Play(Sounds.Speaking); for (var i = 0; i < tick / (DFKeyboard.ShiftLeft ? 2 : 1); i++) { yield return(null); } } break; case "mesnod": IsWaitingResponse = true; while (!DFKeyboard.Z.IsKeyDown) { yield return(null); } // DFKeyboard.Z.IsKeyDown = false; yield return(null); DESound.Play(Sounds.Selected); IsWaitingResponse = false; MesBuffer = ""; break; case "mesend": MessageIsShowing = false; BalloonIsShowing = false; break; case "enstop": Core.I.IsFreezing = true; break; case "enstart": Core.I.IsFreezing = false; break; case "wait": for (var i = 0; i < int.Parse(args[0]); i++) { yield return(null); } break; case "bgmvol": var ch = int.Parse(args[0]); var val = byte.Parse(args[1]); if (val > 127) { val = 127; } if (ch < 0) { ch = 0; } if (ch > 15) { ch = 15; } // todo // Seq.Sm.Channels[ch].Volume = val; break; case "mpt": if (Core.I.CurrentMap is MapData map) { int.TryParse(args[0], out var x); int.TryParse(args[1], out var y); var z = args[2]; if ((z != "表") && (z != "裏")) { break; } if (x < 0) { x = 0; } if (x > map.Size.X - 1) { x = map.Size.X - 1; } if (y < 0) { y = 0; } if (y > map.Size.Y - 1) { y = map.Size.Y - 1; } byte.TryParse(args[3], out var chip); map.Chips[x, y, z == "表" ? 0 : 1] = chip; } break; case "teleport": case "tp": var e = new PreEventArgs(); PreTeleport?.Invoke(e); if (e.IsCanceled) { break; } int level, area; Core.I.IsGoal = false; Core.I.Middle = VectorInt.Zero; switch (args.Length) { case 1: int.TryParse(args[0], out level); Core.I.LoadLevel(level); break; case 2: int.TryParse(args[0], out level); int.TryParse(args[1], out area); Core.I.LoadLevel(level, area); break; } PostTeleport?.Invoke(new EventArgs()); break; } if (CurrentScript.IsEndOfScript) { Core.I.IsFreezing = false; MessageIsShowing = false; BalloonIsShowing = false; CurrentScript = null; } else { CurrentScript.ProgramCounter++; } } }
/// <summary> /// この EntityPlayer を殺害します。 /// </summary> public override void Kill() { if (IsDying) { return; } if (IsFall) { base.Kill(); // イベントで抑制されている可能性があるので確認する if (IsDying) { Velocity = Vector.Zero; Life = 0; DESound.Play(Sounds.PlayerMiss); } return; } if (Core.I.Time == 0) { base.Kill(); if (IsDying) { SetGraphic(5); } return; } if (GodTime > 0) { return; } var e = new PreEventArgs(); PreDamage?.Invoke(this, e); if (!e.IsCanceled) { DESound.Play(Sounds.PowerDown); var e2 = new PlayerGodEventArgs(240, false); PreGod?.Invoke(this, e2); if (!e2.IsCanceled) { GodTime = e2.Time; } Life--; if (Form != PlayerForm.Big) { Form = PlayerForm.Big; } Velocity = Vector.Zero; } if (Life < 1) { SetGraphic(5); base.Kill(); } }
public void InputControl() { if (DFKeyboard.Left) { var e = new PreEventArgs(); PreMove?.Invoke(this, e); if (!e.IsCanceled) { Direction = Direction.Left; Velocity.X -= _spdAddition; if (Velocity.X < -_spdlimit) { Velocity.X = -_spdlimit; } } } else if (DFKeyboard.Right) { var e = new PreEventArgs(); PreMove?.Invoke(this, e); if (!e.IsCanceled) { Direction = Direction.Right; Velocity.X += _spdAddition; if (Velocity.X > _spdlimit) { Velocity.X = _spdlimit; } } } else { Velocity.X *= _spddivition; if ((Velocity.X < 0.1f) && (Velocity.X > -0.1f)) { Velocity.X = 0; } } if (DFKeyboard.Z.IsKeyDown) { if (!IsOnLand && DFKeyboard.Left && (CollisionLeft() == ColliderType.Land)) { Velocity.X = 3f; Velocity.Y = -4f; DESound.Play(Sounds.Destroy); } else if (!IsOnLand && DFKeyboard.Right && (CollisionRight() == ColliderType.Land)) { Velocity.X = -3f; Velocity.Y = -4f; DESound.Play(Sounds.Destroy); } else { if (IsUnderWater) { DESound.Play(Sounds.Swim); Velocity.Y = -2f; IsJumping = false; } else if (IsOnLand || (_flowtimer < 10)) { var e = new PreEventArgs(); PreJump?.Invoke(this, e); if (!e.IsCanceled) { if (!IsJumping) { DESound.Play(Sounds.BigJump); } Velocity.Y = -3.6f - Math.Abs(Velocity.X) / 6.5f; IsJumping = true; Move(); } } } } if (IsOnLand) { _flowtimer = 0; } else { _flowtimer++; } if (!DFKeyboard.Z && IsJumping) { Velocity.Y += 0.1f; } if (DFKeyboard.ShiftLeft) { _spdAddition = 0.4f; _spddivition = 0.9f; _spdlimit = 2.7f; if (!_lshifted) { switch (Form) { case PlayerForm.Fire: DESound.Play(Sounds.ShootFire); Parent.Add( new EntityFireWeapon(Location, Mpts, Map, Parent).SetEntityData( DynamicJson.Parse(@"{""SpeedX"": " + (Direction == Direction.Right ? EntityFireWeapon.SpeedX : -EntityFireWeapon.SpeedX) + "}"))); break; case PlayerForm.Ice: DESound.Play(Sounds.ShootFire); Parent.Add( new EntityIceWeapon(Location, Mpts, Map, Parent).SetEntityData( DynamicJson.Parse(@"{""SpeedX"": " + (Direction == Direction.Right ? EntityIceWeapon.SpeedX : -EntityIceWeapon.SpeedX) + "}"))); break; case PlayerForm.Magic: DESound.Play(Sounds.ShootFire); Parent.Add(new EntityMagicWeapon(Location, Mpts, Map, Parent)); break; } } foreach (EntityLiving entity in Parent.FindEntitiesByType <EntityLiving>()) { var e = entity; if (e.IsDying) { continue; } if ((GodTime > 0) && AteGodItem && ((e.MyGroup == EntityGroup.Enemy) || (e.MyGroup == EntityGroup.MonsterWeapon)) && new RectangleF(e.Location.X, e.Location.Y, e.Size.Width, e.Size.Height).CheckCollision(new RectangleF(Location.X, Location.Y, Size.Width, Size.Height))) { e.Kill(); } } foreach (EntityTurcosShell e in Parent.FindEntitiesByType <EntityTurcosShell>()) { if (e.IsRunning) { if (new RectangleF(Location.ToPoint(), Size).CheckCollision(new RectangleF(e.Location.ToPoint(), e.Size))) { e.Owner = this; } } } _lshifted = true; } else { _lshifted = false; _spdAddition = 0.2f; _spddivition = 0.9f; _spdlimit = 1.4f; } }