//
//  GameScene.h
//  RedCore2
//
//  Created by Gabriel Capella on 31/05/17.
//
//

#ifndef GameScene_h
#define GameScene_h

#include "cocos2d.h"
#include "GameScene/Paddle.h"

class GameScene : public cocos2d::Layer {
    public:
        static cocos2d::Scene* createScene(int level);
        virtual bool init();
        bool onContactBegin(cocos2d::PhysicsContact& contact);
        CREATE_FUNC(GameScene);
        void setLevel(int level);
        void alert(std::string text); // Mostra alerta
    private:
        void caseBallCollision (cocos2d::Node *ball);
        void caseBallCore (cocos2d::Node *core, cocos2d::Node *ball);
        void caseSaveLevel(Node *powerup_ball);
        void NextLevel(cocos2d::Ref *pSender);
        void saveLevel();
        void tripleBallsAppearance();
        void caseTripleBalls(Node *powerup_ball);
        void paddleBallAppearance();
        void caseRaqueteBall(Node *powerup_ball);
        void superBallAppearance();
        void caseSuperBall(Node *powerup_ball);
        void addAndThrowBall();
        void removeBallsAndPowersUP();
        void createPowerUpBody(cocos2d::Color4B color, int tag);
        void delayCallback(const std::function<void ()> &func);
        int level;
        bool over; // salva se o jogo acabou!
        Paddle * paddle;
        cocos2d::Node* balls; // Bolas
        cocos2d::Node* power_ups; // Bolas
        double height, width; // tamanho do quadro
        unsigned long int last_touch; // ultima vez que a bola colidiu com algo
};


#endif /* GameScene_h */
