private void OnTriggerEnter(Collider c) { var battery = c.gameObject.GetComponent <Battery> (); if (battery) { messenger.Broadcast(new BatteryCollectedMessage(battery)); } else { var obstacle = c.gameObject.GetComponent <Obstacle> (); if (obstacle) { messenger.Broadcast(new ObstacleHitMessage(obstacle)); } } }
private void Update() { if (isDepleted) { return; } CurrentBatteryAmount -= decreaseSpeed * robMov.CurrentSpeed / robMov.BaseSpeed * Time.deltaTime; if (CurrentBatteryAmount < 0) { robMes.Broadcast(new BatteryDepletedMessage()); isDepleted = true; } }