
/* -------------------------------------------------
* Copyright 2005 Machineworks Northwest - All Rights reserved
* Programmer(s):  Seth A. Robinson (seth@rtsoft.com): 
* Created 4/16/2005 9:33:56 PM
*/



#pragma once

#include "main.h"
#include "MyEntityManager.h"
#include "MessageDispatcher.h"

class EntPlayer;
class Message;


enum
{
  C_SOUND_COAST_GUARD,
    C_SOUND_LEVEL_START,
    C_SOUND_ROCK_PLACED,

    C_SOUND_RESCUE,

    C_SOUND_GUY1_HELP,
    C_SOUND_GUY2_HELP,
    C_SOUND_GUY3_HELP,

    C_SOUND_GUY4_HELP,//my space taxi impression!

    C_SOUND_GUY1_THANKS,
    C_SOUND_GUY2_THANKS,
    C_SOUND_GUY3_THANKS,
    C_SOUND_GUY4_THANKS,

    C_SOUND_SWIMMER_DIE,
    C_SOUND_CRASH,
    C_SOUND_COOLCAT,
    C_SOUND_RESCUE_BLIP,

      C_SOUND_COUNT

};

#define C_UPGRADE_TYPES 5


class GameLogic
{

public:


    GameLogic();
    ~GameLogic();

      bool Init();
      
      void Update(float step);
      void Render();
      void RebuildBuffers();
      MyEntityManager * GetMyEntityManager() {return &m_myEntityManager;}
      void Kill();
      EntPlayer * GetPlayer(){return m_pPlayer;}
      void DrawGUI();
      void Play(int soundID) {m_sounds[soundID]->play();}
      void OnMessage(Message &msg);
      MessageDispatcher * GetMessageDispatcher(){return &m_messageDispatcher;}
      void AddRock();
      void AddPerson();
      bool ShuttingDown() {return m_sounds[0] == NULL;} //ents will crash if they don't know we're shutting down
      void OnRescued();
      void ResetGame();
      
      //forget accessors, its speed hack time, getting tired

      int m_drownTimerMax;
      float m_lightHouseSpeed;
      float m_beamScale;
      bool m_bSuspended;
      int m_upgrade[C_UPGRADE_TYPES];
      bool m_bJustStarted; //so I can insure the first swimmer of the game says "Help me" to make
      //the objectives clear
      int m_rockSpawnMS;

private:

    void OnKeyDown(const CL_InputEvent &key);
    MyEntityManager m_myEntityManager;
    CL_Slot m_slotKeyDown;
    EntPlayer *m_pPlayer; //remember where he's at
    CL_SoundBuffer *m_sounds[C_SOUND_COUNT];
    MessageDispatcher m_messageDispatcher;


    int m_rescues;
    int m_rescuesNeededForUpgrade;
    int m_rocksPlacedSoFar;
    int m_rocks;
    int m_guysToSpawn;
    int m_spawnSpeed;
    int m_level;
    
    int m_textTimer;
    std::string m_textMessage;

 };

#define GetGameLogic GetApp()->GetGameLogic()
#define GetMyEntityMgr GetGameLogic->GetMyEntityManager()

void GetRandomPosition(CL_Vector2 &v);

