public void Draw() { if (this.DeadScene.IsFlaming()) { DDScene scene = this.DeadScene.GetScene(); DDDraw.SetAlpha(0.5); DDDraw.DrawBegin(Ground.I.Picture.Player, this.X, this.Y); DDDraw.DrawRotate(scene.Rate * 5.0); DDDraw.DrawZoom(1.0 + scene.Rate * 5.0); DDDraw.DrawEnd(); DDDraw.Reset(); return; } if (this.BornScene.IsFlaming()) { if (this.BornScene.IsJustFired()) { this.Born_X = -50.0; this.Born_Y = DDConsts.Screen_H / 2.0; } DDScene scene = this.BornScene.GetScene(); DDUtils.Approach(ref this.Born_X, this.X, 0.9 - 0.3 * scene.Rate); DDUtils.Approach(ref this.Born_Y, this.Y, 0.9 - 0.3 * scene.Rate); DDDraw.SetAlpha(0.5); DDDraw.DrawCenter(Ground.I.Picture.Player, this.Born_X, this.Born_Y); DDDraw.Reset(); return; } if (this.MutekiScene.IsFlaming()) { DDDraw.SetAlpha(0.5); DDDraw.DrawCenter(Ground.I.Picture.Player, this.X, this.Y); DDDraw.Reset(); return; } DDDraw.DrawCenter(Ground.I.Picture.Player, this.X, this.Y); }
public void Perform() { this.ReloadEnemies(); // デフォルトのスタート位置 this.Player.X = this.Map.W * MapTile.WH / 2.0; this.Player.Y = this.Map.H * MapTile.WH / 2.0; foreach (EnemyBox enemy in this.Enemies.Iterate()) // スタート位置 { StartPoint sp = enemy.Value as StartPoint; if (sp != null) { if (sp.Index == this.Status.StartPointIndex) { this.Player.X = sp.X; this.Player.Y = sp.Y; break; } } } this.Player.HP = this.Status.CurrHP; this.Player.FacingLeft = this.Status.FacingLeft; this.WallPicture = WallPictureManager.GetPicutre(this.Map.GetProperty("WALL", "09311.jpg")); { double w = DDConsts.Screen_W + (this.Map.W * MapTile.WH - DDConsts.Screen_W) * WallPicture_SlideRate; double h = DDConsts.Screen_H + (this.Map.H * MapTile.WH - DDConsts.Screen_H) * WallPicture_SlideRate; double zw = w / this.WallPicture.Get_W(); double zh = h / this.WallPicture.Get_H(); double z = Math.Max(zw, zh); z *= 1.01; // margin this.WallPicture_Zoom = z; } DDGround.Camera.X = this.Player.X - DDConsts.Screen_W / 2.0; DDGround.Camera.Y = this.Player.Y - DDConsts.Screen_H / 2.0; DDCurtain.SetCurtain(10); DDEngine.FreezeInput(); // TODO music for (; ; this.Frame++) { { double targCamX = this.Player.X - DDConsts.Screen_W / 2 + (this.CamSlideX * DDConsts.Screen_W / 3); double targCamY = this.Player.Y - DDConsts.Screen_H / 2 + (this.CamSlideY * DDConsts.Screen_H / 3); DDUtils.ToRange(ref targCamX, 0.0, this.Map.W * MapTile.WH - DDConsts.Screen_W); DDUtils.ToRange(ref targCamY, 0.0, this.Map.H * MapTile.WH - DDConsts.Screen_H); DDUtils.Approach(ref DDGround.Camera.X, targCamX, 0.8); DDUtils.Approach(ref DDGround.Camera.Y, targCamY, 0.8); } DDUtils.ToRange(ref DDGround.Camera.X, 0.0, this.Map.W * MapTile.WH - DDConsts.Screen_W); DDUtils.ToRange(ref DDGround.Camera.Y, 0.0, this.Map.H * MapTile.WH - DDConsts.Screen_H); DDGround.ICamera.X = DoubleTools.ToInt(DDGround.Camera.X); DDGround.ICamera.Y = DoubleTools.ToInt(DDGround.Camera.Y); if (DDConfig.LOG_ENABLED && DDKey.GetInput(DX.KEY_INPUT_E) == 1) { this.EditMode(); this.ReloadEnemies(); this.Frame = 0; } // プレイヤー入力 { bool deadOrDamage = this.Player.DeadScene.IsFlaming() || this.Player.DamageScene.IsFlaming(); bool move = false; bool slow = false; bool camSlide = false; int jumpPress = DDInput.A.GetInput(); bool jump = false; bool shagami = false; bool attack = false; if (!deadOrDamage && 1 <= DDInput.DIR_2.GetInput()) { shagami = true; } if (!deadOrDamage && 1 <= DDInput.DIR_4.GetInput()) { this.Player.FacingLeft = true; move = true; } if (!deadOrDamage && 1 <= DDInput.DIR_6.GetInput()) { this.Player.FacingLeft = false; move = true; } if (1 <= DDInput.L.GetInput()) { move = false; camSlide = true; } if (!deadOrDamage && 1 <= DDInput.R.GetInput()) { slow = true; } if (!deadOrDamage && 1 <= jumpPress) { jump = true; } if (!deadOrDamage && 1 <= DDInput.B.GetInput()) { attack = true; } if (DDKey.GetInput(DX.KEY_INPUT_Q) == 1) { break; } if (move) { this.Player.MoveFrame++; shagami = false; } else { this.Player.MoveFrame = 0; } this.Player.MoveSlow = move && slow; if (1 <= this.Player.JumpFrame) { if (jump && this.Player.JumpFrame < 22) { this.Player.JumpFrame++; } else { this.Player.JumpFrame = 0; } } else { //if (jump && jumpPress < 5 && this.Player.TouchGround) if (jump && jumpPress < 5 && this.Player.AirborneFrame < 5) { this.Player.JumpFrame = 1; } } if (camSlide) { if (DDInput.DIR_4.IsPound()) { this.CamSlideCount++; this.CamSlideX--; } if (DDInput.DIR_6.IsPound()) { this.CamSlideCount++; this.CamSlideX++; } if (DDInput.DIR_8.IsPound()) { this.CamSlideCount++; this.CamSlideY--; } if (DDInput.DIR_2.IsPound()) { this.CamSlideCount++; this.CamSlideY++; } DDUtils.ToRange(ref this.CamSlideX, -1, 1); DDUtils.ToRange(ref this.CamSlideY, -1, 1); } else { if (this.CamSlideMode && this.CamSlideCount == 0) { this.CamSlideX = 0; this.CamSlideY = 0; } this.CamSlideCount = 0; } this.CamSlideMode = camSlide; if (this.Player.TouchGround == false) { shagami = false; } if (shagami) { this.Player.ShagamiFrame++; } else { this.Player.ShagamiFrame = 0; } if (attack) { this.Player.AttackFrame++; } else { this.Player.AttackFrame = 0; } } { DDScene scene = this.Player.DeadScene.GetScene(); if (scene.Numer != -1) { if (scene.Numer < 30) { double rate = scene.Numer / 30.0; this.Player.X -= 10.0 * (1.0 - rate) * (this.Player.FacingLeft ? -1 : 1); } if (scene.Remaining == 0) { break; } } } { DDScene scene = this.Player.DamageScene.GetScene(); if (scene.Numer != -1) { this.Player.X -= (9.0 - 6.0 * scene.Rate) * (this.Player.FacingLeft ? -1 : 1); if (scene.Remaining == 0) { this.Player.MutekiScene.FireDelay(); } } } { DDScene scene = this.Player.MutekiScene.GetScene(); if (scene.Numer != -1) { // noop } } // プレイヤー移動 { if (1 <= this.Player.MoveFrame) { double speed = 0.0; if (this.Player.MoveSlow) { speed = this.Player.MoveFrame * 0.2; DDUtils.Minim(ref speed, 2.0); } else { speed = 6.0; } speed *= this.Player.FacingLeft ? -1 : 1; this.Player.X += speed; } else { this.Player.X = (double)DoubleTools.ToInt(this.Player.X); } this.Player.YSpeed += 1.0; // += 重力加速度 if (1 <= this.Player.JumpFrame) { this.Player.YSpeed = -8.0; } DDUtils.Minim(ref this.Player.YSpeed, 8.0); // 落下する最高速度 this.Player.Y += this.Player.YSpeed; } if (this.Player.X < 0.0) // ? マップの左側に出た。 { this.ExitDir = 4; break; } if (this.Map.W * MapTile.WH < this.Player.X) // ? マップの右側に出た。 { this.ExitDir = 6; break; } if (this.Player.Y < 0.0) // ? マップの上側に出た。 { this.ExitDir = 8; break; } if (this.Map.H * MapTile.WH < this.Player.Y) // ? マップの下側に出た。 { this.ExitDir = 2; break; } // プレイヤー位置矯正 { bool touchSide_L = this.Map.GetCell(Map.ToTablePoint(this.Player.X - 10.0, this.Player.Y - MapTile.WH / 2)).Wall || this.Map.GetCell(Map.ToTablePoint(this.Player.X - 10.0, this.Player.Y)).Wall || this.Map.GetCell(Map.ToTablePoint(this.Player.X - 10.0, this.Player.Y + MapTile.WH / 2)).Wall; bool touchSide_R = this.Map.GetCell(Map.ToTablePoint(this.Player.X + 10.0, this.Player.Y - MapTile.WH / 2)).Wall || this.Map.GetCell(Map.ToTablePoint(this.Player.X + 10.0, this.Player.Y)).Wall || this.Map.GetCell(Map.ToTablePoint(this.Player.X + 10.0, this.Player.Y + MapTile.WH / 2)).Wall; if (touchSide_L && touchSide_R) { // noop } else if (touchSide_L) { this.Player.X = (double)DoubleTools.ToInt(this.Player.X / MapTile.WH) * MapTile.WH + 10.0; } else if (touchSide_R) { this.Player.X = (double)DoubleTools.ToInt(this.Player.X / MapTile.WH) * MapTile.WH - 10.0; } bool touchCeiling_L = this.Map.GetCell(Map.ToTablePoint(this.Player.X - 9.0, this.Player.Y - MapTile.WH)).Wall; bool touchCeiling_R = this.Map.GetCell(Map.ToTablePoint(this.Player.X + 9.0, this.Player.Y - MapTile.WH)).Wall; bool touchCeiling = touchCeiling_L && touchCeiling_R; if (touchCeiling_L && touchCeiling_R) { if (this.Player.YSpeed < 0.0) { this.Player.Y = (int)(this.Player.Y / MapTile.WH + 1) * MapTile.WH; this.Player.YSpeed = 0.0; this.Player.JumpFrame = 0; } } else if (touchCeiling_L) { this.Player.X = (double)DoubleTools.ToInt(this.Player.X / MapTile.WH) * MapTile.WH + 9.0; } else if (touchCeiling_R) { this.Player.X = (double)DoubleTools.ToInt(this.Player.X / MapTile.WH) * MapTile.WH - 9.0; } this.Player.TouchGround = this.Map.GetCell(Map.ToTablePoint(this.Player.X - 9.0, this.Player.Y + MapTile.WH)).Wall || this.Map.GetCell(Map.ToTablePoint(this.Player.X + 9.0, this.Player.Y + MapTile.WH)).Wall; if (this.Player.TouchGround) { DDUtils.Minim(ref this.Player.YSpeed, 0.0); double plY = (int)(this.Player.Y / MapTile.WH) * MapTile.WH; DDUtils.Minim(ref this.Player.Y, plY); } if (this.Player.TouchGround) { this.Player.AirborneFrame = 0; } else { this.Player.AirborneFrame++; } } if (this.Frame == 0) // 画面遷移時の微妙なカメラ位置ズレ解消 { DDGround.Camera.X = this.Player.X - DDConsts.Screen_W / 2.0; DDGround.Camera.Y = this.Player.Y - DDConsts.Screen_H / 2.0; DDUtils.ToRange(ref DDGround.Camera.X, 0.0, this.Map.W * MapTile.WH - DDConsts.Screen_W); DDUtils.ToRange(ref DDGround.Camera.Y, 0.0, this.Map.H * MapTile.WH - DDConsts.Screen_H); DDGround.ICamera.X = DoubleTools.ToInt(DDGround.Camera.X); DDGround.ICamera.Y = DoubleTools.ToInt(DDGround.Camera.Y); } if (1 <= this.Player.AttackFrame) { this.Player.Attack(); } this.EnemyEachFrame(); this.WeaponEachFrame(); // Crash { DDCrash playerCrash = DDCrashUtils.Point(new D2Point(this.Player.X, this.Player.Y)); foreach (WeaponBox weapon in this.Weapons.Iterate()) { weapon.Crash = weapon.Value.GetCrash(); } foreach (EnemyBox enemy in this.Enemies.Iterate()) { DDCrash enemyCrash = enemy.Value.GetCrash(); foreach (WeaponBox weapon in this.Weapons.Iterate()) { if (enemyCrash.IsCrashed(weapon.Crash)) { if (enemy.Value.Crashed(weapon.Value) == false) // ? 消滅 { enemy.Dead = true; } if (weapon.Value.Crashed(enemy.Value) == false) // ? 消滅 { weapon.Dead = true; } } } this.Weapons.RemoveAll(weapon => weapon.Dead); if (this.Player.DeadScene.IsFlaming() == false && this.Player.DamageScene.IsFlaming() == false && this.Player.MutekiScene.IsFlaming() == false && enemyCrash.IsCrashed(playerCrash)) { if (enemy.Value.CrashedToPlayer() == false) // ? 消滅 { enemy.Dead = true; } this.Player.Crashed(enemy.Value); } } this.Enemies.RemoveAll(enemy => enemy.Dead); } // 描画ここから this.DrawWall(); this.DrawMap(); this.Player.Draw(); this.DrawEnemies(); this.DrawWeapons(); DDPrint.SetPrint(); DDPrint.Print(DDEngine.FrameProcessingMillis_Worst + " " + this.Player.HP); DDEngine.EachFrame(); } DDEngine.FreezeInput(); if (this.ExitDir == 5) { DDMusicUtils.Fade(); DDCurtain.SetCurtain(30, -1.0); foreach (DDScene scene in DDSceneUtils.Create(40)) { this.DrawWall(); this.DrawMap(); DDEngine.EachFrame(); } } else { double destSlideX = 0.0; double destSlideY = 0.0; switch (this.ExitDir) { case 4: destSlideX = DDConsts.Screen_W; break; case 6: destSlideX = -DDConsts.Screen_W; break; case 8: destSlideY = DDConsts.Screen_H; break; case 2: destSlideY = -DDConsts.Screen_H; break; default: throw null; // never } #if true using (DDSubScreen wallScreen = new DDSubScreen(DDConsts.Screen_W, DDConsts.Screen_H)) { using (wallScreen.Section()) { this.DrawWall(); } foreach (DDScene scene in DDSceneUtils.Create(30)) { this.DrawMap_SlideX = destSlideX * scene.Rate; this.DrawMap_SlideY = destSlideY * scene.Rate; DDCurtain.DrawCurtain(); DDDraw.DrawSimple(wallScreen.ToPicture(), this.DrawMap_SlideX, this.DrawMap_SlideY); this.DrawMap(); DDEngine.EachFrame(); } } #else // old foreach (DDScene scene in DDSceneUtils.Create(10)) { this.DrawWall(); DDCurtain.DrawCurtain(-scene.Rate); this.DrawMap(); DDEngine.EachFrame(); } foreach (DDScene scene in DDSceneUtils.Create(20)) { this.DrawMap_SlideX = destSlideX * scene.Rate; this.DrawMap_SlideY = destSlideY * scene.Rate; DDCurtain.DrawCurtain(-1.0); this.DrawMap(); DDEngine.EachFrame(); } #endif this.DrawMap_SlideX = 0.0; // 復元 this.DrawMap_SlideY = 0.0; // 復元 DDCurtain.SetCurtain(0, -1.0); } // ここでステータスに反映 this.Status.CurrHP = this.Player.HP; this.Status.FacingLeft = this.Player.FacingLeft; }
public void Perform() { this.Player.X = DDConsts.Screen_W / 4; this.Player.Y = DDConsts.Screen_H / 2; this.Player.BornScene.Fire(); DDCurtain.SetCurtain(10); for (; ; this.Frame++) { // プレイヤー行動 { bool bornOrDead = this.Player.BornScene.IsFlaming() || this.Player.DeadScene.IsFlaming(); bool dead = this.Player.DeadScene.IsFlaming(); double xa = 0.0; double ya = 0.0; if (!dead && 1 <= DDInput.DIR_4.GetInput()) // 左移動 { xa = -1.0; } if (!dead && 1 <= DDInput.DIR_6.GetInput()) // 右移動 { xa = 1.0; } if (!dead && 1 <= DDInput.DIR_8.GetInput()) // 上移動 { ya = -1.0; } if (!dead && 1 <= DDInput.DIR_2.GetInput()) // 下移動 { ya = 1.0; } double speed; if (1 <= DDInput.A.GetInput()) // 低速ボタン押下中 { speed = (double)this.Player.SpeedLevel; } else { speed = (double)(this.Player.SpeedLevel * 2); } this.Player.X += xa * speed; this.Player.Y += ya * speed; DDUtils.ToRange(ref this.Player.X, 0.0, DDConsts.Screen_W); DDUtils.ToRange(ref this.Player.Y, 0.0, DDConsts.Screen_H); if (!bornOrDead && 1 <= DDInput.B.GetInput()) // 攻撃ボタン押下中 { this.Player.Shoot(); } if (DDInput.L.GetInput() == 1) { this.Player.SpeedLevel--; } if (DDInput.R.GetInput() == 1) { this.Player.SpeedLevel++; } DDUtils.ToRange(ref this.Player.SpeedLevel, Player.SPEED_LEVEL_MIN, Player.SPEED_LEVEL_MAX); } { DDScene scene = this.Player.BornScene.GetScene(); if (scene.Numer != -1) { if (scene.Remaining == 0) { this.Player.MutekiScene.FireDelay(); } } } { DDScene scene = this.Player.DeadScene.GetScene(); if (scene.Numer != -1) { if (scene.Remaining == 0) { if (this.Status.RemainingLiveCount <= 0) { break; } this.Status.RemainingLiveCount--; this.Player.BornScene.FireDelay(); } } } { DDScene scene = this.Player.MutekiScene.GetScene(); if (scene.Numer != -1) { // noop } } if (this.Scenario.EachFrame() == false) { break; } this.EnemyEachFrame(); this.WeaponEachFrame(); DDCrashView cv = DDKey.GetInput(DX.KEY_INPUT_LSHIFT) == 0 ? null : new DDCrashView(); // Crash { DDCrash playerCrash = DDCrashUtils.Point(new D2Point(this.Player.X, this.Player.Y)); foreach (WeaponBox weapon in this.Weapons.Iterate()) { weapon.Crash = weapon.Value.GetCrash(); } foreach (EnemyBox enemy in this.Enemies.Iterate()) { DDCrash enemyCrash = enemy.Value.GetCrash(); if (cv != null) { cv.Draw(enemyCrash); } foreach (WeaponBox weapon in this.Weapons.Iterate()) { if (enemyCrash.IsCrashed(weapon.Crash)) { if (enemy.Value.Crashed(weapon.Value) == false) // ? 消滅 { enemy.Dead = true; } if (weapon.Value.Crashed(enemy.Value) == false) // ? 消滅 { weapon.Dead = true; } } } this.Weapons.RemoveAll(weapon => weapon.Dead); if (this.Player.BornScene.IsFlaming() == false && this.Player.DeadScene.IsFlaming() == false && this.Player.MutekiScene.IsFlaming() == false && enemyCrash.IsCrashed(playerCrash)) { foreach (DDScene scene in DDSceneUtils.Create(30)) // プレイヤ死亡効果 { this.DrawWall(); this.Player.Draw(); this.DrawEnemies(); DDDraw.SetAlpha(0.3); DDDraw.SetBright(1.0, 0.0, 0.0); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, 0, 0, DDConsts.Screen_W, DDConsts.Screen_H); DDDraw.Reset(); { int ix = DoubleTools.ToInt(this.Player.X); int iy = DoubleTools.ToInt(this.Player.Y); DDDraw.SetBright(1.0, 1.0, 0.0); DDDraw.SetAlpha(scene.Rate); DDDraw.DrawRect_LTRB(DDGround.GeneralResource.WhiteBox, ix - 1, 0, ix + 1, DDConsts.Screen_H); DDDraw.SetAlpha(scene.RemainingRate); DDDraw.DrawRect_LTRB(DDGround.GeneralResource.WhiteBox, 0, iy - 1, DDConsts.Screen_W, iy + 1); DDDraw.Reset(); } DDEngine.EachFrame(); } this.Player.DeadScene.Fire(); } } this.Enemies.RemoveAll(enemy => enemy.Dead); } // ここから描画 this.DrawWall(); this.Player.Draw(); this.DrawEnemies(); this.DrawWeapons(); if (cv != null) { cv.DrawToScreen(0.8); cv.Dispose(); cv = null; } DDPrint.SetPrint(); DDPrint.Print(DDEngine.FrameProcessingMillis_Worst + " " + this.Enemies.Count + " SPEED=" + this.Player.SpeedLevel); DDEngine.EachFrame(); } }