public static void MainWeaponCollision(Canvas canvas) { for (int i = 0; i < lstMainWeaponCollider.Count; i++) { for (int j = 0; j < SpawnEnemy.lstEnemyData.Count; j++) { if (!SpawnEnemy.lstEnemyData[j].isDamage) { Vector p1 = new Vector(lstMainWeaponCollider[i].X, lstMainWeaponCollider[i].Y); Vector size1 = new Vector(32, 32); Vector p2 = new Vector(SpawnEnemy.lstEnemyData[j].position.X, SpawnEnemy.lstEnemyData[j].position.Y); Vector size2 = new Vector(SpawnEnemy.lstEnemyData[j].size.X, SpawnEnemy.lstEnemyData[j].size.Y); if (CollisionCheck.Collision(p1, p2, size1, size2) && SpawnEnemy.lstEnemyData[j].state != EnemyState.Death) { SpawnEnemy.lstEnemyData[j].isDamage = true; SpawnEnemy.lstEnemyData[j].totalInvincibleTime = 0; SpawnEnemy.lstEnemyData[j].coefficient = 0; SpawnEnemy.lstEnemyData[j].totalDistance = new Vector(0, 0); SpawnEnemy.lstEnemyData[j].bps = new Vector(0, 0); SpawnEnemy.lstEnemyData[j].targetDistance = new Vector(32, 32); SpawnEnemy.lstEnemyData[j].isKnockBack = true; if (!Sound.seStop) { Sound.SoundEffectSelector(SeName.Shock); Sound.SoundEffectPlayer(SeName.Shock); Sound.seStop = true; } SpawnEnemy.lstEnemyData[j].life -= 1; if (SpawnEnemy.lstEnemyData[j].life <= 0) { SpawnEnemy.lstEnemyData[j].isWaiting = false; SpawnEnemy.lstEnemyData[j].state = EnemyState.Death; SpawnEnemy.EnemyDeathItemDrop(canvas, SpawnEnemy.lstEnemyData[j].position); } } } } } }
public static void CollisionSubWeapon(Canvas canvas) { for (int i = 0; i < SpawnEnemy.lstEnemyData.Count; i++) { if (ImageData.imgSubWeapon.Count >= 1) { Vector p1 = new Vector(Canvas.GetLeft(ImageData.imgSubWeapon[0]), Canvas.GetTop(ImageData.imgSubWeapon[0])); Vector size1 = new Vector(32, 32); Vector p2 = new Vector(Canvas.GetLeft(SpawnEnemy.lstEnemyData[i].imgEnemy), Canvas.GetTop(SpawnEnemy.lstEnemyData[i].imgEnemy)); Vector size2 = new Vector(SpawnEnemy.lstEnemyData[i].size.X, SpawnEnemy.lstEnemyData[i].size.Y); if (CollisionCheck.Collision(p1, p2, size1, size2) && SpawnEnemy.lstEnemyData[i].state != EnemyState.Death) { canvas.Children.Remove(ImageData.imgSubWeapon[0]); ImageData.imgSubWeapon.Remove(ImageData.imgSubWeapon[0]); if (!Sound.seStop) { Sound.SoundEffectSelector(SeName.Fog); Sound.SoundEffectPlayer(SeName.Fog); Sound.seStop = true; } SpawnEnemy.lstEnemyData[i].life -= 1; if (SpawnEnemy.lstEnemyData[i].life <= 0) { SpawnEnemy.lstEnemyData[i].isWaiting = false; SpawnEnemy.lstEnemyData[i].state = EnemyState.Death; SpawnEnemy.EnemyDeathItemDrop(canvas, SpawnEnemy.lstEnemyData[i].position); } break; } } } }
public static void GameTransitionController(Canvas canvas, Canvas caLife, Canvas caMana) { switch (gameTransition) { case GameTransitionType.Title: if (!endSplashLogo) { splashLogoPhase = 4; switch (splashLogoPhase) { case 0: if (splashWaitTotal < 1000) { splashWaitTotal += MainWindow.elapsedTime; } else { splashLogoPhase++; splashWaitTotal = 0; } break; case 1: if (screenFadeTotal < 1) { double temp = (double)MainWindow.elapsedTime / 2000; screenFadeTotal += Math.Round(temp, 2); ImageData.imgTitle[0].Opacity = screenFadeTotal; } else { ImageData.imgTitle[0].Opacity = 1; splashLogoPhase++; } break; case 2: if (splashWaitTotal < 2000) { splashWaitTotal += MainWindow.elapsedTime; } else { splashLogoPhase++; splashWaitTotal = 0; } break; case 3: if (screenFadeTotal > 0) { double temp = (double)MainWindow.elapsedTime / 2000; screenFadeTotal -= Math.Round(temp, 2); ImageData.imgTitle[0].Opacity = screenFadeTotal; } else { ImageData.imgTitle[0].Opacity = 0; splashLogoPhase++; } break; case 4: if (splashWaitTotal < 1000) { splashWaitTotal += MainWindow.elapsedTime; } else { endSplashLogo = true; screenFadeTotal = 0; Sound.SoundBgmSelector(BgmName.Opening); Sound.bgm.Play(); MainWindow.TitleOpen(canvas); } break; } } else { MainWindow.countTime += MainWindow.elapsedTime; if (MainWindow.countTime >= 1000) { MainWindow.titleStrSwitch = !MainWindow.titleStrSwitch; MainWindow.countTime = 0; if (!MainWindow.titleStrSwitch) { ImageData.imgTitle[1].Visibility = Visibility.Hidden; } else { ImageData.imgTitle[1].Visibility = Visibility.Visible; } } } break; case GameTransitionType.StageInit: StageInit.InitBlockData(); StageDataSetting.SetData(); StageInit.StageBlockSet(canvas); StageManager.StageObjectsSetting(canvas); MainWindow.lblMode.Content = "ゲームモード:ステージ開始"; gameTransition = GameTransitionType.StageStart; break; case GameTransitionType.StageStart: if (!eventStart) { duringTransition = true; StageEvent.InitEvent(); eventCount = 0; eventStart = true; } break; case GameTransitionType.StageDuring: if (StageManager.StageClearCheck()) { gameTransition = GameTransitionType.StageEnd; MainWindow.lblMode.Content = "ゲームモード:ステージ終了"; } else { if (growthEnemy) { SpawnEnemy.SpawnSelect(canvas, ""); growthEnemy = false; } } break; case GameTransitionType.StageEnd: if (!eventStart) { duringTransition = true; eventStart = true; } break; case GameTransitionType.StageNext: if (!stageTestPlay) { StageManager.stageNum++; if (StageManager.stageNum >= StageOrder.lstStageOrder.Count) { MainWindow.timerFrameUpdate.Stop(); MessageBox.Show("すべてのステージが終わりました。ゲームを終了します。", "ゲームの終了", MessageBoxButton.OK, MessageBoxImage.Information); Application.Current.Shutdown(); } StageInit.StageBlockRemove(canvas); StageInit.StageObjectsRemove(canvas); StageInit.StageEnemyRemove(canvas); growthEnemy = false; StageInit.StageItemRemove(canvas); MainWindow.canScreenFade.Visibility = Visibility.Hidden; StageManager.lstClearCondition.Clear(); StageManager.clearFlag = false; MainWindow.lblMode.Content = "ゲームモード:ステージ準備"; gameTransition = GameTransitionType.StageInit; } else { MainWindow.timerFrameUpdate.Stop(); gameTransition = GameTransitionType.EditMode; stageTestPlay = false; StageManager.clearFlag = false; MainWindow.canScreenFade.Visibility = Visibility.Hidden; MainWindow.stageEditor.StageLoad(); MainWindow.stageEditor.StageEditorDataSetting(); StageEditorOperator.EditorPlayerPaletteSetting(); MainWindow.stageEditor.tbcEditSelect.IsEnabled = true; MainWindow.stageEditor.btnStageNumDecrease.IsEnabled = true; MainWindow.stageEditor.btnStageNumIncrease.IsEnabled = true; MainWindow.stageEditor.btnStageOrder.IsEnabled = true; MainWindow.stageEditor.btnStageTestPlay.IsEnabled = true; MainWindow.stageEditor.btnEventWindowOpen.IsEnabled = true; } break; case GameTransitionType.EditMode: break; } }
//frameupdate protected void FrameUpdateTimer_Update(object sender, ElapsedEventArgs e) { try { this.Dispatcher.Invoke(() => { //TimeManagement this.GetNowTime(); elapsedTime = nowTime - lastTime; //debug lblDebugA.Content = PlayerStatus.playerPos.X + "," + PlayerStatus.playerPos.Y; lblDebugB.Content = SystemOperator.PixelPerSecond(PlayerStatus.weight); if (elapsedTime < 0) { elapsedTime += 59999; } KeyController.KeyInterval(); //GameTransition if (!GameTransition.duringTransition) { GameTransition.GameTransitionController(Canvas, CaLife, CaMana); } //EventAction if (GameTransition.eventStart) { if (GameTransition.lstEventTask.Count > 0) { GameTransition.EventTaskCommander(); } if (GameTransition.charaRenderStart) { GameTransition.CharaRender(); } if (GameTransition.screenFadeStart) { GameTransition.ScreenFade(Canvas); } if (!GameTransition.eventBalloonIsOpen) { if (GameTransition.eventCount < StageEvent.listEvent.Count) { GameTransition.EventController(Canvas); } } else { if (KeyController.keyReturn) { EnterKeyAction(Canvas); } } } if (KeyController.keyReturn) { EnterKeyAction(Canvas); } //got to Edit Mode if (GameTransition.gameTransition == GameTransitionType.Title) { if (KeyController.keyE) { mainCanvas.Children.Remove(ImageData.imgTitle[0]); mainCanvas.Children.Remove(ImageData.imgTitle[1]); countTime = 0; GameTransition.gameTransition = GameTransitionType.EditMode; timerFrameUpdate.Stop(); btnViewStageEditorWindow.IsEnabled = true; btnViewMaterialBrowser.IsEnabled = true; btnViewImageManager.IsEnabled = true; btnViewDatabaseWindow.IsEnabled = true; lblMode.Content = "ゲームモード:エディット"; } } //StageDuring game play if (GameTransition.gameTransition == GameTransitionType.StageDuring && !isDeactivated) { Animator.AnimationItem(); Animator.AnimationObject(); if (ObjectChecker.isTrigger && !TalkCommander.isTalk) { ObjectBehavior.OnTriggerTouchEvent(); } if (TalkCommander.isTalk && !TalkCommander.isTalkOpenBalloon) { TalkCommander.TalkWithNpc(Canvas); } if (TalkCommander.isTalkSelecting) { TalkCommander.TalkSelecting(Canvas); } //first action,last Processing including deletion of list SystemOperator.moveCommonAmountX = 0; SystemOperator.moveCommonAmountY = 0; ObjectChecker.CollisionPtoActionCollider(); PlayerBehavior.CollisionPtoE(); PlayerBehavior.MovePlayer(Canvas); PlayerBehavior.FallingPlayer(); Item.FallingItems(); EnemyBehavior.EnemyAction(); Animator.AnimationEnemy(); SubWeapon.SubWeaponPosUpdate(Canvas); if (PlayerStatus.isMainAttack) { MainWeapon.MainWeaponAttack(Canvas); MainWeapon.MainWeaponCollision(Canvas); } SubWeapon.CollisionSubWeapon(Canvas); PlayerStatus.PlayerStatusUpdate(); PlayerBehavior.DamageInvinsibleTimer(); SpawnEnemy.RemoveEnemy(Canvas); SpawnEnemy.ReSpawnEnemy(Canvas); } if (Sound.seStop) { if (Sound.sePlayTime < 60) { Sound.sePlayTime++; } else { Sound.sePlayTime = 0; Sound.seStop = false; } } lastTime = nowTime; }); } catch (TaskCanceledException) { } }
public static void EventController(Canvas canvas) { if (eventCount != StageEvent.listEvent.Count) { if (!eventWaiting && !screenFadeStart) { switch (StageEvent.listEvent[eventCount].eventType) { case EventCommandEnum.Wait: eventWaiting = true; EventWaiting(StageEvent.listEvent[eventCount].eventValue); Console.WriteLine("wait"); break; case EventCommandEnum.Balloon: Vector blpos = StageEvent.listEvent[eventCount].balloonPos; string blstring = StageEvent.listEvent[eventCount].balloonMsg; if (StageEvent.listEvent[eventCount].targetImgType == TargetType.Player) { eventTargetImage = ImageData.imgPlayer; } if (StageEvent.listEvent[eventCount].targetImgType == TargetType.Object) { eventTargetImage = ObjectChecker.lstObject[StageEvent.listEvent[eventCount].targetId].imgObject; } BalloonMessage.OpenBalloon(eventCount, canvas, blpos, eventTargetImage, blstring, false); eventBalloonIsOpen = true; break; case EventCommandEnum.UiVisibility: if (!StageEvent.listEvent[eventCount].uiVisible) { MainWindow.stpPlayerStatus.Visibility = Visibility.Hidden; } else { MainWindow.stpPlayerStatus.Visibility = Visibility.Visible; } break; case EventCommandEnum.KeyLock: KeyController.keyControlLocking = StageEvent.listEvent[eventCount].flagKeyLock; Console.WriteLine("keylock"); break; case EventCommandEnum.Move: lstEventTask.Add(new EventCommandTask { name = EventCommandEnum.Move }); if (StageEvent.listEvent[eventCount].targetImgType == TargetType.Player) { lstEventTask[lstEventTask.Count - 1].targetType = TargetType.Player; lstEventTask[lstEventTask.Count - 1].targetImage = ImageData.imgPlayer; lstEventTask[lstEventTask.Count - 1].moveDistance = StageEvent.listEvent[eventCount].moveDistance; } else if (StageEvent.listEvent[eventCount].targetImgType == TargetType.Object) { lstEventTask[lstEventTask.Count - 1].targetType = TargetType.Object; lstEventTask[lstEventTask.Count - 1].targetImage = ObjectChecker.lstObject[StageEvent.listEvent[eventCount].targetId].imgObject; lstEventTask[lstEventTask.Count - 1].targetID = StageEvent.listEvent[eventCount].targetId; lstEventTask[lstEventTask.Count - 1].moveDistance = StageEvent.listEvent[eventCount].moveDistance; } lstEventTask[lstEventTask.Count - 1].direction = StageEvent.listEvent[eventCount].direction; charaMoveStart = true; break; case EventCommandEnum.BgmPlay: Sound.SoundBgmSelector(StageEvent.listEvent[eventCount].bgmName); Sound.bgm.Play(); Console.WriteLine("bgm"); break; case EventCommandEnum.SePlay: Sound.SoundEffectSelector(StageEvent.listEvent[eventCount].seName); Sound.SoundEffectPlayer(StageEvent.listEvent[eventCount].seName); Console.WriteLine("se"); break; case EventCommandEnum.CharaFadeIn: ImageData.imgPlayer.Opacity = 0; ImageData.imgPlayer.Width = 32; ImageData.imgPlayer.Height = 64; renderRateTotal = 0; charaRenderIndex = eventCount; charaRenderStart = true; break; case EventCommandEnum.CharaImageChange: switch (StageEvent.listEvent[eventCount].targetImgType) { case TargetType.Player: ImageData.imgPlayer.Source = ImageData.ImageSourceSelector(StageEvent.listEvent[eventCount].categoryName, StageEvent.listEvent[eventCount].patternName); break; case TargetType.Enemy: // SpawnEnemy.lstEnemyData[0].imgEnemy.Source = ImageData.ImageSourceSelector(StageEvent.listEvent[eventCount].categoryName, StageEvent.listEvent[eventCount].patternName); break; case TargetType.Object: ObjectChecker.lstObject[StageEvent.listEvent[eventCount].targetId].imgObject.Source = ImageData.ImageSourceSelector(StageEvent.listEvent[eventCount].categoryName, StageEvent.listEvent[eventCount].patternName); break; case TargetType.Item: break; } break; case EventCommandEnum.ScreenFadeIn: switch (StageEvent.listEvent[eventCount].color) { case ColorEnum.White: MainWindow.canScreenFade.Background = new SolidColorBrush(Colors.White); break; case ColorEnum.Black: MainWindow.canScreenFade.Background = new SolidColorBrush(Colors.Black); break; } MainWindow.canScreenFade.Opacity = 0; MainWindow.canScreenFade.Visibility = Visibility.Visible; screenFadeTotal = 0; screenFadeIndex = eventCount; screenFadeStart = true; break; case EventCommandEnum.ScreenFadeOut: screenFadeTotal = 1; screenFadeIndex = eventCount; screenFadeStart = true; break; case EventCommandEnum.GenerateEnemy: SpawnEnemy.GenerateEnemy(canvas, 0, StageEvent.listEvent[eventCount].setPosition); break; case EventCommandEnum.EventEnd: duringTransition = false; eventStart = false; if (gameTransition == GameTransitionType.StageStart) { if (!StageEvent.listEvent[eventCount].eventOnly) { MainWindow.lblMode.Content = "ゲームモード:ステージプレイ"; gameTransition = GameTransitionType.StageDuring; } else { MainWindow.lblMode.Content = "ゲームモード:ステージ初期化"; gameTransition = GameTransitionType.StageNext; } } else if (gameTransition == GameTransitionType.StageEnd) { MainWindow.lblMode.Content = "ゲームモード:ステージ初期化"; gameTransition = GameTransitionType.StageNext; } Console.WriteLine("end"); break; } eventCount++; } } }