public EnemyManager(ContentManager content, StageSelect.SelectEnemy selectEnemy, StageSelect.SelectStage selectStage, Maze maze, Player player) { this.content = content; this.maze = maze; this.player = player; int chaseEnemyNum; int randomWalkEnemyNum; // 敵数を決める switch (selectEnemy) { case StageSelect.SelectEnemy.Few: chaseEnemyNum = 10; break; case StageSelect.SelectEnemy.Regular: chaseEnemyNum = 15; break; case StageSelect.SelectEnemy.Much: chaseEnemyNum = 20; break; default: throw new ArgumentException(); } randomWalkEnemyNum = chaseEnemyNum; switch (selectStage) { case StageSelect.SelectStage.Small: randomWalkEnemyNum *= 1; break; case StageSelect.SelectStage.Regular: randomWalkEnemyNum *= 2; break; case StageSelect.SelectStage.Big: randomWalkEnemyNum *= 3; break; default: throw new ArgumentException(); } // リストにChaseEnemyを突っ込む for (int i = 0; i < chaseEnemyNum; i++) { Point enemyPosition = GetEnemyInitialPosition(maze, player); enemies.Add(new ChaseEnemy(content, enemyPosition, Collidable.Orientation.North, maze, player)); } // リストにRandomWalkEnemyNumを突っ込む for (int i = 0; i < randomWalkEnemyNum; i++) { Point enemyPosition = GetEnemyInitialPosition(maze, player); enemies.Add(new RandomWalkEnemy(content, enemyPosition, Collidable.Orientation.North, maze, player, rand.Next())); } }
/// <summary> /// ランキングシーン /// </summary> /// <param name="content"></param> /// <param name="graphicsDevice"></param> /// <param name="selectStage"></param> public Ranking(ContentManager content, GraphicsDevice graphicsDevice, StageSelect.SelectStage selectStage) { this.content = content; this.graphicsDevice = graphicsDevice; //ステージサイズ取得 this.selectStage = selectStage; LoadContent(); NewRecordFlag = false; DrawFlag = false; //音声初期化 cueBGM = SoundManager.Instance.SoundBank.GetCue("result"); cueBGM.Play(); //フェードアウト初期化 fadeout = new FadeOut(content, graphicsDevice, FadeOut.SceneType.OutGame); }
public Score(ContentManager content, GraphicsDevice graphicsDevice, GameTime gameTime, StageSelect.SelectStage selectStage) { // スタート時のゲーム時間を保存 startGameTime = new GameTime(gameTime.TotalGameTime, gameTime.ElapsedGameTime); this.content = content; this.graphicsDevice = graphicsDevice; LoadContent(); switch (selectStage) { case StageSelect.SelectStage.Small: timeLimit = new TimeSpan(0, 3, 5); break; case StageSelect.SelectStage.Regular: timeLimit = new TimeSpan(0, 3, 35); break; case StageSelect.SelectStage.Big: timeLimit = new TimeSpan(0, 4, 5); break; } }
/// <summary> /// ランキングシーン /// </summary> /// <param name="content"></param> /// <param name="graphicsDevice"></param> /// <param name="totalTime"></param> /// <param name="selectStage"></param> public Ranking(ContentManager content, GraphicsDevice graphicsDevice, TimeSpan totalTime, StageSelect.SelectStage selectStage) { this.content = content; this.graphicsDevice = graphicsDevice; //ステージサイズ取得 this.selectStage = selectStage; //クリア時間取得 this.totalTime = totalTime; LoadContent(); NewRecordFlag = false; DrawFlag = true; //ランキングチェック newRank = checkRancking(totalTime, csvstr); //レコード更新フラグ確認 if (newRank >= 0 && newRank <= 2) NewRecordFlag = true; //音声初期化 cueBGM = SoundManager.Instance.SoundBank.GetCue("result"); cueBGM.Play(); fadeout = new FadeOut(content, graphicsDevice, FadeOut.SceneType.OutGame); }
/// <summary> /// メインゲームシーン /// </summary> /// <param name="content"></param> /// <param name="graphicsDevice"></param> /// <param name="input"></param> public GameIn(ContentManager content, GraphicsDevice graphicsDevice, GameTime gameTime, StageSelect.SelectStage selectStage, StageSelect.SelectEnemy selectEnemy) { this.content = content; this.graphicsDevice = graphicsDevice; this.selectStage = selectStage; // 乱数の初期化 rand = new Random(); // 迷路初期化。難易度によって大きさを変える maze = new Maze(content, selectStage); Point playerPosition; Point goalPosition; while (true) { playerPosition = maze.RandomPoint(); goalPosition = maze.RandomPoint(); // 迷路の斜辺の長さを求める。三平方の定理 c^2 = sqrt(a^2 + b^2) double hypotenuse = Math.Sqrt(maze.Width * maze.Width + maze.Height * maze.Height); // 0.5斜辺 < 距離 < 0.6斜辺ならOK double distance = Math.Sqrt((playerPosition.X - goalPosition.X) * (playerPosition.X - goalPosition.X) + (playerPosition.Y - goalPosition.Y) * (playerPosition.Y - goalPosition.Y)); if (hypotenuse * 0.5 < distance && distance < hypotenuse * 0.6) { break; } } //プレイヤー初期化 player = new Player(content, playerPosition, Collidable.Collidable.Orientation.East, maze); //ゴール初期化 goalobj = new GoalObject(content, goalPosition, Collidable.Collidable.Orientation.East, maze); // Enemyマネージャ初期化 enemyManager = new EnemyManager(content, selectEnemy, selectStage, maze, player); //背景モデルの宣言 backmodel = new BackGround(content); //カメラの初期設定 camera = new Camera(player); // ミニマップの初期化 miniMap = new MiniMap(content, graphicsDevice); // スコアの初期化 score = new Score(content, graphicsDevice, gameTime, selectStage); //フェードアウト処理 fadeout = new FadeOut(content, graphicsDevice, FadeOut.SceneType.InGame); // カウントダウン countdown = new CountDown(content, graphicsDevice, gameTime); // BGMの再生 cueBGM = SoundManager.Instance.SoundBank.GetCue("game"); }
public Maze(ContentManager contentManager, StageSelect.SelectStage selectStage) { // 迷路初期化。難易度によって大きさを変える int width = 0; int height = 0; switch (selectStage) { case StageSelect.SelectStage.Small: width = 3; height = 2; break; case StageSelect.SelectStage.Regular: width = 4; height = 3; break; case StageSelect.SelectStage.Big: width = 5; height = 4; break; } // XMLの読み込み XElement xmlDoc = XElement.Load(xmlFilename); List<string> fieldChipNameList = new List<string>(); foreach (var elem in xmlDoc.Descendants("chip")) fieldChipNameList.Add(elem.Value); // ランダムにチップを選択 List<string> necessaryFieldChipList = new List<string>(width * height); Random random = new Random(); for (int i = 0; i < width * height; i++) necessaryFieldChipList.Add(fieldChipNameList[random.Next(fieldChipNameList.Count)]); // チップの読み込み int[,][, ,] fieldChips = new int[height, width][, ,]; foreach (var fieldChipName in necessaryFieldChipList.Select((v, i) => new { v, i })) fieldChips[fieldChipName.i / width, fieldChipName.i % width] = LoadFieldChip(@"Content\Maze\Field\" + fieldChipName.v); int[, ,] field = ConbineFieldChip(fieldChips); movableArea = new bool[field.GetLength(0), field.GetLength(1)]; Width = movableArea.GetLength(1); Height = movableArea.GetLength(0); for (int i = 0; i < field.GetLength(0); i++) for (int j = 0; j < field.GetLength(1); j++) movableArea[i, j] = field[i, j, 0] == 0; wallBig = contentManager.Load<Model>(@"Maze\BigWall\BigWallbrick"); wallSmall = contentManager.Load<Model>(@"Maze\SmallWall\SmallWallbrick"); groundBig = contentManager.Load<Model>(@"Maze\BigGround\TileGroundB"); groundSmall = contentManager.Load<Model>(@"Maze\SmallGround\TileGroundS"); drawAreaRadius = 17; #region ToonEffect //wallBig.ReplaceAllEffects(effect => EffectTranslator.Translate(contentManager, effect)); //wallSmall.ReplaceAllEffects(effect => EffectTranslator.Translate(contentManager, effect)); #endregion #region BasicEffect foreach (ModelMesh mesh in this.wallBig.Meshes) { foreach (BasicEffect effect in mesh.Effects) { //デフォルトのライト適用 effect.EnableDefaultLighting(); effect.DirectionalLight0.Direction = new Vector3(0, 10, 0); effect.DirectionalLight1.Direction = new Vector3(0, -10, 0); //effect.DirectionalLight2.Direction = new Vector3(0, -5, 0); } } foreach (ModelMesh mesh in this.wallSmall.Meshes) { foreach (BasicEffect effect in mesh.Effects) { //デフォルトのライト適用 effect.EnableDefaultLighting(); //effect.DirectionalLight0.Direction = new Vector3(0, 10, 0); //effect.DirectionalLight1.Direction = new Vector3(0, -5, 0); } } #endregion }
/// <summary> /// キー入力を行いランキング用CSVを更新するクラス /// </summary> /// <param name="content"></param> /// <param name="graphicsDevice"></param> /// <param name="ranknumber">更新されるランキング順位</param> /// <param name="scoretime">スコアタイム</param> /// <param name="csvfime">CSVファイルの中身</param> /// <param name="selectStage"></param> public KeyBoardInput(ContentManager content, GraphicsDevice graphicsDevice, int ranknumber, string recordtime, StageSelect.SelectStage selectStage) { this.content = content; this.graphicsDevice = graphicsDevice; this.rankNumber = ranknumber; this.recordtime = recordtime; this.selectStage = selectStage; LoadContent(); DecideFlag = false; FinalDecideFlag = false; nametext = ""; }