/// <summary> /// プレイヤーの位置を指定してカメラ位置設定 /// </summary> /// <param name="player"></param> public Camera(Player player) { //カメラ距離設定 cameraheight = (float)(distance * Math.Sin(angle)); cameradepth = (float)(distance * Math.Cos(angle)); direction = new Vector3(0, -cameraheight, -cameradepth) + diffDistance; //カメラ位置設定 position = player.Position3; position.Y += cameraheight; //ローテーション用Matrix Matrix rotationMatrix = Matrix.CreateRotationY(player.Rotate); //カメラポイントを回転 Vector3 transformedRefeence = Vector3.Transform(direction, rotationMatrix); //プレイヤーの角度に合わせてカメラ位置移動 position.Z += cameradepth * (float)Math.Cos((double)player.Rotate); position.X += cameradepth * (float)Math.Sin((double)player.Rotate); View = Matrix.CreateLookAt(position, position + transformedRefeence, new Vector3(0, 1, 0)); //π/4 float viewAngle = MathHelper.PiOver4; float aspectRatio = (float)GameMain.ScreenWidth / GameMain.ScreenHeight; float nearClip = 1.0f; float farClip = 2000.0f; Projection = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio, nearClip, farClip); }
public void Update(Player player, GameTime gameTime) { // 経過時間を計算 totalTime = gameTime.TotalGameTime - startGameTime.TotalGameTime; // ペナルティを受けた回数だけ経過時間を10秒足す for (int i = 0; i < penaltyTime; i++) { totalTime += new TimeSpan(0, 0, 10); } // 残り時間を計算 remaningTime = timeLimit - totalTime; if (remaningTime < TimeSpan.Zero) { remaningTime = TimeSpan.Zero; } }
internal void Update(Player player) { stock = player.stock; }
public void Update(Player player) { // デバッグ用カメラ切り替え if (Input.Instance.PushKey(Microsoft.Xna.Framework.Input.Keys.F)) { debugCamera = !debugCamera; } if (debugCamera) { // 真上(高さ50)からプレイヤーを見下ろす視点 position = new Vector3(player.Position3.X, 50, player.Position3.Z); View = Matrix.CreateLookAt(position, position + Vector3.Down, new Vector3(0, 0, -1)); } else { //カメラ位置をプレイヤーに合わせる position = player.Position3; position += offset; position.Y += cameraheight; //ローテーション用Matrix Matrix rotationMatrix = Matrix.CreateRotationY(player.Rotate + camerarotate); //カメラポイントを回転 Vector3 transformedRefeence = Vector3.Transform(direction, rotationMatrix); //プレイヤーの角度に合わせてカメラ位置移動 position.Z += cameradepth * (float)Math.Cos((double)player.Rotate); position.X += cameradepth * (float)Math.Sin((double)player.Rotate); View = Matrix.CreateLookAt(position, position + transformedRefeence, new Vector3(0, 1, 0)); } }
/// <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"); }