private void SetData(BulletData value) { if (value) { data = value; speed = data.Speed; direction = data.Direction; } }
public void Move(Control.Direction direction) { float step = Time.deltaTime * maxSpeed; float axisStep = Mathf.Abs(Mathf.Sqrt((step * step) / 2)); switch (direction) { case Control.Direction.Up: tran.Translate(new Vector2(0, step)); break; case Control.Direction.Down: tran.Translate(new Vector2(0, -step)); break; case Control.Direction.Right: tran.Translate(new Vector2(step, 0)); break; case Control.Direction.Left: tran.Translate(new Vector2(-step, 0)); break; case Control.Direction.UpRight: axisStep = Mathf.Abs(Mathf.Sqrt((step * step) / 2)); tran.Translate(new Vector2(axisStep, axisStep)); break; case Control.Direction.UpLeft: axisStep = Mathf.Abs(Mathf.Sqrt((step * step) / 2)); tran.Translate(new Vector2(-axisStep, axisStep)); break; case Control.Direction.DownRight: axisStep = Mathf.Abs(Mathf.Sqrt((step * step) / 2)); tran.Translate(new Vector2(axisStep, -axisStep)); break; case Control.Direction.DownLeft: axisStep = Mathf.Abs(Mathf.Sqrt((step * step) / 2)); tran.Translate(new Vector2(-axisStep, -axisStep)); break; } if (tran.position.x > LevelController.PLAYER_CRIT_DOT_X) { tran.position = new Vector2(LevelController.PLAYER_CRIT_DOT_X, tran.position.y); } else if (tran.position.x < -LevelController.PLAYER_CRIT_DOT_X) { tran.position = new Vector2(-LevelController.PLAYER_CRIT_DOT_X, tran.position.y); } if (tran.position.y > LevelController.PLAYER_CRIT_DOT_Y) { tran.position = new Vector2(tran.position.x, LevelController.PLAYER_CRIT_DOT_Y); } else if (tran.position.y < -LevelController.PLAYER_CRIT_DOT_Y) { tran.position = new Vector2(tran.position.x, -LevelController.PLAYER_CRIT_DOT_Y); } lastMotorSpeed = 1; }