/// <summary> /// 移動更新 /// </summary> /// <param name="moveState"></param> /// <param name="maze"></param> protected override void Move(Collidable.MoveState moveState, Maze maze) { //停止状態のとき対応する初期動作を行う if (currentMoveState == MoveState.Stop) { switch (moveState) { case MoveState.Advance: StartAdvance(maze); break; case MoveState.Back: StartBack(maze); break; case MoveState.Stop: break; case MoveState.TurnLeft: StartTurnLeft(); break; case MoveState.TurnRight: StartTurnRight(); break; } } //状態に対応する動作を行う,動作終了後Stop状態に遷移 else { //switch (moveState) switch (currentMoveState) { case MoveState.Advance: Advancing(); break; case MoveState.Back: Backing(); break; case MoveState.Stop: break; case MoveState.TurnLeft: TurningLeft(); break; case MoveState.TurnRight: TurningRight(); break; } } }
/// <summary> /// オブジェクト同士の衝突判定 /// </summary> /// <param name="coll"></param> /// <returns></returns> public bool Collision(Collidable coll) { /* //モデルの基本包括球 BoundingSphere baseBoundingSphere1 = new BoundingSphere(); BoundingSphere baseBoundingSphere2 = new BoundingSphere(); //モデルの包括球 BoundingSphere sphere1BoundingSphere = new BoundingSphere(); BoundingSphere sphere2BoundingSphere = new BoundingSphere(); //包括球取得 baseBoundingSphere1 = this.model.Meshes[0].BoundingSphere; baseBoundingSphere2 = coll.model.Meshes[0].BoundingSphere; //各モデル用の包括球半径設定 sphere1BoundingSphere.Radius = baseBoundingSphere1.Radius * this.scale.X * 0.8f; sphere2BoundingSphere.Radius = baseBoundingSphere2.Radius * coll.scale.X * 0.8f; //衝突判定用の球を設定 sphere1BoundingSphere.Center = this.position3 + baseBoundingSphere1.Center; sphere2BoundingSphere.Center = coll.position3 + baseBoundingSphere2.Center; //衝突判定 return sphere1BoundingSphere.Intersects(sphere2BoundingSphere); */ double diff = Math.Pow(this.position3.X - coll.position3.X, 2) + Math.Pow((this.position3.Y + this.Radius * this.scale.Y) - (coll.position3.Y + this.Radius * this.scale.Y), 2) + Math.Pow(this.position3.Z - coll.position3.Z, 2); return diff <= Math.Pow(this.Radius * this.scale.X * 0.8f + coll.Radius * coll.scale.X * 0.8f, 2); }