public void OnKillEnemy(Enemy enemy) { gameSceneState.OnRemoveEnemy(enemy); gameSceneState.SetZoom(false); heliPlayer.ApplyHeliPlayerData(gameSceneState.HeliPlayerData); view.ApplyGameSceneState(gameSceneState); if (gameSceneState.TargetEnemyList.Count == 0) { var currentSubStage = subStageList.FirstOrDefault(s => s.SubStageId == gameSceneState.SubStageId); var nextSubStage = subStageList.FirstOrDefault(s => s.SubStageId == gameSceneState.NextSubStageId); if (gameSceneState.SubStageId == nextSubStage.NextSubStageId) { SceneManager.Inst.SwitchScene <GameResultScene>(new GameResultSceneInitData() { GameInstance = initData.GameInstance, ClearTime = Time.time - startTime }); return; } currentSubStage.SetColliderActive(false); cameraTrack.SetSubStage(gameSceneState.NextSubStageId, OnChangeStage); } }
public override void OnInitializeScene(ISceneInitData _initData) { initData = (GameSceneInitData)_initData; GameInstance.Inst.PlayBGM(new BgmEnum[] { BgmEnum.Game, BgmEnum.GameAmbient }); field = GenericPrefab.InstantiatePathFormat <Field>(initData.FieldId.ToString()); cameraTrack = field.GetCameraTrack(); heliPlayer = GenericPrefab.Instantiate <HeliPlayer>(cameraTrack.GetCameraJoint()); subStageList = field.GetSubStageList(); //GameSceneState { int enemyCount = 0; var fistStage = subStageList.FirstOrDefault(); Transform firstTarget = null; if (fistStage != null) { var firstEnemy = fistStage.EnemyList.FirstOrDefault(); enemyCount = fistStage.EnemyList.Count; if (firstEnemy != null) { firstTarget = firstEnemy.TargetJoint; } } gameSceneState = new GameSceneState() { TargetEnemyList = fistStage.EnemyList.ToList(), HeliPlayerData = new HeliPlayerData() { Zoom = false, Target = firstTarget }, SubStageId = fistStage.SubStageId, NextSubStageId = fistStage.NextSubStageId, LeftEnemyCount = enemyCount, CurrentEnemyIndex = 0 }; fistStage.SetColliderActive(true); gameSceneState.InvalidTarget(); heliPlayer.ApplyHeliPlayerData(gameSceneState.HeliPlayerData); view.ApplyGameSceneState(gameSceneState); } //init enemy { var enemyInitData = new EnemyInitData() { OnKillEnemy = OnKillEnemy, OnRemoveEnemy = OnRemoveEnemy }; foreach (var subStage in subStageList) { foreach (var enemy in subStage.EnemyList) { enemy.Initialize(enemyInitData); } } } //Init CameraTrack cameraTrack.SetSubStage(1); startTime = Time.time; view.ApplyTime(Time.time - startTime); }