public static void HandleCollisionEnter(Hittable collidingHittable, GameObject otherCollidingObject) { if (otherCollidingObject.gameObject.TryGetComponent <PlayerLife>(out _)) { return; } Airship collidingAirship = collidingHittable.gameObject.GetComponentInParent <Airship>(); Airship otherCollidingAirship = otherCollidingObject.gameObject.GetComponentInParent <Airship>(); if (collidingAirship && otherCollidingAirship && collidingAirship == otherCollidingAirship) { return; // Airship, donĀ“t hit yourself } Vector3 relativeVelocity = Vector3.zero; int damage = 0; if (collidingAirship && otherCollidingAirship) { relativeVelocity = collidingAirship.Velocity - otherCollidingAirship.Velocity; damage = Mathf.FloorToInt(Vector3.Magnitude(relativeVelocity)); } else { //relativeVelocity = collidingAirship.Velocity; damage = collidingHittable.MaxHealth * 2; } collidingHittable.GetDamage(damage); }
public void Break(Airship referenceShip) { airship.BreakFollowing(referenceShip); airship.ForceModifyer = -1f; StopAllCoroutines(); StartCoroutine(CheckSpeed()); StartCoroutine(BalanceSpeed(referenceShip)); }
public void Start() { Debug.Log("Started player"); playerController = GetComponent <PlayerController>(); airship = GameObject.FindGameObjectWithTag("Airship").GetComponent <Airship>(); anim = GetComponent <Animator>(); transform.SetParent(GameObject.FindGameObjectWithTag("Airship").transform); }
private void SpawnNewEnemy(int enemy, Lane lane) { GameObject newEnemy = Instantiate(enemyModels[enemy], GetPosition(lane), Quaternion.identity, enemyList.transform); Airship newEnemyRenderer = newEnemy.GetComponent <Airship>(); lane.SetAirship(newEnemyRenderer); enemyList.AddEnemy(newEnemyRenderer); newEnemyRenderer.SetManagingObjects(metalManager, enemyList); }
private void EditAirship(Airship airship) { airship.Name = GetName(); airship.Purpose = GetPorp(); airship.NumScrews = GetNumScrews(); airship.Weight = GetWeight(); airship.MaxHeight = GetMaxHeight(); airship.TakeoffWeight = GetTakeoffWeight(); airship.Shell = GetShell(); }
public void BreakFollowing(Airship newCollidingAirship) { if (newCollidingAirship == this) { return; } foreach (CollisionAvoider collisionAvoider in collisionAvoiders) { collisionAvoider.Break(newCollidingAirship); } }
public void SetAirship(Airship airship) { receivedAirship = airship; SetName(airship.Name); SetPorp(airship.Purpose); SetNumScrews(airship.NumScrews); SetWeight(airship.Weight); SetMaxHeight(airship.MaxHeight); SetTakeoffWeight(airship.TakeoffWeight); SetShell(airship.Shell); }
public IEnumerator ChangeTarget(Airship oldTarget) { yield return(new WaitForSeconds(changeTargetIfHiddenTime)); if (turret.Target == oldTarget && turret.TargetHidden) // controll that turrent did not change the target and target is still hidden { List <Airship> enemies = enemyList.GetEnemies().GetRange(0, enemyList.GetEnemies().Count); enemies.Remove(oldTarget); turret.TargetHidden = false; SearchNearestTarget(enemies.ToArray()); } }
private void OnTriggerEnter(Collider other) //colliding ship is set only on enter and never removed, new ones just override { Airship newCollidingAirship = other.gameObject.GetComponentInParent <Airship>(); if (newCollidingAirship != null) //if colliding object is a Airship { //set as new colliding and change speed collidingAirship = newCollidingAirship; collidingAirship.AddCollisionAvoider(this); Break(collidingAirship); } }
public void StartGame() { spawner.ResetWaves(); startScreen.SetActive(false); gamingScreen.SetActive(true); gameOver.SetActive(false); Time.timeScale = 1f; pointController.ResetPoints(); currentAirShip = ((GameObject)Instantiate(airshipPrefab, new Vector2(0, 0), Quaternion.identity)).GetComponent <Airship>(); currentPlayer = ((GameObject)Instantiate(playerPrefab, currentAirShip.GetPlayerStartLocation(), Quaternion.identity)).GetComponent <Player>(); gameState = GameState.Gaming; spawner.NextWave(); }
private async Task SendWebPushNotificationAsync(string userId, string notificationType, string notificationId, ITenant tenant, WebPushTemplate webPushTemplate) { if (webPushTemplate is null) { throw new Exception($"There is no WebPushTemplate defined for tenant: {tenant.Id} and notification type: {notificationType}"); } // UserId will be a combination of tenantId and userId of that business. string airshipUserId = $"{tenant.Id}:{userId}"; // Fetch the shared airship config url from the tenant tenant.Properties.TryGet(Constants.TenantPropertyNames.AirshipKeyVaultUrl, out string airshipKeyVaultUrl); if (string.IsNullOrEmpty(airshipKeyVaultUrl)) { throw new Exception($"There is no SharedAirshipConfig defined for tenant: {tenant.Id} and notification type: {notificationType}"); } string?airshipSecretsString = await KeyVaultHelper.GetDeliveryChannelSecretAsync(this.configuration, airshipKeyVaultUrl).ConfigureAwait(false); if (string.IsNullOrEmpty(airshipSecretsString)) { throw new Exception("There is no airship delivery channel configuration setup in the keyvault"); } // Convert secret to airship secret model Airship airshipSecrets = JsonConvert.DeserializeObject <Airship>(airshipSecretsString); var airshipDeliveryChannelObject = new AirshipDeliveryChannel( webPushTemplate.Title !, webPushTemplate.Body !, webPushTemplate.ActionUrl !); try { AirshipWebPushResponse?airshipResponse = await this.SendAirshipNotificationAsync( airshipUserId, airshipDeliveryChannelObject, airshipSecrets).ConfigureAwait(false); await this.UpdateNotificationDeliveryStatusAsync( airshipDeliveryChannelObject.ContentType, notificationId, airshipResponse is null?UserNotificationDeliveryStatus.Unknown : UserNotificationDeliveryStatus.NotTracked, tenant).ConfigureAwait(false); } catch (Exception ex) { await this.UpdateNotificationDeliveryStatusAsync(airshipDeliveryChannelObject.ContentType, notificationId, UserNotificationDeliveryStatus.PermanentlyFailed, tenant, ex.Message).ConfigureAwait(false); } }
IEnumerator BalanceSpeed(Airship referenceShip) { while (!speedBalanced) { if (referenceShip.Velocity.z <= airship.Velocity.z) { speedBalanced = true; } else { yield return(new WaitForSeconds(0.2f)); } } }
private void ButSave_Click(object sender, EventArgs e) { if (receivedAirship == null) { Airship airship = new Airship(); airship.TypeName = TypeNames.airship; EditAirship(airship); FMain.AddVehicle(airship); } else { EditAirship(receivedAirship); } Close(); }
// Pauses the player and all enemies (does not modify timeScale) public void ActionPause(bool paused) { actionPaused = paused; // Necessary for message dialogue pauseDimmer.targetAlpha = paused ? 0.5f : 0; RefreshAllActionButtons(); PlayerMover.instance.enabled = !paused; List <GameObject> enemyList = ObjectContainer.GetEnemiesAndWounded(); foreach (GameObject unit in enemyList) { AutoMover autoMover = unit.GetComponent <AutoMover>(); if (autoMover != null) { autoMover.enabled = !paused; } HideMover hideMover = unit.GetComponent <HideMover>(); if (hideMover != null) { hideMover.enabled = !paused; } Airship airship = unit.GetComponent <Airship>(); if (airship != null) { airship.enabled = !paused; } } List <GameObject> projectiles = ObjectContainer.GetAllProjectiles(); foreach (GameObject projectile in projectiles) { Projectile proj = projectile.GetComponent <Projectile>(); if (proj != null) { proj.enabled = !paused; } } }
IEnumerator CheckIfShipLeft() //checks every sec if spwaned ship is far enough away to spawn a new one { while (true) { if (HasAirship) { if (transform.position.z - newAirship.transform.position.z > minDistance) { newAirship = null; yield return(new WaitUntil(() => HasAirship == true)); } else { yield return(new WaitForSeconds(1)); } } else { yield return(new WaitUntil(() => HasAirship == true)); } } }
void SearchNearestTarget(Airship[] enemies) { float shortestDistance = turret.Range; Airship nearestEnemy = null; foreach (Airship enemy in enemies) { float distanceToEnemy = Vector3.Distance(turret.TurretAimCenter, enemy.transform.position); if (distanceToEnemy <= turret.Range && distanceToEnemy < shortestDistance && turret.TurretAimCenter.y <= enemy.transform.position.y) { shortestDistance = distanceToEnemy; nearestEnemy = enemy; } } if (nearestEnemy != null) { turret.Target = nearestEnemy; } else { turret.Target = null; } }
public void SetAirship(Airship airship) { newAirship = airship; }
public void AddEnemy(Airship enemie) { enemies.Add(enemie); }
public void RemoveEnemy(Airship enemie) { enemies.Remove(enemie); }
void Start() { airship = GetComponentInParent <Airship>(); // get attached airship }
protected Airship airship = null; //airship this is attached to protected override void Start() { base.Start(); airship = GetComponentInParent <Airship>(); //get attached airship airship.AddMass(partMass); }
/// <summary> /// Send a web push airship notification. /// </summary> /// <param name="airshipUserId">Targetted Airship User.</param> /// <param name="airshipDeliveryChannel">The <see cref="AirshipDeliveryChannel"/>.</param> /// <param name="airshipSecrets">The <see cref="Airship"/>.</param> private async Task <AirshipWebPushResponse?> SendAirshipNotificationAsync(string airshipUserId, AirshipDeliveryChannel airshipDeliveryChannel, Airship airshipSecrets) { if (airshipDeliveryChannel is null) { throw new Exception(); } AirshipClient?airshipClient = this.airshipClientFactory.GetAirshipClient(airshipSecrets.ApplicationKey !, airshipSecrets.MasterSecret !); var newNotification = new Notification() { Alert = airshipDeliveryChannel.Title, Web = new WebAlert() { Alert = airshipDeliveryChannel.Body, Title = airshipDeliveryChannel.Title, }, Actions = new Actions() { Open = new OpenUrlAction { Type = "url", Content = airshipDeliveryChannel.ActionUrl }, }, }; return(await airshipClient.SendWebPushNotification(airshipUserId, newNotification).ConfigureAwait(false)); }
private void Start() { newAirship = null; StartCoroutine(CheckIfShipLeft()); }