/// <summary> /// パズルの回転を行います。 /// </summary> /// <param name="direction">回転方向</param> void Rotation(RotDirection direction) { var buffer = new Block[blocks.Length]; Array.Copy(blocks, buffer, blocks.Length); for (int y = 0; y < rowColumn; y++) { for (int x = 0; x < rowColumn; x++) { switch (direction) { case RotDirection.Right: buffer[(rowColumn - 1) - y + rowColumn * x] = blocks[(y * rowColumn) + x]; break; case RotDirection.Left: buffer[(y * rowColumn) + x] = blocks[(rowColumn - 1) - y + rowColumn * x]; break; } } } // ここは参照の代入でOK blocks = buffer; // 回転アニメーションを開始 StartCoroutine(RotationAnim(direction)); }
private GeometryNode ObstModel; //Geometry Node und Model #endregion #region Constructor public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode) { FOV = NORMAL_FOV; DeltaGiro = DELTA_THETA; Active = true; ActAngle = 0; InitAngle = 0; MaxAng = 360; RadActAngle = 0; GirDir = RotDirection.RECHS; RotaMode = RotMode.CONTINUE; this.BulletModel = BulletModel; BulletMat = BulletMaterial; GMarkerNode = GrdMarkerNode; WBullets = new List <Bullet>(); //Config type of Shoot WaitBullet = WAIT_SHOOT; CountToShoot = WaitBullet; ReloadTime = WAIT_RELOAD; CountToReload = 0; CountOfBullets = 0; NumBullets = Game_Logic.MAX_BULLET; RadOffset = Math.PI * (95) / 180.0; BulletOffset = new Vector3(0, 10, 30); }
/// <summary> /// パズルの回転に伴うアニメーション /// </summary> /// <param name="direction">回転方向</param> /// <returns></returns> IEnumerator RotationAnim(RotDirection direction) { isMovable = false; // 回転に合わせたアニメーションがあるAcid,Friendのみここで呼び出し foreach (var block in blocks) { if (block != null && block is AcidBlock) { block.OnRotation(direction == RotDirection.Right ? Block.Rotation.Right : Block.Rotation.Left); } if (block != null && block is FriendBlock) { block.OnRotation(direction == RotDirection.Right ? Block.Rotation.Right : Block.Rotation.Left); } } // 全体で0.5 var duration = 0.5f; var _t = 0.0f; // 前フレームまでの回転量を保存しておく float angle = 0.0f; while (true) { _t += Time.deltaTime; if (_t > duration) { break; } // 0~1比率計算 var ratio = _t / duration; // ease_out var ease = Mathf.Abs(90.0f * ratio * (ratio - 2.0f) + duration); // (今フレームで回転させる量)=(現フレームまでの回転量)-(前フレームまでの回転量) var perFrame = ease * (direction == RotDirection.Right ? -1 : 1) - angle; // 回転量を更新 angle += perFrame; // 回転を加算 puzzle.transform.Rotate( new Vector3(0, 0, 1), perFrame); yield return(null); } puzzle.transform.localRotation = Quaternion.Euler(0, 0, 0); FixRotation(direction); // ここのコルーチンの流れ要整理 yield return(new WaitForSeconds(0.5f)); isMovable = true; }
private IEnumerator SpeedRewindRoutine(float rewindTime) { _RotSpeed = 0f; _UpdateRoutine.Start(UpdateRoutine()); if (RotDirChangePercent >= UnityEngine.Random.value) { _RotDirection = _RotDirection == RotDirection.CoClockWise ? RotDirection.ClockWise : RotDirection.CoClockWise; } for (float i = 0f; i < rewindTime; i += Time.deltaTime * Time.timeScale) { float ratio = Mathf.Clamp(i / rewindTime, 0f, 1f); _RotSpeed = Mathf.Lerp(0f, _OriginalRotSpeed, _RewindCurve.Evaluate(ratio)); yield return(null); } _RotSpeed = _OriginalRotSpeed; _SpeedRewindRoutine.Finish(); }
public void Rotation() { //Chage the angle if (GirDir == RotDirection.RECHS) { ActAngle += DeltaGiro; } else { ActAngle -= DeltaGiro; } //Validate of the tipe of Rotation if (RotaMode == RotMode.CONTINUE) { if (ActAngle > MaxAng) { ActAngle -= MaxAng; } } else { if (ActAngle > MaxAng) { GirDir = RotDirection.LINKS; } if (ActAngle < InitAngle) { GirDir = RotDirection.RECHS; } } //Saco Radianes RadActAngle = Math.PI * ActAngle / 180.0; //parentTransNode.Translation = ActPos; //parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(ActAngle)); }
// 回転後のデータを反映 void FixRotation(RotDirection rotation) { // Acidの回転アニメーションはここでは呼び出さない(設計ミスか? // 矢印の方向更新を行っています foreach (var block in blocks) { if (block != null && !(block is AcidBlock)) { // ここのキャストはよくなさすぎるが一旦変にいじらない前提として放置で。。。 block.OnRotation((Block.Rotation)(int) rotation); } } // 一度落下前の状態に移動 for (int i = 0; i < blocks.Length; i++) { if (blocks[i] != null) { blocks[i].transform.localPosition = new Vector2(i / rowColumn - (rowColumn / 2.0f - 0.5f), i % rowColumn - (rowColumn / 2.0f - 0.5f)); } } // 回転後落下させる Drop(0.5f); }
private List<Bullet> WBullets; //Bullets For Weapon #endregion Fields #region Constructors public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode) { FOV = NORMAL_FOV; DeltaGiro = DELTA_THETA; Active = true; ActAngle = 0; InitAngle = 0; MaxAng = 360; RadActAngle = 0; GirDir = RotDirection.RECHS; RotaMode = RotMode.CONTINUE; this.BulletModel = BulletModel; BulletMat = BulletMaterial; GMarkerNode = GrdMarkerNode; WBullets = new List<Bullet>(); //Config type of Shoot WaitBullet = WAIT_SHOOT; CountToShoot = WaitBullet; ReloadTime = WAIT_RELOAD; CountToReload = 0; CountOfBullets = 0; NumBullets = Game_Logic.MAX_BULLET; RadOffset = Math.PI * (95) / 180.0; BulletOffset = new Vector3(0, 10, 30); }
public void Rotation() { //Chage the angle if(GirDir == RotDirection.RECHS) ActAngle += DeltaGiro; else ActAngle -= DeltaGiro; //Validate of the tipe of Rotation if (RotaMode == RotMode.CONTINUE) { if (ActAngle > MaxAng) ActAngle -= MaxAng; } else { if (ActAngle > MaxAng) GirDir = RotDirection.LINKS; if (ActAngle < InitAngle) GirDir = RotDirection.RECHS; } //Saco Radianes RadActAngle = Math.PI * ActAngle / 180.0; //parentTransNode.Translation = ActPos; //parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), MathHelper.ToRadians(ActAngle)); }
public static extern void RotateIndefinitely(IntPtr board, byte strand, ushort period, RotDirection direction);
public static extern void Rotate(IntPtr board, byte strand, byte count, ushort period, RotDirection direction);