// Update is called once per frame protected virtual void Update() { if (currentHealth <= 0) { Destroy(); } if (HealthDelay.Check(Time.deltaTime) && HealthTimer.Check(Time.deltaTime)) { Heal(healthIncrement); } }
protected override void Update() { if (!IsActivated || !GameManager.Instance.hasGameStarted) { return; } base.Update(); if (moneyAndFoodTimer.Check(Time.deltaTime)) { MoneyAdded.Invoke(moneyIncrement); if (isFood) { FoodAdded.Invoke(foodIncrement); } } }
// Update is called once per frame void Update() { if (!building.IsActivated) { return; } if (damageTimer.Check(Time.deltaTime)) { Kaban minHealthKaban = null; var closeEnoughKabans = GameObject.FindGameObjectsWithTag("Kaban") .Select(x => x.GetComponent <Kaban>()) .Where(CanBeShooted); foreach (var kaban in closeEnoughKabans) { if (minHealthKaban == null || kaban.currentHealth < minHealthKaban.currentHealth) { minHealthKaban = kaban; } } shootedKaban = minHealthKaban; if (shootedKaban != null) { shootedKaban.TakeDamage(damage); } } if (shootedKaban != null && shootedKaban.gameObject) { shootRayRenderer.SetPosition(0, transform.position); shootRayRenderer.SetPosition(1, shootedKaban.transform.position); shootRayRenderer.enabled = true; } else { shootRayRenderer.enabled = false; } }
protected override void Update() { base.Update(); if (!IsAlive || !GameManager.Instance.hasGameStarted) { return; } if (hungChecker.Check(Time.deltaTime)) { isHung = IsHung(); if (isHung) { wanderPoint = null; } } AlignWithGround(); // ReSharper disable once Unity.PerformanceCriticalCodeInvocation targetBuilding = GetTargetBuilding(); if (targetBuilding) { NavigateTo(targetBuilding.transform.position); return; } if (wanderPoint == null || navigationAgent.destination == wanderPoint && navigationAgent.remainingDistance <= wanderPointRadius) { wanderPoint = GetWanderPoint(); } if (wanderPoint.HasValue) { NavigateTo(wanderPoint.Value); } }