Main Page · Modules · All Classes · Class Hierarchy
MAStandFartSkit.cpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #include "MAStandFartSkit.hpp"
23 
24 #include "core/MARandomness.hpp"
25 #include "types/MARobotState.hpp"
26 #include "controllers/MALegController.hpp"
27 #include "MAStandFunnySkitFinish.hpp"
28 
29 MAStandFartSkit::MAStandFartSkit() : MABehavior(MCGetClassName(this)), SoundPlayed(false)
30 {
31 }
32 
33 
35 {
37 }
38 
39 
41 {
42  MA_RANDOM_POINT_1(FartSkit, 1, 4)
43 
44  if (FartSkit == 1)
45  SkitName = "SKIT:stand_fart1";
46  else
47  if (FartSkit == 2)
48  SkitName = "SKIT:stand_fart2";
49  else
50  if (FartSkit == 3)
51  SkitName = "SKIT:stand_fart1_reverse";
52  else
53  SkitName = "SKIT:stand_fart2_reverse";
54 
55  StartTransition(*MA::LegLF, SkitName);
56  StartTransition(*MA::LegLH, SkitName);
57  StartTransition(*MA::LegRF, SkitName);
58  StartTransition(*MA::LegRH, SkitName);
59 }
60 
61 
63 {
64  if (GetElapsedActivatedStateTime() > 2000 && !SoundPlayed)
65  {
66  MA_RANDOM_POINT_1(FartSound, 1, 8)
67 
68  PlaySound(std::string("fart")+MCToStr(FartSound)+"_effect");
69  SoundPlayed = true;
70  }
71 }
72 
73 
75 {
77 }
#define MA_RANDOM_POINT_1(_variable_name, _min, _max)
Set a random point with one value.
int GetElapsedActivatedStateTime() const
Get the elapsed activated state time.
Definition: MABehavior.cpp:561
Behavior base class.
Definition: MABehavior.hpp:157
int PlaySound(const std::string &name)
Play a sound and register the playback.
Definition: MABehavior.cpp:823
std::string MCToStr(const T value, bool hex_manipulator=false)
Convert an other type to string with std::stringstream.
Definition: MCDefs.hpp:360
virtual MABehavior::StimulusLevelType GetCurrentStimulus() override
Get the current behavior stimulus.
Finish a funny skit while standing.
virtual void FinishingActions() override
Perform actions when the behavior is being finished.
#define MABEHAVIOR_CREATE(_behavior, _master,...)
Create behaviors with custom constructor safely.
Definition: MABehavior.hpp:43
std::string MCGetClassName(T *instance=nullptr, const std::string &name_suffix="")
Get a class name.
Definition: MCDefs.hpp:627
void ActivatedStateUpdate() override
Perform actions when the behavior is in activated state.
MABehavior * GetMaster()
Get the master behavior.
Definition: MABehavior.cpp:486
virtual void ActivatingActions() override
Perform actions when the behavior is being activated.
void StartTransition(MAController &controller, const std::string &transition_name)
Start a transition.
Definition: MABehavior.cpp:793