void StageEndlessLayer::initMiddlePlanetsWithRound(int round)
{
	if(round >= 4)
	{				
		CCPoint posi = getRandomPlanetPosition();
		if(posi.x > 0 && posi.y > 0)
			makePlanet(kForceSideMiddle, posi , 6, 0)->stopIncrease();		
	}
}
void SolarSystemCreator::createWorlds()
{
    double currentDistance;
    _star->numDesert(0);
    _star->numGasGiant(0);

    double prevSatDistance = 0.0;
    //double prevDistance = 0.0;

    const double MIN_PLANET_DISTANCE_GG = 4000000.0;
    const double MAX_OUTER_PLANET = 100.0;

    _star->calcStarValue();
    for (int h = 0; h < _orbits; h++) {
        bool advanceNextPlanet = true;
        do {
            Planet px;
            px.setStar(_star.data());
            if (h == 0) {
                double dModifier = 0.1;
                if (_star->starType() == NSStar::stM)
                    dModifier *= .33;
                if (_star->starType() == NSStar::stK)
                    dModifier *= .66;
                if (_star->starType() == NSStar::stF)
                    dModifier *= 1.25;
                currentDistance = dModifier + SSGX::floatRand() * dModifier;
            }
            else {
                prevSatDistance = currentDistance;
                auto minDistance = currentDistance + (prevSatDistance * 50.0 / 150000000.0);
                auto newDistance = (currentDistance * (1.05+ (double)(rand() % 900)/1000.0)) - currentDistance;
                if (minDistance > newDistance)
                    currentDistance += minDistance;
                else
                    currentDistance += newDistance;
            }
            int chance = SSGX::d10();
            if (chance < 8 && currentDistance < MAX_OUTER_PLANET) {
                makePlanet(advanceNextPlanet, MIN_PLANET_DISTANCE_GG, currentDistance, prevSatDistance, px);
            }
        } while (!advanceNextPlanet);

    }
    _star->calcStarValue();

}
// round从0算起
void StageEndlessLayer::initCatPlanetsWithRound(int round)
{
	int countForSide = 0;
	if(round < 2)
		countForSide = 2;
	else
		countForSide = 3;

	for(int i = 0; i <countForSide; i++)
	{	
		int fightUnit = 10;
		CCPoint posi = getRandomPlanetPosition();
		if(posi.x > 0 && posi.y > 0)
		{			
			Planet* cat = makePlanet(kForceSideCat, posi, fightUnit, 0);
			m_pCatPlanetArray->addObject(cat);
		}
	}
		
    // 以9为一个循环数
	int levelSum = (round % 9)* 1.5;
	levelSum -=2;
	if(levelSum < 0)
		levelSum = 0;
	if(levelSum > 5)
		levelSum = 5;
		
	while(levelSum > 0)
	{
		CCObject* pOb = NULL;			
		CCARRAY_FOREACH(m_pCatPlanetArray, pOb)
		{
			Planet* pPlanet = (Planet*) pOb;		
			if(!pPlanet->isDirty())
			{	
				if(levelSum >0)
				{
					pPlanet->levelUp();
					--levelSum;
				}
			}
		}
	}
void Stage3_03Layer::initPlanets()
{
	m_pCat1 = makePlanet(kForceSideCat, ccp(593, 56), 8, 0);

	m_pDog1 = makePlanet(kForceSideDog, ccp(403,56), 16, 1);
	m_pDog2 = makePlanet(kForceSideDog, ccp(593,229), 16, 1);

	makePlanet(kForceSideMiddle, ccp(192,377), 2, 2)->stopIncrease();
	makePlanet(kForceSideMiddle, ccp(94,221), 2, 2)->stopIncrease();
	makePlanet(kForceSideMiddle, ccp(384,377), 2, 2)->stopIncrease();

	makeStar(ccp(334, 244));
	makeStar(ccp(153, 93));
	makeStar(ccp(570, 412));

	// 这一关里一开始将AI停掉,过一段时间手动发起进攻
	m_bIsAIStopped = true;	
}