Pie Noon
An open source project by FPL.
 All Classes Pages
multiplayer_controller.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef MULTIPLAYER_CONTROLLER_H_
16 #define MULTIPLAYER_CONTROLLER_H_
17 
18 #include <vector>
19 #include "common.h"
20 #include "controller.h"
21 #include "game_state.h"
22 
23 namespace fpl {
24 namespace pie_noon {
25 
26 // The MultiplayerController class is a thin interface between
27 // MultiplayerDirector and the game state.
28 //
29 // MultiplayerDirector tells each MultiplayerController what it wants it to do
30 // for the given turn, then it's MultiplayerController's job to inject the
31 // correct button presses with the correct timing to make it happen.
33  public:
35 
36  // Give the multiplayer controller everything it will need.
37  void Initialize(GameState* gamestate_ptr, const Config* config);
38 
39  // Decide what the character is doing this frame.
40  virtual void AdvanceFrame(WorldTime delta_time);
41 
42  void AimAtCharacter(int character_id); // Aim towards this character.
43  void HoldBlock(WorldTime block_delay,
44  WorldTime block_hold); // Block for a predetermined time.
45  void ThrowPie(WorldTime throw_delay); // Throw a pie where we are aiming.
46  void GrowPie(WorldTime grow_delay); // Grow a pie to the next level.
47 
48  void Reset(); // Reset our action and target back to defaults.
49 
50  // Sometimes MultiplayerDirector needs access to our character.
51  // This gives it that access.
52  const Character& GetCharacter();
53 
54  private:
55  GameState* gamestate_; // Pointer to the gamestate object
56  const Config* config_; // Pointer to the config structure
57  CharacterId aim_at_character_id_; // Who to aim at.
58  WorldTime block_delay_; // How long to wait until blocking.
59  WorldTime block_hold_; // How many milliseconds we are blocking.
60  WorldTime throw_pie_delay_; // After this long, throw a pie.
61  WorldTime grow_pie_delay_; // After this long, grow the pie 1 level.
62 };
63 
64 } // pie_noon
65 } // fpl
66 
67 #endif // MULTIPLAYER_CONTROLLER_H_
Definition: character.h:55
Definition: multiplayer_controller.h:32
Definition: game_state.h:56
Definition: controller.h:26