public void Verify() { if (TakeOffPoint == null) { throw new AnalyticalServicesException(24000, "TakeOffPoint must be set in this service."); } if (LandingPoint == null) { throw new AnalyticalServicesException(24000, "LandingPoint must be set in this service."); } TakeOffPoint.Verify(); LandingPoint.Verify(); OutputSettings.Verify(); if (Speed <= 0) { throw new AnalyticalServicesException(23600, "Speed must be greater than 0."); } if (Altitude <= 0) { throw new AnalyticalServicesException(23600, "Route altitude must be greater than 0."); } }
private LandingPoint FindLandingPoint() { GameObject[] landingPointGameObjects = GameObject.FindGameObjectsWithTag("LandingPoint"); // Build a list of valid landing points. List <LandingPoint> validLandingPoints = new List <LandingPoint>(); foreach (GameObject pointGameObject in landingPointGameObjects) { LandingPoint point = pointGameObject.GetComponent <LandingPoint>(); if (point == null) { continue; } if (point.isOccupied) { continue; } validLandingPoints.Add(point); } if (validLandingPoints.Count == 0) { return(null); } int RandIndex = Random.Range(0, validLandingPoints.Count - 1); return(validLandingPoints[RandIndex]); }
void Update() { if (birdState == BirdState.Waiting) { // Decrement the wait timer. If we've still got time left, // we return. targetTime -= Time.deltaTime; if (targetTime > 0.0f) { return; } // Try to find another location to fly to. LandingPoint landingPoint = FindLandingPoint(); // If we didn't find a landing point, or we found the one we're // currently on, reset the wait timer and return. if (landingPoint == null || landingPoint == currentLandingPoint) { ResetWaitTimer(); return; } // Unclaim the old point, and claim the new point. previousLandingPoint = currentLandingPoint; currentLandingPoint = landingPoint; if (previousLandingPoint != null) { previousLandingPoint.isOccupied = false; } currentLandingPoint.isOccupied = true; flightTime = 0.0f; birdState = BirdState.Flying; } else if (birdState == BirdState.Flying) { flightTime += Time.deltaTime; float totalFlightTime = GetFlightTime(); float normalizedFlightTime = flightTime / totalFlightTime; transform.position = Vector3.Lerp( previousLandingPoint.transform.position, currentLandingPoint.transform.position, FlightCurve.Evaluate(normalizedFlightTime)); // If we're close enough to the new location, reset our wait timer, // and change state back to waiting. if (Vector3.Distance(transform.position, currentLandingPoint.transform.position) < 0.001f) { ResetWaitTimer(); birdState = BirdState.Waiting; } } }
/*---------------------------------------------------------------------*/ /// <summary> /// スコアとボーナス燃料の計算 /// </summary> /// <param name="status">ランダーのステータス</param> /// <param name="point">着陸地点</param> /// <param name="score">スコア受け取り用変数</param> /// <param name="bonusfuel">ボーナス燃料受け取り用変数</param> private void ScoreCalc(LanderStatus status, LandingPoint point, out float score, out float bonusfuel) { // ステータス情報の取得 LanderStatus.STATUS _status = status.GetStatus(); // 水平速度と垂直速度をベクトルとし、ベクトルの長さの半分をスピード値として取得する。 int speed = (int)(new Vector2(_status.horizontal_speed, _status.vertical_speed).magnitude / 2); // 計算ベース値からスピード値を引いた値に着陸地点のボーナス倍率をかけた値をスコアとする。 score = (Const.MainGameData.SCORE_CALC_BASE - speed) * point.GetBonusRate(); // スコアにボーナス燃料倍率をかけた値をボーナス燃料とする。 bonusfuel = score * Const.MainGameData.BONUS_FUEL_RATE; }
//Finds a free landing point to spawn on public void FlyToSpawn() { foreach (LandingPoint point in landingPoints) { if (!point.isOccupied && !point.Targeted) { transform.position = point.transform.position; currentPoint = point; point.isOccupied = true; point.Occupator = this.gameObject; break; } } }
void Start() { birdState = BirdState.Waiting; // Try to find a starting spot. currentLandingPoint = FindLandingPoint(); if (currentLandingPoint != null) { currentLandingPoint.isOccupied = true; transform.position = currentLandingPoint.transform.position; } // Reset our wait timer. ResetWaitTimer(); }
public async Task <SaveLandingPointResponse> SaveAsync(LandingPoint landingPoint) { try { await _landingPointRepository.AddAsync(landingPoint); await _unitOfWork.CompleteAsync(); return(new SaveLandingPointResponse(landingPoint)); } catch (Exception ex) { return(new SaveLandingPointResponse($"An error has occured while saving the Landing Point: {ex.Message}")); } }
/*---------------------------------------------------------------------*/ /// <summary> /// 着陸処理 /// </summary> private void Landing(GameObject point) { // 推進ロケットの炎を非表示にする。 _RocketFire.SetActive(false); // 着陸に成功しているかチェックする。 isLanding = isSuccess; // 入力フラグをfalseにする。 isInputEnable = false; // RigidbodyのisKinematicをtrueにする。 _Rigidbody.isKinematic = true; // 着陸に失敗しているならゲーム-バー処理 if (isLanding == false) { GameOver(); } // 着陸に成功しているなら着陸地点を保持 else { _LandingPoint = point.transform.parent.GetComponent <LandingPoint> (); } }
//Moves bird to the chosen new point. //Bird begins flight after the alert animation is finished and ends flight when within a short range of the landing point. //Once bird has landed, it can now be detected again. private void FlyToPoint() { if (animator.GetCurrentAnimatorStateInfo(0).IsName("Flying")) { transform.LookAt(newPoint.transform.position); //transform.position = Vector3.Lerp(transform.position, newPoint.transform.position, flightSpeed * Time.deltaTime); transform.position = Vector3.MoveTowards(transform.position, newPoint.transform.position, flightSpeed * Time.deltaTime); } if (Vector3.Distance(transform.position, newPoint.transform.position) < 2f) { flying = false; animator.SetBool("IsFlying", false); animator.SetTrigger("HasLanded"); currentPoint = newPoint; currentPoint.isOccupied = true; currentPoint.Occupator = this.gameObject; currentPoint.Targeted = false; canBeDetected = true; } }
/*---------------------------------------------------------------------*/ /// <summary> /// 初期化処理 /// 初回の場合は引数の指定無し、ステージ移動の場合は引数に値を設定すること。 /// </summary> /// <param name="fuel">燃料の値</param> public void Init(float fuel = Const.LanderData.INIT_FUEL) { // ステータスの初期化 _Status.SetFuel(fuel); fFuel = fuel; // SpriteRendererの設定 _SpriteRenderer.gameObject.SetActive(true); // 推進ロケットの炎を非表示にする。 _RocketFire.SetActive(false); // 座標の初期化 Vector2 vInitPos = new Vector2(); vInitPos.x = Random.Range(Const.LanderData.INIT_POS_X_MIN, Const.LanderData.INIT_POS_X_MAX); vInitPos.y = Const.LanderData.INIT_POS_Y; this.transform.position = vInitPos; // 回転値の初期化 this.transform.rotation = Quaternion.identity; // RigidBody2Dの設定 _Rigidbody.velocity = new Vector2(); _Rigidbody.isKinematic = true; // フラグの初期化 isLanding = false; isDestroy = false; isInputEnable = false; isRocket = false; isFuelAlert = false; _SpriteRenderer.color = Color.white; // 着陸した着陸地点をnullにする。 _LandingPoint = null; // 初期化完了 isInit = true; }
public async Task AddAsync(LandingPoint landingPoint) { await _context.LandingPoints.AddAsync(landingPoint); }
/// <summary> /// Creates a success response. /// </summary> /// <param name="category">Saved category.</param> /// <returns>Response.</returns> public SaveLandingPointResponse(LandingPoint landingPoint) : this(true, string.Empty, landingPoint) { }
private SaveLandingPointResponse(bool success, string message, LandingPoint landingPoint) : base(success, message) { LandingPoint = landingPoint; }