[colobot] 74/100: Implement damage alarm (#916)
Didier Raboud
odyx at moszumanska.debian.org
Thu Jun 1 18:10:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit df12f87b47f9811e6ed2cf1aa15031576d8ed7dc
Author: DavivaD <davivad at wp.pl>
Date: Mon May 22 10:01:36 2017 +0100
Implement damage alarm (#916)
Implements part of #320
---
src/sound/sound_type.cpp | 3 ++-
src/sound/sound_type.h | 1 +
src/ui/object_interface.cpp | 22 ++++++++++++++++++++--
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/sound/sound_type.cpp b/src/sound/sound_type.cpp
index 5eb4c53..964782d 100644
--- a/src/sound/sound_type.cpp
+++ b/src/sound/sound_type.cpp
@@ -109,7 +109,8 @@ const std::unordered_map<std::string, SoundType> SOUND_STRINGS =
{"mushroom", SOUND_MUSHROOM},
{"firep", SOUND_FIREp},
{"explog1", SOUND_EXPLOg1},
- {"explog2", SOUND_EXPLOg2}
+ {"explog2", SOUND_EXPLOg2},
+ {"alarms", SOUND_ALARMs}
};
} // anonymous namespace
diff --git a/src/sound/sound_type.h b/src/sound/sound_type.h
index 360708d..6985622 100644
--- a/src/sound/sound_type.h
+++ b/src/sound/sound_type.h
@@ -116,6 +116,7 @@ enum SoundType
SOUND_EXPLOg1 = 79, /*!< ShooterBots damaging objects. */
SOUND_EXPLOg2 = 80, /*!< OrgaShooterBots damaging objects. */
SOUND_MOTORd = 81, /*!< Scribbler/ToyBot engine. */
+ SOUND_ALARMs = 82, /*!< Bot shield alarm. */
SOUND_MAX /** number of items in enum */
};
diff --git a/src/ui/object_interface.cpp b/src/ui/object_interface.cpp
index a435c82..c819540 100644
--- a/src/ui/object_interface.cpp
+++ b/src/ui/object_interface.cpp
@@ -1484,7 +1484,25 @@ void CObjectInterface::UpdateInterface(float rTime)
if ( pg != nullptr )
{
assert(m_object->Implements(ObjectInterfaceType::Shielded));
- pg->SetLevel(dynamic_cast<CShieldedObject*>(m_object)->GetShield());
+ icon = 3; // orange/gray
+ float shield = dynamic_cast<CShieldedObject*>(m_object)->GetShield();
+
+ if ( shield < 0.4f && shield != 0.0f) // low but not zero?
+ {
+ if ( m_lastAlarmTime >= 0.8f ) // blinks?
+ {
+ shield = 1.0f;
+ icon = 2; // red
+ }
+ if ( m_lastAlarmTime >= 1.0f )
+ {
+ m_sound->Play(SOUND_ALARMs, 0.5f); // beep-beep
+ m_lastAlarmTime = 0.0f;
+ }
+ }
+
+ pg->SetLevel(shield);
+ pg->SetIcon(icon);
}
pg = static_cast< CGauge* >(pw->SearchControl(EVENT_OBJECT_GRANGE));
@@ -1494,7 +1512,7 @@ void CObjectInterface::UpdateInterface(float rTime)
icon = 2; // blue/red
range = dynamic_cast<CJetFlyingObject*>(m_object)->GetReactorRange();
- if ( range < 0.2f && range != 0.0f && !m_physics->GetLand() )
+ if ( range < 0.2f && range != 0.0f && !m_physics->GetLand() ) // low but not zero/landed?
{
if ( Math::Mod(m_time, 0.5f) >= 0.2f ) // blinks?
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list