newlist

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#ifndef __HERO_H__
#define __HERO_H__

#include "GameFrameHead.h"

#include "GameParam.h"

class CHero
{
public:



    struct  Attribute
    {
        //成就
        ////long long llTotalMoney;
        //long long llTotalScores;

        long long llTotalComplete;
        long long llTotalPerfectToComplete;


        int  levelComplete[LEVEL_AMOUNT];
        bool levelAllComplete[LEVEL_AMOUNT];    


        //解锁成就
        

        //一局 最高纪录
        long long llTopMoney;

    
        //生涯存档
        struct CareerArchive
        {
            bool bCompletion;
            bool bGood;
            int    nScore;
            int nHeightScore;
            int nBestStep;
        };

    
        //完成的关卡
        map<int, CareerArchive> career;


        //教学
        bool bBaseTeaching;
        bool bLigatureTeaching;
        bool bRatingTeaching;

        //成就
        map<int, bool> mapAchievementComplete;
        map<int, bool> mapAchievementPerfectToComplete;
        map<int, bool> mapAchievementMode;
    };


public:
    CHero();
    ~CHero();
    
    bool init();

    Attribute* getAttribute()const;

    Attribute::CareerArchive* getCareer(int nId);


private:
    Attribute* m_pAttribute;

};

#endif//__HERO_H__
#include "Hero.h"
#include "GameParam.h"
#include "XCommon.h"
#include "GameConfig.h"
#include "GameLogic.h"

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "GameCenter.h"
#endif

CHero::CHero()
{
    m_pAttribute = new Attribute();
}

CHero::~CHero()
{
    SAFE_DELETE(m_pAttribute);
}

CHero::Attribute* CHero::getAttribute() const
{
    return m_pAttribute;
}

bool CHero::init()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    
    int nSize = sizeof(GAMECENTER_ID_Complete) / sizeof(GAMECENTER_ID_Complete[0]);
    for(int i = 0; i < nSize; i++)
    {
        m_pAttribute->mapAchievementComplete[i] = false;
    }

    nSize = sizeof(GAMECENTER_ID_PerfectToComplete) / sizeof(GAMECENTER_ID_PerfectToComplete[0]);
    for (int i = 0; i < nSize; i++)
    {
        m_pAttribute->mapAchievementPerfectToComplete[i] = false;
    }

    for (int i = 0; i < LEVEL_AMOUNT; i++)
    {
        m_pAttribute->mapAchievementMode[i] = false;
    }

#endif 

    return true;
}

CHero::Attribute::CareerArchive* CHero::getCareer( int nId )
{
    for (map<int, CHero::Attribute::CareerArchive>::iterator it = m_pAttribute->career.begin(); it != m_pAttribute->career.end(); it++)
    {
        if (it->first == nId)
        {
            return &it->second;
        }
    }
    return NULL;
}

 

posted on 2013-06-30 14:02  一枚程序  阅读(547)  评论(0编辑  收藏  举报